Implement axis movement method
This commit is contained in:
parent
1ca27dab58
commit
ca800331de
@ -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],
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user