g13gui: bindings: Setup preliminaries for keycode decoding

This commit is contained in:
June Tate-Gans 2021-05-02 23:47:54 -05:00
parent 8a6fc4b0f0
commit 9a9f504995

View File

@ -1,7 +1,12 @@
#!/usr/bin/python3 #!/usr/bin/python3
import gi
from evdev import ecodes as e from evdev import ecodes as e
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk, GObject, Gdk
from g13gui.g13.common import G13Keys from g13gui.g13.common import G13Keys
""" """
@ -77,3 +82,19 @@ ALL_STICK_MODES = frozenset({
DEFAULT_LCD_COLOR = (1.0, 0.0, 0.0) DEFAULT_LCD_COLOR = (1.0, 0.0, 0.0)
def KeycodeIsModifier(code):
return code in (
e.KEY_LEFTSHIFT, e.KEY_RIGHTSHIFT,
e.KEY_LEFTCTRL, e.KEY_RIGHTCTRL,
e.KEY_LEFTALT, e.KEY_RIGHTALT)
def BindsToKeynames(binds):
keybinds = []
for bind in binds:
name = e.KEY[bind][4:].capitalize()
keybinds.append(name)
return keybinds