mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-04 12:00:16 +00:00
improved logs, removed redundant start_reading, fixed unresponsive keyboard
This commit is contained in:
parent
bdebee3ce9
commit
4a745eb2e9
@ -247,7 +247,6 @@ class KeycodeInjector:
|
||||
capabilities[EV_KEY] += list(macro.get_capabilities())
|
||||
|
||||
if abs_to_rel:
|
||||
del capabilities[EV_ABS]
|
||||
# those are the requirements to recognize it as mouse
|
||||
# on my system. REL_X and REL_Y are of course required to
|
||||
# accept the events that the mouse-movement-mapper writes.
|
||||
@ -270,6 +269,10 @@ class KeycodeInjector:
|
||||
del capabilities[ecodes.EV_SYN]
|
||||
if ecodes.EV_FF in capabilities:
|
||||
del capabilities[ecodes.EV_FF]
|
||||
if ecodes.EV_ABS in capabilities:
|
||||
# EV_KEY events are ignoerd by the os when EV_ABS capabilities
|
||||
# are present
|
||||
del capabilities[ecodes.EV_ABS]
|
||||
|
||||
return capabilities
|
||||
|
||||
@ -327,6 +330,9 @@ class KeycodeInjector:
|
||||
|
||||
macros[key] = macro
|
||||
|
||||
if len(macros) == 0:
|
||||
logger.debug('No macros configured')
|
||||
|
||||
# certain capabilities can have side effects apparently. with an
|
||||
# EV_ABS capability, EV_REL won't move the mouse pointer anymore.
|
||||
# so don't merge all InputDevices into one UInput device.
|
||||
|
@ -24,9 +24,6 @@
|
||||
|
||||
import math
|
||||
|
||||
import evdev
|
||||
|
||||
from evdev.ecodes import EV_KEY
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
|
||||
from keymapper.data import get_data_path
|
||||
@ -368,6 +365,7 @@ class Window:
|
||||
"""Load the mapping."""
|
||||
self.dbus.stop_injecting(self.selected_device)
|
||||
self.show_status(CTX_APPLY, 'Applied the system default')
|
||||
logger.info('Applied system default for "%s"', self.selected_preset)
|
||||
GLib.timeout_add(10, self.show_device_mapping_status)
|
||||
|
||||
def show_status(self, context_id, message, tooltip=None):
|
||||
@ -438,7 +436,7 @@ class Window:
|
||||
preset = self.selected_preset
|
||||
device = self.selected_device
|
||||
|
||||
logger.debug('Applying preset "%s" for "%s"', preset, device)
|
||||
logger.info('Applying preset "%s" for "%s"', preset, device)
|
||||
|
||||
if custom_mapping.changed:
|
||||
self.show_status(
|
||||
@ -456,9 +454,6 @@ class Window:
|
||||
if not success:
|
||||
self.show_status(CTX_ERROR, 'Error: Could not grab devices!')
|
||||
|
||||
# restart reading because after injecting the device landscape
|
||||
# changes a bit
|
||||
keycode_reader.start_reading(device)
|
||||
GLib.timeout_add(10, self.show_device_mapping_status)
|
||||
|
||||
def on_autoload_switch(self, _, active):
|
||||
@ -495,8 +490,9 @@ class Window:
|
||||
|
||||
def show_device_mapping_status(self):
|
||||
"""Figure out if this device is currently under keymappers control."""
|
||||
if self.dbus.is_injecting(self.selected_device):
|
||||
logger.info('This device is currently mapped.')
|
||||
device = self.selected_device
|
||||
if self.dbus.is_injecting(device):
|
||||
logger.info('Device "%s" is currently mapped', device)
|
||||
self.get('apply_system_layout').set_opacity(1)
|
||||
else:
|
||||
self.get('apply_system_layout').set_opacity(0.4)
|
||||
|
@ -98,3 +98,4 @@ inject the users autoloaded presets instead (if any are configured)
|
||||
## Resources
|
||||
|
||||
[PyGObject API Reference](https://lazka.github.io/pgi-docs/)
|
||||
[python-evdev](https://python-evdev.readthedocs.io/en/stable/)
|
||||
|
@ -71,7 +71,8 @@ class TestInjector(unittest.TestCase):
|
||||
assert absinfo is False
|
||||
return {
|
||||
evdev.ecodes.EV_SYN: [1, 2, 3],
|
||||
evdev.ecodes.EV_FF: [1, 2, 3]
|
||||
evdev.ecodes.EV_FF: [1, 2, 3],
|
||||
evdev.ecodes.EV_ABS: [1, 2, 3]
|
||||
}
|
||||
|
||||
mapping = Mapping()
|
||||
@ -109,6 +110,7 @@ class TestInjector(unittest.TestCase):
|
||||
self.assertNotIn(evdev.ecodes.EV_SYN, capabilities)
|
||||
self.assertNotIn(evdev.ecodes.EV_FF, capabilities)
|
||||
self.assertNotIn(evdev.ecodes.EV_REL, capabilities)
|
||||
self.assertNotIn(evdev.ecodes.EV_ABS, capabilities)
|
||||
|
||||
def test_grab(self):
|
||||
# path is from the fixtures
|
||||
|
Loading…
Reference in New Issue
Block a user