06-02-2014 12:12 AM
Hi, what I would like to do is read input from a usb gamepad and change a Color box and change text infront of the box. However, the controller outputs a t/f for each button.
(Button 1,2,3,4 will change color, and 5,6,7,8 will determine what text will display over the color box( 4 diff text displays))
My problem is how do I say "Def. If neither 1,2,3,4 are presses-black, If button 1 is pressed-blue, If button 2 is pressed-green...etc..."
I have tried a case structure, but they can only say T/F once, which would be fine but the color box can only accept one input... I have attached a picture of what I have that wont work, I need an alternative...
Thank you,
Brent S.
06-02-2014 02:44 AM
You can build array of the buttons and then give it to "search 1 d array" and then use a single case structure.
06-02-2014 02:49 AM
Like this
06-02-2014 07:51 AM
Since your data is already a cluster you can use the Cluster to Array, then use the seach 1D array for a True eliminating the need for the build array.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-08-2026 08:53 AM
Since the buttons come in as booleans in a cluster, convert the cluster to an array, then use Search 1D Array to find the index of the first True. That index (0–3 for buttons 1–4) can directly drive a single Case Structure. Inside the case, output the color you want. If Search 1D Array returns -1, that means none are pressed, so set the color to black.
Same idea for buttons 5–8: convert to array, search for True, use that index to select which string to display (you can use another Case Structure or an array of strings and index it).
The key is: don’t wire each boolean separately into logic. Collapse them into an index first, then make one decision based on that.
05-11-2026 07:25 AM - edited 05-11-2026 08:00 AM
05-12-2026 05:03 AM - edited 05-12-2026 05:04 AM
what are button 9 to 12 supposed to do?
can those be ignored?
can only one button be pressed at any time?
or is it always a combination of one color button and one message button?
eg are button 1 and button 5 pressed together and you need to identify that case?
if so, I think it is an option to interpret the button cluster of 12 booleans as one binary number via "boolean array to number.vi"
gamepade number 0 "no button at all"
gamepad number 17 "button 1 and button 4 pressed" = "blue, message 4"