# Found a bug with a gamepad (Retrolink SNES Controller) on Linux

**URL:** https://discourse.glfw.org/t/found-a-bug-with-a-gamepad-retrolink-snes-controller-on-linux/1306
**Category:** support
**Created:** [March 23, 2019, 4:53pm UTC](https://discourse.glfw.org/t/found-a-bug-with-a-gamepad-retrolink-snes-controller-on-linux/1306 "2019-03-23T16:53:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![londnoir](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/londnoir/32/245_2.png) [@londnoir](https://discourse.glfw.org/u/londnoir)
#### Post date: [March 23, 2019, 4:53pm UTC](https://discourse.glfw.org/t/found-a-bug-with-a-gamepad-retrolink-snes-controller-on-linux/1306/1 "2019-03-23T16:53:12Z")

</div>

Hello,

I recently bought a gamepad to test a code with my project.

The gamepad is seen as a “Retrolink SNES Controller” (GUID:03000000790000001100000010010000).

The bug is the UP and LEFT keys. They are not detected properly. I dig in the code and found out that to know if one button is pressed on the pad was to test if the value is over 0.0f, but this is only correct with DOWN and RIGHT on that kind of device.

So I modify “input.c” at 1260

const float value = js-\>axes[e-\>index] \* e-\>axisScale + e-\>axisOffset;  
if (value \> 0.f)  
state-\>buttons[i] = GLFW\_PRESS;

By :

const float value = js-\>axes[e-\>index] \* e-\>axisScale + e-\>axisOffset;  
if ( e-\>axisOffset \< 0 )  
{  
if (value \> 0.f)  
state-\>buttons[i] = GLFW\_PRESS;  
}  
else  
{  
if (value \< 0.f)  
state-\>buttons[i] = GLFW\_PRESS;  
}

Now it works. But the code breaks obviously others gamepads because there are not working the same way with the directional pad. I don’t know really what to do, but here is a bug.

---

<div class="post-metadata">

### Author: ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)
#### Post date: [March 25, 2019, 1:55pm UTC](https://discourse.glfw.org/t/found-a-bug-with-a-gamepad-retrolink-snes-controller-on-linux/1306/2 "2019-03-25T13:55:36Z")

</div>

That is definitely a bug, thank you! Will update when a fix is merged.

---

<div class="post-metadata">

### Author: ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)
#### Post date: [March 28, 2019, 10:42pm UTC](https://discourse.glfw.org/t/found-a-bug-with-a-gamepad-retrolink-snes-controller-on-linux/1306/3 "2019-03-28T22:42:13Z")

</div>

Your fix (with slight tweaks) has been merged to `master`. Thank you!

---

<div class="post-metadata">

### Author: ![londnoir](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/londnoir/32/245_2.png) [@londnoir](https://discourse.glfw.org/u/londnoir)
#### Post date: [March 31, 2019, 9:42pm UTC](https://discourse.glfw.org/t/found-a-bug-with-a-gamepad-retrolink-snes-controller-on-linux/1306/4 "2019-03-31T21:42:48Z")

</div>

Oh cool, happy it helped. thanks 🙂
