[Gambas-user] Joystick
Tobias Boege
tobs at taboege.de
Fri Nov 5 18:14:33 CET 2021
On Fri, 05 Nov 2021, Benoît Minisini wrote:
> Le 05/11/2021 à 17:31, Tobias Boege via User a écrit :
> > On Fri, 05 Nov 2021, Admin wrote:
> > > ------------------------------------
> > > Public Sub Main()
> > >
> > > Shell "cat /dev/input/js0" For Read As "Joystick"
> > >
> > > End
> > > -----
> > > Public Sub Joystick_Read()
> > > Dim joyEvent As String
> > > Dim size As Integer
> > > Dim events As Byte[]
> > >
> > > size = Lof(Last)
> > > joyEvent = Read #Last, size
> > >
> > > events = Byte[].FromString(joyEvent)
> > >
> > > Print events[0], events[1], events[2], events[3], events[4], events[5],
> > > events[6], events[7]
> > >
> > > End
> > > ------------------------------------
> > >
> > > and it looks like it's pretty readable. I don't know what first four bytes
> > > mean, but last four are "pressed/released" or analog value of axis, analog
> > > value of second axis, number of analog stick used (buttons are always 1)
> > > and, finally, button number. That's totally enough. It would be nice to have
> > > a simple gb.joystick class that just works like keypress for joysticks, but
> > > this works too.
> > >
> >
> > Curiously, it exists in a years old merge request that I never followed
> > through with because it was an afternoon project and the component would
> > be very small and Linux-specific. But the code still exists here:
> >
> > https://gitlab.com/gambas/gambas/-/merge_requests/76
> >
> > but it is written in C for incorporation into the Gambas source tree.
> > Yours will be easier to just dump into a project.
> >
> > Best,
> > Tobias
> >
>
> Oops, I completly forgot that merge request! Is it finished?
>
Honestly, I have no idea anymore. I am on the run to catch a train and
won't have my hardware available to check it out over the weekend, but
I vaguely remember being satisfied with it.
Maybe someone else can try compiling and testing it in the meantime?
Best,
Tobias
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list