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 | |
parent | a87abdb28f929623354270f257cc63bf73b3e74c (diff) | |
download | rockbox-87e37a4d48ada935808aa85a86526b24ea482bb6.tar.gz rockbox-87e37a4d48ada935808aa85a86526b24ea482bb6.zip |
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
-rw-r--r-- | apps/keymaps/keymap-xduoox20.c | 16 | ||||
-rw-r--r-- | apps/keymaps/keymap-xduoox3ii.c | 16 | ||||
-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 |
6 files changed, 68 insertions, 30 deletions
diff --git a/apps/keymaps/keymap-xduoox20.c b/apps/keymaps/keymap-xduoox20.c index 00df9c89e7..20a53b92e3 100644 --- a/apps/keymaps/keymap-xduoox20.c +++ b/apps/keymaps/keymap-xduoox20.c | |||
@@ -35,10 +35,10 @@ | |||
35 | * Insert LAST_ITEM_IN_LIST at the end of each mapping | 35 | * Insert LAST_ITEM_IN_LIST at the end of each mapping |
36 | */ | 36 | */ |
37 | static const struct button_mapping button_context_standard[] = { | 37 | static const struct button_mapping button_context_standard[] = { |
38 | { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE }, | 38 | { ACTION_STD_PREV, BUTTON_NEXT, BUTTON_NONE }, |
39 | { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, | 39 | { ACTION_STD_PREVREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, |
40 | { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE }, | 40 | { ACTION_STD_NEXT, BUTTON_PREV, BUTTON_NONE }, |
41 | { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, | 41 | { ACTION_STD_NEXTREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, /* Backwards! */ |
42 | { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, | 42 | { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, |
43 | { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, | 43 | { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, |
44 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | 44 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, |
@@ -145,10 +145,10 @@ static const struct button_mapping button_context_quickscreen[] = { | |||
145 | /** Settings - General Mappings **/ | 145 | /** Settings - General Mappings **/ |
146 | static const struct button_mapping button_context_settings[] = { | 146 | static const struct button_mapping button_context_settings[] = { |
147 | { ACTION_SETTINGS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, | 147 | { ACTION_SETTINGS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, |
148 | { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE }, | 148 | { ACTION_STD_PREV, BUTTON_NEXT, BUTTON_NONE }, |
149 | { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, | 149 | { ACTION_STD_PREVREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, |
150 | { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE }, | 150 | { ACTION_STD_NEXT, BUTTON_PREV, BUTTON_NONE }, |
151 | { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, | 151 | { ACTION_STD_NEXTREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, /* Backwards! */ |
152 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | 152 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, |
153 | { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, | 153 | { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, |
154 | 154 | ||
diff --git a/apps/keymaps/keymap-xduoox3ii.c b/apps/keymaps/keymap-xduoox3ii.c index a8cf349e0d..d33b9d1f20 100644 --- a/apps/keymaps/keymap-xduoox3ii.c +++ b/apps/keymaps/keymap-xduoox3ii.c | |||
@@ -35,10 +35,10 @@ | |||
35 | * Insert LAST_ITEM_IN_LIST at the end of each mapping | 35 | * Insert LAST_ITEM_IN_LIST at the end of each mapping |
36 | */ | 36 | */ |
37 | static const struct button_mapping button_context_standard[] = { | 37 | static const struct button_mapping button_context_standard[] = { |
38 | { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE }, | 38 | { ACTION_STD_PREV, BUTTON_NEXT, BUTTON_NONE }, |
39 | { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, | 39 | { ACTION_STD_PREVREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, |
40 | { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE }, | 40 | { ACTION_STD_NEXT, BUTTON_PREV, BUTTON_NONE }, |
41 | { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, | 41 | { ACTION_STD_NEXTREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, /* Backwards! */ |
42 | { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, | 42 | { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, |
43 | { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, | 43 | { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, |
44 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | 44 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, |
@@ -145,10 +145,10 @@ static const struct button_mapping button_context_quickscreen[] = { | |||
145 | /** Settings - General Mappings **/ | 145 | /** Settings - General Mappings **/ |
146 | static const struct button_mapping button_context_settings[] = { | 146 | static const struct button_mapping button_context_settings[] = { |
147 | { ACTION_SETTINGS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, | 147 | { ACTION_SETTINGS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, |
148 | { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE }, | 148 | { ACTION_STD_PREV, BUTTON_NEXT, BUTTON_NONE }, |
149 | { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, | 149 | { ACTION_STD_PREVREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, |
150 | { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE }, | 150 | { ACTION_STD_NEXT, BUTTON_PREV, BUTTON_NONE }, |
151 | { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, | 151 | { ACTION_STD_NEXTREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, /* Backwards! */ |
152 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | 152 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, |
153 | { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, | 153 | { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, |
154 | 154 | ||
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){ | |||
141 | 141 | ||
142 | #if defined(XDUOO_X20) | 142 | #if defined(XDUOO_X20) |
143 | sysfs_get_int(sysfs_bal_switch, &status); | 143 | sysfs_get_int(sysfs_bal_switch, &status); |
144 | if (status) ps = 3; // balance | 144 | if (status) ps = 3; // balanced output |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | xduoo_set_output(ps); | 147 | xduoo_set_output(ps); |
@@ -159,7 +159,12 @@ void xduoo_set_output(int ps) | |||
159 | /* Output port switch */ | 159 | /* Output port switch */ |
160 | last_ps = ps; | 160 | last_ps = ps; |
161 | alsa_controls_set_ints("Output Port Switch", 1, &last_ps); | 161 | alsa_controls_set_ints("Output Port Switch", 1, &last_ps); |
162 | audiohw_set_volume(vol_l_hw, vol_r_hw); | 162 | audiohw_set_volume(vol_l_hw, vol_r_hw); |
163 | |||
164 | #if defined(XDUOO_X3II) | ||
165 | /* Enable/disable headphone remote ADC */ | ||
166 | sysfs_set_string("/sys/devices/platform/earpods_adc.0/earpods_adc/earpods_adc_sw", (ps == 2) ? "on" : "off"); | ||
167 | #endif | ||
163 | } | 168 | } |
164 | } | 169 | } |
165 | 170 | ||
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 @@ | |||
19 | * KIND, either express or implied. | 19 | * KIND, either express or implied. |
20 | * | 20 | * |
21 | ****************************************************************************/ | 21 | ****************************************************************************/ |
22 | |||
23 | #include <poll.h> | 22 | #include <poll.h> |
24 | #include <errno.h> | 23 | #include <errno.h> |
25 | #include <unistd.h> | 24 | #include <unistd.h> |
@@ -72,6 +71,11 @@ void button_close_device(void) | |||
72 | num_devices = 0; | 71 | num_devices = 0; |
73 | } | 72 | } |
74 | 73 | ||
74 | #ifdef BUTTON_DELAY_RELEASE | ||
75 | static int button_delay_release = 0; | ||
76 | static int delay_tick = 0; | ||
77 | #endif | ||
78 | |||
75 | int button_read_device(void) | 79 | int button_read_device(void) |
76 | { | 80 | { |
77 | static int button_bitmap = 0; | 81 | static int button_bitmap = 0; |
@@ -81,6 +85,15 @@ int button_read_device(void) | |||
81 | int wheel_ticks = 0; | 85 | int wheel_ticks = 0; |
82 | #endif | 86 | #endif |
83 | 87 | ||
88 | #ifdef BUTTON_DELAY_RELEASE | ||
89 | /* First de-assert delayed-release buttons */ | ||
90 | if (button_delay_release && current_tick >= delay_tick) | ||
91 | { | ||
92 | button_bitmap &= ~button_delay_release; | ||
93 | button_delay_release = 0; | ||
94 | } | ||
95 | #endif | ||
96 | |||
84 | /* check if there are any events pending and process them */ | 97 | /* check if there are any events pending and process them */ |
85 | while(poll(poll_fds, num_devices, 0)) | 98 | while(poll(poll_fds, num_devices, 0)) |
86 | { | 99 | { |
@@ -92,17 +105,14 @@ int button_read_device(void) | |||
92 | int size = read(poll_fds[i].fd, &event, sizeof(event)); | 105 | int size = read(poll_fds[i].fd, &event, sizeof(event)); |
93 | if(size == (int)sizeof(event)) | 106 | if(size == (int)sizeof(event)) |
94 | { | 107 | { |
95 | int keycode = event.code; | 108 | /* map linux event code to rockbox button bitmap */ |
109 | int bmap = button_map(event.code); | ||
110 | |||
96 | /* event.value == 0x10000 means press | 111 | /* event.value == 0x10000 means press |
97 | * event.value == 0 means release | 112 | * event.value == 0 means release |
98 | */ | 113 | */ |
99 | bool press = event.value ? true : false; | 114 | if(event.value) |
100 | |||
101 | /* map linux event code to rockbox button bitmap */ | ||
102 | if(press) | ||
103 | { | 115 | { |
104 | int bmap = button_map(keycode); | ||
105 | |||
106 | #ifdef HAVE_SCROLLWHEEL | 116 | #ifdef HAVE_SCROLLWHEEL |
107 | /* Filter out wheel ticks */ | 117 | /* Filter out wheel ticks */ |
108 | if (bmap & BUTTON_SCROLL_BACK) | 118 | if (bmap & BUTTON_SCROLL_BACK) |
@@ -111,18 +121,28 @@ int button_read_device(void) | |||
111 | wheel_ticks++; | 121 | wheel_ticks++; |
112 | bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD); | 122 | bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD); |
113 | #endif | 123 | #endif |
124 | #ifdef BUTTON_DELAY_RELEASE | ||
125 | bmap &= ~BUTTON_DELAY_RELEASE; | ||
126 | #endif | ||
114 | button_bitmap |= bmap; | 127 | button_bitmap |= bmap; |
115 | } | 128 | } |
116 | else | 129 | else |
117 | { | 130 | { |
118 | int bmap = button_map(keycode); | 131 | #ifdef BUTTON_DELAY_RELEASE |
132 | /* Delay the release of any requested buttons */ | ||
133 | if (bmap & BUTTON_DELAY_RELEASE) | ||
134 | { | ||
135 | button_delay_release |= bmap & ~BUTTON_DELAY_RELEASE; | ||
136 | delay_tick = current_tick + HZ/20; | ||
137 | bmap = 0; | ||
138 | } | ||
139 | #endif | ||
119 | 140 | ||
120 | #ifdef HAVE_SCROLLWHEEL | 141 | #ifdef HAVE_SCROLLWHEEL |
121 | /* Wheel gives us press+release back to back; ignore the release */ | 142 | /* Wheel gives us press+release back to back; ignore the release */ |
122 | bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD); | 143 | bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD); |
123 | #endif | 144 | #endif |
124 | button_bitmap &= ~bmap; | 145 | button_bitmap &= ~bmap; |
125 | |||
126 | } | 146 | } |
127 | } | 147 | } |
128 | } | 148 | } |
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 @@ | |||
36 | #define BUTTON_MAIN (BUTTON_POWER | BUTTON_HOME | BUTTON_OPTION | BUTTON_PREV | \ | 36 | #define BUTTON_MAIN (BUTTON_POWER | BUTTON_HOME | BUTTON_OPTION | BUTTON_PREV | \ |
37 | BUTTON_NEXT | BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN) | 37 | BUTTON_NEXT | BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN) |
38 | 38 | ||
39 | #define BUTTON_DELAY_RELEASE 0x00010000 | ||
40 | |||
39 | /* Software power-off */ | 41 | /* Software power-off */ |
40 | #define POWEROFF_BUTTON BUTTON_POWER | 42 | #define POWEROFF_BUTTON BUTTON_POWER |
41 | #define POWEROFF_COUNT 25 | 43 | #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) | |||
37 | return BUTTON_OPTION; | 37 | return BUTTON_OPTION; |
38 | 38 | ||
39 | case KEY_UP: | 39 | case KEY_UP: |
40 | return BUTTON_PREV; | 40 | return BUTTON_NEXT; |
41 | 41 | ||
42 | case KEY_DOWN: | 42 | case KEY_DOWN: |
43 | return BUTTON_NEXT; | 43 | return BUTTON_PREV; |
44 | 44 | ||
45 | case KEY_ENTER: | 45 | case KEY_ENTER: |
46 | return BUTTON_PLAY; | 46 | return BUTTON_PLAY; |
@@ -54,6 +54,17 @@ int button_map(int keycode) | |||
54 | case KEY_POWER: | 54 | case KEY_POWER: |
55 | return BUTTON_POWER; | 55 | return BUTTON_POWER; |
56 | 56 | ||
57 | #if defined(XDUOO_X3II) /* Headphone remote */ | ||
58 | case KEY_NEXTSONG: | ||
59 | return (BUTTON_NEXT | BUTTON_DELAY_RELEASE); | ||
60 | |||
61 | case KEY_PLAYPAUSE: | ||
62 | return (BUTTON_PLAY | BUTTON_DELAY_RELEASE); | ||
63 | |||
64 | case KEY_PREVIOUSSONG: | ||
65 | return (BUTTON_PREV | BUTTON_DELAY_RELEASE); | ||
66 | |||
67 | #endif | ||
57 | default: | 68 | default: |
58 | return 0; | 69 | return 0; |
59 | } | 70 | } |