Files
@ 6e77747319ab
Branch filter:
Location: led-matrix-software/controller.py - annotation
6e77747319ab
969 B
text/x-python
Added base software to select and run demos/games, along with a couple demos
6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab 6e77747319ab | ### controller.py
### Author: Matthew Reed
import sys
import time
import signal
import logging
import threading
import configparser
from enum import Enum
from evdev import InputDevice, categorize, ecodes
import asyncio
from select import select
class Controller:
def __init__(self, config):
self.config = config
self.connect()
def connect(self):
try:
self.dev = InputDevice('/dev/input/event0')
except FileNotFoundError:
self.dev = None
except PermissionError:
self.dev = None
def read_input(self):
if self.dev == None:
self.connect()
events = []
if self.dev != None:
try:
for event in self.dev.read():
events.append(event)
except BlockingIOError:
pass
return events
|