Joystick Class

Post

Posted
Rating:
#1 (In Topic #809)
Regular
PartierSP is in the usergroup ‘Regular’
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.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
there was merge request made by Tobias Boerge 2 years ago for a class called gb.joystick

might be worth a look…

Files · gb.joystick · Gambas / gambas · GitLab
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
PartierSP is in the usergroup ‘Regular’
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.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
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 :)
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
PartierSP is in the usergroup ‘Regular’
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.
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
Technopeasant is in the usergroup ‘Regular’
This is quite an interesting find.
Online now: No Back to the top
1 guest and 0 members have just viewed this.