Why Joytest mix sincr/asincr reading pad and buttons?
Moderator: Stef
Why Joytest mix sincr/asincr reading pad and buttons?
Just testing Sample/joystest
Use handleInput(); into main() loop, that means, every loop we enter this function to check UP,DOWN,LEFT,RIGHT
But use joyEvent() to check A,B,C,Start
Why?
I mean, I put UP,DOWN,LEFT,RIGHT into joyEvent() and only works 1 time when pressing button, I need to release it and push again
Why can't use async for every button?
that means in any shutmup I can't use joyEvent() to detect pushing fire button, if I want auto-fire
Not sure why SGDK works like this
Use handleInput(); into main() loop, that means, every loop we enter this function to check UP,DOWN,LEFT,RIGHT
But use joyEvent() to check A,B,C,Start
Why?
I mean, I put UP,DOWN,LEFT,RIGHT into joyEvent() and only works 1 time when pressing button, I need to release it and push again
Why can't use async for every button?
that means in any shutmup I can't use joyEvent() to detect pushing fire button, if I want auto-fire
Not sure why SGDK works like this
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Re: Why Joytest mix sincr/asincr reading pad and buttons?
joytest is merely an example of reading the controllers, not the end-all/be-all of controller godhood. You can handle the controllers any way you wish. If registering an event handler would work better for your game, use that instead of directly reading the state. Reading the state was simply an easier way of doing the example which just shows the current state of the controllers. The event callback is called any time any button on any controller changes, so entering the handler, you know something changed, you just need to check what changed and do whatever you need to do on that button change.
Re: Why Joytest mix sincr/asincr reading pad and buttons?
Thanks Chilli Willy.
How can I check, in a callback func, a button pressed without release-and-push-again?
How can I check, in a callback func, a button pressed without release-and-push-again?
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Re: Why Joytest mix sincr/asincr reading pad and buttons?
I saw before postingChilly Willy wrote: ↑Sat Mar 09, 2019 3:03 pmLook at the sprite example to see how you use the callback function.
joyEvent() : just check A, B and C buttons
handleInput() : just check D-PAD to move Sonic
I think 'problem' (is not really a problem) is that callback only is called when a change was done, in this case push RIGH and RELEASE
So If I push RIGH and don't release -> no change -> no more callbacks
PD: I prefer reading the state with handleInput() but I want to learn, so I ask
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Re: Why Joytest mix sincr/asincr reading pad and buttons?
If you're looking for something like autofire, I'd set a flag in the event callback saying the fire button is pushed, then call the fire code periodically from the main loop where it checks the fire button flag. That seems like the easiest way to do autofire with joy events to me. So the joy events are asynchronous, but the firing is synchronous to the main loop at a set rate.
Re: Why Joytest mix sincr/asincr reading pad and buttons?
Thanks Chilly Willy