|
1 | 1 | import math |
2 | 2 | import asyncio |
3 | | -import time |
4 | 3 | import logging |
5 | 4 |
|
6 | | -from joycontrol.controller_state import ControllerState |
| 5 | +from joycontrol.controller_state import button_push, button_press, button_release |
7 | 6 | from joycontrol.command_line_interface import ControllerCLI |
8 | 7 |
|
9 | 8 | logger = logging.getLogger(__name__) |
@@ -57,28 +56,12 @@ async def right_stick(self, direction=None, angle=None, power=MAX_STICK_POWER): |
57 | 56 | await self.stick('right', direction, angle, power) |
58 | 57 |
|
59 | 58 | async def button_press(self, *buttons): |
60 | | - if not buttons: |
61 | | - raise ValueError('No Buttons were given.') |
62 | | - |
63 | 59 | logger.debug('Press {}'.format(', '.join(buttons))) |
64 | | - button_state = self.controller_state.button_state |
65 | | - for button in buttons: |
66 | | - button_state.set_button(button) |
67 | | - |
68 | | - # send report |
69 | | - await self.controller_state.send() |
| 60 | + await button_press(self.controller_state, *buttons) |
70 | 61 |
|
71 | 62 | async def button_release(self, *buttons): |
72 | | - if not buttons: |
73 | | - raise ValueError('No Buttons were given.') |
74 | | - |
75 | 63 | logger.debug('Release {}'.format(', '.join(buttons))) |
76 | | - button_state = self.controller_state.button_state |
77 | | - for button in buttons: |
78 | | - button_state.set_button(button, pushed=False) |
79 | | - |
80 | | - # send report |
81 | | - await self.controller_state.send() |
| 64 | + await button_release(self.controller_state, *buttons) |
82 | 65 |
|
83 | 66 | async def button_push(self, *buttons, press_time_sec=0.1): |
84 | 67 | await self.button_press(*buttons) |
|
0 commit comments