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: def __repr__(self) -> str:
return f'Axis(code={self.code}, delta={self.delta})' 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( def maybe_make_key(
code: Optional[int], code: Optional[int],

View File

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