Hi!
Someone knows how to detect multiple buttons pressed at the same time?
Currently I’m using this to get the pressed or released keys:
msg = port.GetMessage()
if (type(msg) = “roUniversalControlEvent”)
code = msg.GetInt()
if(code = 106)
Hi!
Someone knows how to detect multiple buttons pressed at the same time?
Currently I’m using this to get the pressed or released keys:
msg = port.GetMessage()
if (type(msg) = “roUniversalControlEvent”)
code = msg.GetInt()
if(code = 106)
With the SDK I don’t think “at the same time” is accurate - as a msg can only hold a single event per cycle.
What you’re looking for here would be “held down while other buttons are already pressed” would be closer to what you can do.
How to do that -
for a simple two-button combination
CodeA=0
CodeB=0
msg=port.GetMessage()
if type(msg)="roUniversalControlEvent"
code=msg.GetInt()
if code=113
CodeA=0 'Select is released
elseif code=13 'Select is Pressed
CodeA=1
if CodeB=1
'both buttons are down
end if
elseif code=106
CodeB=0 'Play/Paused is released
elseif code=6 'Play/Paused is pressed
CodeB=1
if CodeA=1
'both buttons are down
end if
end if
end if
Something like that might work - at least on an roScreen where the UniversalControlEvent is available (as TheEndless mentioned in a different thread).
edited for corrections…
Hi, thanks for the reply!
I’ll try to explain what I need again:
when the user press the b button, I detect and start the behavior B.
if the user release the b button, I detect and stop the behavior B.
if the user press and not release the B button, the behavior B will stay active.
If the user press the A button while pressing the B, I cannot detect the pressing of A button.
I imagine that when the button B are being pressed, no message will be generated, so I could be able to detect the pressing of the A button, right?
“destruk” wrote:
With the SDK I don’t think “at the same time” is accurate - as a msg can only hold a single event per cycle.
What you’re looking for here would be “held down while other buttons are already pressed” would be closer to what you can do.How to do that -
for a simple two-button combinationCodeA=0 CodeB=0 msg=port.GetMessage() if type(msg)="roUniversalControlEvent" code=msg.GetInt() if code=113 CodeA=0 'Select is released elseif code=13 'Select is Pressed CodeA=1 if CodeB=1 'both buttons are down end if elseif code=106 CodeB=0 'Play/Paused is released elseif code=6 'Play/Paused is pressed CodeB=1 if CodeA=1 'both buttons are down end if end if end ifSomething like that might work - at least on an roScreen where the UniversalControlEvent is available (as TheEndless mentioned in a different thread).
I’m already doing what you said. I use a variable to hold that the B button was pressed and when it is released I mark this variable. But in the next screen refresh cycles, while the B button is being pressed, the GetMessage() does not return any code when I press others buttons.
In that case it’s not going to work.