You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was experiencing some issues while mapping my "NVIDIA Corporation NVIDIA Controller v01.03" gamepad, connected over USB. It seems to me that mapping other controllers might give the same problems, but I can't check that.
With some work and the patches (against d452411) listed below, I did manage to get the following mapping: 03000000550900001072000011010000,NVIDIA Corporation NVIDIA Controller v01.03,a:b0,b:b1,x:b2,y:b3,start:b7,leftstick:b8,rightstick:b9,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:a10,righttrigger:a9,platform:Linux
Unable to register movement of "Right Stick Up", "Left Trigger" and "Right Trigger". I believe that this is due to the gap in ABS code: ABS_Z is 2 and ABS_RZ is 5, with nothing in between. A few empty slots later, there is ABS_GAS and ABS_BRAKE at 9 and 10. The following patch fixes the confusion between index and value in abs_map.
diff --git a/src/input/evdev.c b/src/input/evdev.c
index 5f78716..fb2903f 100644
--- a/src/input/evdev.c+++ b/src/input/evdev.c@@ -403,7 +403,7 @@ static bool evdev_handle_mapping_event(struct input_event *ev, struct input_devi
} else if (ev->value < parms.avg - parms.range/2) {
*currentAbs = dev->abs_map[ev->code];
*currentReverse = true;
- } else if (ev->code == *currentAbs)+ } else if (dev->abs_map[ev->code] == *currentAbs)
return false;
} else if (currentHat != NULL) {
if (hat_index >= 0 && hat_index < 4) {
@@ -532,13 +532,12 @@ void evdev_create(const char* device, struct mapping* mappings, bool verbose) {
devices[dev].key_map[i - BTN_MISC] = nbuttons++;
}
- int naxes = 0;
for (int i = 0; i < ABS_MAX; ++i) {
/* Skip hats */
if (i == ABS_HAT0X)
i = ABS_HAT3Y;
else if (libevdev_has_event_code(devices[dev].dev, EV_ABS, i))
- devices[dev].abs_map[i] = naxes++;+ devices[dev].abs_map[i] = i;
}
devices[dev].controllerId = -1;
The "D-Pad Up" and "D-Pad Down" were being mapped to dpup:h0.9 and dpdown:h0.12 instead of dpup:h0.1 and dpdown:h0.4. Resetting hats_state after deciding each hat button fixes that:
diff --git a/src/input/evdev.c b/src/input/evdev.c
index e04bf9c..5f78716 100644
--- a/src/input/evdev.c+++ b/src/input/evdev.c@@ -409,6 +409,9 @@ static bool evdev_handle_mapping_event(struct input_event *ev, struct input_devi
if (hat_index >= 0 && hat_index < 4) {
*currentHat = hat_index;
*currentHatDir = hat_constants[dev->hats_state[hat_index][1] + 1][dev->hats_state[hat_index][0] + 1];
+ //reset the states for the next hat button+ dev->hats_state[hat_index][1] = 0;+ dev->hats_state[hat_index][0] = 0;
return false;
}
}
In the final mapping output, the name is blank, which makes the mapping reader skip a:b0 (strtok does that for empty fields). The cause of the blank name is an off-by-one(?) overflow due to the wrong size for strncpy.
One remaining issue is that, to map "Left Trigger" and "Right Trigger", one should only tap the triggers only very shortly: the detection code does not take into account that the value starts at 0 instead of halfway.
Finally, more as FYI, the "Back" and "Home" buttons on the gamepad don't do anything during the mapping because their codes (KEY_BACK, KEY_HOMEPAGE) are not within the correct ranges. Since I wanted to get the same behavior as with the Nvidia GameStream app, I used the patch below. This prolly interferes with keyboard input, but is good enough for me personally.
I was experiencing some issues while mapping my "NVIDIA Corporation NVIDIA Controller v01.03" gamepad, connected over USB. It seems to me that mapping other controllers might give the same problems, but I can't check that.
With some work and the patches (against d452411) listed below, I did manage to get the following mapping:
03000000550900001072000011010000,NVIDIA Corporation NVIDIA Controller v01.03,a:b0,b:b1,x:b2,y:b3,start:b7,leftstick:b8,rightstick:b9,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:a10,righttrigger:a9,platform:Linux
abs_map
.dpup:h0.9
anddpdown:h0.12
instead ofdpup:h0.1
anddpdown:h0.4
. Resettinghats_state
after deciding each hat button fixes that:a:b0
(strtok does that for empty fields). The cause of the blank name is an off-by-one(?) overflow due to the wrong size forstrncpy
.One remaining issue is that, to map "Left Trigger" and "Right Trigger", one should only tap the triggers only very shortly: the detection code does not take into account that the value starts at 0 instead of halfway.
Finally, more as FYI, the "Back" and "Home" buttons on the gamepad don't do anything during the mapping because their codes (
KEY_BACK
,KEY_HOMEPAGE
) are not within the correct ranges. Since I wanted to get the same behavior as with the Nvidia GameStream app, I used the patch below. This prolly interferes with keyboard input, but is good enough for me personally.The text was updated successfully, but these errors were encountered: