Implement axis movement method

This commit is contained in:
xs5871 2022-10-22 20:49:12 +00:00 committed by xs5871
parent 1ca27dab58
commit ca800331de
2 changed files with 10 additions and 9 deletions

View File

@ -42,6 +42,10 @@ class Axis:
def __repr__(self) -> str:
return f'Axis(code={self.code}, delta={self.delta})'
def move(self, keyboard: Keyboard, delta: int):
keyboard.hid_pending = True
self.delta += delta
def maybe_make_key(
code: Optional[int],

View File

@ -106,21 +106,18 @@ class MouseKeys(Module):
if self.move_step < self.max_speed:
self.move_step = self.move_step + 1
if self._right_activated:
keyboard.axes['X'].delta += self.move_step
keyboard.axes['X'].move(keyboard, self.move_step)
if self._left_activated:
keyboard.axes['X'].delta -= self.move_step
keyboard.axes['X'].move(keyboard, -self.move_step)
if self._up_activated:
keyboard.axes['Y'].delta -= self.move_step
keyboard.axes['Y'].move(keyboard, -self.move_step)
if self._down_activated:
keyboard.axes['Y'].delta += self.move_step
keyboard.hid_pending = True
keyboard.axes['Y'].move(keyboard, self.move_step)
if self._mw_up_activated:
keyboard.axes['W'].delta += self.move_step
keyboard.hid_pending = True
keyboard.axes['W'].move(keyboard, 1)
if self._mw_down_activated:
keyboard.axes['W'].delta -= self.move_step
keyboard.hid_pending = True
keyboard.axes['W'].move(keyboard, -1)
def before_hid_send(self, keyboard):
return