diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2021-03-10 19:03:00 -0500 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-03-10 21:35:44 -0500 |
commit | 87e37a4d48ada935808aa85a86526b24ea482bb6 (patch) | |
tree | 3510f9dc2177d0993480e28cceabee1e2f35861c /firmware | |
parent | a87abdb28f929623354270f257cc63bf73b3e74c (diff) |
xduoo_x3ii: Improvements in the meymappings!
* PREV/NEXT now swapped so they do what is expected in most contexts
* List and setting context retains prior behavior
* Enable the ADC that reads the headset remote and map the keys.
* As ADC-based remote "events" arrive as press/release pairs,
delay the button release.
Change-Id: I22d4eac3bfe1573b50eca795cf377bdafdeb5336
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/audio/xduoolinux_codec.c | 9 | ||||
-rw-r--r-- | firmware/target/hosted/button-devinput.c | 40 | ||||
-rw-r--r-- | firmware/target/hosted/xduoo/button-target.h | 2 | ||||
-rw-r--r-- | firmware/target/hosted/xduoo/button-xduoo.c | 15 |
4 files changed, 52 insertions, 14 deletions
diff --git a/firmware/drivers/audio/xduoolinux_codec.c b/firmware/drivers/audio/xduoolinux_codec.c index 3ce35aa62a..c78864db2c 100644 --- a/firmware/drivers/audio/xduoolinux_codec.c +++ b/firmware/drivers/audio/xduoolinux_codec.c @@ -141,7 +141,7 @@ int xduoo_get_outputs(void){ #if defined(XDUOO_X20) sysfs_get_int(sysfs_bal_switch, &status); - if (status) ps = 3; // balance + if (status) ps = 3; // balanced output #endif xduoo_set_output(ps); @@ -159,7 +159,12 @@ void xduoo_set_output(int ps) /* Output port switch */ last_ps = ps; alsa_controls_set_ints("Output Port Switch", 1, &last_ps); - audiohw_set_volume(vol_l_hw, vol_r_hw); + audiohw_set_volume(vol_l_hw, vol_r_hw); + +#if defined(XDUOO_X3II) + /* Enable/disable headphone remote ADC */ + sysfs_set_string("/sys/devices/platform/earpods_adc.0/earpods_adc/earpods_adc_sw", (ps == 2) ? "on" : "off"); +#endif } } diff --git a/firmware/target/hosted/button-devinput.c b/firmware/target/hosted/button-devinput.c index 90e6fb0340..b1b4dfca5d 100644 --- a/firmware/target/hosted/button-devinput.c +++ b/firmware/target/hosted/button-devinput.c @@ -19,7 +19,6 @@ * KIND, either express or implied. * ****************************************************************************/ - #include <poll.h> #include <errno.h> #include <unistd.h> @@ -72,6 +71,11 @@ void button_close_device(void) num_devices = 0; } +#ifdef BUTTON_DELAY_RELEASE +static int button_delay_release = 0; +static int delay_tick = 0; +#endif + int button_read_device(void) { static int button_bitmap = 0; @@ -81,6 +85,15 @@ int button_read_device(void) int wheel_ticks = 0; #endif +#ifdef BUTTON_DELAY_RELEASE + /* First de-assert delayed-release buttons */ + if (button_delay_release && current_tick >= delay_tick) + { + button_bitmap &= ~button_delay_release; + button_delay_release = 0; + } +#endif + /* check if there are any events pending and process them */ while(poll(poll_fds, num_devices, 0)) { @@ -92,17 +105,14 @@ int button_read_device(void) int size = read(poll_fds[i].fd, &event, sizeof(event)); if(size == (int)sizeof(event)) { - int keycode = event.code; + /* map linux event code to rockbox button bitmap */ + int bmap = button_map(event.code); + /* event.value == 0x10000 means press * event.value == 0 means release */ - bool press = event.value ? true : false; - - /* map linux event code to rockbox button bitmap */ - if(press) + if(event.value) { - int bmap = button_map(keycode); - #ifdef HAVE_SCROLLWHEEL /* Filter out wheel ticks */ if (bmap & BUTTON_SCROLL_BACK) @@ -111,18 +121,28 @@ int button_read_device(void) wheel_ticks++; bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD); #endif +#ifdef BUTTON_DELAY_RELEASE + bmap &= ~BUTTON_DELAY_RELEASE; +#endif button_bitmap |= bmap; } else { - int bmap = button_map(keycode); +#ifdef BUTTON_DELAY_RELEASE + /* Delay the release of any requested buttons */ + if (bmap & BUTTON_DELAY_RELEASE) + { + button_delay_release |= bmap & ~BUTTON_DELAY_RELEASE; + delay_tick = current_tick + HZ/20; + bmap = 0; + } +#endif #ifdef HAVE_SCROLLWHEEL /* Wheel gives us press+release back to back; ignore the release */ bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD); #endif button_bitmap &= ~bmap; - } } } diff --git a/firmware/target/hosted/xduoo/button-target.h b/firmware/target/hosted/xduoo/button-target.h index 20bae1c6f6..d1a2b27624 100644 --- a/firmware/target/hosted/xduoo/button-target.h +++ b/firmware/target/hosted/xduoo/button-target.h @@ -36,6 +36,8 @@ #define BUTTON_MAIN (BUTTON_POWER | BUTTON_HOME | BUTTON_OPTION | BUTTON_PREV | \ BUTTON_NEXT | BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN) +#define BUTTON_DELAY_RELEASE 0x00010000 + /* Software power-off */ #define POWEROFF_BUTTON BUTTON_POWER #define POWEROFF_COUNT 25 diff --git a/firmware/target/hosted/xduoo/button-xduoo.c b/firmware/target/hosted/xduoo/button-xduoo.c index f5b6c6be62..2daa7da16b 100644 --- a/firmware/target/hosted/xduoo/button-xduoo.c +++ b/firmware/target/hosted/xduoo/button-xduoo.c @@ -37,10 +37,10 @@ int button_map(int keycode) return BUTTON_OPTION; case KEY_UP: - return BUTTON_PREV; + return BUTTON_NEXT; case KEY_DOWN: - return BUTTON_NEXT; + return BUTTON_PREV; case KEY_ENTER: return BUTTON_PLAY; @@ -54,6 +54,17 @@ int button_map(int keycode) case KEY_POWER: return BUTTON_POWER; +#if defined(XDUOO_X3II) /* Headphone remote */ + case KEY_NEXTSONG: + return (BUTTON_NEXT | BUTTON_DELAY_RELEASE); + + case KEY_PLAYPAUSE: + return (BUTTON_PLAY | BUTTON_DELAY_RELEASE); + + case KEY_PREVIOUSSONG: + return (BUTTON_PREV | BUTTON_DELAY_RELEASE); + +#endif default: return 0; } |