forked from mirror/joycontrol
Hotfix: Make controller emulation work on new Switch version
This commit is contained in:
@@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
async def _send_empty_input_reports(transport):
|
||||
report = InputReport()
|
||||
while True:
|
||||
for i in range(10):
|
||||
await transport.write(report)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
@@ -117,13 +117,15 @@ async def create_hid_server(protocol_factory, ctl_psm=17, itr_psm=19, device_id=
|
||||
transport = L2CAP_Transport(asyncio.get_event_loop(), protocol, client_itr, client_ctl, 50, capture_file=capture_file)
|
||||
protocol.connection_made(transport)
|
||||
|
||||
# send some empty input reports until the Switch decides to reply
|
||||
# HACK: send some empty input reports until the Switch decides to reply
|
||||
future = asyncio.ensure_future(_send_empty_input_reports(transport))
|
||||
await protocol.wait_for_output_report()
|
||||
"""
|
||||
future.cancel()
|
||||
try:
|
||||
await future
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
"""
|
||||
|
||||
return protocol.transport, protocol
|
||||
|
||||
@@ -49,7 +49,6 @@ class L2CAP_Transport(asyncio.Transport):
|
||||
self._read_thread = None
|
||||
break
|
||||
|
||||
#logger.debug(f'received "{list(data)}"')
|
||||
await self._protocol.report_received(data, self._itr_sock.getpeername())
|
||||
|
||||
def start_reader(self):
|
||||
@@ -99,6 +98,8 @@ class L2CAP_Transport(asyncio.Transport):
|
||||
await self._is_reading.wait()
|
||||
data = await self._loop.sock_recv(self._itr_sock, self._read_buffer_size)
|
||||
|
||||
# logger.debug(f'received "{list(data)}"')
|
||||
|
||||
if not data:
|
||||
# disconnect happened
|
||||
logger.error('No data received.')
|
||||
@@ -146,7 +147,8 @@ class L2CAP_Transport(asyncio.Transport):
|
||||
size = struct.pack('i', len(_bytes))
|
||||
self._capture_file.write(_time + size + _bytes)
|
||||
|
||||
#logger.debug(f'sending "{_bytes}"')
|
||||
# logger.debug(f'sending "{_bytes}"')
|
||||
|
||||
try:
|
||||
await self._loop.sock_sendall(self._itr_sock, _bytes)
|
||||
except OSError as err:
|
||||
|
||||
Reference in New Issue
Block a user