Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] Joystick buttons work in some apps but not in others

Random Man A
Years of Service
User Offline
Joined: 1st Mar 2007
Posted: 11th May 2022 05:42 Edited at: 12th May 2022 03:12
This post has been marked by the post author as the answer.
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:

And here's a section of code from another app where the joystick button does work:

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.]


The author of this post has marked a post as an answer.

Go to answer

Login to post a reply

Server time is: 2023-09-30 19:52:19
Your offset time is: 2023-09-30 19:52:19