tocoteron / joycon-python

driver for Joy-Con (Nintendo Switch)
Other
116 stars 27 forks source link

Get input when joycon is connected to switch #28

Open krzysztofkrzeslak opened 2 years ago

krzysztofkrzeslak commented 2 years ago

Hello, Have some unusual use-case for this library and wondering if this is possible. I want make it work in a way that I'll be still able to get joycon inputs while they connected to the Switch. As you might know, it's possible to install L4T Linux/Ubuntu on Switch which I already did and was able to connect joys using this library via Bluetooth, but problem is that they're working only in "detached" mode, which means when they're disconnected from the console, as soon I connect them I get the following message:

Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/krzysiek/moje/tello/joycon-python/pyjoycon/joycon.py", line 115, in _update_input_report
    report = self._read_input_report()
  File "/home/krzysiek/moje/tello/joycon-python/pyjoycon/joycon.py", line 72, in _read_input_report
    return bytes(self._joycon_device.read(self._INPUT_REPORT_SIZE))
  File "/home/krzysiek/.local/lib/python3.6/site-packages/hid/__init__.py", line 163, in read
    size = self.__hidcall(hidapi.hid_read, self.__dev, data, size)
  File "/home/krzysiek/.local/lib/python3.6/site-packages/hid/__init__.py", line 148, in __hidcall
    raise HIDException(err)
hid.HIDException: Input/output error

My use case is to make a Python script running on a Linux switch within which I can control some external device(ex. drone), but I would like to use it with Joycons connected to the console. I know that L4T Linux has a possibility to work in attached mode as they can be used as a mouse even, below is some example: https://www.youtube.com/watch?v=nhN4vtMYqzA

Maybe you have some ideas on how to make communication via this library work in "attached" mode?

pbsds commented 2 years ago

You most likely can't have two separate drivers/daemons handshake and communicate with the joycons and the same time.

I have no clue how L4T does things, but there is a possibility they've merged and rely on nintendo-hid by DanielOgorchock. Perhaps have a look at joycond?

krzysztofkrzeslak commented 2 years ago

Hi, thanks for response, this library which you provided seems promising, but I found also another library that is able to read joycon via serial python-evdev so maybe I'll be able to use this library for bluetooth mode and evdev for docked mode :)