mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-03 06:26:04 +00:00
Add mapping for wireless xbox controller
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
default,Default Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,
|
||||
xwc,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,
|
||||
0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),platform:Linux,a:b0,b:b1,x:b2,y:b3,start:b7,back:b6,guide:b8,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,lefttrigger:a5,righttrigger:a4,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a2,righty:a3,
|
||||
0300000000f000000300000000010000,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Linux,
|
||||
0300000000f00000f100000000010000,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Linux,
|
||||
|
||||
@@ -429,6 +429,7 @@ void evdev_create(const char* device, struct mapping* mappings, bool verbose) {
|
||||
|
||||
struct libevdev *evdev = libevdev_new();
|
||||
libevdev_set_fd(evdev, fd);
|
||||
const char* name = libevdev_get_name(evdev);
|
||||
|
||||
int16_t guid[8] = {0};
|
||||
guid[0] = int16_to_le(libevdev_get_id_bustype(evdev));
|
||||
@@ -442,23 +443,29 @@ void evdev_create(const char* device, struct mapping* mappings, bool verbose) {
|
||||
buf += sprintf(buf, "%02x", ((unsigned char*) guid)[i]);
|
||||
|
||||
struct mapping* default_mapping = NULL;
|
||||
struct mapping* xwc_mapping = NULL;
|
||||
while (mappings != NULL) {
|
||||
if (strncmp(str_guid, mappings->guid, 32) == 0) {
|
||||
if (verbose)
|
||||
printf("Detected %s (%s) on %s\n", mappings->name, str_guid, device);
|
||||
printf("Detected %s (%s) on %s as %s\n", name, str_guid, device, mappings->name);
|
||||
|
||||
break;
|
||||
} else if (strncmp("default", mappings->guid, 32) == 0)
|
||||
default_mapping = mappings;
|
||||
else if (strncmp("xwc", mappings->guid, 32) == 0)
|
||||
default_mapping = mappings;
|
||||
|
||||
mappings = mappings->next;
|
||||
}
|
||||
|
||||
if (mappings != NULL && strstr(name, "Xbox 360 Wireless Receiver") != NULL)
|
||||
mappings = xwc_mapping;
|
||||
|
||||
bool is_keyboard = libevdev_has_event_code(evdev, EV_KEY, KEY_Q);
|
||||
bool is_mouse = libevdev_has_event_type(evdev, EV_REL) || libevdev_has_event_code(evdev, EV_KEY, BTN_LEFT);
|
||||
|
||||
if (mappings == NULL && !(is_keyboard || is_mouse)) {
|
||||
fprintf(stderr, "No mapping available for %s (%s)\n", device, str_guid);
|
||||
fprintf(stderr, "No mapping available for %s (%s) on %s\n", name, str_guid, device);
|
||||
mappings = default_mapping;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user