Skip to content

feat: add 'Pro Controller' #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pyjoycon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from .event import ButtonEventJoyCon
from .device import get_device_ids, get_ids_of_type
from .device import is_id_L
from .device import get_R_ids, get_L_ids
from .device import get_R_id, get_L_id
from .device import get_R_ids, get_L_ids, get_PRO_ids
from .device import get_R_id, get_L_id, get_PRO_id


__version__ = "0.2.4"
Expand All @@ -19,6 +19,8 @@
"get_L_ids",
"get_R_id",
"get_R_ids",
"get_PRO_id",
"get_PRO_ids",
"get_device_ids",
"get_ids_of_type",
"is_id_L",
Expand Down
3 changes: 2 additions & 1 deletion pyjoycon/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
JOYCON_VENDOR_ID = 0x057E
JOYCON_L_PRODUCT_ID = 0x2006
JOYCON_R_PRODUCT_ID = 0x2007
JOYCON_PRODUCT_IDS = (JOYCON_L_PRODUCT_ID, JOYCON_R_PRODUCT_ID)
JOYCON_PRO_PRODUCT_ID = 0x2009
JOYCON_PRODUCT_IDS = (JOYCON_L_PRODUCT_ID, JOYCON_R_PRODUCT_ID, JOYCON_PRO_PRODUCT_ID)
21 changes: 18 additions & 3 deletions pyjoycon/device.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hid
from .constants import JOYCON_VENDOR_ID, JOYCON_PRODUCT_IDS
from .constants import JOYCON_L_PRODUCT_ID, JOYCON_R_PRODUCT_ID
from .constants import JOYCON_L_PRODUCT_ID, JOYCON_R_PRODUCT_ID, JOYCON_PRO_PRODUCT_ID


def get_device_ids(debug=False):
Expand Down Expand Up @@ -42,12 +42,14 @@ def get_ids_of_type(lr, **kw):
"""
returns a list of tuples like `(vendor_id, product_id, serial_number)`

arg: lr : str : put `R` or `L`
arg: lr : str : put `R` or `L` or `PRO`
"""
if lr.lower() == "l":
product_id = JOYCON_L_PRODUCT_ID
else:
elif lr.lower() == "r":
product_id = JOYCON_R_PRODUCT_ID
else:
product_id = JOYCON_PRO_PRODUCT_ID
return [i for i in get_device_ids(**kw) if i[1] == product_id]


Expand All @@ -60,6 +62,11 @@ def get_L_ids(**kw):
"""returns a list of tuple like `(vendor_id, product_id, serial_number)`"""
return get_ids_of_type("L", **kw)


def get_PRO_ids(**kw):
"""returns a list of tuple like `(vendor_id, product_id, serial_number)`"""
return get_ids_of_type("PRO", **kw)


def get_R_id(**kw):
"""returns a tuple like `(vendor_id, product_id, serial_number)`"""
Expand All @@ -75,3 +82,11 @@ def get_L_id(**kw):
if not ids:
return (None, None, None)
return ids[0]


def get_PRO_id(**kw):
"""returns a tuple like `(vendor_id, product_id, serial_number)`"""
ids = get_PRO_ids(**kw)
if not ids:
return (None, None, None)
return ids[0]