Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
xoviat authored Jan 13, 2017
2 parents 4fe4b51 + a7c7d5e commit d3bf224
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions keyboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class _State(object): pass

_pressed_events = {}
class _KeyboardListener(_GenericListener):
def init(self):
_os_keyboard.init()

def pre_process_event(self, event):
if not event.scan_code and event.name == 'unknown':
return False
Expand Down
2 changes: 2 additions & 0 deletions keyboard/_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def start_if_necessary(self):
self.lock.acquire()
try:
if not self.listening:
self.init()

self.listening = True
self.listening_thread = Thread(target=self.listen)
self.listening_thread.daemon = True
Expand Down
4 changes: 4 additions & 0 deletions keyboard/_nixkeyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def build_device():
ensure_root()
device = aggregate_devices('kbd')

def init():
build_device()
build_tables()

pressed_modifiers = set()

def listen(queue):
Expand Down
1 change: 1 addition & 0 deletions keyboard/_winkeyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def setup_tables():
shift_is_pressed = False
alt_gr_is_pressed = False

init = setup_tables

def listen(queue):
setup_tables()
Expand Down
2 changes: 2 additions & 0 deletions keyboard/mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

_pressed_events = set()
class _MouseListener(_GenericListener):
def init(self):
_os_mouse.init()
def pre_process_event(self, event):
if isinstance(event, ButtonEvent):
if event.event_type in (UP, DOUBLE):
Expand Down

0 comments on commit d3bf224

Please sign in to comment.