def __init__(self): self.proc = childprocess.ChildProcess() if CONFIG.get(CONFIG_SECTION, CONFIG_PLAYER) is None: self.setup() self.player = CONFIG.get(CONFIG_SECTION, CONFIG_PLAYER) self.channels = [] self.currentChannelId = -1
def readLoop(self): device = evdev.InputDevice(CONFIG.get(CONFIG_SECTION, CONFIG_DEVPATH)) self.device = device logger.info(self.__class__.__name__ + " opening device: " + str(device)) device.grab() logger.info(self.__class__.__name__ + " opened device: " + str(device)) try: for event in device.read_loop(): if event.type == evdev.ecodes.EV_KEY: if evdev.categorize(event) == None: continue logger.info(self.__class__.__name__ + " input: " + str(evdev.categorize(event))) keyevent = evdev.KeyEvent(event) if keyevent.keystate in ( 1, ): #state: 0=up, 1=down, 2=hold keycode = keyevent.keycode self.keydispatcher.dispatch(keycode) #print("scancode: ", evdev.KeyEvent(event).scancode, "keycode:", evdev.KeyEvent(event).keycode) #print("event:", evdev.categorize(event)) except: type, value, traceback = sys.exc_info() logger.info(self.__class__.__name__ + " Error: " + str(value) + "\n" + str(traceback))
def __init__(self, keydispatcher): self.keydispatcher = keydispatcher if CONFIG.get(CONFIG_SECTION, 'devicepath') is None: self.setup()