tocoteron / joycon-python

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

how do I add the joy con analog sticks? #24

Open SpiderHulkZM opened 3 years ago

SpiderHulkZM commented 3 years ago

I don't know how to connect the analog sticks

KaizenCris commented 1 year ago

Hi, I know this issue is old, so I'm unsure if I should open a new one. I see the button events getting triggered by ButtonEventJoyCon. But not the Joy stick events. Is this feature available?

Is there any example of how to get this data?

KaizenCris commented 1 year ago

I found the answer. So in case anyone else need it too here it is: It can be found using the get_status() function inside the 'analog-sticks' key

You can also use get_stick_left_horizontal() and get_stick_left_vertical() functions in case you don't need all the status results.

from pyjoycon import JoyCon, get_R_id
import time

joycon_id = get_R_id()
joycon = JoyCon(*joycon_id)

while(1):
    print(joycon.get_status()['analog-sticks'])
    print(joycon.get_stick_left_horizontal(), joycon.get_stick_left_vertical())
    time.sleep(0.05)

It seems the output is not so intuitive so I used the joycon.py file included in this fork. (That way I get (+) or (-) results depending on left right top bottom):

And that's it = )

nahlahman commented 1 year ago

Is there a way to implement the joycon's calibration data for the sticks with joycon-python?

pbsds commented 1 year ago

https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/spi_flash_notes.md#analog-stick-factory-and-user-calibration