Fixed bug #5221 - Add SDL_AndroidSendMessage()

This commit is contained in:
Sylvain 2022-02-01 11:30:43 +01:00
parent 97269e143d
commit fe2ed6cf6f
No known key found for this signature in database
GPG key ID: 5F87E02E5BC0939E
4 changed files with 20 additions and 0 deletions

View file

@ -425,6 +425,15 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permis
*/
extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
/**
* Send a user command to SDLActivity
* override "boolean onUnhandledMessage(Message msg)" to handle the message
*
* \param command user command that must be greater or equal to 0x8000
* \param param user parameter
*/
extern DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param);
#endif /* __ANDROID__ */
/* Platform specific functions for WinRT */

View file

@ -2126,6 +2126,15 @@ void Android_JNI_HapticStop(int device_id)
/* See SDLActivity.java for constants. */
#define COMMAND_SET_KEEP_SCREEN_ON 5
int SDL_AndroidSendMessage(Uint32 command, int param)
{
if (command >= 0x8000) {
return Android_JNI_SendMessage(command, param);
}
return -1;
}
/* sends message to be handled on the UI event dispatch thread */
int Android_JNI_SendMessage(int command, int param)
{

View file

@ -855,3 +855,4 @@
#define SDL_GameControllerHasRumbleTriggers SDL_GameControllerHasRumbleTriggers_REAL
#define SDL_hid_ble_scan SDL_hid_ble_scan_REAL
#define SDL_PremultiplyAlpha SDL_PremultiplyAlpha_REAL
#define SDL_AndroidSendMessage SDL_AndroidSendMessage_REAL

View file

@ -924,3 +924,4 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_GameControllerHasRumble,(SDL_GameController *a),(a)
SDL_DYNAPI_PROC(SDL_bool,SDL_GameControllerHasRumbleTriggers,(SDL_GameController *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_hid_ble_scan,(SDL_bool a),(a),)
SDL_DYNAPI_PROC(int,SDL_PremultiplyAlpha,(int a, int b, Uint32 c, const void *d, int e, Uint32 f, void *g, int h),(a,b,c,d,e,f,g,h),return)
SDL_DYNAPI_PROC(int,SDL_AndroidSendMessage,(Uint32 a, int b),(a,b),return)