Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: metroid2010 on March 31, 2019, 11:26:50 AM

Title: Customizing keymaps
Post by: metroid2010 on March 31, 2019, 11:26:50 AM
Hello,

I have found no docs related to how keymaps work and how can they be modified.
Is there any proper developer documentation, besides the comments in the code?
I'm trying to get the power button on a AGPTek Rocker to turn off the screen, instead of locking the buttons.
Some pointers on where to start would be really appreciated.
Title: Re: Customizing keymaps
Post by: saratoga on March 31, 2019, 01:33:06 PM
I don't think there is any documentation besides the code.
Title: Re: Customizing keymaps
Post by: metroid2010 on April 01, 2019, 03:29:45 AM
That was fast, thanks

Could I get a quick explanation of how are buttons implemented?
How do the structs in keymap_*.h work, how are single press, double press, and long press implemented, and which file contains the actions associated with each?
Title: Re: Customizing keymaps
Post by: Bilgus on April 01, 2019, 10:20:22 AM
https://github.com/Rockbox/rockbox/blob/master/apps/keymaps/keymap-agptekrocker.c

Excerpt:

Code: [Select]

/* {Action Code,    Button code,    Prereq button code } */

static const struct button_mapping button_context_standard[]  = {
    { ACTION_STD_PREV,       BUTTON_UP,                   BUTTON_NONE },
    { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT,     BUTTON_NONE },
    { ACTION_STD_NEXT,       BUTTON_DOWN,                 BUTTON_NONE },
    { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT,   BUTTON_NONE },
    { ACTION_STD_OK,         BUTTON_SELECT|BUTTON_REL,    BUTTON_SELECT },
    { ACTION_STD_OK,         BUTTON_RIGHT,                BUTTON_NONE },
    { ACTION_STD_CANCEL,     BUTTON_LEFT,                 BUTTON_NONE },
    { ACTION_STD_CONTEXT,    BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
    { ACTION_STD_MENU,       BUTTON_POWER,                BUTTON_NONE },

    LAST_ITEM_IN_LIST
}; /* button_context_standard */

///////////////////////////

{ ACTION_STD_KEYLOCK,     BUTTON_POWER,                 BUTTON_NONE },


For how this struct is utilized see action.c
https://github.com/Rockbox/rockbox/blob/master/apps/action.c
Title: Re: Customizing keymaps
Post by: Bilgus on April 01, 2019, 10:27:06 AM
Does the Rocker currently have a button that turns off the screen?

If not then the keymaps are the least of your worries