Programming individual buttons in EasyC?


In EasyC, you can use the digital joystick as, well, the joystick. But I was wondering if it was possible to program the individual buttons, such as U7, D7, L7, R7, of the digital joystick instead of programming the entire pad. I’m still using EasyC, so if someone could direct me on how to do it in EasyC, that’d be great.



I have not tried that but I would imagine that you can if you do something like the following:
Assign variables
Get digital input from that button then use either an if statement or case/switch to get what you need done.

Just an idea.

First create the variable that will hold the current button values into in the ‘Variables’ area. You’ll want the variables to be integers.

Then you set those variable values through the ‘Get Joystick Digital’ function. This will set the variables to the current value of the buttons, which will either be 0 or 1.

Its also helpful to make a list of global constants and save it as a programming template. eg J1 =1, J2 = 2, M1 = 1, Bdn =1, Bup =2 etc, Ch7=7

Then you can change a meaningless maze of numbers like
buttonValue =GetJoystickDigital( 1, 7, 1 );

into something more meaningful like
buttonValue = GetJoystickDigital( J1, Ch7, Bdn);