[main] Add input thread logic and logging
To the main application, add an input thread that "simply" reads sys.stdin events and transmits them via core.input. Additionally, set up some initial logging (yeah, for threading, this is needed immediately)
This commit is contained in:
parent
fca364554e
commit
468e30ce66
2 changed files with 48 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
import uuid
|
||||
import logging
|
||||
|
||||
import util.cli
|
||||
|
||||
LEFT_MOUSE = 1
|
||||
|
@ -7,6 +9,14 @@ RIGHT_MOUSE = 3
|
|||
WHEEL_UP = 4
|
||||
WHEEL_DOWN = 5
|
||||
|
||||
def button_name(button):
|
||||
if button == LEFT_MOUSE: return 'left-mouse'
|
||||
if button == RIGHT_MOUSE: return 'right-mouse'
|
||||
if button == MIDDLE_MOUSE: return 'middle-mouse'
|
||||
if button == WHEEL_UP: return 'wheel-up'
|
||||
if button == WHEEL_DOWN: return 'wheel-down'
|
||||
return 'n/a'
|
||||
|
||||
callbacks = {}
|
||||
|
||||
class Object(object):
|
||||
|
@ -18,6 +28,7 @@ class Object(object):
|
|||
return self._id
|
||||
|
||||
def register(obj, button=None, cmd=None):
|
||||
logging.debug('registering callback {} {}'.format(obj.id(), button))
|
||||
callbacks.setdefault(obj.id(), {}).setdefault(button, []).append(cmd)
|
||||
|
||||
def trigger(event):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue