From 5cbeb88541ebbfe388b3d60a1c7564b556b9748b Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sun, 16 May 2021 16:44:01 +0100 Subject: FiiO M3K: keymap improvements & fixes - Add support for skip and seek while the player is locked. (Thanks to @bahus for the suggestion) - Fix touch zones because the down button zone ended up being a lot smaller than expected due to the touchpad's wonkiness. Also added a visual display of the touchpad to its debug menu. - Fixes the pictureflow keymap because it was mostly unusable. Change-Id: Ic0da4f8df3613ff7828ce1cb940ed9e77ada3281 --- apps/keymaps/keymap-fiiom3k.c | 19 +++++++ apps/plugins/pictureflow/pictureflow.c | 9 ++++ firmware/export/config/fiiom3k.h | 1 + .../mips/ingenic_x1000/fiiom3k/button-fiiom3k.c | 61 ++++++++++++++++++++-- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/apps/keymaps/keymap-fiiom3k.c b/apps/keymaps/keymap-fiiom3k.c index 440f851650..94d2dbc172 100644 --- a/apps/keymaps/keymap-fiiom3k.c +++ b/apps/keymaps/keymap-fiiom3k.c @@ -76,6 +76,16 @@ static const struct button_mapping button_context_wps[] = { LAST_ITEM_IN_LIST }; /* button_context_wps */ +static const struct button_mapping button_context_wps_locked[] = { + {ACTION_WPS_SKIPNEXT, BUTTON_VOL_UP|BUTTON_REL, BUTTON_PLAY|BUTTON_VOL_UP}, + {ACTION_WPS_SEEKFWD, BUTTON_PLAY|BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE}, + {ACTION_WPS_STOPSEEK, BUTTON_PLAY|BUTTON_VOL_UP|BUTTON_REL, BUTTON_PLAY|BUTTON_VOL_UP|BUTTON_REPEAT}, + {ACTION_WPS_SKIPPREV, BUTTON_VOL_DOWN|BUTTON_REL, BUTTON_PLAY|BUTTON_VOL_DOWN}, + {ACTION_WPS_SEEKBACK, BUTTON_PLAY|BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE}, + {ACTION_WPS_STOPSEEK, BUTTON_PLAY|BUTTON_VOL_DOWN|BUTTON_REL, BUTTON_PLAY|BUTTON_VOL_DOWN|BUTTON_REPEAT}, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_WPS) +}; /* button_context_wps_locked */ + static const struct button_mapping button_context_tree[] = { {ACTION_TREE_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY}, {ACTION_TREE_WPS, BUTTON_BACK|BUTTON_REPEAT, BUTTON_BACK}, @@ -242,6 +252,15 @@ static const struct button_mapping button_context_usb_hid_mode_browser[] = { const struct button_mapping* get_context_mapping(int context) { + switch (context) + { + case CONTEXT_WPS|CONTEXT_LOCKED: + return button_context_wps_locked; + default: + context &= ~CONTEXT_LOCKED; + break; + } + switch (context) { default: diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 9faf53661e..9731d92d35 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -148,6 +148,15 @@ const struct button_mapping pf_context_buttons[] = {PF_CONTEXT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_FFWD}, {PF_TRACKLIST, BUTTON_FFWD|BUTTON_REL, BUTTON_FFWD}, {PF_WPS, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY}, +#elif CONFIG_KEYPAD == FIIO_M3K_PAD + {PF_PREV, BUTTON_LEFT, BUTTON_NONE}, + {PF_PREV_REPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE}, + {PF_NEXT, BUTTON_RIGHT, BUTTON_NONE}, + {PF_NEXT_REPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE}, + {PF_MENU, BUTTON_POWER|BUTTON_REL, BUTTON_POWER}, + {PF_QUIT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_POWER}, + {PF_CONTEXT, BUTTON_MENU|BUTTON_REL, BUTTON_MENU}, + {PF_TRACKLIST, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU}, #endif #if CONFIG_KEYPAD == IAUDIO_M3_PAD LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD|CONTEXT_REMOTE) diff --git a/firmware/export/config/fiiom3k.h b/firmware/export/config/fiiom3k.h index 86f41fca46..2c212b031d 100644 --- a/firmware/export/config/fiiom3k.h +++ b/firmware/export/config/fiiom3k.h @@ -124,4 +124,5 @@ #define HAVE_VOLUME_IN_LIST #define HAVE_QUICKSCREEN #define HAVE_HOTKEY +#define HAVE_LOCKED_ACTIONS #define AB_REPEAT_ENABLE diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c index e27e0be464..b5193152a2 100644 --- a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c +++ b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c @@ -110,6 +110,19 @@ static struct ft_state_machine { int cur_x, cur_y; } fsm; +/* coordinates below this are the left hand buttons, + * coordinates above this are part of the scrollbar */ +#define SCROLLSTRIP_LEFT_X 80 + +/* top and bottom cutoffs for the center of the strip, + * divides it into top/middle/bottom zones */ +#define SCROLLSTRIP_TOP_Y 105 +#define SCROLLSTRIP_BOT_Y 185 + +/* cutoffs for the menu/left button zones */ +#define MENUBUTTON_Y 80 +#define LEFTBUTTON_Y 190 + static int touch_to_button(int x, int y) { if(x == 900) { @@ -120,19 +133,19 @@ static int touch_to_button(int x, int y) return BUTTON_RIGHT; else return 0; - } else if(x < 80) { + } else if(x < SCROLLSTRIP_LEFT_X) { /* Left strip */ - if(y < 80) + if(y < MENUBUTTON_Y) return BUTTON_MENU; - else if(y > 190) + else if(y > LEFTBUTTON_Y) return BUTTON_LEFT; else return 0; } else { /* Middle strip */ - if(y < 100) + if(y < SCROLLSTRIP_TOP_Y) return BUTTON_UP; - else if(y > 220) + else if(y > SCROLLSTRIP_BOT_Y) return BUTTON_DOWN; else return BUTTON_SELECT; @@ -489,6 +502,24 @@ bool dbg_fiiom3k_touchpad(void) "IDLE", "PRESS", "REPORT", "SCROLL_PRESS", "SCROLLING" }; + /* definition of box used to represent the touchpad */ + const int pad_w = LCD_WIDTH; + const int pad_h = LCD_HEIGHT; + const int box_h = pad_h - SYSFONT_HEIGHT*5; + const int box_w = pad_w * box_h / pad_h; + const int box_x = (LCD_WIDTH - box_w) / 2; + const int box_y = SYSFONT_HEIGHT * 9 / 2; + + /* cutoffs converted to box coordinates */ + const int ss_left_x = box_x + SCROLLSTRIP_LEFT_X * box_w / pad_w; + const int ss_top_y = box_y + SCROLLSTRIP_TOP_Y * box_h / pad_h; + const int ss_bot_y = box_y + SCROLLSTRIP_BOT_Y * box_h / pad_h; + const int menubtn_y = box_y + MENUBUTTON_Y * box_h / pad_h; + const int leftbtn_y = box_y + LEFTBUTTON_Y * box_h / pad_h; + + bool draw_areas = true; + bool draw_border = true; + do { int line = 0; lcd_clear_display(); @@ -496,6 +527,26 @@ bool dbg_fiiom3k_touchpad(void) lcd_putsf(0, line++, "button: %08x", fsm.buttons); lcd_putsf(0, line++, "pos x: %4d orig x: %4d", fsm.cur_x, fsm.orig_x); lcd_putsf(0, line++, "pos y: %4d orig y: %4d", fsm.cur_y, fsm.orig_y); + + /* draw touchpad box borders */ + if(draw_border) + lcd_drawrect(box_x, box_y, box_w, box_h); + + /* draw crosshair */ + int tx = box_x + fsm.cur_x * box_w / pad_w; + int ty = box_y + fsm.cur_y * box_h / pad_h; + lcd_hline(tx-2, tx+2, ty); + lcd_vline(tx, ty-2, ty+2); + + /* draw the button areas */ + if(draw_areas) { + lcd_vline(ss_left_x, box_y, box_y+box_h); + lcd_hline(ss_left_x, box_x+box_w, ss_top_y); + lcd_hline(ss_left_x, box_x+box_w, ss_bot_y); + lcd_hline(box_x, ss_left_x, menubtn_y); + lcd_hline(box_x, ss_left_x, leftbtn_y); + } + lcd_update(); } while(getbtn() != BUTTON_POWER); return false; -- cgit v1.2.3