2015-08-15 03:07:37 +00:00
|
|
|
#include "types.h"
|
|
|
|
#include "linux-dist/evdev_mappings.h"
|
2015-08-21 13:03:08 +00:00
|
|
|
#include <linux/input.h>
|
2015-08-15 03:07:37 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-08-19 01:18:12 +00:00
|
|
|
struct AxisData
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Controller
|
2015-08-15 03:07:37 +00:00
|
|
|
{
|
2015-08-17 21:46:28 +00:00
|
|
|
int fd;
|
|
|
|
ControllerMapping* mapping;
|
2015-08-19 01:18:12 +00:00
|
|
|
AxisData data_x;
|
|
|
|
AxisData data_y;
|
|
|
|
AxisData data_trigger_left;
|
|
|
|
AxisData data_trigger_right;
|
|
|
|
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-18 18:57:18 +00:00
|
|
|
extern int input_evdev_init(Controller* controller, const char* device, const char* mapping_fname);
|
2015-08-17 21:46:28 +00:00
|
|
|
extern bool input_evdev_handle(Controller* controller, u32 port);
|
2015-08-18 18:57:18 +00:00
|
|
|
|
|
|
|
|
2015-08-19 01:18:12 +00:00
|
|
|
|
2015-08-19 05:04:36 +00:00
|
|
|
|
2015-08-19 08:08:58 +00:00
|
|
|
|