Kernel/LibInput: Rework Joystick handling

Joystick axis and buttons are now named to standard values, this allows
interfacing multiple different controllers (only DS3 is supported)

Add ioctl calls for userspace to set joystick player leds and rumble

Only use DS3 code paths when we detect that the attached device is
actually an DS3 controller

update test-joystick program to the new interface and add support to
control rumble and player leds
This commit is contained in:
2026-01-07 19:01:07 +02:00
parent a5318448f5
commit 24d91eee90
5 changed files with 359 additions and 63 deletions

View File

@@ -5,7 +5,45 @@
namespace LibInput
{
// TODO: not used but here if we ever make controller
enum JoystickButton
{
JSB_DPAD_UP,
JSB_DPAD_DOWN,
JSB_DPAD_LEFT,
JSB_DPAD_RIGHT,
JSB_FACE_UP,
JSB_FACE_DOWN,
JSB_FACE_LEFT,
JSB_FACE_RIGHT,
JSB_STICK_LEFT,
JSB_STICK_RIGHT,
JSB_SHOULDER_LEFT,
JSB_SHOULDER_RIGHT,
JSB_MENU,
JSB_START,
JSB_SELECT,
JSB_COUNT,
};
enum JoystickAxis
{
JSA_STICK_LEFT_X,
JSA_STICK_LEFT_Y,
JSA_STICK_RIGHT_X,
JSA_STICK_RIGHT_Y,
JSA_TRIGGER_LEFT,
JSA_TRIGGER_RIGHT,
JSA_COUNT,
};
// TODO: not used but exists if we ever make controller
// support generating events instead of being polled
struct JoystickEvent
{
@@ -14,15 +52,9 @@ namespace LibInput
struct JoystickState
{
struct Axis
{
int64_t value;
int64_t min;
int64_t max;
};
Axis axis[4];
bool buttons[32];
// axis are mapped to range [-32767, +32767]
int16_t axis[JSA_COUNT];
bool buttons[JSB_COUNT];
};
}