mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Remote android button handling (again). do the press/unpress more like other targets (i.e correctly). The DPAD is special in that the press/unpress happens too quickly, so always post it with the BUTTON_REL. This means all keymaps using the dpad need to remember it will always have a BUTTON_REL (which also means they cant do repeats, which are impossible anyway).
Also make the back button go back to the OS home from the rockbox main menu git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28475 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
45fa8245ea
commit
a41041aeb4
5 changed files with 75 additions and 55 deletions
|
@ -38,15 +38,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const struct button_mapping button_context_standard[] = {
|
static const struct button_mapping button_context_standard[] = {
|
||||||
{ ACTION_STD_PREV, BUTTON_DPAD_UP, BUTTON_NONE },
|
{ ACTION_STD_PREV, BUTTON_DPAD_UP|BUTTON_REL, BUTTON_NONE },
|
||||||
{ ACTION_STD_PREVREPEAT, BUTTON_DPAD_UP|BUTTON_REPEAT, BUTTON_NONE },
|
{ ACTION_STD_NEXT, BUTTON_DPAD_DOWN|BUTTON_REL, BUTTON_NONE },
|
||||||
{ ACTION_STD_NEXT, BUTTON_DPAD_DOWN, BUTTON_NONE },
|
|
||||||
{ ACTION_STD_NEXTREPEAT, BUTTON_DPAD_DOWN|BUTTON_REPEAT, BUTTON_NONE },
|
|
||||||
|
|
||||||
{ ACTION_STD_OK, BUTTON_DPAD_CENTER|BUTTON_REL, BUTTON_DPAD_CENTER },
|
{ ACTION_STD_OK, BUTTON_DPAD_CENTER, BUTTON_NONE },
|
||||||
{ ACTION_STD_OK, BUTTON_DPAD_RIGHT|BUTTON_REL, BUTTON_DPAD_RIGHT },
|
{ ACTION_STD_OK, BUTTON_DPAD_RIGHT|BUTTON_REL, BUTTON_NONE },
|
||||||
{ ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE },
|
{ ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE },
|
||||||
{ ACTION_STD_CANCEL, BUTTON_DPAD_LEFT|BUTTON_REL, BUTTON_DPAD_LEFT },
|
{ ACTION_STD_CANCEL, BUTTON_BACK|BUTTON_REPEAT, BUTTON_BACK },
|
||||||
|
{ ACTION_STD_CANCEL, BUTTON_DPAD_LEFT|BUTTON_REL, BUTTON_NONE },
|
||||||
|
|
||||||
{ ACTION_STD_CONTEXT, BUTTON_MENU, BUTTON_NONE },
|
{ ACTION_STD_CONTEXT, BUTTON_MENU, BUTTON_NONE },
|
||||||
|
|
||||||
|
@ -78,12 +77,10 @@ static const struct button_mapping button_context_listtree_scroll_without_combo[
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct button_mapping button_context_settings[] = {
|
static const struct button_mapping button_context_settings[] = {
|
||||||
{ ACTION_SETTINGS_INC, BUTTON_DPAD_RIGHT, BUTTON_NONE },
|
{ ACTION_SETTINGS_INC, BUTTON_DPAD_RIGHT|BUTTON_REL, BUTTON_NONE },
|
||||||
{ ACTION_SETTINGS_INCREPEAT, BUTTON_DPAD_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
|
{ ACTION_SETTINGS_DEC, BUTTON_DPAD_LEFT|BUTTON_REL, BUTTON_NONE },
|
||||||
{ ACTION_SETTINGS_DEC, BUTTON_DPAD_LEFT, BUTTON_NONE },
|
{ ACTION_STD_OK, BUTTON_DPAD_CENTER, BUTTON_NONE },
|
||||||
{ ACTION_SETTINGS_DECREPEAT, BUTTON_DPAD_LEFT|BUTTON_REPEAT, BUTTON_NONE },
|
{ ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE },
|
||||||
{ ACTION_STD_OK, BUTTON_DPAD_CENTER, BUTTON_NONE },
|
|
||||||
{ ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE },
|
|
||||||
|
|
||||||
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
|
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
|
||||||
}; /* button_context_settings */
|
}; /* button_context_settings */
|
||||||
|
@ -124,24 +121,13 @@ static const struct button_mapping button_context_quickscreen[] = {
|
||||||
|
|
||||||
static const struct button_mapping button_context_pitchscreen[] = {
|
static const struct button_mapping button_context_pitchscreen[] = {
|
||||||
|
|
||||||
{ ACTION_PS_INC_SMALL, BUTTON_DPAD_RIGHT, BUTTON_NONE },
|
{ ACTION_PS_INC_SMALL, BUTTON_DPAD_RIGHT|BUTTON_REL, BUTTON_NONE },
|
||||||
{ ACTION_PS_INC_BIG, BUTTON_DPAD_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
|
{ ACTION_PS_DEC_SMALL, BUTTON_DPAD_LEFT|BUTTON_REL, BUTTON_NONE },
|
||||||
{ ACTION_PS_DEC_SMALL, BUTTON_DPAD_LEFT, BUTTON_NONE },
|
{ ACTION_PS_EXIT, BUTTON_BACK, BUTTON_NONE },
|
||||||
{ ACTION_PS_DEC_BIG, BUTTON_DPAD_LEFT|BUTTON_REPEAT, BUTTON_NONE },
|
|
||||||
{ ACTION_PS_EXIT, BUTTON_BACK, BUTTON_NONE },
|
|
||||||
|
|
||||||
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
|
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
|
||||||
}; /* button_context_pitchcreen */
|
}; /* button_context_pitchcreen */
|
||||||
|
|
||||||
static const struct button_mapping button_context_keyboard[] = {
|
|
||||||
{ ACTION_KBD_PAGE_FLIP, BUTTON_MENU, BUTTON_NONE },
|
|
||||||
{ ACTION_KBD_CURSOR_LEFT, BUTTON_DPAD_LEFT, BUTTON_NONE },
|
|
||||||
{ ACTION_KBD_CURSOR_LEFT, BUTTON_DPAD_LEFT|BUTTON_REPEAT, BUTTON_NONE },
|
|
||||||
{ ACTION_KBD_CURSOR_RIGHT, BUTTON_DPAD_RIGHT, BUTTON_NONE },
|
|
||||||
{ ACTION_KBD_CURSOR_RIGHT, BUTTON_DPAD_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
|
|
||||||
|
|
||||||
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
|
|
||||||
}; /* button_context_keyboard */
|
|
||||||
|
|
||||||
static const struct button_mapping button_context_radio[] = {
|
static const struct button_mapping button_context_radio[] = {
|
||||||
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
|
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
|
||||||
|
@ -181,8 +167,6 @@ const struct button_mapping* target_get_context_mapping(int context)
|
||||||
case CONTEXT_SETTINGS_TIME:
|
case CONTEXT_SETTINGS_TIME:
|
||||||
return button_context_time;
|
return button_context_time;
|
||||||
|
|
||||||
case CONTEXT_YESNOSCREEN:
|
|
||||||
return button_context_yesno;
|
|
||||||
case CONTEXT_FM:
|
case CONTEXT_FM:
|
||||||
return button_context_radio;
|
return button_context_radio;
|
||||||
case CONTEXT_BOOKMARKSCREEN:
|
case CONTEXT_BOOKMARKSCREEN:
|
||||||
|
@ -191,8 +175,6 @@ const struct button_mapping* target_get_context_mapping(int context)
|
||||||
return button_context_quickscreen;
|
return button_context_quickscreen;
|
||||||
case CONTEXT_PITCHSCREEN:
|
case CONTEXT_PITCHSCREEN:
|
||||||
return button_context_pitchscreen;
|
return button_context_pitchscreen;
|
||||||
case CONTEXT_KEYBOARD:
|
|
||||||
return button_context_keyboard;
|
|
||||||
}
|
}
|
||||||
return button_context_standard;
|
return button_context_standard;
|
||||||
}
|
}
|
||||||
|
|
|
@ -639,7 +639,15 @@ void root_menu(void)
|
||||||
case GO_TO_ROOT:
|
case GO_TO_ROOT:
|
||||||
if (last_screen != GO_TO_ROOT)
|
if (last_screen != GO_TO_ROOT)
|
||||||
selected = get_selection(last_screen);
|
selected = get_selection(last_screen);
|
||||||
|
#if (CONFIG_PLATFORM&PLATFORM_ANDROID)
|
||||||
|
/* When we are in the main menu we want the hardware BACK
|
||||||
|
* button to be handled by Android instead of rockbox */
|
||||||
|
android_ignore_back_button(true);
|
||||||
|
#endif
|
||||||
next_screen = do_menu(&root_menu_, &selected, NULL, false);
|
next_screen = do_menu(&root_menu_, &selected, NULL, false);
|
||||||
|
#if (CONFIG_PLATFORM&PLATFORM_ANDROID)
|
||||||
|
android_ignore_back_button(false);
|
||||||
|
#endif
|
||||||
if (next_screen != GO_TO_PREVIOUS)
|
if (next_screen != GO_TO_PREVIOUS)
|
||||||
last_screen = GO_TO_ROOT;
|
last_screen = GO_TO_ROOT;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,26 +23,24 @@
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "android_keyevents.h"
|
#include "android_keyevents.h"
|
||||||
|
|
||||||
|
static bool ignore_back_button = false;
|
||||||
|
void android_ignore_back_button(bool yes)
|
||||||
|
{
|
||||||
|
ignore_back_button = yes;
|
||||||
|
}
|
||||||
|
|
||||||
int key_to_button(int keyboard_key)
|
int key_to_button(int keyboard_key)
|
||||||
{
|
{
|
||||||
switch (keyboard_key)
|
switch (keyboard_key)
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
return BUTTON_NONE;
|
|
||||||
case KEYCODE_BACK:
|
case KEYCODE_BACK:
|
||||||
return BUTTON_BACK;
|
return ignore_back_button ? BUTTON_NONE : BUTTON_BACK;
|
||||||
case KEYCODE_DPAD_UP:
|
|
||||||
return BUTTON_DPAD_UP;
|
|
||||||
case KEYCODE_DPAD_DOWN:
|
|
||||||
return BUTTON_DPAD_DOWN;
|
|
||||||
case KEYCODE_DPAD_LEFT:
|
|
||||||
return BUTTON_DPAD_LEFT;
|
|
||||||
case KEYCODE_DPAD_RIGHT:
|
|
||||||
return BUTTON_DPAD_RIGHT;
|
|
||||||
case KEYCODE_DPAD_CENTER:
|
|
||||||
return BUTTON_DPAD_CENTER;
|
|
||||||
case KEYCODE_MENU:
|
case KEYCODE_MENU:
|
||||||
return BUTTON_MENU;
|
return BUTTON_MENU;
|
||||||
|
case KEYCODE_DPAD_CENTER:
|
||||||
|
return BUTTON_DPAD_CENTER;
|
||||||
|
default:
|
||||||
|
return BUTTON_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,3 +64,25 @@ unsigned multimedia_to_button(int keyboard_key)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned dpad_to_button(int keyboard_key)
|
||||||
|
{
|
||||||
|
switch (keyboard_key)
|
||||||
|
{
|
||||||
|
/* These buttons only post a single release event.
|
||||||
|
* doing otherwise will cause action.c to lock up waiting for
|
||||||
|
* a release (because android sends press/unpress to us too quickly
|
||||||
|
*/
|
||||||
|
case KEYCODE_DPAD_UP:
|
||||||
|
return BUTTON_DPAD_UP|BUTTON_REL;
|
||||||
|
case KEYCODE_DPAD_DOWN:
|
||||||
|
return BUTTON_DPAD_DOWN|BUTTON_REL;
|
||||||
|
case KEYCODE_DPAD_LEFT:
|
||||||
|
return BUTTON_DPAD_LEFT|BUTTON_REL;
|
||||||
|
case KEYCODE_DPAD_RIGHT:
|
||||||
|
return BUTTON_DPAD_RIGHT|BUTTON_REL;
|
||||||
|
default:
|
||||||
|
return BUTTON_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
void button_init_device(void);
|
void button_init_device(void);
|
||||||
int button_read_device(int *data);
|
int button_read_device(int *data);
|
||||||
unsigned multimedia_to_button(int keyboard_key);
|
unsigned multimedia_to_button(int keyboard_key);
|
||||||
|
unsigned dpad_to_button(int keyboard_key);
|
||||||
|
void android_ignore_back_button(bool yes);
|
||||||
|
|
||||||
/* Main unit's buttons */
|
/* Main unit's buttons */
|
||||||
#define BUTTON_MENU 0x00000001
|
#define BUTTON_MENU 0x00000001
|
||||||
|
|
|
@ -71,30 +71,40 @@ Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jobject this,
|
||||||
unsigned button = 0;
|
unsigned button = 0;
|
||||||
|
|
||||||
if (!state)
|
if (!state)
|
||||||
|
{
|
||||||
button = multimedia_to_button((int)keycode);
|
button = multimedia_to_button((int)keycode);
|
||||||
|
if (!button)
|
||||||
if (button)
|
button = dpad_to_button((int)keycode);
|
||||||
{ /* multimeida buttons are handled differently */
|
if (button)
|
||||||
queue_post(&button_queue, button, 0);
|
queue_post(&button_queue, button, 0);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
button = key_to_button(keycode);
|
if (!button)
|
||||||
|
{
|
||||||
|
button = key_to_button(keycode);
|
||||||
|
}
|
||||||
|
|
||||||
if (button == BUTTON_NONE)
|
if (button == BUTTON_NONE)
|
||||||
|
{
|
||||||
|
last_btns = button;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
{
|
{
|
||||||
last_btns |= button;
|
last_btns |= button;
|
||||||
last_button_tick = current_tick;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
last_btns &= (~button);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void button_init_device(void)
|
void button_init_device(void)
|
||||||
{
|
{
|
||||||
last_button_tick = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int button_read_device(int *data)
|
int button_read_device(int *data)
|
||||||
|
@ -110,7 +120,5 @@ int button_read_device(int *data)
|
||||||
if (last_touch_state == STATE_DOWN)
|
if (last_touch_state == STATE_DOWN)
|
||||||
btn |= touch;
|
btn |= touch;
|
||||||
|
|
||||||
if (TIME_AFTER(current_tick, last_button_tick+5))
|
|
||||||
last_btns = 0;
|
|
||||||
return btn;
|
return btn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue