Exemple #1
0
 def process_key_event(self, send_key_action_cb, wid, key_event):
     """ Caps_Lock and Num_Lock don't work properly: they get reported more than once,
         they are reported as not pressed when the key is down, etc
         So we just ignore those and rely on the list of "modifiers" passed
         with each keypress to let the server set them for us when needed.
     """
     if key_event.keyval==2**24-1 and key_event.keyname=="VoidSymbol":
         return
     #self.modifier_mappings = None       #{'control': [(37, 'Control_L'), (105, 'Control_R')], 'mod1':
     #self.modifier_keys = {}             #{"Control_L" : "control", ...}
     #self.modifier_keycodes = {}         #{"Control_R" : [105], ...}
     #self.modifier_keycodes = {"ISO_Level3_Shift": [108]}
     #we can only deal with 'Alt_R' and simulate AltGr (ISO_Level3_Shift)
     #if we have modifier_mappings
     if key_event.keyname=="Alt_R" and len(self.modifier_mappings)>0:
         keyname = "ISO_Level3_Shift"
         altgr_keycodes = self.modifier_keycodes.get(keyname, [])
         if len(altgr_keycodes)>0:
             self.emulate_altgr = key_event.pressed
             if key_event.pressed and self.last_key_event_sent:
                 #check for spurious control and undo it
                 last_wid, last_key_event = self.last_key_event_sent
                 if last_wid==wid and last_key_event.keyname=="Control_L" and last_key_event.pressed==True:
                     #undo it:
                     last_key_event.pressed = False
                     KeyboardBase.process_key_event(self, send_key_action_cb, last_wid, last_key_event)
             self.AltGr_modifiers(key_event.modifiers, not key_event.pressed)
     self.last_key_event_sent = (wid, key_event)
     #now fallback to default behaviour:
     KeyboardBase.process_key_event(self, send_key_action_cb, wid, key_event)
Exemple #2
0
 def __init__(self):
     KeyboardBase.__init__(self)
     try:
         from xpra.x11.bindings.keyboard_bindings import X11KeyboardBindings  #@UnresolvedImport
         self.keyboard_bindings = X11KeyboardBindings()
     except Exception as e:
         log.warn("failed load posix keyboard bindings: %s", e)
         self.keyboard_bindings = None
Exemple #3
0
 def send_delayed_key(self):
     #timeout: this must be a real one, send it now
     dk = self.delayed_event
     log("send_delayed_key() delayed_event=%s", dk)
     if dk:
         self.delayed_event = None
         altgr = win32api.GetKeyState(win32con.VK_RMENU) not in (0, 1)
         if altgr:
             KeyboardBase.process_key_event(self, *dk)
Exemple #4
0
 def __init__(self):
     KeyboardBase.__init__(self)
     self.swap_keys = True
     self.meta_modifier = None
     self.control_modifier = None
     self.num_lock_modifier = None
     self.num_lock_state = True
     self.num_lock_keycode = NUM_LOCK_KEYCODE
     self.key_translations = {}
Exemple #5
0
 def __init__(self):
     KeyboardBase.__init__(self)
     self.keymap_modifiers = None
     try:
         from xpra.x11.bindings.keyboard_bindings import X11KeyboardBindings   #@UnresolvedImport
         self.keyboard_bindings = X11KeyboardBindings()
     except Exception as e:
         log.warn("failed load posix keyboard bindings: %s", e)
         self.keyboard_bindings = None
Exemple #6
0
 def send_delayed_key(self):
     #timeout: this must be a real one, send it now
     dk = self.delayed_event
     log("send_delayed_key() delayed_event=%s", dk)
     if dk:
         self.delayed_event = None
         altgr = win32api.GetKeyState(win32con.VK_RMENU) not in (0, 1)
         if altgr:
             KeyboardBase.process_key_event(self, *dk)
Exemple #7
0
 def process_key_event(self, send_key_action_cb, wid, key_event):
     """ Caps_Lock and Num_Lock don't work properly: they get reported more than once,
         they are reported as not pressed when the key is down, etc
         So we just ignore those and rely on the list of "modifiers" passed
         with each keypress to let the server set them for us when needed.
     """
     if key_event.keyval == 2**24 - 1 and key_event.keyname == "VoidSymbol":
         log("process_key_event: ignoring %s", key_event)
         return
     #self.modifier_mappings = None       #{'control': [(37, 'Control_L'), (105, 'Control_R')], 'mod1':
     #self.modifier_keys = {}             #{"Control_L" : "control", ...}
     #self.modifier_keycodes = {}         #{"Control_R" : [105], ...}
     #self.modifier_keycodes = {"ISO_Level3_Shift": [108]}
     #we can only deal with 'Alt_R' and simulate AltGr (ISO_Level3_Shift)
     #if we have modifier_mappings
     if EMULATE_ALTGR and self.altgr_modifier and len(
             self.modifier_mappings) > 0:
         rmenu = GetKeyState(win32con.VK_RMENU)
         if key_event.keyname == "Control_L":
             log(
                 "process_key_event: %s pressed=%s, with GetKeyState(VK_RMENU)=%s",
                 key_event.keyname, key_event.pressed, rmenu)
             #AltGr is often preceded by a spurious "Control_L" event
             #delay this one a little bit so we can skip it if an "AltGr" does come through next:
             if key_event.pressed:
                 if rmenu in (0, 1):
                     self.delayed_event = (send_key_action_cb, wid,
                                           key_event)
                     #needed for altgr emulation timeouts:
                     from xpra.gtk_common.gobject_compat import import_glib
                     glib = import_glib()
                     glib.timeout_add(EMULATE_ALTGR_CONTROL_KEY_DELAY,
                                      self.send_delayed_key)
                 return
             if not key_event.pressed and rmenu not in (0, 1):
                 #unpressed: could just skip it?
                 #(but maybe the real one got pressed.. and this would get it stuck)
                 pass
         if key_event.keyname == "Alt_R":
             log(
                 "process_key_event: Alt_R pressed=%s, with GetKeyState(VK_RMENU)=%s",
                 key_event.pressed, rmenu)
             if rmenu in (0, 1) and key_event.pressed:
                 #cancel "Control_L" if one was due:
                 self.delayed_event = None
             #modify the key event so that it will only trigger the modifier update,
             #and not not the key event itself:
             key_event.string = ""
             key_event.keyname = ""
             key_event.group = -1
             key_event.keyval = -1
             key_event.keycode = -1
             self.AltGr_modifiers(key_event.modifiers)
     self.send_delayed_key()
     KeyboardBase.process_key_event(self, send_key_action_cb, wid,
                                    key_event)
Exemple #8
0
 def send_delayed_key(self):
     #timeout: this must be a real one, send it now
     dk = self.delayed_event
     if dk:
         self.delayed_event = None
         altgr = win32api.GetKeyState(win32con.VK_RMENU) not in (0, 1)
         if altgr:
             send_key_action_cb, wid, key_event = dk
             KeyboardBase.process_key_event(self, send_key_action_cb, wid,
                                            key_event)
Exemple #9
0
 def set_modifier_mappings(self, mappings):
     KeyboardBase.set_modifier_mappings(self, mappings)
     self.num_lock_modifier = self.modifier_keys.get("Num_Lock")
     log("set_modifier_mappings found 'Num_Lock' with modifier value: %s", self.num_lock_modifier)
     for x in ("ISO_Level3_Shift", "Mode_switch"):
         mod = self.modifier_keys.get(x)
         if mod:
             self.altgr_modifier = mod
             log("set_modifier_mappings found 'AltGr'='%s' with modifier value: %s", x, self.altgr_modifier)
             break
Exemple #10
0
 def set_modifier_mappings(self, mappings):
     KeyboardBase.set_modifier_mappings(self, mappings)
     self.num_lock_modifier = self.modifier_keys.get("Num_Lock")
     log("set_modifier_mappings found 'Num_Lock' with modifier value: %s", self.num_lock_modifier)
     for x in ("ISO_Level3_Shift", "Mode_switch"):
         mod = self.modifier_keys.get(x)
         if mod:
             self.altgr_modifier = mod
             log("set_modifier_mappings found 'AltGr'='%s' with modifier value: %s", x, self.altgr_modifier)
             break
Exemple #11
0
 def __init__(self):
     KeyboardBase.__init__(self)
     self.keymap_modifiers = None
     try:
         from xpra.x11.bindings.keyboard_bindings import X11KeyboardBindings  #@UnresolvedImport
         self.keyboard_bindings = X11KeyboardBindings()
     except Exception as e:
         log.error("Error: failed to load posix keyboard bindings")
         log.error(" %s", str(e) or type(e))
         self.keyboard_bindings = None
Exemple #12
0
 def send_delayed_key(self):
     #timeout: this must be a real one, send it now
     dk = self.delayed_event
     log("send_delayed_key() delayed_event=%s", dk)
     if dk:
         self.delayed_event = None
         rmenu = GetKeyState(win32con.VK_RMENU)
         log("send_delayed_key() GetKeyState(VK_RMENU)=%s", rmenu)
         if rmenu not in (0, 1):
             KeyboardBase.process_key_event(self, *dk)
Exemple #13
0
 def __init__(self):
     KeyboardBase.__init__(self)
     self.num_lock_modifier = None
     self.altgr_modifier = None
     self.delayed_event = None
     #workaround for "period" vs "KP_Decimal" with gtk2 (see ticket #586):
     #translate "period" with keyval=46 and keycode=110 to KP_Decimal:
     KEY_TRANSLATIONS[("period", 46, 110)] = "KP_Decimal"
     #workaround for "fr" keyboards, which use a different key name under X11:
     KEY_TRANSLATIONS[("dead_tilde", 65107, 50)] = "asciitilde"
     KEY_TRANSLATIONS[("dead_grave", 65104, 55)] = "grave"
Exemple #14
0
 def __init__(self):
     KeyboardBase.__init__(self)
     self.emulate_altgr = False
     self.num_lock_modifier = None
     self.last_key_event_sent = None
     #workaround for "period" vs "KP_Decimal" with gtk2 (see ticket #586):
     #translate "period" with keyval=46 and keycode=110 to KP_Decimal:
     KEY_TRANSLATIONS[("period",     46,     110)]   = "KP_Decimal"
     #workaround for "fr" keyboards, which use a different key name under X11:
     KEY_TRANSLATIONS[("dead_tilde", 65107,  50)]    = "asciitilde"
     KEY_TRANSLATIONS[("dead_grave", 65104,  55)]    = "grave"
Exemple #15
0
 def set_modifier_mappings(self, mappings):
     KeyboardBase.set_modifier_mappings(self, mappings)
     self.meta_modifier = self.modifier_keys.get("Meta_L") or self.modifier_keys.get("Meta_R")
     self.control_modifier = self.modifier_keys.get("Control_L") or self.modifier_keys.get("Control_R")
     self.num_lock_modifier = self.modifier_keys.get("Num_Lock")
     log("set_modifier_mappings(%s) meta=%s, control=%s, numlock=%s", mappings, self.meta_modifier, self.control_modifier, self.num_lock_modifier)
     #find the keysyms and keycodes to use for each key we may translate:
     for orig_keysym in KEYS_TRANSLATION_OPTIONS.keys():
         new_def = self.find_translation(orig_keysym)
         if new_def is not None:
             self.key_translations[orig_keysym] = new_def
     log("set_modifier_mappings(..) swap keys translations=%s", self.key_translations)
Exemple #16
0
 def set_modifier_mappings(self, mappings):
     KeyboardBase.set_modifier_mappings(self, mappings)
     self.meta_modifier = self.modifier_keys.get("Meta_L") or self.modifier_keys.get("Meta_R")
     self.control_modifier = self.modifier_keys.get("Control_L") or self.modifier_keys.get("Control_R")
     self.num_lock_modifier = self.modifier_keys.get("Num_Lock")
     log("set_modifier_mappings(%s) meta=%s, control=%s, numlock=%s", mappings, self.meta_modifier, self.control_modifier, self.num_lock_modifier)
     #find the keysyms and keycodes to use for each key we may translate:
     for orig_keysym in KEYS_TRANSLATION_OPTIONS.keys():
         new_def = self.find_translation(orig_keysym)
         if new_def is not None:
             self.key_translations[orig_keysym] = new_def
     log("set_modifier_mappings(..) swap keys translations=%s", self.key_translations)
Exemple #17
0
 def mask_to_names(self, mask):
     names = KeyboardBase.mask_to_names(self, mask)
     if self.swap_keys and self.meta_modifier is not None and self.control_modifier is not None:
         meta_on = bool(mask & META_MASK)
         meta_set = self.meta_modifier in names
         control_set = self.control_modifier in names
         log(
             "mask_to_names names=%s, meta_on=%s, meta_set=%s, control_set=%s",
             names, meta_on, meta_set, control_set)
         if meta_on and not control_set:
             log("mask_to_names swapping meta for control: %s for %s",
                 self.meta_modifier, self.control_modifier)
             names.append(self.control_modifier)
             if meta_set:
                 names.remove(self.meta_modifier)
         elif control_set and not meta_on:
             log("mask_to_names swapping control for meta: %s for %s",
                 self.control_modifier, self.meta_modifier)
             names.remove(self.control_modifier)
             if not meta_set:
                 names.append(self.meta_modifier)
     #deal with numlock:
     if self.num_lock_modifier is not None:
         if self.num_lock_state and self.num_lock_modifier not in names:
             names.append(self.num_lock_modifier)
         elif not self.num_lock_state and self.num_lock_modifier in names:
             names.remove(self.num_lock_modifier)
     log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #18
0
 def mask_to_names(self, mask):
     names = KeyboardBase.mask_to_names(self, mask)
     if self.swap_keys and self.meta_modifier is not None and self.control_modifier is not None:
         meta_on = bool(mask & META_MASK)
         meta_set = self.meta_modifier in names
         control_set = self.control_modifier in names
         log("mask_to_names names=%s, meta_on=%s, meta_set=%s, control_set=%s", names, meta_on, meta_set, control_set)
         if meta_on and not control_set:
             log("mask_to_names swapping meta for control: %s for %s", self.meta_modifier, self.control_modifier)
             names.append(self.control_modifier)
             if meta_set:
                 names.remove(self.meta_modifier)
         elif control_set and not meta_on:
             log("mask_to_names swapping control for meta: %s for %s", self.control_modifier, self.meta_modifier)
             names.remove(self.control_modifier)
             if not meta_set:
                 names.append(self.meta_modifier)
     #deal with numlock:
     if self.num_lock_modifier is not None:
         if self.num_lock_state and self.num_lock_modifier not in names:
             names.append(self.num_lock_modifier)
         elif not self.num_lock_state and self.num_lock_modifier in names:
             names.remove(self.num_lock_modifier)
     log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #19
0
 def process_key_event(self, send_key_action_cb, wid, key_event):
     """ Caps_Lock and Num_Lock don't work properly: they get reported more than once,
         they are reported as not pressed when the key is down, etc
         So we just ignore those and rely on the list of "modifiers" passed
         with each keypress to let the server set them for us when needed.
     """
     if key_event.keyval==2**24-1 and key_event.keyname=="VoidSymbol":
         log("process_key_event: ignoring %s", key_event)
         return
     #self.modifier_mappings = None       #{'control': [(37, 'Control_L'), (105, 'Control_R')], 'mod1':
     #self.modifier_keys = {}             #{"Control_L" : "control", ...}
     #self.modifier_keycodes = {}         #{"Control_R" : [105], ...}
     #self.modifier_keycodes = {"ISO_Level3_Shift": [108]}
     #we can only deal with 'Alt_R' and simulate AltGr (ISO_Level3_Shift)
     #if we have modifier_mappings
     if EMULATE_ALTGR and self.altgr_modifier and len(self.modifier_mappings)>0:
         rmenu = win32api.GetKeyState(win32con.VK_RMENU)
         if key_event.keyname=="Control_L":
             log("process_key_event: %s pressed=%s, with GetKeyState(VK_RMENU)=%s", key_event.keyname, key_event.pressed, rmenu)
             #AltGr is often preceded by a spurious "Control_L" event
             #delay this one a little bit so we can skip it if an "AltGr" does come through next:
             if key_event.pressed:
                 if rmenu in (0, 1):
                     self.delayed_event = (send_key_action_cb, wid, key_event)
                     glib.timeout_add(EMULATE_ALTGR_CONTROL_KEY_DELAY, self.send_delayed_key)
                 return
             if not key_event.pressed and rmenu not in (0, 1):
                 #unpressed: could just skip it?
                 #(but maybe the real one got pressed.. and this would get it stuck)
                 pass
         if key_event.keyname=="Alt_R":
             log("process_key_event: Alt_R pressed=%s, with GetKeyState(VK_RMENU)=%s", key_event.pressed, rmenu)
             if rmenu in (0, 1) and key_event.pressed:
                 #cancel "Control_L" if one was due:
                 self.delayed_event = None
             #modify the key event so that it will only trigger the modifier update,
             #and not not the key event itself:
             key_event.string = ""
             key_event.keyname = ""
             key_event.group = -1
             key_event.keyval = -1
             key_event.keycode = -1
             self.AltGr_modifiers(key_event.modifiers)
     self.send_delayed_key()
     KeyboardBase.process_key_event(self, send_key_action_cb, wid, key_event)
Exemple #20
0
 def mask_to_names(self, mask):
     names = KeyboardBase.mask_to_names(self, mask)
     if self.num_lock_modifier is not None:
         if self.num_lock_state and self.num_lock_modifier not in names:
             names.append(self.num_lock_modifier)
         elif not self.num_lock_state and self.num_lock_modifier in names:
             names.remove(self.num_lock_modifier)
     log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #21
0
 def mask_to_names(self, mask):
     names = KeyboardBase.mask_to_names(self, mask)
     if self.num_lock_modifier is not None:
         if self.num_lock_state and self.num_lock_modifier not in names:
             names.append(self.num_lock_modifier)
         elif not self.num_lock_state and self.num_lock_modifier in names:
             names.remove(self.num_lock_modifier)
     log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #22
0
 def process_key_event(self, send_key_action_cb, wid, key_event):
     """ Caps_Lock and Num_Lock don't work properly: they get reported more than once,
         they are reported as not pressed when the key is down, etc
         So we just ignore those and rely on the list of "modifiers" passed
         with each keypress to let the server set them for us when needed.
     """
     log("win32.process_key_event(%s, %s, %s)", send_key_action_cb, wid,
         key_event)
     if key_event.keyval == 2**24 - 1 and key_event.keyname == "VoidSymbol":
         return
     #self.modifier_mappings = None       #{'control': [(37, 'Control_L'), (105, 'Control_R')], 'mod1':
     #self.modifier_keys = {}             #{"Control_L" : "control", ...}
     #self.modifier_keycodes = {}         #{"Control_R" : [105], ...}
     #self.modifier_keycodes = {"ISO_Level3_Shift": [108]}
     #we can only deal with 'Alt_R' and simulate AltGr (ISO_Level3_Shift)
     #if we have modifier_mappings
     if key_event.keyname == "Alt_R" and len(self.modifier_mappings) > 0:
         keyname = "ISO_Level3_Shift"
         altgr_keycodes = self.modifier_keycodes.get(keyname, [])
         if len(altgr_keycodes) > 0:
             self.emulate_altgr = key_event.pressed
             if key_event.pressed and self.last_key_event_sent:
                 #check for spurious control and undo it
                 last_wid, last_key_event = self.last_key_event_sent
                 if last_wid == wid and last_key_event.keyname == "Control_L" and last_key_event.pressed == True:
                     #undo it:
                     last_key_event.pressed = False
                     KeyboardBase.process_key_event(self,
                                                    send_key_action_cb,
                                                    last_wid,
                                                    last_key_event)
             self.AltGr_modifiers(key_event.modifiers,
                                  not key_event.pressed)
     if key_event.keyname == "period" and key_event.keyval == 46 and key_event.keycode == 110:
         log("patched 'period' keyname to 'KP_Decimal'")
         key_event.keyname = "KP_Decimal"
     elif key_event.keyname == "dead_tilde" and key_event.keyval == 65107 and key_event.keycode == 50:
         log("patched 'dead_tilde' keyname to 'asciitilde'")
         key_event.keyname = "asciitilde"
     elif key_event.keyname == "dead_grave" and key_event.keyval == 65104 and key_event.keycode == 55:
         log("patched 'dead_grave' keyname to 'grave'")
         key_event.keyname = "grave"
     self.last_key_event_sent = (wid, key_event)
     send_key_action_cb(wid, key_event)
Exemple #23
0
 def process_key_event(self, send_key_action_cb, wid, key_event):
     """ Caps_Lock and Num_Lock don't work properly: they get reported more than once,
         they are reported as not pressed when the key is down, etc
         So we just ignore those and rely on the list of "modifiers" passed
         with each keypress to let the server set them for us when needed.
     """
     if key_event.keyval == 2**24 - 1 and key_event.keyname == "VoidSymbol":
         return
     #self.modifier_mappings = None       #{'control': [(37, 'Control_L'), (105, 'Control_R')], 'mod1':
     #self.modifier_keys = {}             #{"Control_L" : "control", ...}
     #self.modifier_keycodes = {}         #{"Control_R" : [105], ...}
     #self.modifier_keycodes = {"ISO_Level3_Shift": [108]}
     #we can only deal with 'Alt_R' and simulate AltGr (ISO_Level3_Shift)
     #if we have modifier_mappings
     if EMULATE_ALTGR and self.altgr_modifier and len(
             self.modifier_mappings) > 0:
         if key_event.keyname == "Control_L":
             altgr = win32api.GetKeyState(win32con.VK_RMENU) not in (0, 1)
             #AltGr is often preceded by a spurious "Control_L" event
             #delay this one a little bit so we can skip it if an "AltGr" does come through next:
             if key_event.pressed:
                 if not altgr:
                     self.delayed_event = (send_key_action_cb, wid,
                                           key_event)
                     glib.timeout_add(EMULATE_ALTGR_CONTROL_KEY_DELAY,
                                      self.send_delayed_key)
                 return
             if not key_event.pressed and altgr:
                 #unpressed: could just skip it?
                 #(but maybe the real one got pressed.. and this would get it stuck)
                 pass
         if key_event.keyname == "Alt_R":
             #cancel "Control_L" if one was due:
             self.delayed_event = None
             return
     self.send_delayed_key()
     KeyboardBase.process_key_event(self, send_key_action_cb, wid,
                                    key_event)
Exemple #24
0
 def mask_to_names(self, mask):
     """ Patch NUMLOCK and AltGr """
     names = KeyboardBase.mask_to_names(self, mask)
     if self.emulate_altgr:
         self.AltGr_modifiers(names)
     if self.num_lock_modifier:
         try:
             import win32api         #@UnresolvedImport
             import win32con         #@UnresolvedImport
             numlock = win32api.GetKeyState(win32con.VK_NUMLOCK)
             log("mask_to_names(%s) GetKeyState(VK_NUMLOCK)=%s", mask, numlock)
             if numlock and self.num_lock_modifier not in names:
                 names.append(self.num_lock_modifier)
             elif not numlock and self.num_lock_modifier in names:
                 names.remove(self.num_lock_modifier)
         except:
             pass
     log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #25
0
 def mask_to_names(self, mask):
     """ Patch NUMLOCK and AltGr """
     names = KeyboardBase.mask_to_names(self, mask)
     altgr = win32api.GetKeyState(win32con.VK_RMENU) not in (0, 1)
     if altgr:
         self.AltGr_modifiers(names)
     if self.num_lock_modifier:
         try:
             numlock = win32api.GetKeyState(win32con.VK_NUMLOCK)
             if numlock and self.num_lock_modifier not in names:
                 names.append(self.num_lock_modifier)
             elif not numlock and self.num_lock_modifier in names:
                 names.remove(self.num_lock_modifier)
             log("mask_to_names(%s) GetKeyState(VK_NUMLOCK)=%s, names=%s", mask, numlock, names)
         except:
             pass
     else:
         log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #26
0
 def mask_to_names(self, mask):
     """ Patch NUMLOCK and AltGr """
     names = KeyboardBase.mask_to_names(self, mask)
     if self.emulate_altgr:
         self.AltGr_modifiers(names)
     if self.num_lock_modifier:
         try:
             import win32api         #@UnresolvedImport
             import win32con         #@UnresolvedImport
             numlock = win32api.GetKeyState(win32con.VK_NUMLOCK)
             if numlock and self.num_lock_modifier not in names:
                 names.append(self.num_lock_modifier)
             elif not numlock and self.num_lock_modifier in names:
                 names.remove(self.num_lock_modifier)
             log("mask_to_names(%s) GetKeyState(VK_NUMLOCK)=%s, names=%s", mask, numlock, names)
         except:
             pass
     else:
         log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #27
0
 def mask_to_names(self, mask):
     """ Patch NUMLOCK and AltGr """
     names = KeyboardBase.mask_to_names(self, mask)
     if EMULATE_ALTGR:
         rmenu = GetKeyState(win32con.VK_RMENU)
         #log("GetKeyState(VK_RMENU)=%s", rmenu)
         if rmenu not in (0, 1):
             self.AltGr_modifiers(names)
     if self.num_lock_modifier:
         try:
             numlock = GetKeyState(win32con.VK_NUMLOCK)
             if numlock and self.num_lock_modifier not in names:
                 names.append(self.num_lock_modifier)
             elif not numlock and self.num_lock_modifier in names:
                 names.remove(self.num_lock_modifier)
             log("mask_to_names(%s) GetKeyState(VK_NUMLOCK)=%s, names=%s", mask, numlock, names)
         except:
             pass
     else:
         log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #28
0
 def mask_to_names(self, mask):
     names = KeyboardBase.mask_to_names(self, mask)
     log("mask_to_names names=%s, meta mod=%s, control mod=%s, num lock mod=%s, num lock state=%s",
         names, self.meta_modifier, self.control_modifier, self.num_lock_modifier, self.num_lock_state)
     if self.swap_keys and self.meta_modifier is not None and self.control_modifier is not None:
         #clear both:
         for x in (self.control_modifier, self.meta_modifier):
             if x in names:
                 names.remove(x)
         #re-add as needed:
         if mask & META_MASK:
             names.append(self.control_modifier)
         if mask & CONTROL_MASK:
             names.append(self.meta_modifier)
     #deal with numlock:
     if self.num_lock_modifier is not None:
         if self.num_lock_state and self.num_lock_modifier not in names:
             names.append(self.num_lock_modifier)
         elif not self.num_lock_state and self.num_lock_modifier in names:
             names.remove(self.num_lock_modifier)
     log("mask_to_names(%s)=%s", mask, names)
     return names
Exemple #29
0
 def set_modifier_mappings(self, mappings):
     KeyboardBase.set_modifier_mappings(self, mappings)
     self.num_lock_modifier = self.modifier_keys.get("Num_Lock")
Exemple #30
0
 def __init__(self):
     KeyboardBase.__init__(self)
     self.emulate_altgr = False
     self.num_lock_modifier = None
     self.last_key_event_sent = None
Exemple #31
0
 def set_modifier_mappings(self, mappings):
     KeyboardBase.set_modifier_mappings(self, mappings)
     self.num_lock_modifier = self.modifier_keys.get("Num_Lock")
     log("set_modifier_mappings found 'Num_Lock' modifier value: %s", self.num_lock_modifier)
Exemple #32
0
 def set_modifier_mappings(self, mappings):
     KeyboardBase.set_modifier_mappings(self, mappings)
     self.num_lock_modifier = self.modifier_keys.get("Num_Lock")
Exemple #33
0
 def __init__(self):
     KeyboardBase.__init__(self)
     self.init_vars()
Exemple #34
0
 def cleanup(self):
     self.init_vars()
     KeyboardBase.cleanup(self)
Exemple #35
0
 def __init__(self):
     KeyboardBase.__init__(self)
     self.emulate_altgr = False
     self.num_lock_modifier = None
     self.last_key_event_sent = None