added power key to hids

This commit is contained in:
Devaev Maxim 2020-07-16 21:58:06 +03:00
parent 5613a7b2b5
commit 2f640b7a08
4 changed files with 16 additions and 3 deletions

View File

@ -28,9 +28,11 @@ import dataclasses
from typing import Set from typing import Set
from typing import List from typing import List
from typing import Optional
import Xlib.keysymdef.latin1 import Xlib.keysymdef.latin1
import Xlib.keysymdef.miscellany import Xlib.keysymdef.miscellany
import Xlib.keysymdef.xf86
import mako.template import mako.template
@ -60,9 +62,15 @@ class _KeyMapping:
def _resolve_keysym(name: str) -> int: def _resolve_keysym(name: str) -> int:
code = getattr(Xlib.keysymdef.latin1, name, None) code: Optional[int] = None
if code is None: for module in [
code = getattr(Xlib.keysymdef.miscellany, name, None) Xlib.keysymdef.latin1,
Xlib.keysymdef.miscellany,
Xlib.keysymdef.xf86,
]:
code = getattr(module, name, None)
if code is not None:
break
assert code is not None, name assert code is not None, name
return code return code

View File

@ -108,6 +108,7 @@ INLINE KeyboardKeycode keymap(uint8_t code) {
case 69: return KEY_PAGE_UP; case 69: return KEY_PAGE_UP;
case 85: return KEY_PAUSE; case 85: return KEY_PAUSE;
case 51: return KEY_PERIOD; case 51: return KEY_PERIOD;
case 105: return KEY_POWER;
case 66: return KEY_PRINT; case 66: return KEY_PRINT;
case 17: return KEY_Q; case 17: return KEY_Q;
case 48: return KEY_QUOTE; case 48: return KEY_QUOTE;

View File

@ -103,3 +103,4 @@ Numpad8,101,KEYPAD_8,0x60,0x48,XK_KP_8
Numpad9,102,KEYPAD_9,0x61,0x49,XK_KP_9 Numpad9,102,KEYPAD_9,0x61,0x49,XK_KP_9
Numpad0,103,KEYPAD_0,0x62,0x52,XK_KP_0 Numpad0,103,KEYPAD_0,0x62,0x52,XK_KP_0
NumpadDecimal,104,KEYPAD_DOT,0x63,0x53,XK_KP_Decimal NumpadDecimal,104,KEYPAD_DOT,0x63,0x53,XK_KP_Decimal
Power,105,KEY_POWER,0x66,0xe05e,XK_XF86_Sleep

1 web_name serial_code arduino_name otg_key at1_code x11_names
103 Numpad9 102 KEYPAD_9 0x61 0x49 XK_KP_9
104 Numpad0 103 KEYPAD_0 0x62 0x52 XK_KP_0
105 NumpadDecimal 104 KEYPAD_DOT 0x63 0x53 XK_KP_Decimal
106 Power 105 KEY_POWER 0x66 0xe05e XK_XF86_Sleep

View File

@ -148,6 +148,7 @@ KEYMAP: Dict[str, Key] = {
"Numpad9": Key(serial=SerialKey(code=102), otg=OtgKey(code=97, is_modifier=False)), "Numpad9": Key(serial=SerialKey(code=102), otg=OtgKey(code=97, is_modifier=False)),
"Numpad0": Key(serial=SerialKey(code=103), otg=OtgKey(code=98, is_modifier=False)), "Numpad0": Key(serial=SerialKey(code=103), otg=OtgKey(code=98, is_modifier=False)),
"NumpadDecimal": Key(serial=SerialKey(code=104), otg=OtgKey(code=99, is_modifier=False)), "NumpadDecimal": Key(serial=SerialKey(code=104), otg=OtgKey(code=99, is_modifier=False)),
"Power": Key(serial=SerialKey(code=105), otg=OtgKey(code=102, is_modifier=False)),
} }
@ -312,6 +313,7 @@ X11_TO_AT1 = {
65511: At1Key(code=57435, shift=False), # XK_Meta_L 65511: At1Key(code=57435, shift=False), # XK_Meta_L
65512: At1Key(code=57436, shift=False), # XK_Meta_R 65512: At1Key(code=57436, shift=False), # XK_Meta_R
65383: At1Key(code=57437, shift=False), # XK_Menu 65383: At1Key(code=57437, shift=False), # XK_Menu
269025071: At1Key(code=57438, shift=False), # XK_XF86_Sleep
} }
@ -420,4 +422,5 @@ AT1_TO_WEB = {
57435: "MetaLeft", 57435: "MetaLeft",
57436: "MetaRight", 57436: "MetaRight",
57437: "ContextMenu", 57437: "ContextMenu",
57438: "Power",
} }