You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor: centralize duplicated gamepad axis max constant #489
The Linux and Windows gamepad drivers each define their own local const AXIS_MAX = 32767:
src/server/drivers/linux/gamepad.ts
src/server/drivers/windows/gamepad.ts
This is the same magic number duplicated in two places. If the axis range ever needs to change, both files must be updated in lockstep, and a missed update would cause inconsistent gamepad behavior between platforms.
Scope
Pure refactor — no behavior change.
Add export const GAMEPAD_AXIS_MAX = 32767 to src/server/constants.ts.
Remove the local AXIS_MAX definitions from the Linux and Windows gamepad
drivers.
Import and use GAMEPAD_AXIS_MAX in both files.
The scaling math is unchanged: Math.round(norm * GAMEPAD_AXIS_MAX) produces the exact same values as before.
Not in scope
src/server/drivers/mac/gamepad.ts uses an 8-bit HID axis range (-127..127), not 32767, so it is intentionally left untouched.
Verification
npm run test passes locally (existing gamepad tests cover both drivers).
Grep for 32767 and AXIS_MAX across src/ shows no remaining local definitions in driver code.
Activity
github-actions commentedon Nov 15, 2026
Discussions are carried on Discord.
Instead of commenting here, go to the Discord channel.
If you find this project useful, a GitHub star would be appreciated.