01-17-2006, 07:05 AM
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 >)
thanks!
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!