• Welcome to Theos PowerBasic Museum 2017.

SDL_Joystick type definition

Started by Vincent van der Leun, January 26, 2009, 11:50:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Vincent van der Leun

Hi Jose (and others reading this),

I recently became aware of the SDL library... and it simply ROCKS! It's truly a joy to use. I am very grateful you took the time to translate the many headerfiles to PowerBASIC include files.

Although I've bought PowerBASIC for Windows 8 more than a year ago (recently upgraded my copy to version 9, as I love OOP) , I never really used it until now. I have lots of experience with other languages and I know from experience that learning a new language is the most fun when you have a project to do (especially when I don't have deadlines ;) ), so I am toying with SDL and PB 9 right now. I've planned to support joysticks in my little project.

Maybe I missed something, but I could not find the definition of the SDL_Joystick type in the PB include files.

I tried to translate them myself from the original C source and Visual C++ header files that I've downloaded from the original SDL site, but I got stuck.

While I could find the definition of the SDL_Joystick struct in the SDL_sysjoystick.h of the original sourcecode, I could not find the definition of the "struct joystick_hwdata", that is used in the SDL_Joystick struct. This struct is commented with /* Driver dependent information */ . I assume a pointer-reference to a PB type of at least the same size as the original is neccessary in the PB header, because otherwise it would probably corrupt memory (if I understand things correctly).

Can anybody shed some light on this? ;) Many thanks for your time!
It's been too long ago I've programmed in plain C, I remember that I really loved this language very much. I often missed the simple malloc statements in other languages... Oh well!

All the best,
Vincent

José Roca

 
You don't need the definition of the _SDL_Joystick structure to use the functions. It is used as an opaque pointer.

joystick_hwdata is a private structure used to keep track of a joystick:


struct joystick_hwdata
{
LPDIRECTINPUTDEVICE2 InputDevice;
int buffered;

input_t Inputs[MAX_INPUTS];
int NumInputs;
};


Quote
I often missed the simple malloc statements in other languages... Oh well!

You can use malloc and almost all the other functions of msvcrt.dll if you use my Windows API Headers: http://www.jose.it-berater.org/smfforum/index.php?board=344.0

Vincent van der Leun

Hi,

Thanks for your reply.

Now I see... I don't need the members of the SDL_Joystick at al..  SDL allocs the memory itself and my variable just points to it and I can use the various API functions to retrieve information about the joystick.

Weird, I tried a search utility, but it could not locate the word "joystick_hwdata" in any SDL source file.. well it was getting late, so I probably spelled it wrong or something!

I will look at your msvcrt.dll definition!

Best regards,
Vincent