From 5999e3c0b9c20895e56a0f10ff3733111fd30991 Mon Sep 17 00:00:00 2001 From: WhiteMagic Date: Fri, 2 Feb 2018 22:54:09 +1100 Subject: [PATCH] Removing unused code --- gremlin/execution_graph.py | 57 +++-------------------------------- gremlin/sendinput.py | 36 ---------------------- gremlin/windows_event_hook.py | 10 ------ 3 files changed, 5 insertions(+), 98 deletions(-) diff --git a/gremlin/execution_graph.py b/gremlin/execution_graph.py index 1fb0688a..9bc4b851 100644 --- a/gremlin/execution_graph.py +++ b/gremlin/execution_graph.py @@ -18,8 +18,8 @@ from abc import abstractmethod, ABCMeta from collections import namedtuple import copy +import logging -# from action_plugins.remap import Remap from gremlin import actions, base_classes, common, error @@ -42,34 +42,6 @@ def __init__(self, container): """ self.execution_graph = ContainerExecutionGraph(container) - # # Reorder containers such that if those containing remap actions are - # # executed last - # pre_containers = [] - # post_containers = [] - # for i, container in enumerate(input_item.containers): - # # Don't include virtual button based containers they are handled - # # separately - # if container.virtual_button: - # continue - # contains_remap = False - # for action_set in container.action_sets: - # for action in action_set: - # if isinstance(action, action_plugins.remap.Remap): - # contains_remap |= True - # if contains_remap: - # post_containers.append(i) - # else: - # pre_containers.append(i) - # - # ordered_containers = [] - # for i in pre_containers: - # ordered_containers.append(input_item.containers[i]) - # for i in post_containers: - # ordered_containers.append(input_item.containers[i]) - # - # for container in ordered_containers: - # self.execution_graphs.append(ContainerExecutionGraph(container)) - def __call__(self, event): """Executes the callback based on the event's content. @@ -95,10 +67,10 @@ def __call__(self, event): shared_value = copy.deepcopy(value) if event == common.InputType.VirtualButton: - self.execution_graph.process_event(event, copy.deepcopy(value)) - print("VIRTUAL BUTTON CODE PATH") - 0 / 0 - # TODO: remove this + # TODO: remove this at a future stage + logging.getLogger("system").error( + "Virtual button code path being used" + ) else: self.execution_graph.process_event(event, shared_value) @@ -329,25 +301,6 @@ def _build_graph(self, container): self._create_transitions(sequence) - # def _create_virtual_button(self, container): - # """Creates a VirtualButton object for the provided container. - # - # :param container data to use in order to generate the VirtualButton - # """ - # input_type = container.get_input_type() - # if input_type == common.InputType.JoystickAxis: - # return actions.AxisButton( - # container.virtual_button.lower_limit, - # container.virtual_button.upper_limit, - # container.virtual_button.direction - # ) - # elif input_type == common.InputType.JoystickHat: - # return actions.HatButton( - # container.virtual_button.directions - # ) - # else: - # raise error.GremlinError("Invalid virtual button provided") - class ActionSetExecutionGraph(AbstractExecutionGraph): diff --git a/gremlin/sendinput.py b/gremlin/sendinput.py index c858458b..2fc0dd41 100644 --- a/gremlin/sendinput.py +++ b/gremlin/sendinput.py @@ -164,39 +164,3 @@ def _send_input(*inputs): cbSize = ctypes.c_int(ctypes.sizeof(_INPUT)) return ctypes.windll.user32.SendInput(nInputs, pInputs, cbSize) - - -# # for _ in range(10): -# # mouse_wheel(1) -# # time.sleep(0.2) -# -# # mouse_press(MouseButton.Back) -# # mouse_release(MouseButton.Back) -# # time.sleep(0.5) -# # mouse_press(MouseButton.Forward) -# # mouse_release(MouseButton.Forward) -# -# pps = 15 -# step = 1.0 -# delay = 1.0 / (pps / step) -# -# while delay < 0.01: -# step += 1.0 -# delay = 1.0 / (pps / step) -# -# step = int(step) -# print(delay, step) -# -# # while rate < 0.01: -# # rate = 1.0 / pps -# # pps -# # print(rate) -# #amount = 1000 / 20 -# -# # mouse_press(MouseButton.Left) -# t_start = time.time() -# while time.time() - t_start < 1: -# mouse_relative_motion(step, 0) -# time.sleep(delay) -# # mouse_release(MouseButton.Left) -# diff --git a/gremlin/windows_event_hook.py b/gremlin/windows_event_hook.py index 9c5e821d..891b8666 100644 --- a/gremlin/windows_event_hook.py +++ b/gremlin/windows_event_hook.py @@ -300,20 +300,10 @@ def _process_event(self, n_code, w_param, l_param): else: print(w_param) - # print(button_id) evt = MouseEvent(button_id, is_pressed, False) for cb in self._callbacks: cb(evt) - # Extract data from the message - # print(n_code, w_param) - # if l_param[2] is not None: - # # print(l_param[0], l_param[1], bin(l_param[2])) - # print(w_param, l_param[2] & (0x0001 << 16)) - # # - # # 1 0000 0000 0000 0000 - # # 10 0000 0000 0000 0000 - # Pass the event on to the next callback in the chain return ctypes.windll.user32.CallNextHookEx( self.hook_id,