Hi coders!
i try to access SDL-Functions in GLB. Did anyone did it before?
Have no luck on that one...
[EDIT2]:
OK got it!
Had no luck with the GCC Version of SDL so i change it with the VC-Version.
Linking the Libs and using the Headerfiles are fine now! :)
hm.. It would be nice to see some small example how to use such SDL inline :-)
From what I remember GLBasic doesn't feature haptics - vibration/rumble, at least I didn't found any code for it, so
so maybe using directly 'SDL haptics' could be a solution, if there would be easy way to get internal GLB joystick handle.
Hi Dreamerman,
see Attachment!
Go to Project->Options in Ink change the path to the LIB-Folder to
-L "C:\PATH_TO_THE_FOLDER\SDL_Calls\SDL2_VC\lib\x86" -lSDL2
Then everything should work.
Maybe there is the old GLB-Bug with "RETURN" should be "return" in inline, IF->if ...
Code is a bit "Hacky" but you get the point ^^
Thank You, nice and clean piece of code. Thats good to be able to use SDL functions directly like that.
Played with vibration/rumble but SDL tells me that my X360 controller doesn't support any haptic effects, yet it's marked as haptic device - SDL_JoystickIsHaptic return True, all gamecontroller/haptics initialization goes ok. Even when trying simplest code - some default haptic effect, my controller powers off, heh first time I see something like this, ofc. gamepad is fully working in any game... Will need to check this later..
Never used Haptic-things :S
Therefor i can't help... Sry
No problem, it looks that my problem got solved, after 'verifying' my code with C++ test project from SDL2 source.. and replacing batteries in gamepad to fully charged ones :D Still few times it had same problem, nevertheless, it's great to add some kind of force feedback/rumble effects to GLB projects. I will need to do some small project with examples.
Edit:
Proper project will come later, now what's need to be added to test haptics:
'global' variables in SDL2_Window type:
#include <stdio.h> // for printf
SDL_Joystick *myJoystick = NULL;
SDL_Haptic *myHaptic = NULL;
Init subsystems:
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
SDL_InitSubSystem(SDL_INIT_HAPTIC);
after Init if window is created:
// Open the device
myJoystick = SDL_JoystickOpen(0);
printf("Haptic Init\n");
myHaptic = SDL_HapticOpenFromJoystick(myJoystick);
if(myHaptic == NULL)
{
printf("Error in opening Haptic Device (i.e. Rumble)\n");
printf(SDL_GetError());
}
else
{
printf("Haptic Device (i.e. Rumble) Opened\n");
}
printf("Number of Haptic Devices: %1d\n", SDL_NumHaptics());
printf("Controller is Haptic?: %1d\n", SDL_JoystickIsHaptic(myJoystick));
if (SDL_HapticRumbleInit( myHaptic ) != 0) printf("SDL_HapticRumbleInit error: %1d \n", SDL_GetError());
basic rumble effect:
FUNCTION RunRumble%:
INLINE
if (SDL_HapticRumblePlay( myHaptic, 0.25, 2000 ) != 0) printf("%10d \n", SDL_GetError());
ENDINLINE
ENDFUNCTION
change CloseWindow to clean after additional stuff:
FUNCTION CloseWindow:
INLINE
SDL_JoystickClose( myJoystick );
SDL_HapticClose( myHaptic );
ENDINLINE
self.running = FALSE
ENDFUNCTION
Test your gamepad from main loop with: Win.RunRumble()
Hopefully this can be used without all that window/rendered related stuff, thanks again :-)
Edit2:
It looks like only 'JOYSTICK' and 'HAPTIC' subsystems are needed so it's great, only small piece of coded needed for nice rumble effects :-)
It's a good idea.
In addition, the OOP version (although personally I don't like that).
Good work :good:
Some useful stuff here, thank guys! :booze:
You know about FORCEFEEDBACK command, do you?
omg :giveup: How could I missed that :blink: really :lol:
But there is some problem, FORCEFEEDBACK isn't working with my x360 controller, if I'm getting it properly a 'FORCEFEEDBACK 0, 500, 1, 1' should do rumble effect but it does nothing. Ofc checked other possible parameters and same result, also tried example from help file and this also doesn't work, tried with GLB 14, 15 and newest 16, no luck.
Hallo,
I only get these Errors:
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.17.312 SN:4369dded - 3D, NET
Wordcount:26 commands
compiling:
linking:
gpc_tempg.o:gpc_tempg.cpp:(.text+0x1ac): undefined reference to `SDL_HapticRumblePlay'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x1b5): undefined reference to `SDL_GetError'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x1df): undefined reference to `SDL_JoystickClose'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x1ec): undefined reference to `SDL_HapticClose'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x267): undefined reference to `SDL_RenderPresent'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x2b5): undefined reference to `SDL_RenderPresent'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x317): undefined reference to `SDL_RenderClear'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x365): undefined reference to `SDL_RenderClear'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x43b): undefined reference to `SDL_SetRenderDrawColor'
gpc_tempg.o:gpc_tempg.cpp:(.text+0x913): undefined reference to `SDL_PollEvent'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xbb0): undefined reference to `SDL_InitSubSystem'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xbbc): undefined reference to `SDL_InitSubSystem'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xbc8): undefined reference to `SDL_InitSubSystem'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xbd5): undefined reference to `SDL_CreateWindowFrom'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xbf7): undefined reference to `SDL_CreateRenderer'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xc0b): undefined reference to `SDL_SetWindowTitle'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xc62): undefined reference to `SDL_JoystickOpen'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xc80): undefined reference to `SDL_HapticOpenFromJoystick'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xc9e): undefined reference to `SDL_NumHaptics'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xcbb): undefined reference to `SDL_JoystickIsHaptic'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xcd8): undefined reference to `SDL_HapticRumbleInit'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xcf1): undefined reference to `SDL_GetError'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xd1d): undefined reference to `SDL_GetError'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xd5f): undefined reference to `SDL_CreateWindowAndRenderer'
gpc_tempg.o:gpc_tempg.cpp:(.text+0xd7b): undefined reference to `SDL_SetWindowTitle'
D:/Program Files (x86)/Steam/steamapps/common/GLBasic_SDK/Compiler/platform/Win32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 10 (VERSION) name: 1 lang: 409
collect2.exe: error: ld returned 1 exit status
*** FATAL ERROR - Bitte die Compiler-Ausgabe ins Forum kopieren
Are you trying to INLINE SDL? Because it's not used in Windows builds (yet). The size of the executable would increate significantly.
I would only test the Projekt in the "SDL_Calls.zip" from Schranz0r but i get the Errors