Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Odd button behaviour
From: Magnus Holmgren (lear_at_algonet.se)
Date: 2002-10-13


Hi,

Sometimes the following code in main_menu.c:show_info() will always set
done to true on the first iteration of the loop:

    sleep(HZ/2);
        
    /* Wait for a key to be pushed */
    if(button_get(false) & ~BUTTON_REL)
        done = true;

I.e., it drops out of the information screen after half a second. I
haven't yet figured out what that "sometimes" is. In fact, I don't quite
see how the above code could work at all, since menu.c calls the menu
function on button press (thus, there will always come a release event
to the button queue; masking out BUTTON_REL just gives you the key that
was released). Something like this looks better:

    button = button_get(false);

    if ((button != BUTTON_NONE)
        && !(button & (BUTTON_REL | BUTTON_REPEAT)))

I.e., wait for any button that's neither a release, nor a repeat.

Another thing: if you hold two buttons down, and release one of them,
you get two events: the release of the release button (obviously), but
also a "press" of the button still being held. Should it really behave
like that? While I can see a point in doing so (it indicates the button
being down), it also seems like a "fake" button event is generated...

-- 
Magnus Holmgren



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa