src/core/android/SDL_android.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 19 Mar 2013 23:03:57 -0700
changeset 7018 9cef1005df5f
parent 6885 700f1b25f77f
child 7039 f69b305b053d
permissions -rw-r--r--
Fixed bug 1700 - Joysticks not supported in Android
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4994
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     2
  Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6792
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4994
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     7
  arising from the use of this software.
4994
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    11
  freely, subject to the following restrictions:
4994
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
4994
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "SDL_config.h"
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
/* Set up for C function definitions, even when using C++ */
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#ifdef __cplusplus
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
/* *INDENT-OFF* */
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
extern "C" {
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
/* *INDENT-ON* */
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#endif
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
6555
f2c03c06d987 Fixed bug 1614 - SDL for Android does not implement TextInput API
Sam Lantinga <slouken@libsdl.org>
parents: 6464
diff changeset
    30
#include "SDL_rect.h"
f2c03c06d987 Fixed bug 1614 - SDL for Android does not implement TextInput API
Sam Lantinga <slouken@libsdl.org>
parents: 6464
diff changeset
    31
4994
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
/* Interface from the SDL library into the Android Java activity */
6792
a15821a3471f Fixed bug 1616 - SDL does not use values set with SDL_GL_SetAttribute on Android
Sam Lantinga <slouken@libsdl.org>
parents: 6654
diff changeset
    33
extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples);
5000
6a10693e66c3 Cleaned up internal accelerometer interface
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    34
extern void Android_JNI_SwapWindow();
6a10693e66c3 Cleaned up internal accelerometer interface
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    35
extern void Android_JNI_SetActivityTitle(const char *title);
7018
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    36
#ifdef ENABLE_ACCELOMETER_AS_EMULATED_JOYSTICK
6212
78d854de3a66 Fixed bug 1368 - Enabling joystick subsystem cause an infinite loop
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    37
extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
7018
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    38
#endif
6654
2ecfb25be1e2 Synchronized the on-screen keyboard state with whether we are accepting text input.
Sam Lantinga <slouken@libsdl.org>
parents: 6642
diff changeset
    39
extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
2ecfb25be1e2 Synchronized the on-screen keyboard state with whether we are accepting text input.
Sam Lantinga <slouken@libsdl.org>
parents: 6642
diff changeset
    40
extern void Android_JNI_HideTextInput();
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4994
diff changeset
    41
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4994
diff changeset
    42
// Audio support
5000
6a10693e66c3 Cleaned up internal accelerometer interface
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    43
extern int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames);
6a10693e66c3 Cleaned up internal accelerometer interface
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    44
extern void* Android_JNI_GetAudioBuffer();
6a10693e66c3 Cleaned up internal accelerometer interface
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    45
extern void Android_JNI_WriteAudioBuffer();
6a10693e66c3 Cleaned up internal accelerometer interface
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    46
extern void Android_JNI_CloseAudioDevice();
4994
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
5582
1281a3f1f0a6 Allow Android platforms to read from .apk files via the RWOPS interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    48
#include "SDL_rwops.h"
1281a3f1f0a6 Allow Android platforms to read from .apk files via the RWOPS interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    49
1281a3f1f0a6 Allow Android platforms to read from .apk files via the RWOPS interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    50
int Android_JNI_FileOpen(SDL_RWops* ctx, const char* fileName, const char* mode);
6642
b716011e53ce Added an API to get the size of a file - WARNING! ABI CHANGE!
Sam Lantinga <slouken@libsdl.org>
parents: 6555
diff changeset
    51
Sint64 Android_JNI_FileSize(SDL_RWops* ctx);
b716011e53ce Added an API to get the size of a file - WARNING! ABI CHANGE!
Sam Lantinga <slouken@libsdl.org>
parents: 6555
diff changeset
    52
Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence);
5582
1281a3f1f0a6 Allow Android platforms to read from .apk files via the RWOPS interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    53
size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, size_t size, size_t maxnum);
1281a3f1f0a6 Allow Android platforms to read from .apk files via the RWOPS interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    54
size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer, size_t size, size_t num);
1281a3f1f0a6 Allow Android platforms to read from .apk files via the RWOPS interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    55
int Android_JNI_FileClose(SDL_RWops* ctx);
1281a3f1f0a6 Allow Android platforms to read from .apk files via the RWOPS interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    56
6464
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6448
diff changeset
    57
/* Clipboard support */
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6448
diff changeset
    58
int Android_JNI_SetClipboardText(const char* text);
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6448
diff changeset
    59
char* Android_JNI_GetClipboardText();
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6448
diff changeset
    60
SDL_bool Android_JNI_HasClipboardText();
ab55284b389f Fixed bug 1573 - SDL does not support system clipboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6448
diff changeset
    61
6448
64a6297a8b93 Fixed bug 1606 - SDL does not implement SDL_GetPowerInfo() for Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
    62
/* Power support */
64a6297a8b93 Fixed bug 1606 - SDL does not implement SDL_GetPowerInfo() for Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
    63
int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent);
64a6297a8b93 Fixed bug 1606 - SDL does not implement SDL_GetPowerInfo() for Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6392
diff changeset
    64
7018
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    65
/* Joystick/accelerometer support */
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    66
int Android_JNI_JoystickInit();
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    67
int Android_JNI_JoystickQuit();
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    68
int Android_JNI_GetNumJoysticks();
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    69
char* Android_JNI_GetJoystickName(int i);
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    70
int Android_JNI_GetJoystickNumOfAxes(int index);
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    71
#ifdef ENABLE_ACCELOMETER_AS_EMULATED_JOYSTICK
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    72
char* Android_GetAccelName();
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    73
#endif
9cef1005df5f Fixed bug 1700 - Joysticks not supported in Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    74
6354
17840f487124 Fixes #1422, removes global JNI Env, uses per thread copies, adds thread auto detaching.
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6212
diff changeset
    75
// Threads
17840f487124 Fixes #1422, removes global JNI Env, uses per thread copies, adds thread auto detaching.
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6212
diff changeset
    76
#include <jni.h>
17840f487124 Fixes #1422, removes global JNI Env, uses per thread copies, adds thread auto detaching.
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6212
diff changeset
    77
static void Android_JNI_ThreadDestroyed(void*);
17840f487124 Fixes #1422, removes global JNI Env, uses per thread copies, adds thread auto detaching.
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6212
diff changeset
    78
JNIEnv *Android_JNI_GetEnv(void);
17840f487124 Fixes #1422, removes global JNI Env, uses per thread copies, adds thread auto detaching.
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6212
diff changeset
    79
int Android_JNI_SetupThread(void);
17840f487124 Fixes #1422, removes global JNI Env, uses per thread copies, adds thread auto detaching.
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6212
diff changeset
    80
6392
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6354
diff changeset
    81
// Generic messages
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6354
diff changeset
    82
int Android_JNI_SendMessage(int command, int param);
fa7eb111f994 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Sam Lantinga <slouken@libsdl.org>
parents: 6354
diff changeset
    83
4994
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
/* Ends C function definitions when using C++ */
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
#ifdef __cplusplus
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
/* *INDENT-OFF* */
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
}
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
/* *INDENT-ON* */
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
#endif
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
e4ed74189d63 Added missing header
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
/* vi: set ts=4 sw=4 expandtab: */