Page 1 of 1

Controller button held down

Posted: Sun Feb 10, 2013 11:48 am
by teepo
Hi.. I'm a pretty new programmer and I'm new to sega genesis and game programming in general. I'm using sgdk

I want to know, how can you detect if a button is held down and constantly do something while it is held down. for instance moving a character right while the right button is held down?

I looked into the sgdk joypad handling source code and it says it updates controller state at each vblank period and only fires an event whenever a state change is detected.

Posted: Sun Feb 10, 2013 4:47 pm
by Stef
Hi,

You should look into the sample source code.
The cube flat example exactly do what you want to do to make the cube spinning faster or slower :

http://code.google.com/p/sgdk/source/br ... lat/main.c

The method you have to use is

Code: Select all

joyState = JOY_readJoypad(joy_number);
so it returns the current button state of the specified joystick.

Posted: Sun Feb 10, 2013 6:10 pm
by teepo
Thanks :D

For some reason, looking through the samples escaped my mind completely.