Difference between revisions of "Modules/input/Usage"

From MSX Game Library

< Modules‎ | input

Line 2: Line 2:
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
u8 joyStat = Joystick_Read(JOY_PORT_1);
 
u8 joyStat = Joystick_Read(JOY_PORT_1);
if (joyStat & JOY_INPUT_TRIGGER_A)
+
if ((joyStat & JOY_INPUT_TRIGGER_A) == 0)
 
{
 
{
 
// Joystick A boutton pressed
 
// Joystick A boutton pressed
 
}
 
}
else if (joyStat & JOY_INPUT_TRIGGER_B)
+
else if ((joyStat & JOY_INPUT_TRIGGER_B) == 0)
 
{
 
{
 
// Joystick B boutton pressed
 
// Joystick B boutton pressed
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 22:10, 7 January 2024

Check joystick bouton example:

u8 joyStat = Joystick_Read(JOY_PORT_1);
if ((joyStat & JOY_INPUT_TRIGGER_A) == 0)
{
	// Joystick A boutton pressed
}
else if ((joyStat & JOY_INPUT_TRIGGER_B) == 0)
{
	// Joystick B boutton pressed
}