Atlas - SDL_android.h
Home / ext / SDL / src / core / android Lines: 1 | Size: 5890 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21#include "SDL_internal.h" 22 23#ifndef SDL_android_h 24#define SDL_android_h 25 26// Set up for C function definitions, even when using C++ 27#ifdef __cplusplus 28/* *INDENT-OFF* */ 29extern "C" { 30/* *INDENT-ON* */ 31#endif 32 33#include <EGL/eglplatform.h> 34#include <android/native_window_jni.h> 35 36#include "../../audio/SDL_sysaudio.h" 37 38// this appears to be broken right now (on Android, not SDL, I think...?). 39#define ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES 0 40 41// Life cycle 42typedef enum 43{ 44 SDL_ANDROID_LIFECYCLE_WAKE, 45 SDL_ANDROID_LIFECYCLE_PAUSE, 46 SDL_ANDROID_LIFECYCLE_RESUME, 47 SDL_ANDROID_LIFECYCLE_LOWMEMORY, 48 SDL_ANDROID_LIFECYCLE_DESTROY, 49 SDL_NUM_ANDROID_LIFECYCLE_EVENTS 50} SDL_AndroidLifecycleEvent; 51 52void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event); 53bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS); 54 55void Android_LockActivityMutex(void); 56void Android_UnlockActivityMutex(void); 57 58void Android_SetAllowRecreateActivity(bool enabled); 59 60// Interface from the SDL library into the Android Java activity 61extern void Android_JNI_SetActivityTitle(const char *title); 62extern void Android_JNI_SetWindowStyle(bool fullscreen); 63extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint); 64extern void Android_JNI_MinimizeWindow(void); 65extern bool Android_JNI_ShouldMinimizeOnFocusLoss(void); 66 67extern bool Android_JNI_GetAccelerometerValues(float values[3]); 68extern void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect); 69extern void Android_JNI_HideScreenKeyboard(void); 70extern ANativeWindow *Android_JNI_GetNativeWindow(void); 71 72extern SDL_DisplayOrientation Android_JNI_GetDisplayNaturalOrientation(void); 73extern SDL_DisplayOrientation Android_JNI_GetDisplayCurrentOrientation(void); 74 75// Audio support 76void Android_StartAudioHotplug(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording); 77void Android_StopAudioHotplug(void); 78extern void Android_AudioThreadInit(SDL_AudioDevice *device); 79 80// Detecting device type 81extern bool Android_IsDeXMode(void); 82extern bool Android_IsChromebook(void); 83 84bool Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode); 85Sint64 Android_JNI_FileSize(void *userdata); 86Sint64 Android_JNI_FileSeek(void *userdata, Sint64 offset, SDL_IOWhence whence); 87size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOStatus *status); 88size_t Android_JNI_FileWrite(void *userdata, const void *buffer, size_t size, SDL_IOStatus *status); 89bool Android_JNI_FileClose(void *userdata); 90bool Android_JNI_EnumerateAssetDirectory(const char *path, SDL_EnumerateDirectoryCallback cb, void *userdata); 91bool Android_JNI_GetAssetPathInfo(const char *path, SDL_PathInfo *info); 92 93// Environment support 94void Android_JNI_GetManifestEnvironmentVariables(void); 95int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode); 96 97// Clipboard support 98bool Android_JNI_SetClipboardText(const char *text); 99char *Android_JNI_GetClipboardText(void); 100bool Android_JNI_HasClipboardText(void); 101 102// Power support 103int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seconds, int *percent); 104 105// Joystick support 106void Android_JNI_PollInputDevices(void); 107 108// Haptic support 109void Android_JNI_PollHapticDevices(void); 110void Android_JNI_HapticRun(int device_id, float intensity, int length); 111void Android_JNI_HapticRumble(int device_id, float low_frequency_intensity, float high_frequency_intensity, int length); 112void Android_JNI_HapticStop(int device_id); 113 114// Video 115bool Android_JNI_SuspendScreenSaver(bool suspend); 116 117// Touch support 118void Android_JNI_InitTouch(void); 119 120// Threads 121#include <jni.h> 122JNIEnv *Android_JNI_GetEnv(void); 123bool Android_JNI_SetupThread(void); 124 125// Locale 126bool Android_JNI_GetLocale(char *buf, size_t buflen); 127 128// Generic messages 129bool Android_JNI_SendMessage(int command, int param); 130 131// MessageBox 132bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); 133 134// Cursor support 135int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y); 136void Android_JNI_DestroyCustomCursor(int cursorID); 137bool Android_JNI_SetCustomCursor(int cursorID); 138bool Android_JNI_SetSystemCursor(int cursorID); 139 140// Relative mouse support 141bool Android_JNI_SupportsRelativeMouse(void); 142bool Android_JNI_SetRelativeMouseEnabled(bool enabled); 143 144// Show toast notification 145bool Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset); 146 147bool Android_JNI_OpenURL(const char *url); 148 149int SDL_GetAndroidSDKVersion(void); 150 151bool SDL_IsAndroidTablet(void); 152bool SDL_IsAndroidTV(void); 153 154// File Dialogs 155bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void *userdata, 156 const SDL_DialogFileFilter *filters, int nfilters, bool forwrite, 157 bool multiple); 158 159// Ends C function definitions when using C++ 160#ifdef __cplusplus 161/* *INDENT-OFF* */ 162} 163/* *INDENT-ON* */ 164#endif 165 166#endif // SDL_android_h 167[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.