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:
@@ -54,9 +54,14 @@ struct winsize
|
||||
#define SND_GET_SAMPLE_RATE 61 /* stores sample rate to uint32_t argument */
|
||||
#define SND_RESET_BUFFER 62 /* stores the size of internal buffer to uint32_t argument and clears the buffer */
|
||||
#define SND_GET_BUFFERSZ 63 /* stores the size of internal buffer to uint32_t argument */
|
||||
#define SND_GET_TOTAL_PINS 64 /* gets the number of pins on the current device */
|
||||
#define SND_GET_PIN 65 /* gets the currently active pin */
|
||||
#define SND_SET_PIN 66 /* sets the currently active pin */
|
||||
#define SND_GET_TOTAL_PINS 64 /* gets the number of pins on the current device as uint32_t */
|
||||
#define SND_GET_PIN 65 /* gets the currently active pin as uint32_t */
|
||||
#define SND_SET_PIN 66 /* sets the currently active pin to uint32_t */
|
||||
|
||||
#define JOYSTICK_GET_LEDS 80 /* get controller led bitmap to uint8_t argument */
|
||||
#define JOYSTICK_SET_LEDS 81 /* set controller leds to uint8_t bitmap */
|
||||
#define JOYSTICK_GET_RUMBLE 82 /* get controller rumble strength to uint8_t argument */
|
||||
#define JOYSTICK_SET_RUMBLE 83 /* set controller rumble strength to uint8_t argument */
|
||||
|
||||
int ioctl(int, int, ...);
|
||||
|
||||
|
||||
@@ -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];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user