2015-08-19 08:20:52 +00:00
|
|
|
#pragma once
|
2015-08-21 13:03:08 +00:00
|
|
|
#include <linux/input.h>
|
2015-08-19 08:20:52 +00:00
|
|
|
#include "types.h"
|
2015-08-15 03:07:37 +00:00
|
|
|
|
2015-08-19 08:20:52 +00:00
|
|
|
struct EvdevControllerMapping
|
|
|
|
{
|
2018-07-18 09:19:53 +00:00
|
|
|
const std::string name;
|
2015-08-19 08:20:52 +00:00
|
|
|
const int Btn_A;
|
|
|
|
const int Btn_B;
|
|
|
|
const int Btn_C;
|
|
|
|
const int Btn_D;
|
|
|
|
const int Btn_X;
|
|
|
|
const int Btn_Y;
|
|
|
|
const int Btn_Z;
|
|
|
|
const int Btn_Start;
|
|
|
|
const int Btn_Escape;
|
|
|
|
const int Btn_DPad_Left;
|
|
|
|
const int Btn_DPad_Right;
|
|
|
|
const int Btn_DPad_Up;
|
|
|
|
const int Btn_DPad_Down;
|
|
|
|
const int Btn_DPad2_Left;
|
|
|
|
const int Btn_DPad2_Right;
|
|
|
|
const int Btn_DPad2_Up;
|
|
|
|
const int Btn_DPad2_Down;
|
|
|
|
const int Btn_Trigger_Left;
|
|
|
|
const int Btn_Trigger_Right;
|
|
|
|
const int Axis_DPad_X;
|
|
|
|
const int Axis_DPad_Y;
|
|
|
|
const int Axis_DPad2_X;
|
|
|
|
const int Axis_DPad2_Y;
|
|
|
|
const int Axis_Analog_X;
|
|
|
|
const int Axis_Analog_Y;
|
|
|
|
const int Axis_Trigger_Left;
|
|
|
|
const int Axis_Trigger_Right;
|
|
|
|
const bool Axis_Analog_X_Inverted;
|
|
|
|
const bool Axis_Analog_Y_Inverted;
|
|
|
|
const bool Axis_Trigger_Left_Inverted;
|
|
|
|
const bool Axis_Trigger_Right_Inverted;
|
|
|
|
};
|
2015-08-15 03:07:37 +00:00
|
|
|
|
2015-08-19 08:20:52 +00:00
|
|
|
struct EvdevAxisData
|
2015-08-19 01:18:12 +00:00
|
|
|
{
|
|
|
|
s32 range; // smaller size than 32 bit might cause integer overflows
|
|
|
|
s32 min;
|
2015-08-19 08:08:58 +00:00
|
|
|
void init(int fd, int code, bool inverted);
|
2015-08-19 01:18:12 +00:00
|
|
|
s8 convert(int value);
|
|
|
|
};
|
|
|
|
|
2015-08-19 08:20:52 +00:00
|
|
|
struct EvdevController
|
2015-08-15 03:07:37 +00:00
|
|
|
{
|
2015-08-17 21:46:28 +00:00
|
|
|
int fd;
|
2015-08-19 08:20:52 +00:00
|
|
|
EvdevControllerMapping* mapping;
|
|
|
|
EvdevAxisData data_x;
|
|
|
|
EvdevAxisData data_y;
|
|
|
|
EvdevAxisData data_trigger_left;
|
|
|
|
EvdevAxisData data_trigger_right;
|
2015-12-14 00:09:03 +00:00
|
|
|
int rumble_effect_id;
|
2015-08-19 01:18:12 +00:00
|
|
|
void init();
|
2015-08-15 03:07:37 +00:00
|
|
|
};
|
|
|
|
|
2015-08-21 12:32:04 +00:00
|
|
|
#define EVDEV_DEVICE_CONFIG_KEY "evdev_device_id_%d"
|
2015-08-18 18:57:18 +00:00
|
|
|
#define EVDEV_MAPPING_CONFIG_KEY "evdev_mapping_%d"
|
2015-08-15 03:07:37 +00:00
|
|
|
#define EVDEV_DEVICE_STRING "/dev/input/event%d"
|
2015-08-18 18:57:18 +00:00
|
|
|
#define EVDEV_MAPPING_PATH "/mappings/%s"
|
2015-08-15 03:07:37 +00:00
|
|
|
|
|
|
|
#ifdef TARGET_PANDORA
|
2015-08-17 21:46:28 +00:00
|
|
|
#define EVDEV_DEFAULT_DEVICE_ID_1 4
|
2015-08-15 03:07:37 +00:00
|
|
|
#else
|
2015-08-17 21:46:28 +00:00
|
|
|
#define EVDEV_DEFAULT_DEVICE_ID_1 0
|
2015-08-15 03:07:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define EVDEV_DEFAULT_DEVICE_ID(port) (port == 1 ? EVDEV_DEFAULT_DEVICE_ID_1 : -1)
|
|
|
|
|
2015-08-19 08:20:52 +00:00
|
|
|
extern int input_evdev_init(EvdevController* controller, const char* device, const char* mapping_fname);
|
|
|
|
extern bool input_evdev_handle(EvdevController* controller, u32 port);
|
2015-12-14 00:09:03 +00:00
|
|
|
extern void input_evdev_rumble(EvdevController* controller, u16 pow_strong, u16 pow_weak);
|