So I have three apps I'm working on simultaneously - they're all part of the same project, a simple gameshow game using four Xbox360 controllers, and each app is different rounds. For two of these, the joysticks work perfectly, I can use the "A" button to buzz in, no problem. Unfortunately, the first app, the oldest and most complex, is the problem - I have a joystick testing section at the beginning of the app that works just fine, however, when I get to the buzzing in section, the buttons don't work, nothing happens. I originally wrote this first app using the keyboard to buzz in, and if I swap the "if GetRawJoystickButtonState(1,1)=1" for "if GetRawKeyState(82)=1", pressing the R key on the keyboard works. It's as if there's a command somewhere in my code after the joystick test that breaks the joystick button detection.
I don't know if it'll help, but here's the section of code where the joystick doesn't work:
do
if GetRawJoystickButtonState(1,3)=1
PlayerFirst=1
SetSpriteVisible(8,1)
PlayerAnswer=1
PlaySound(5)
BuzzerTimer=Timer()+5
exit
endif
if GetRawJoystickButtonState(1,1)=1
PlayerFirst=1
SetSpriteVisible(8,1)
PlayerAnswer=2
PlaySound(5)
BuzzerTimer=Timer()+5
exit
endif
if GetRawJoystickButtonState(1,2)=1
PlayerFirst=1
SetSpriteVisible(8,1)
PlayerAnswer=3
PlaySound(5)
BuzzerTimer=Timer()+5
exit
endif
if GetRawJoystickButtonState(2,3)=1
ChaserFirst=1
SetSpriteVisible(9,1)
ChaserAnswer=1
PlaySound(6)
BuzzerTimer=Timer()+5
exit
endif
if GetRawJoystickButtonState(2,1)=1
ChaserFirst=1
SetSpriteVisible(9,1)
ChaserAnswer=2
PlaySound(6)
BuzzerTimer=Timer()+5
exit
endif
if GetRawJoystickButtonState(2,2)=1
ChaserFirst=1
SetSpriteVisible(9,1)
ChaserAnswer=3
PlaySound(6)
BuzzerTimer=Timer()+5
exit
endif
loop
And here's a section of code from another app where the joystick button does work:
if Players>1 and Buzz=0
if GetRawJoystickButtonState(1,1)=1 and VCooldown=0
PlaySound(4)
Buzzed=1
VCooldown=1
VCooldownTimer=Timer()+1.5
Buzz=1
gosub Buzzer
endif
if GetRawJoystickButtonState(2,1)=1 and BCooldown=0
PlaySound(4)
Buzzed=2
BCooldown=1
BCooldownTimer=Timer()+1.5
Buzz=1
gosub Buzzer
endif
if GetRawJoystickButtonState(3,1)=1 and NCooldown=0 and Players>=3
PlaySound(4)
Buzzed=3
NCooldown=1
NCooldownTimer=Timer()+1.5
Buzz=1
gosub Buzzer
endif
if GetRawJoystickButtonState(4,1)=1 and MCooldown=0 and Players=4
PlaySound(4)
Buzzed=4
MCooldown=1
MCooldownTimer=Timer()+1.5
Buzz=1
gosub Buzzer
endif
endif
The only difference I can see is that the working one is checking for the same button on 4 joysticks, and the non-working one is checking for three possible button presses from 2 joysticks. I can't for the life of me understand why that would be the problem, but if it is, I'm in trouble. Otherwise, does anyone know of a command that breaks joysticks, or why this would happen?
[EDIT: Nevermind, I am an idiot. Apparently, joysticks need Sync() inside the loop instead of outside of it, whereas the keyboard keeps working without Sync(). Or something like that. In any event, it's working now. Sorry.]
Thanks,
Aaron