• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Linux Raspberry Gamepad (detecting too many)

S

Silverman71

Guest
Hi!

I'm doing some test-compilation on a Raspberry Pi 4 and Gamemaker.
Everything works fine except that when I run my game it detects all devices that are attached through USB on the Pi as gamepads.

I am adding a player object for every "gamepad detected" in Async-System as described here https://www.yoyogames.com/blog/75/coffee-break-tutorials-setting-up-and-using-gamepad

When I run the code on my PC I only get one player object but on the Raspberry I get 3 or more (Gamepad, Mouse, Keyboard).
Looking at the terminal window from where I start the game on the Raspberry I can see that it detects gamepads but also "guessing" that some devices aren't gamepads.

But (as far as I can see) there is no way for me to check in the code if the detected device in Async-System really is a gamepad or not.
Anyone got any ideas?


With kind regards
Mike
 
S

Silverman71

Guest
Update

I think I solved it, although maybe a little dirty.

In the Async-System event after a gamepad has been detected I check the description of it.
Turns out that the name is "" if it's not a proper gamepad.
So if the length of the string for the description is larger than 0, then I create a player object.


GML:
var pad = async_load[? "pad_index"];       // Get the pad index value from the async_load map

if ( string_length(gamepad_get_description(pad)) > 0 )
{
    ...
    // Do the usual stuff
}
 
S

Silverman71

Guest
What's the GUID for the ghost gamepads? gamepad_get_guid()
Hi!
They are as follow.

I know it's the keyboard and mouse that comes up too since I have a USB Keyboard/Mouse switcher attached to the RPI to switch between my computer and the RPI.
If I start the game via SSH when I don't have the keyboard and mouse switched to the RPI I only get one player object.
As soon as I switch the keyboard/mouse to the RPI the other playerobject pops up.

I ran evtest and the keyboard uses three as seen in the pic below.

IMG_2190.JPG

Here are the GUID's.

Event = gamepad discovered
Pad = 0
030000001f08000001e4000010010000
USB gamepad

Event = gamepad discovered
Pad = 5
0300000080accf35002c93739badcf7e

Event = gamepad discovered
Pad = 1
0000000058b2cf31002c9373a3b3cf7e

Event = gamepad discovered
Pad = 2
01000000c8afcf32002c9373a3b3cf7e

Event = gamepad discovered
Pad = 4
ffffffff98adcf34002c9373a3b3cf7e
 
S

Silverman71

Guest
Outstanding detail, thank you very much. I've been working on an open source input library so having coverage of edge cases like this is very helpful.
Looks very interesting!!!

Maybe I could bother you for another question then, slightly going off-topic but still related to RPI and gamepads.
Perhaps you've came across the dpad problem for gamepads on RPI/Linux?

At least my "crappy" SNES-clone gamepad goes from 0-1 on the axis (x & y) on RPI instead of -1 to 1 as it does for GMS on Windows.
If I look at the terminal window for the game I see that YoYo GameLinux Runner finds the gamepad and also states that the gamepad has two absolute axis.
With the values ranging from 127,0,255,0 as seen in the quote below.

GAMEPAD: Enumerating 3
Joystick: USB gamepad , bustype = 3, vendor = 0x081f, product = 0xe401, version = 272
looks like a joystick with guid : 030000001f08000001e4000010010000
Unable to find mapping for device "USB gamepad "
Joystick has button: 0x120
Joystick has button: 0x121
Joystick has button: 0x122
Joystick has button: 0x123
Joystick has button: 0x124
Joystick has button: 0x125
Joystick has button: 0x126
Joystick has button: 0x127
Joystick has button: 0x128
Joystick has button: 0x129
Joystick has absolute axis: 0x00
Values = { 127, 0, 255, 0, 15 }
Joystick has absolute axis: 0x01
Values = { 127, 0, 255, 0, 15 }
There is of course the possibility that I don't know enough about GMS since I've started out with it not so long ago.
But with the code I'm using now I can only move right and down on the gamepad. Did some googling and came across similar problems and the solution there was to recompile the kernel which I really don't feel like doing.

How to read the axises correct with GMS on RPI?
Any idéas or tips would be welcome!
 

offalynne

Member
Are the axes OK on the Xbox pad?

There is precedent for that GUID (albiet in a different mapping format) via the recalbox project, though it seems to suggest the axes should be fine: https://gist.github.com/DouglasdeMoura/bb667b9d5ff9bdf4c8c2c00816c3f2e4#file-es_input-cfg-L647

To be honest you're likely encountering problems that are beyond repairing with GM's gamepad implementation alone since it's built for Ubuntu LTS and not Pi. It's hard to know what exactly you're missing that would correct the difference.


Necro edit: Joystick axes are unsigned on Linux. GM signs the axes on mapped devices; since OP's device doesn't have a map, joystick axes will show 0 to 1 values as opposed to the exepcted -1 to 1. It seems that otherwise (as of 2.3.4 beta) gamepads work on Pi as expected on Linux. As for the false-positive on "connected devices" where devices that aren't gamepads are enumerating as such, ignoring devices with an empty description field as OP suggests seems to be an effective stopgap solution.
 
Last edited:
Top