Skip to content
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

Feature/joystick #74

Open
wants to merge 3 commits into
base: main
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
2 changes: 2 additions & 0 deletions src/main/python/keyboard_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def __init__(self, dev, usb_send=hid_send):
self.macro = b""
self.vibl = False
self.custom_keycodes = None
self.joystick = None
self.midi = None

self.lighting_qmk_rgblight = self.lighting_qmk_backlight = self.lighting_vialrgb = False
Expand Down Expand Up @@ -299,6 +300,7 @@ def reload_layout(self, sideload_json=None):
if "vial" in payload:
vial = payload["vial"]
self.vibl = vial.get("vibl", False)
self.joystick = vial.get("joystick", None)
self.midi = vial.get("midi", None)

self.layout_labels = payload["layouts"].get("labels")
Expand Down
41 changes: 41 additions & 0 deletions src/main/python/keycodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,41 @@ def LT(layer):
K(132, "KC_LSCR", "Locking\nScroll", "Locking Scroll Lock", alias=["KC_LOCKING_SCROLL"]),
]

KEYCODES_JOYSTICK = [
K(0x5D08, "JS_BUTTON0", "Joystick\nBtn 0", "Joystick Button 0"),
K(0x5D09, "JS_BUTTON1", "Joystick\nBtn 1", "Joystick Button 1"),
K(0x5D0A, "JS_BUTTON2", "Joystick\nBtn 2", "Joystick Button 2"),
K(0x5D0B, "JS_BUTTON3", "Joystick\nBtn 3", "Joystick Button 3"),
K(0x5D0C, "JS_BUTTON4", "Joystick\nBtn 4", "Joystick Button 4"),
K(0x5D0D, "JS_BUTTON5", "Joystick\nBtn 5", "Joystick Button 5"),
K(0x5D0E, "JS_BUTTON6", "Joystick\nBtn 6", "Joystick Button 6"),
K(0x5D0F, "JS_BUTTON7", "Joystick\nBtn 7", "Joystick Button 7"),
K(0x5D10, "JS_BUTTON8", "Joystick\nBtn 8", "Joystick Button 8"),
K(0x5D11, "JS_BUTTON9", "Joystick\nBtn 9", "Joystick Button 9"),
K(0x5D12, "JS_BUTTON10", "Joystick\nBtn 10", "Joystick Button 10"),
K(0x5D13, "JS_BUTTON11", "Joystick\nBtn 11", "Joystick Button 11"),
K(0x5D14, "JS_BUTTON12", "Joystick\nBtn 12", "Joystick Button 12"),
K(0x5D15, "JS_BUTTON13", "Joystick\nBtn 13", "Joystick Button 13"),
K(0x5D16, "JS_BUTTON14", "Joystick\nBtn 14", "Joystick Button 14"),
K(0x5D17, "JS_BUTTON15", "Joystick\nBtn 15", "Joystick Button 15"),
K(0x5D18, "JS_BUTTON16", "Joystick\nBtn 16", "Joystick Button 16"),
K(0x5D19, "JS_BUTTON17", "Joystick\nBtn 17", "Joystick Button 17"),
K(0x5D1A, "JS_BUTTON18", "Joystick\nBtn 18", "Joystick Button 18"),
K(0x5D1B, "JS_BUTTON19", "Joystick\nBtn 19", "Joystick Button 19"),
K(0x5D1C, "JS_BUTTON20", "Joystick\nBtn 20", "Joystick Button 20"),
K(0x5D1D, "JS_BUTTON21", "Joystick\nBtn 21", "Joystick Button 21"),
K(0x5D1E, "JS_BUTTON22", "Joystick\nBtn 22", "Joystick Button 22"),
K(0x5D1F, "JS_BUTTON23", "Joystick\nBtn 23", "Joystick Button 23"),
K(0x5D20, "JS_BUTTON24", "Joystick\nBtn 24", "Joystick Button 24"),
K(0x5D21, "JS_BUTTON25", "Joystick\nBtn 25", "Joystick Button 25"),
K(0x5D22, "JS_BUTTON26", "Joystick\nBtn 26", "Joystick Button 26"),
K(0x5D23, "JS_BUTTON27", "Joystick\nBtn 27", "Joystick Button 27"),
K(0x5D24, "JS_BUTTON28", "Joystick\nBtn 28", "Joystick Button 28"),
K(0x5D25, "JS_BUTTON29", "Joystick\nBtn 29", "Joystick Button 29"),
K(0x5D26, "JS_BUTTON30", "Joystick\nBtn 30", "Joystick Button 30"),
K(0x5D27, "JS_BUTTON31", "Joystick\nBtn 31", "Joystick Button 31"),
]

KEYCODES_TAP_DANCE = []

KEYCODES_USER = []
Expand Down Expand Up @@ -769,6 +804,10 @@ def create_custom_user_keycodes(custom_keycodes):
)
)

def create_joystick_keycodes(joystickEnabled):
if joystickEnabled:
KEYCODES_MEDIA.extend(KEYCODES_JOYSTICK)

def create_midi_keycodes(midiSettingLevel):
KEYCODES_MIDI.clear()

Expand Down Expand Up @@ -826,6 +865,8 @@ def generate_keycodes_for_mask(label, mask):
else:
create_user_keycodes()

create_joystick_keycodes(keyboard.joystick)

create_midi_keycodes(keyboard.midi)

recreate_keycodes()
Expand Down