[Gambas-user] A fine afternoon for a good rant

Cedron Dawg cedron at exede.net
Thu Feb 28 20:11:29 CET 2019


I have been drinking from a firehose the last few weeks.  I do not want to remake the version of Gambas on my machine so I did not read that section in detail.  

There is no gp.sdl option in the Project/Properties/Components list.

Looking at the source code, there is a Cjoystick in .../sdl, but not in .../sdl2.  It appears to be a wrapper around SDL_Joystick, which is fine with me if it is fine with you.

Somebody could have mentioned its availability a little earlier.  Would Tobias have bothered to start a new branch if he knew about it?

As for my attempt, I have recoded the top to fix something I know now is quite wrong.  I've attached the file.  Notice that I put your name in the copyright figuring you should have legal control.  There is very little of Tobi's code left, none of his names, but most the **G comments are still his.

If it works for you, please incorporate it.  I can get by with using my shared library to develop the GamePad based programs I have in mind.  I will return to trying to make components when I am more experienced and familiar with the environment.

If the GB.Watch mechanism is the right one, I believe I have coded that part correctly.

This was my guess at returning a string array.  Did I do it right?  At first I didn't think I should free the ListEntry, but afterthought says the string array makes a reference and if I don't free it  there will be a memory leak.  The previous version does not have the GB.Free.

/*--- Set the Return Array  ????? Not sure this is right at all
*/
        void* theReturnArray;
        char* theListEntry;
        int   f;
        
        GB.New( &theReturnArray, "String[]", NULL, NULL );

        for( f = 0; f < theFoundCount; f++ )
        {
            theListEntry = GB.NewString( theList[f], 0 );
            theReturnArray->Add( theListEntry );
            GB.Free( theListEntry );
        }

        GB.ReturnObject( &theReturnArray );

You should still buy yourself a GamePad.


=========================================================
[...snip...]

Welcome to the world of programming.

Before reading "how to make components", did you read the wiki page 
"compilation and installation", where it is explained how to compile and 
install Gambas from sources? Apparently no.

You have to generate the "./configure" file first, by running 
"./reconf-all".

See that page: http://gambaswiki.org/wiki/install

As for the joystick support, I thought that SDL would be enough. You 
usually use SDL to make games.

Anyway, it could be a good idea to make a component that gives access to 
libevdev.

As for your event management problem, no, you don't have to poll.

According to what I read in the libevdec doc, you just have to watch the 
evdev file descriptor returned by libevdev_get_fd(), and then use 
libevdev_next_event() in the watch handler.

As for adding a component in the source tree, it's a boring and ugly 
work. Because it's based on autoconf & automake, and it's them that make 
the process boring and ugly.

I can do it for you.

I strongly suggest to make a component with a C part and a Gambas part. 
The C part will contain only helpers functions, and the Gambas part will 
be the actual public interface of the component.

Regards,

-- 
Benoît Minisini

----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: c_joystick_Ced_0_0_3.c
Type: text/x-c++src
Size: 18119 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190228/41580d6e/attachment-0001.c>


More information about the User mailing list