Page 1 of 1

Joystick Class

Posted: Friday 21st January 2022 10:41am
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.

Re: Joystick Class

Posted: Friday 21st January 2022 7:45pm
by BruceSteers
there was merge request made by Tobias Boerge 2 years ago for a class called gb.joystick

might be worth a look...

Re: Joystick Class

Posted: Friday 21st January 2022 10:06pm
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.

Re: Joystick Class

Posted: Saturday 22nd January 2022 7:01am
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 :)

Re: Joystick Class

Posted: Monday 24th January 2022 5:02am
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.

Re: Joystick Class

Posted: Sunday 13th March 2022 5:56am
by Technopeasant
This is quite an interesting find.