[Android] Try to improve handling of DPAD|GAMEPAD + KEYBOARD devices

It seems some devices report themselves as DPAD or GAMEPAD and KEYBOARD as well,
and we need to route different keycodes to different parts of SDL.
This commit is contained in:
Gabriel Jacobo
2013-11-19 10:00:05 -03:00
parent 48954ba194
commit fdfea4ad1f
3 changed files with 18 additions and 14 deletions

View File

@@ -148,19 +148,19 @@ void Java_org_libsdl_app_SDLActivity_onNativeResize(
}
// Paddown
void Java_org_libsdl_app_SDLActivity_onNativePadDown(
int Java_org_libsdl_app_SDLActivity_onNativePadDown(
JNIEnv* env, jclass jcls,
jint padId, jint keycode)
{
Android_OnPadDown(padId, keycode);
return Android_OnPadDown(padId, keycode);
}
// Padup
void Java_org_libsdl_app_SDLActivity_onNativePadUp(
int Java_org_libsdl_app_SDLActivity_onNativePadUp(
JNIEnv* env, jclass jcls,
jint padId, jint keycode)
{
Android_OnPadUp(padId, keycode);
return Android_OnPadUp(padId, keycode);
}
/* Joy */

View File

@@ -128,7 +128,6 @@ keycode_to_SDL(int keycode)
break;
default:
SDL_Log("The button you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> Android KeyCode %d", keycode);
return -1;
break;
}
@@ -313,9 +312,10 @@ Android_OnPadDown(int padId, int keycode)
int button = keycode_to_SDL(keycode);
if (button >= 0) {
SDL_PrivateJoystickButton(SYS_Joysticks[padId], button , SDL_PRESSED);
return 0;
}
return 0;
return -1;
}
int
@@ -324,9 +324,10 @@ Android_OnPadUp(int padId, int keycode)
int button = keycode_to_SDL(keycode);
if (button >= 0) {
SDL_PrivateJoystickButton(SYS_Joysticks[padId], button, SDL_RELEASED);
return 0;
}
return 0;
return -1;
}
int