def __init__(self, t_sec, t_usec, typ, code, val): self.ih = input_header() self.seconds = t_sec self.microseconds = t_usec self.type = typ self.code = code self.value = val
#!/usr/bin/env python import mpd import threading import gobject import subprocess as sp import re from sys import exit from types import MethodType import console import input_header keycode = input_header.input_header() class scroller: def __init__(self, io, scrolllist, startix=0): self.io = io self.list = scrolllist self.size = len(scrolllist) self.ix = startix def scroll(self): self.io.output(self.list[self.ix]) while 1: code = self.io.input() if code == keycode.KEY_ENTER: return (-1, self.list[self.ix]) elif code == keycode.KEY_RIGHT: return (self.ix, self.list[self.ix]) elif code == keycode.KEY_LEFT:
while True: code, val = self.readkeyevent() if val > 0: #lockcode = code #while True: # code, val = self.readkeyevent() # if code == lockcode and val != 1: # returns on key-release or key-hold # return code # 0 is generated by a repeat keypress if code == 0: return self.last_key else: self.last_key = code return code def run(self): while 1: self.readkeyevent(True) if __name__ == "__main__": gobject.threads_init() from input_header import input_header ih = input_header() r = reader("/dev/input/event9") def print_event(obj, ev): print ev r.connect("key_down", print_event) r.trap_repeat(True) r.run()