Qbasicnews.com
problem with joy[] in allegro - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: problem with joy[] in allegro (/thread-8759.html)



problem with joy[] in allegro - syn9 - 01-17-2006

hi. i'm trying to use allegro's joystick routines, but whenever i try to access dat in joy[] the program crashes... heres the code i'm using. and before you ask why i'm not using sdl's joystick routines is because sdl wont deteck my joystick >)

Code:
#include once "sdl\sdl.bi"
#include once "allegro.bi"


allegro_init

install_joystick(JOY_TYPE_AUTODETECT)

print num_joysticks

dim event as SDL_Event, video as sdl_surface ptr

print "sdl_init"
if SDL_Init(SDL_INIT_VIDEO) < 0 THEN
    PRINT "could not init sdl: "; SDL_GetError
    end
end if



video = sdl_setvideomode(320, 240, 16, 0)

do
    
    sdl_pumpEvents
    poll_joystick
    
    while SDL_PollEvent(@event)
        select case event.type
        case SDL_KEYDOWN
            exit do
        end select
    wend
    
    if joy[0].button(0).b then print "button 1 pressed"
loop


sdl_quit

remove_joystick
allegro_exit

thanks!


problem with joy[] in allegro - syn9 - 01-17-2006

v1c helped me out. heres his solution::

Quote:The "joy" global is incorrectly declared in inc/allegro.bi, change it to:

Code:
Extern Import joy(0 to MAX_JOYSTICKS-1) Alias "joy" As JOYSTICK_INFO

At line 1157.

Access it using array indexing after that, not pointer indexing.



problem with joy[] in allegro - Dr_Davenstein - 01-18-2006

Bah! Glfw loves joysticks. :lol:


problem with joy[] in allegro - syn9 - 01-18-2006

ok, i tried it, and it worked >) i'll give glfw a second chance and port zero gtr over to it that way i dont have to use 3 libraries to make the game run how i want it to >D thanks Dr_D


problem with joy[] in allegro - Dr_Davenstein - 01-18-2006

Cool! :wtnod: