ANDROID: Map gamepad inputs to joystick events
Previously most buttons were being ignored and A and B were mapped to mouse clicks. This maps A and B and several more buttons to Joypad button presses instead.
This commit is contained in:
parent
d5277a95c0
commit
fb9416eacb
1 changed files with 36 additions and 20 deletions
|
@ -1106,10 +1106,10 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
case JE_GAMEPAD:
|
||||
switch (arg1) {
|
||||
case AKEY_EVENT_ACTION_DOWN:
|
||||
e.type = Common::EVENT_KEYDOWN;
|
||||
e.type = Common::EVENT_JOYBUTTON_DOWN;
|
||||
break;
|
||||
case AKEY_EVENT_ACTION_UP:
|
||||
e.type = Common::EVENT_KEYUP;
|
||||
e.type = Common::EVENT_JOYBUTTON_UP;
|
||||
break;
|
||||
default:
|
||||
LOGE("unhandled jaction on gamepad key: %d", arg1);
|
||||
|
@ -1117,32 +1117,48 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
}
|
||||
|
||||
switch (arg2) {
|
||||
case AKEYCODE_BUTTON_START:
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_START;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_SELECT:
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_BACK;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_MODE:
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_GUIDE;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_A:
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_A;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_B:
|
||||
switch (arg1) {
|
||||
case AKEY_EVENT_ACTION_DOWN:
|
||||
e.type = (arg2 == AKEYCODE_BUTTON_A?
|
||||
Common::EVENT_LBUTTONDOWN :
|
||||
Common::EVENT_RBUTTONDOWN);
|
||||
break;
|
||||
case AKEY_EVENT_ACTION_UP:
|
||||
e.type = (arg2 == AKEYCODE_BUTTON_A?
|
||||
Common::EVENT_LBUTTONUP :
|
||||
Common::EVENT_RBUTTONUP);
|
||||
break;
|
||||
}
|
||||
|
||||
e.mouse = dynamic_cast<AndroidCommonGraphics *>(_graphicsManager)->getMousePosition();
|
||||
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_B;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_X:
|
||||
e.kbd.keycode = Common::KEYCODE_ESCAPE;
|
||||
e.kbd.ascii = Common::ASCII_ESCAPE;
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_X;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_Y:
|
||||
e.type = Common::EVENT_MAINMENU;
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_Y;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_L1:
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_LEFT_SHOULDER;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_R1:
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_SHOULDER;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_THUMBL:
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_LEFT_STICK;
|
||||
break;
|
||||
|
||||
case AKEYCODE_BUTTON_THUMBR:
|
||||
e.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_STICK;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue