Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with joy[] in allegro
#1
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!
Reply
#2
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.
Reply
#3
Bah! Glfw loves joysticks. :lol:
Reply
#4
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
Reply
#5
Cool! :wtnod:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)