input: add support for sdl gamecontrollerdb to setup default mappings for controllers
* Add support for sdl style gamecontrollerdb to setup default mappings for controllers * Do not cache game controller entries, find them dynamically in the file when needed Co-authored-by: Zakk <zakk@rsdio.com>
This commit is contained in:
19
input.cpp
19
input.cpp
@@ -28,6 +28,7 @@
|
||||
#include "joymapping.h"
|
||||
#include "support.h"
|
||||
#include "profiling.h"
|
||||
#include "gamecontroller_db.h"
|
||||
|
||||
#define NUMDEV 30
|
||||
#define NUMPLAYERS 6
|
||||
@@ -36,6 +37,7 @@
|
||||
|
||||
char joy_bnames[NUMBUTTONS][32] = {};
|
||||
int joy_bcount = 0;
|
||||
static struct pollfd pool[NUMDEV + 3];
|
||||
|
||||
static int ev2amiga[] =
|
||||
{
|
||||
@@ -1126,7 +1128,7 @@ enum QUIRK
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vid, pid;
|
||||
uint16_t bustype, vid, pid, version;
|
||||
char idstr[256];
|
||||
char mod;
|
||||
|
||||
@@ -2286,9 +2288,12 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
|
||||
{
|
||||
if (!load_map(get_map_name(dev, 1), &input[dev].mmap, sizeof(input[dev].mmap)))
|
||||
{
|
||||
memset(input[dev].mmap, 0, sizeof(input[dev].mmap));
|
||||
memcpy(input[dev].mmap, def_mmap, sizeof(def_mmap));
|
||||
//input[dev].has_mmap++;
|
||||
if (!gcdb_map_for_controller(input[dev].bustype, input[dev].vid, input[dev].pid, input[dev].version, pool[dev].fd, input[dev].mmap))
|
||||
{
|
||||
memset(input[dev].mmap, 0, sizeof(input[dev].mmap));
|
||||
memcpy(input[dev].mmap, def_mmap, sizeof(def_mmap));
|
||||
//input[dev].has_mmap++;
|
||||
}
|
||||
}
|
||||
if (!input[dev].mmap[SYS_BTN_OSD_KTGL + 2]) input[dev].mmap[SYS_BTN_OSD_KTGL + 2] = input[dev].mmap[SYS_BTN_OSD_KTGL + 1];
|
||||
|
||||
@@ -3228,8 +3233,6 @@ void send_map_cmd(int key)
|
||||
#define CMD_FIFO "/dev/MiSTer_cmd"
|
||||
#define LED_MONITOR "/sys/class/leds/hps_led0/brightness_hw_changed"
|
||||
|
||||
static struct pollfd pool[NUMDEV + 3];
|
||||
|
||||
// add sequential suffixes for non-merged devices
|
||||
void make_unique(uint16_t vid, uint16_t pid, int type)
|
||||
{
|
||||
@@ -3382,6 +3385,8 @@ void mergedevs()
|
||||
input[i].bind = j;
|
||||
input[i].vid = input[j].vid;
|
||||
input[i].pid = input[j].pid;
|
||||
input[i].version = input[j].version;
|
||||
input[i].bustype = input[j].bustype;
|
||||
input[i].quirk = input[j].quirk;
|
||||
memcpy(input[i].name, input[j].name, sizeof(input[i].name));
|
||||
memcpy(input[i].idstr, input[j].idstr, sizeof(input[i].idstr));
|
||||
@@ -4221,6 +4226,8 @@ int input_test(int getchar)
|
||||
ioctl(pool[n].fd, EVIOCGID, &id);
|
||||
input[n].vid = id.vendor;
|
||||
input[n].pid = id.product;
|
||||
input[n].version = id.version;
|
||||
input[n].bustype = id.bustype;
|
||||
|
||||
ioctl(pool[n].fd, EVIOCGUNIQ(sizeof(uniq)), uniq);
|
||||
ioctl(pool[n].fd, EVIOCGNAME(sizeof(input[n].name)), input[n].name);
|
||||
|
||||
Reference in New Issue
Block a user