forked from mirror/joycontrol
split button_push into distinct putton_down and button_up functions
This commit is contained in:
@@ -187,7 +187,7 @@ class ButtonState:
|
|||||||
self._byte_1 = self._byte_2 = self._byte_3 = 0
|
self._byte_1 = self._byte_2 = self._byte_3 = 0
|
||||||
|
|
||||||
|
|
||||||
async def button_push(controller_state, *buttons, sec=0.1):
|
async def button_down(controller_state, *buttons):
|
||||||
if not buttons:
|
if not buttons:
|
||||||
raise ValueError('No Buttons were given.')
|
raise ValueError('No Buttons were given.')
|
||||||
|
|
||||||
@@ -199,7 +199,13 @@ async def button_push(controller_state, *buttons, sec=0.1):
|
|||||||
|
|
||||||
# send report
|
# send report
|
||||||
await controller_state.send()
|
await controller_state.send()
|
||||||
await asyncio.sleep(sec)
|
|
||||||
|
|
||||||
|
async def button_up(controller_state, *buttons):
|
||||||
|
if not buttons:
|
||||||
|
raise ValueError('No Buttons were given.')
|
||||||
|
|
||||||
|
button_state = controller_state.button_state
|
||||||
|
|
||||||
for button in buttons:
|
for button in buttons:
|
||||||
# release button
|
# release button
|
||||||
@@ -209,6 +215,12 @@ async def button_push(controller_state, *buttons, sec=0.1):
|
|||||||
await controller_state.send()
|
await controller_state.send()
|
||||||
|
|
||||||
|
|
||||||
|
async def button_push(controller_state, *buttons, sec=0.1):
|
||||||
|
await button_down(controller_state, *buttons)
|
||||||
|
await asyncio.sleep(sec)
|
||||||
|
await button_up(controller_state, *buttons)
|
||||||
|
|
||||||
|
|
||||||
class _StickCalibration:
|
class _StickCalibration:
|
||||||
def __init__(self, h_center, v_center, h_max_above_center, v_max_above_center, h_max_below_center, v_max_below_center):
|
def __init__(self, h_center, v_center, h_max_above_center, v_max_above_center, h_max_below_center, v_max_below_center):
|
||||||
self.h_center = h_center
|
self.h_center = h_center
|
||||||
|
|||||||
Reference in New Issue
Block a user