mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-19 13:21:37 +00:00
Android: update with suggestions
This commit is contained in:
@@ -1358,7 +1358,7 @@ JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
|
||||
jint device_id, jint keycode)
|
||||
{
|
||||
#ifdef SDL_JOYSTICK_ANDROID
|
||||
int button = android_keycode_to_SDL(keycode);
|
||||
int button = Android_keycode_to_SDL(keycode);
|
||||
if (button >= 0) {
|
||||
RPC_Prepare(onNativePadDown);
|
||||
RPC_Add(device_id);
|
||||
@@ -1385,7 +1385,7 @@ JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
|
||||
jint device_id, jint keycode)
|
||||
{
|
||||
#ifdef SDL_JOYSTICK_ANDROID
|
||||
int button = android_keycode_to_SDL(keycode);
|
||||
int button = Android_keycode_to_SDL(keycode);
|
||||
if (button >= 0) {
|
||||
RPC_Prepare(onNativePadUp);
|
||||
RPC_Add(device_id);
|
||||
|
||||
@@ -1514,8 +1514,12 @@ static void SDL_PumpEventsInternal(bool push_sentinel)
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
// Android event processing is independent of the video subsystem
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
SDL_Window *window = _this->windows;
|
||||
Android_PumpEvents(window, 0);
|
||||
if (_this) {
|
||||
SDL_Window *window = _this->windows;
|
||||
if (window) {
|
||||
Android_PumpEvents(window, 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Get events from the video subsystem
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
@@ -1750,8 +1754,12 @@ bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS)
|
||||
}
|
||||
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
SDL_Window *window = _this->windows;
|
||||
Android_PumpEvents(window, delay);
|
||||
if (_this) {
|
||||
SDL_Window *window = _this->windows;
|
||||
if (window) {
|
||||
Android_PumpEvents(window, delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
@@ -64,7 +64,7 @@ static int numjoysticks = 0;
|
||||
* This code manipulation is done to get a sequential list of codes.
|
||||
* FIXME: This is only suited for the case where we use a fixed number of buttons determined by ANDROID_MAX_NBUTTONS
|
||||
*/
|
||||
int android_keycode_to_SDL(int keycode)
|
||||
int Android_keycode_to_SDL(int keycode)
|
||||
{
|
||||
// FIXME: If this function gets too unwieldy in the future, replace with a lookup table
|
||||
int button = 0;
|
||||
@@ -198,7 +198,7 @@ bool Android_OnPadDown(int device_id, int keycode)
|
||||
{
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
SDL_joylist_item *item;
|
||||
int button = android_keycode_to_SDL(keycode);
|
||||
int button = Android_keycode_to_SDL(keycode);
|
||||
if (button >= 0) {
|
||||
SDL_LockJoysticks();
|
||||
item = JoystickByDeviceId(device_id);
|
||||
@@ -218,7 +218,7 @@ bool Android_OnPadUp(int device_id, int keycode)
|
||||
{
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
SDL_joylist_item *item;
|
||||
int button = android_keycode_to_SDL(keycode);
|
||||
int button = Android_keycode_to_SDL(keycode);
|
||||
if (button >= 0) {
|
||||
SDL_LockJoysticks();
|
||||
item = JoystickByDeviceId(device_id);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "../SDL_sysjoystick.h"
|
||||
|
||||
extern int android_keycode_to_SDL(int keycode);
|
||||
extern int Android_keycode_to_SDL(int keycode);
|
||||
extern bool Android_OnPadDown(int device_id, int keycode);
|
||||
extern bool Android_OnPadUp(int device_id, int keycode);
|
||||
extern bool Android_OnJoy(int device_id, int axisnum, float value);
|
||||
|
||||
@@ -24,5 +24,4 @@ extern void Android_InitEvents(void);
|
||||
extern void Android_PumpEvents(SDL_Window *window, Sint64 timeoutNS);
|
||||
extern bool Android_WaitActiveAndLockActivity(SDL_Window *window);
|
||||
extern void Android_QuitEvents(void);
|
||||
|
||||
extern void Android_PumpLifecycleEvents(SDL_Window *window);
|
||||
|
||||
@@ -47,11 +47,8 @@ struct SDL_WindowData
|
||||
|
||||
};
|
||||
|
||||
|
||||
bool Android_nativeSurfaceCreated(SDL_Window *window);
|
||||
bool Android_nativeSurfaceChanged(SDL_Window *window);
|
||||
void Android_nativeSurfaceDestroyed(SDL_Window *window);
|
||||
|
||||
|
||||
|
||||
#endif // SDL_androidwindow_h_
|
||||
|
||||
Reference in New Issue
Block a user