Files
@ 835bac5d3b3c
Branch filter:
Location: led-matrix-software/controller.py - annotation
835bac5d3b3c
1.0 KiB
text/x-python
Added new demos and handle splash screens and controller input
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 835bac5d3b3c 835bac5d3b3c 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
except OSError:
self.dev = None
return events
|