home button mash test

This commit is contained in:
Robert Martin
2020-01-29 20:51:59 +09:00
parent 07f539743d
commit 1fd9e2b655
4 changed files with 89 additions and 21 deletions
+23
View File
@@ -5,6 +5,7 @@ import socket
import logging_default as log
import utils
from buttons import Buttons
from device import HidDevice
from protocol import controller_protocol_factory, Controller
from report import InputReport
@@ -63,6 +64,24 @@ async def send_empty_input_reports(transport):
await asyncio.sleep(1)
async def mash_home_button(transport):
report = InputReport()
report.set_input_report_id(0x21)
report.set_misc()
buttons = Buttons()
for _ in range(30):
buttons.home()
report.data[4:7] = buttons.to_list()
await transport.write(report)
await asyncio.sleep(0.1)
buttons.home()
report.data[4:7] = buttons.to_list()
await transport.write(report)
await asyncio.sleep(.3)
async def main():
transport, protocol = await create_hid_server(controller_protocol_factory(Controller.PRO_CONTROLLER), 17, 19)
@@ -75,6 +94,10 @@ async def main():
except asyncio.CancelledError:
pass
await asyncio.sleep(5)
await mash_home_button(transport)
# stop communication after some time
await asyncio.sleep(60)
logger.info('Stopping communication...')