diff --git a/src/cthulhu/dbus_service.py b/src/cthulhu/dbus_service.py index a32dedc..9af6f6a 100644 --- a/src/cthulhu/dbus_service.py +++ b/src/cthulhu/dbus_service.py @@ -48,11 +48,15 @@ from . import cthulhu_platform # pylint: disable=no-name-in-module from . import script_manager from . import cthulhu_state -# Lazy import to avoid circular dependency +# Lazy imports to avoid circular dependency def _get_input_event(): from . import input_event return input_event +def _get_input_event_manager(): + from . import input_event_manager + return input_event_manager + class HandlerType(enum.Enum): """Enumeration of handler types for D-Bus methods.""" @@ -670,7 +674,12 @@ class CthulhuRemoteController: def _wrapper(notify_user): event = _get_input_event().RemoteControllerEvent() script = cthulhu_state.activeScript - return method(script=script, event=event, notify_user=notify_user) + if script is None: + manager = script_manager.getManager() + script = manager.getDefaultScript() + rv = method(script=script, event=event, notify_user=notify_user) + _get_input_event_manager().getManager().process_remote_controller_event(event) + return rv return _wrapper handler_info = _HandlerInfo( python_function_name=attr_name, @@ -692,7 +701,9 @@ class CthulhuRemoteController: if script is None: manager = script_manager.getManager() script = manager.getDefaultScript() - return method(script=script, event=event, **kwargs) + rv = method(script=script, event=event, **kwargs) + _get_input_event_manager().getManager().process_remote_controller_event(event) + return rv return _wrapper handler_info = _HandlerInfo( python_function_name=attr_name, diff --git a/src/cthulhu/input_event_manager.py b/src/cthulhu/input_event_manager.py index 959a2d8..c79f1c8 100644 --- a/src/cthulhu/input_event_manager.py +++ b/src/cthulhu/input_event_manager.py @@ -256,6 +256,14 @@ class InputEventManager: mouse_event.setClickCount(self._determine_mouse_event_click_count(mouse_event)) self._last_input_event = mouse_event + def process_remote_controller_event(self, event: input_event.RemoteControllerEvent) -> None: + """Processes this RemoteController event.""" + + # TODO - JD: It probably makes sense to process remote controller events here rather + # than just updating state. + self._last_input_event = event + self._last_non_modifier_key_event = None + def process_keyboard_event(self, _device, pressed, keycode, keysym, modifiers, text): """Processes this Atspi keyboard event."""