PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to repeat button press?

Hi, I'm trying to get my buttons to repeat when held. I tried setting SetRepeatRates and also added CheckRepeat to my frame processing but no button events are repeated.

Can you please provide a brief sample and explanation on how to generate repeated button events?

ps. my code is based off of the helloworld sample.

Thanks.
Hi NamGMan,

You're only able to get repeated keystrokes by using ClassEInput. Use ecd.input->GetKeyPressCount() to get the amount of key strokes since the last frame. More information can be found here: http://www.edgelib.com/index.php?node=1018

You can also continuously call ecd.input->GetKeyEvent() until it returns false. The key scancode and event type (like first press, repeat or release) are contained in the E_INPUTEVENT structure. Please refer to this page for more information: http://www.edgelib.com/index.php?node=770
Hi, thanks for the info. I now have repeating events. :)

However, SetRepeatRates does not seem to have any effect. I have tried both GetKeyPressCount and GetKeyEvent and neither seem to be affected by SetRepeatRates.

How do I effectively change the intervals between repeat events?

Here is a small snippet of how I'm using GetKeyEvent:

Code:

E_INPUTEVENT ev;
while (ecd.input->GetKeyEvent(&ev;)) {
if (ev.action == dA && ev.type == EIE_REPEAT) {
//handle event
}
}
Hi NamGMan,

You're code looks correct, please also check for EIE_PRESSED instead of only for repeat.

Unfortunately, there is a bug in EDGELIB which prevents the SetRepeatRates() function from working correctly. It will be fixed in the next version.
Hi, if I get your meaning the reason why I'm not checking for EIE_PRESSED is because the initial button press is passed through the OnButtonDown in the ClassEdge implementation.

Should I scrap the OnButtonDown (and similar) methods and move all input handling into the noted routine?

Thanks.
I recommend using ClassEInput for all your input events. It also allows you to use the improved keymappings for your application menus.