Support and General Use > User Interface and Voice

Sansa Clip +: hold (key lock) function for recording screen

(1/1)

adw:
I'm trying to add a "key lock" function for my Sansa Clip +. So far I have added:

apps/keymaps/keymap-clip.c

/** Recording Screen **/
static const struct button_mapping button_context_recscreen[]  = {
...
#ifndef HAS_BUTTON_HOLD /* Clip+ */
    { ACTION_STD_KEYLOCK,        BUTTON_HOME|BUTTON_SELECT,     BUTTON_NONE },
#endif /* HAS_BUTTON_HOLD */
...

apps/recorder/recording.c

...
static bool keys_locked = false;
...
        if (button == ACTION_STD_KEYLOCK)
        {
            if (keys_locked)
            {
                keys_locked = false;
                splash(HZ/2, str(LANG_KEYLOCK_OFF));
            }
            else
            {
                keys_locked = true;
                splash(HZ/2, str(LANG_KEYLOCK_ON));
            }
        }

        if (keys_locked)
        {
            splash(HZ/2, str(LANG_KEYLOCK_ON));
        }
        else
        {
            switch(button)
            ...
            } /*switch(button)*/
        } /*if(keys_locked)*/

This is doing the job for most keys, but the UP and DOWN keys that change the item during recording (Voulme / Gain / Filename) are not locked, and I can't figure out where these keys are handled. Can anyone give me a hint please?

JdGordon:
above the code you're fiddling with will be a call to something like gui_synclist_do_button(), check the lock before entering that.

adw:
Thank you, JdGordon, that was too obvious for me to see it...

I have also udated splash messages and screen blanking.

My complete changes are shown below. If anyone cares to make a patch out of it (with proper HAS_BUTTON_HOLD everywhere and support for all players), feel free to use my code as a starting point.


apps/keymaps/keymap-clip.c

/** Recording Screen **/
static const struct button_mapping button_context_recscreen[]  = {
...

--- Code: ---#ifndef HAS_BUTTON_HOLD /* Clip+ */
    { ACTION_STD_KEYLOCK,        BUTTON_HOME|BUTTON_SELECT,     BUTTON_NONE },
#endif /* HAS_BUTTON_HOLD */
--- End code ---
...

apps/recorder/recording.c

...

--- Code: ---static bool keys_locked = false;
--- End code ---
...

--- Code: ---        if (button == ACTION_STD_KEYLOCK)
        {
            if (keys_locked)
            {
                keys_locked = false;
                splash(HZ/2, str(LANG_KEYLOCK_OFF));
                screen_update = NB_SCREENS;
                update_list = true;
                send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
            }
            else
            {
                keys_locked = true;
                screen_update = 0;
                update_list = false;
                FOR_NB_SCREENS(i)
                {
                    screens[i].clear_display();
                }
                splash(HZ/2, str(LANG_KEYLOCK_ON));
                FOR_NB_SCREENS(i)
                {
                    screens[i].clear_display();
                }
                button_clear_queue();
            }
        }

        if (keys_locked)
        {
            if (button != BUTTON_NONE)
            {
                splash(HZ/2, str(LANG_KEYLOCK_ON));
                FOR_NB_SCREENS(i)
                {
                    screens[i].clear_display();
                }
            }
        }
        else
        {
--- End code ---
           /* let list handle the button */
            gui_synclist_do_button(&lists, &button, LIST_WRAP_UNLESS_HELD);

            switch(button)
            ...
            } /*switch(button)*/

--- Code: ---        } /*if(keys_locked)*/
--- End code ---

Navigation

[0] Message Index

Go to full version