Joystick Class

Post your must have Gambas Components/Controls/Classes/Modules here.
Post Reply
PartierSP
Posts: 57
Joined: Tuesday 30th November 2021 12:14am
Location: Canada
Contact:

Joystick Class

Post by PartierSP »

I've been looking for a way to integrate a joystick into one of my Gambas projects but couldn't find any official support. After doing a lot of searching, I found a wonderful project written by jsbsan on GitHub where he started to reproduce the old video game 1945 in Gambas and it has joystick support!

It appears the class he used was originally written as a C program and then translated to Gambas and then modified to work with jsbsan's program. I have since simplified the code and added a couple new events for easier integration into other projects.

I have also written a small program to demonstrate how to use this class. When the demo starts, it will try to connect to joysticks /dev/input/js0 and /dev/input/js3, notifying the user if a device is missing before continuing on. If js0 connects, then it will monitor button and axis states.
Attachments
ScreenCap.png
ScreenCap.png (17.99 KiB) Viewed 8264 times
joystick-class.zip
(19.59 KiB) Downloaded 363 times
User avatar
BruceSteers
Posts: 1505
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Joystick Class

Post by BruceSteers »

there was merge request made by Tobias Boerge 2 years ago for a class called gb.joystick

might be worth a look...

https://gitlab.com/gambas/gambas/-/tree/gb.joystick
If at first you don't succeed , try doing something differently.
BruceS
PartierSP
Posts: 57
Joined: Tuesday 30th November 2021 12:14am
Location: Canada
Contact:

Re: Joystick Class

Post by PartierSP »

Yes I have seen that. I downloaded that request and merged it into the latest source and successfully compiled it. But I was having trouble getting it to work. And seeing that it has fallen stale by 2 years I figured it isn't coming any time soon. :(

So I taking the 'advise' from your signature, "If at first you don't succeed , try it differently." ;) This got me something that is working now today. And if someone else wants to try it, they don't have to go through the mess of downloading and merging that pull request while risking messing up Gambas IDE on their system.

I'd gladly close this off and discourage anyone from building a program based on this if that pull request gets merged into master. But until then, we need something that people can share and use within an unaltered Gambas environment.
User avatar
BruceSteers
Posts: 1505
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Joystick Class

Post by BruceSteers »

Aah sorry fella i just thought maybe you had not seen it and maybe it would be a handy thing to check out to improve your own.

My guess would be development stopped at gambas hq due to a lack of interest.

if you have a working easy to use class i'd suggest getting on the gambas mailing list and see if anyone thinks it's worth inclusion as it seems they just gave up on it.

Thanks for sharing.
I'm sure people will find it useful and like you say , a whole lot easier than trying to get the old/stale gambas branch of yesteryear :)
If at first you don't succeed , try doing something differently.
BruceS
PartierSP
Posts: 57
Joined: Tuesday 30th November 2021 12:14am
Location: Canada
Contact:

Re: Joystick Class

Post by PartierSP »

No probs. Suggestions are always welcomed. :)

I did some more playing around with the class I uploaded and for some reason its not letting me create an instance at run time. I end up loosing the ability to click things with the mouse. But dropping an instance onto a form works well. So this is not a great solution in my opinion. But its a start.

Maybe I should try to sign up to the Gambas bug tracker. Maybe I could nudge someone into looking at it again.

I find it frustrating that the bug tracker system is not read only for anyone not logged in. This is one of the only projects I've come across that does this.
User avatar
Technopeasant
Posts: 138
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: Joystick Class

Post by Technopeasant »

This is quite an interesting find.
Technical director,
Piga Software
http://icculus.org/piga/
Post Reply