Topic: Joystick support for Linux

Hello community,

I noticed that Maratis does not have any joystick/gamepad support for Linux at the moment.
Because of that I wrote a joystick class for Linux and integrated it into the current Maratis svn code.

I am experiencing some minor input lags with my controller on Linux so testing is appreciated wink

http://pastebin.com/wpmdqBN1 ==> The patch with my changes

Sponk

Re: Joystick support for Linux

Hi, thanks !
I will merge your patch to the trunk when I find some time,
nice work !

Re: Joystick support for Linux

The patch is in the trunk, thank you Sponk !

I don't have access to linux to test it, is there a linux user that can help with this ?
> first by testing that the compilation is going without errors
> then by testing a controller

Thanks for the help.

Re: Joystick support for Linux

Ubuntu linux 12.10
current svn compiles without errors
can't get joystick input

Re: Joystick support for Linux

Lamberto: What code did you use to test the functionality? (I mean the lua code)

I tested it with three different joysticks on Ubuntu 12.10, Ubuntu 13.04 and openSUSE 12.3.
All three worked without any problems.

Does your joystick work with other programs/games?

Do you use multiple joysticks? I found a bug when using two controllers at the same time (I will fix it later today).

Sponk

PS: Thanks for your feedback smile

EDIT: Fixed typo

Last edited by Sponk (2013-04-17 17:19:35)

Re: Joystick support for Linux

Hi Sponk
this is the code I used for testing

function onSceneUpdate()
    print(getAxis("JOY1_Y"))
    print(isKeyPressed("JOY1_BUTTON1"))
end

just tried on different machine (same OS) with different joypad and I got same result:

0
false

Lamberto

Re: Joystick support for Linux

I can't reproduce it.
I get correct output.

Could you give me the output of

lsusb

and

/dev/input/js0

using the terminal?

Sponk

EDIT: I used the code stated earlier

Last edited by Sponk (2013-04-15 19:24:59)

Re: Joystick support for Linux

lsusb returns

Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 056a:0010 Wacom Co., Ltd Graphire
Bus 001 Device 006: ID 12bd:d012  
Bus 001 Device 005: ID 058f:6364 Alcor Micro Corp. AU6477 Card Reader Controller
Bus 002 Device 003: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 002 Device 004: ID 046d:09a5 Logitech, Inc. Quickcam 3000 For Business
Bus 002 Device 005: ID 1a1d:8301 Veho 
Bus 002 Device 008: ID 0cf3:3005 Atheros Communications, Inc. AR3011 Bluetooth
Bus 002 Device 007: ID 0409:02b9 NEC Corp. 

joypad is Bus 001 Device 006: ID 12bd:d012

I tried "cat /dev/input/js0" that returns weird characters while pressing joypad buttons (meaning it works)

as final test used jstest-gtk and output is fine

any guess?
Lamberto

Re: Joystick support for Linux

I don't really know why it does not work for you.
The driver seems to be loaded and function properly.

Are you sure you used the version from SVN while testing?
You can find it in

trunk/dev/prod/linux2/release/Maratis/Bin

in your Maratis source directory.

Sponk

Re: Joystick support for Linux

Hi,

I've tested cheap ACME gamepad on Ubuntu 12.04 (Maratis r200), but it doesn't work me either. Gamepad is functioning fine. Can I give you any more info to make it easier to debug?

Re: Joystick support for Linux

Sponk wrote:

Are you sure you used the version from SVN while testing?

sure but ... wait.
I was adding some printf in your code to figure out where the problem was, and... now it works! mumble mumble...  it may be due from some package installed by jstest-gtk. I must try Maratis svn version on freshly installed Ubuntu machine.

Lamberto

Re: Joystick support for Linux

Lamberto: So it now works as expected? Could you please describe exactly your steps to make it work?

I still don't know what exactly caused the failure. Maybe I will find it later wink

TaeZ: You could possibly fix it the same way as Lamberto

Nice to hear that it is not solely my fault wink

Sponk

13

Re: Joystick support for Linux

Will test on my Fedora 17 box as soon as i get hold of a another joystick smile. Thanks for your efforts Sponk!

Re: Joystick support for Linux

usmangani289: Thanks for your feedback!

About the reconnect: It does not work because the joystick gets initialized once the game starts. Reconnecting could lead to undefined behaviour. I will see whether I can make some PnP detection to detect reconnected and newly connected devices.

About the 'precision mode': I don't think I could do something about it. I get data from the driver as it comes. I don't change anything about the values. If the button was common for all joysticks I could try to emulate the wanted behaviour but I think it's not that common for a joystick to even have this button.

I read about the vibration feature but I don't know how to expose it to the Maratis SDK since there is no engine support for that yet (As far as I know).

Thanks for you feedback big_smile
I will see what I can do about your 'problems' wink

Sponk

Re: Joystick support for Linux

I fixed a bug affecting people using two joysticks at the same time.

Patch: http://pastebin.com/XCpGUDWB

Sponk

Re: Joystick support for Linux

Again, I fixed a bug about two axes being interchanged.
Additionally I cleaned up the code.

Patch: http://pastebin.com/i0p6dTAy

Sponk