Python driver for Nintendo Switch Joy-Con
We are referring to dekuNukem/Nintendo_Switch_Reverse_Engineering
Install
pip install joycon-python hidapi pyglm
Usage
Quick status check
cd joycon-python/
python -m pyjoycon.joycon
or use as module
from pyjoycon import JoyCon, get_R_id
joycon_id = get_R_id()
joycon = JoyCon(*joycon_id)
joycon.get_status()
Status values
{
'battery': {
'charging': 0,
'level': 2
},
'buttons': {
'right': {
'y': 0,
'x': 0,
'b': 0,
'a': 0,
'sr': 0,
'sl': 0,
'r': 0,
'zr': 0
},
'shared': {
'minus': 0,
'plus': 0,
'r-stick': 0,
'l-stick': 0,
'home': 0,
'capture': 0,
'charging-grip': 0
},
'left': {
'down': 0,
'up': 0,
'right': 0,
'left': 0,
'sr': 0,
'sl': 0,
'l': 0,
'zl': 0
}
},
'analog-sticks': {
'left': {
'horizontal': 0,
'vertical': 0
},
'right': {
'horizontal': 2170,
'vertical': 1644
}
},
'accel': {
'x': 879,
'y': 1272,
'z': 549
},
'gyro': {
'x': -354,
'y': -7,
'z': 281
}
}
You need cython-hidapi to use Bluetooth / HID connection in Python.
Alternatively, you can use hid instead if cython-hidapi fails to find your JoyCons.
Gyroscope
We have a specialized class which tracks the gyroscope for you, and exposes this tracked state in a simplified manner:
from pyjoycon import GyroTrackingJoyCon, get_R_id
import time
joycon_id = get_R_id()
joycon = GyroTrackingJoyCon(*joycon_id)
for i in range(20):
print("joycon pointer: ", joycon.pointer)
print("joycon rotation: ", joycon.rotation)
print("joycon direction:", joycon.direction)
print()
time.sleep(0.05)
Button events
We have a specialized class which tracks the state of the JoyCon buttons and
provides changes as events. Here is an example of how it could be used with pygame:
from pyjoycon import ButtonEventJoyCon, get_R_id
import pygame
joycon_id = get_R_id()
joycon = ButtonEventJoyCon(*joycon_id)
...
while 1:
pygame.time.wait(int(1000/60))
...
for event_type, status in joycon.events():
print(event_type, status)
...
pygame.display.flip()
Combining multiple JoyCon helper classes
import pyjoycon
class MyJoyCon(
pyjoycon.GyroTrackingJoyCon,
pyjoycon.ButtonEventJoyCon,
): pass
Environments
- macOS Mojave (10.14.6)
- Python (3.7.4)
- hidapi (0.7.99.post21)
Metadata
Release files for joycon-python 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| joycon-python-0.2.4.tar.gz | 9.1 kB | Without provenance | Details for joycon-python-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| joycon_python-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for joycon_python-0.2.4-py3-none-any.whl |
Total release size: 19.7 kB
Release files / joycon-python-0.2.4.tar.gz
| Download URL | joycon-python-0.2.4.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a58a91338b98b1b9b262257401ddcf5908291164f5bb0ec098484527688a02e
|
|
BLAKE2b-256 checksum How to use checksums |
a1361aff097a7cdb121635c611edf30c61434da74595d34479bf7aac5b499636
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.7
|
Release files / joycon_python-0.2.4-py3-none-any.whl
| Download URL | joycon_python-0.2.4-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1695cf10d875db2183c7abea464c6e7715684087d5d14ccbfb42eb56a7e4c968
|
|
BLAKE2b-256 checksum How to use checksums |
c23638ff84089ad583b7b0f82f33fba61bfeccf037a624d41b7cfe185f966823
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.7
|
Security for joycon-python 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.