NXC buttons help

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
gamemaker99
Posts: 16
Joined: 09 Oct 2010, 16:50

NXC buttons help

Post by gamemaker99 »

Hello
I am making a kirby-like platformer for the NXT using the nxt buttons(so everyone can play), but I can't get NXC to recognize two button presses at the same time. Only one is shown as being pressed. I am using ButtonPressed for each button to detect if a certain one is pressed, but if i push two, the NXT will only detect one.
"To be able to ask a question clearly is two-thirds of the way to getting it answered."
-John Ruskin-
h-g-t
Posts: 552
Joined: 07 Jan 2011, 08:59
Location: Albania

Re: NXC buttons help

Post by h-g-t »

I can't remember where exactly but in a recent post John Hansen stated that the NXC code applies a mutex to the buttoncall function to specifically avoid reading two buttons at once.

Don't know if you can press two touch sensors at once.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: NXC buttons help

Post by nxtboyiii »

You cannot press the left+ right, or left+center or right+center, but you can press center+exit, left+exit, right+exit, touch+touch(touch is touch sensor), left+touch, right+touch, exit+touch, center+touch, center+touch+touch, left+touch+touch,right+touch+touch, etc.
Thanks, and have a nice day,
nxtboy III

programnxt.com
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC buttons help

Post by afanofosc »

And support for sensing multiple button presses at the same time (as described by nxtboyiii) requires the enhanced NBC/NXC firmware. The standard firmware does not support sensing multiple button presses at the same time.

The limitations described by nxtboyiii are due to the hardware design of the NXT buttons.

The reference to acquire and release in ButtonPressed has to do with trying to read button state from two different threads at the same time - not the ability to sense multiple buttons actually pressed at the same time.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests