ROBOTC.net forums
http://robotc.net/forums/

TETRIX Remote Control Buttons - Information
http://robotc.net/forums/viewtopic.php?f=52&t=2106
Page 1 of 1

Author:  tfriez [ Thu Jan 14, 2010 10:30 am ]
Post subject:  TETRIX Remote Control Buttons - Information

In ROBOTC 2.01, the behaviors of the Joy1Btn and Joy2Btn functions have been changed.

In previous versions, these functions would return the individual bit-mask value of the buttons. This means that following buttons would return the following values:
Button 1 = 1
Button 2 = 2
Button 3 = 4
Button 4 = 8
etc.

Because of this, most common usage of this function would be something like this:
Code:
while(joy1Btn(3) != 0)
{
Do Some Code
}

Which isn't always very intuitive.

To make this simpler, we added some bit logic to reduce all button values to return a "1" when the button is pressed. So now that means...
Button 1 = 1
Button 2 = 1
Button 3 = 1
Button 4 = 1
etc.

For those who like to see things behind the scenes, lines 83-86 from the JoystickInclude.c file shows how this works:
Code:
bool joy1Btn(int btn)
{   return ((joystick.joy1_Buttons & (1 << (btn - 1))) != 0);  }
bool joy2Btn(int btn)
{   return ((joystick.joy2_Buttons & (1 << (btn - 1))) != 0);  }


I hope this provides some clarification on button usage. If not, please post in this topic and we'll try and update this post to provide clearer information.

Author:  StevenChartis [ Sat Nov 09, 2013 7:36 am ]
Post subject:  Re: TETRIX Remote Control Buttons - Information

Would'nt it be much easier to do
Code:
return joystick.joy1_Buttons >> btn) & 1);

Obviously it would be the same, and it is much easier to read, so my question is does the method you posted have a slight speed advantage?
Edit: after reviewing my post, I am pretty sure the method I posted would have speed advantages, because it has nearly half the amount of operations.

Author:  kevinhunt [ Fri Apr 18, 2014 10:31 am ]
Post subject:  Re: TETRIX Remote Control Buttons - Information

thanks for that information..keep us updated..

juegosdecasinoespana.com

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/