diff --git a/README.md b/README.md index 5c6e48ff..9dadd6aa 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ work. # Running -``` +```bash sudo python3 setup.py install && sudo key-mapper-gtk -d ``` @@ -26,7 +26,7 @@ No idea which one are relevant at the moment sudo is required because some tests actually read /dev stuff. -``` +```bash sudo python3 setup.py install && sudo python3 tests/test.py ``` diff --git a/bin/key-mapper-gtk b/bin/key-mapper-gtk index 5231f456..2cb83806 100755 --- a/bin/key-mapper-gtk +++ b/bin/key-mapper-gtk @@ -129,7 +129,12 @@ class Window: else: logger.debug('Presets for "%s": %s', device, ', '.join(presets)) preset_selection = self.get('preset_selection') + + preset_selection.handler_block_by_func(self.on_select_preset) + # otherwise the handler is called with None for each removed preset preset_selection.remove_all() + preset_selection.handler_unblock_by_func(self.on_select_preset) + for preset in presets: preset_selection.append(preset, preset) # and select the newest one (on the top) diff --git a/data/key-mapper.glade b/data/key-mapper.glade index fb8b6e6e..e42f5d05 100644 --- a/data/key-mapper.glade +++ b/data/key-mapper.glade @@ -6,25 +6,49 @@ 450 False Key Mapper + False True False - vertical - + True False - 10 - 10 + vertical - + True False - Device - 10 - 0 + 10 + 10 + + + True + False + Device + 13 + 0 + + + False + True + 0 + + + + + True + False + + + + True + True + 1 + + False @@ -33,17 +57,192 @@ - + True False - - True + False True 1 + + + True + False + 10 + vertical + 10 + + + True + False + 10 + + + gtk-apply + 80 + True + True + True + True + + + False + True + 0 + + + + + gtk-save + 80 + True + True + True + True + + + False + True + 1 + + + + + gtk-new + 80 + True + True + True + True + + + + False + True + 2 + + + + + True + False + 0 + + + True + True + 3 + + + + + gtk-delete + 80 + True + True + True + True + + + False + True + 4 + + + + + False + True + 0 + + + + + True + False + 10 + + + 50 + True + False + preset + 13 + 0 + + + False + True + 0 + + + + + 200 + True + False + + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 10 + + + True + False + Rename + 13 + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 2 + + + + + False + True + 2 + + False @@ -59,31 +258,27 @@ False True - 10 1 - + + 200 True False - 10 vertical - 10 - + True False - 10 + 10 - - gtk-new - 80 + + 50 True - True - True - True - + False + Mapping + 0 True @@ -92,35 +287,21 @@ - - gtk-save + + gtk-add 80 True True True True + - True + False True 1 - - - gtk-delete - 80 - True - True - True - True - - - True - True - 2 - - False @@ -129,82 +310,48 @@ - + True False - 10 + 10 + 10 + 10 + 2 + 2 - 50 True False - preset - 10 - 0 + True + Mapping - False - True - 0 + 2 + 0 - - 200 + True False - + True + Key - True - True - 1 + 1 + 0 + + + - False + True True 1 - - - True - False - 10 - - - True - False - Rename - 10 - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 2 - - False @@ -212,103 +359,6 @@ 2 - - - True - False - - - False - True - 10 - 3 - - - - - True - False - 10 - - - 50 - True - False - Mapping - 0 - - - True - True - 0 - - - - - gtk-add - 80 - True - True - True - True - - - - False - True - 1 - - - - - False - True - 4 - - - - - True - False - 10 - 10 - 10 - 10 - 10 - - - True - False - True - Mapping - - - 2 - 0 - - - - - True - False - True - Key - - - 1 - 0 - - - - - - - - True - True - 5 - - diff --git a/data/screenshot.png b/data/screenshot.png index a3b24312..25786349 100644 Binary files a/data/screenshot.png and b/data/screenshot.png differ diff --git a/keymapper/presets.py b/keymapper/presets.py index c9a27179..e607888c 100644 --- a/keymapper/presets.py +++ b/keymapper/presets.py @@ -42,14 +42,21 @@ def get_devices(): return _devices devices = [evdev.InputDevice(path) for path in evdev.list_devices()] + # group them together by usb device because there could be stuff like # "Logitech USB Keyboard" and "Logitech USB Keyboard Consumer Control" grouped = {} for device in devices: + # only keyboard devices + # https://www.kernel.org/doc/html/latest/input/event-codes.html + if not evdev.ecodes.EV_KEY in device.capabilities().keys(): + continue + usb = device.phys.split('/')[0] if grouped.get(usb) is None: grouped[usb] = [] grouped[usb].append((device.name, device.path)) + # now write down all the paths of that group result = {} for group in grouped.values():