Skip to content

Jedi Knight: gamepad bumpers switch weapons, the d-pad picks and uses Force powers - #42

Merged
finger563 merged 1 commit into
mainfrom
fix/jk-gamepad-weapons-force
Nov 25, 2026
Merged

finger563 merged 1 commit into
mainfrom
fix/jk-gamepad-weapons-force

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Engine side: esp-cpp/OpenJKDF2#7. This PR bumps components/jk/OpenJKDF2 to that branch (0f72de90).

Summary

A USB gamepad had no way to change weapons or use a Force power in Jedi Knight. Now, as on desktop OpenJKDF2:

Control In play
Left stick move / strafe
Right stick look
R2 / L2 fire / secondary fire
R1 / L1 next / previous weapon
D-pad left / right previous / next Force power
D-pad up (held) use the Force power
A, B, X, Y / Start unchanged (activate, jump, crouch, use item / JK's menu)

JK's own menus are unchanged.

How

  • Tab5 HAL: GamepadDetail, from Tab5Emu::gamepad_detail(), keeps apart what GamepadState folds together:
    • L1/R1 alone;
    • whether the pad has shown it has triggers (L2/R2 pressed since it connected);
    • its d-pad alone.
  • usb_hid.cpp: reads the d-pad from the pad's own fields, either a hat switch or the d-pad usages, since the hid-rp decoder folds the d-pad and the left stick together. The Backbone Pro has four d-pad usage fields and no hat. The connect log now says which one a pad has.
  • jk_esp_read_input:
    • with the d-pad known, the left stick moves (W/A/S/D) and the d-pad goes to the engine as the joystick hat (jk_esp_input_t.dpad);
    • once the pad has shown triggers, they fire and L1/R1 go to the joystick binds;
    • a pad without triggers keeps firing with L/R, and one whose d-pad can't be told apart keeps moving with it.

Testing (Tab5)

  • Injected presses through the input path:
    • R1, R1, L1 went from weapon 2 to 3 to 4 and back to 3.
    • D-pad right, right, left went from Force Jump to Force Speed and back to Force Jump.
    • Holding d-pad up activated Force Jump.
  • Real hardware, a Backbone Pro:
    • The bumpers, triggers and Force controls worked by hand.
    • The d-pad first still moved, because the pad has no hat switch. That was fixed by reading its d-pad usages: the connect log now reads 0 hat switch(es), 4 d-pad usage field(s).
  • Two JK launches and quits on the build: about 37.5 fps, and PSRAM back to the boot value after each quit.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

… Force powers

A USB gamepad had no way to change weapons or use a Force power in Jedi
Knight. Now, as on desktop OpenJKDF2: R1 / L1 = next / previous weapon, the
d-pad's left / right = previous / next Force power and up = use it (held).
Fire stays on R2 / L2, and the left stick moves.

- Tab5 HAL: GamepadDetail (Tab5Emu::gamepad_detail()) keeps apart what
  GamepadState folds together: L1 / R1 alone, whether the pad has shown it
  has triggers (L2 / R2 pressed since it connected), and its d-pad alone.
  usb_hid.cpp reads the d-pad from the pad's own fields, a hat switch or the
  d-pad usages (the Backbone Pro has four of those and no hat); the decoder
  folds it with the left stick.
- jk_esp_read_input: with the d-pad known, the left stick moves (W/A/S/D)
  and the d-pad goes to the engine as the joystick hat (jk_esp_input_t.dpad).
  Once the pad has shown triggers, they fire and L1 / R1 go to the joystick
  binds (bits 10 / 11 of joy_buttons). A pad without triggers keeps firing
  with L / R, and one whose d-pad can't be told apart keeps moving with it.
- OpenJKDF2 esp32/gamepad-weapons-force: the ESP32 joystick binds and the
  input read that feeds them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@finger563
finger563 merged commit a7cbb19 into main Nov 25, 2026
1 check passed
@finger563
finger563 deleted the fix/jk-gamepad-weapons-force branch November 25, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant