Improved Android support
This commit is contained in:
parent
0ce7f0c409
commit
b8ce680511
2 changed files with 9 additions and 20 deletions
21
src/core.c
21
src/core.c
|
@ -79,8 +79,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
#include <jni.h> // Java native interface
|
//#include <android/sensor.h> // Android sensors functions (accelerometer, gyroscope, light...)
|
||||||
#include <android/sensor.h> // Android sensors functions
|
|
||||||
#include <android/window.h> // Defines AWINDOW_FLAG_FULLSCREEN and others
|
#include <android/window.h> // Defines AWINDOW_FLAG_FULLSCREEN and others
|
||||||
#include <android_native_app_glue.h> // Defines basic app state struct and manages activity
|
#include <android_native_app_glue.h> // Defines basic app state struct and manages activity
|
||||||
|
|
||||||
|
@ -361,7 +360,7 @@ void InitWindow(int width, int height, const char *title)
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
// Android activity initialization
|
// Android activity initialization
|
||||||
void InitWindow(int width, int height, struct android_app *state)
|
void InitWindow(int width, int height, void *state)
|
||||||
{
|
{
|
||||||
TraceLog(INFO, "Initializing raylib (v1.6.0)");
|
TraceLog(INFO, "Initializing raylib (v1.6.0)");
|
||||||
|
|
||||||
|
@ -370,7 +369,7 @@ void InitWindow(int width, int height, struct android_app *state)
|
||||||
screenWidth = width;
|
screenWidth = width;
|
||||||
screenHeight = height;
|
screenHeight = height;
|
||||||
|
|
||||||
app = state;
|
app = (struct android_app *)state;
|
||||||
internalDataPath = app->activity->internalDataPath;
|
internalDataPath = app->activity->internalDataPath;
|
||||||
|
|
||||||
// Set desired windows flags before initializing anything
|
// Set desired windows flags before initializing anything
|
||||||
|
@ -524,6 +523,7 @@ int GetScreenHeight(void)
|
||||||
return screenHeight;
|
return screenHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(PLATFORM_ANDROID)
|
||||||
// Show mouse cursor
|
// Show mouse cursor
|
||||||
void ShowCursor()
|
void ShowCursor()
|
||||||
{
|
{
|
||||||
|
@ -580,6 +580,7 @@ void DisableCursor()
|
||||||
#endif
|
#endif
|
||||||
cursorHidden = true;
|
cursorHidden = true;
|
||||||
}
|
}
|
||||||
|
#endif // !defined(PLATFORM_ANDROID)
|
||||||
|
|
||||||
// Sets Background Color
|
// Sets Background Color
|
||||||
void ClearBackground(Color color)
|
void ClearBackground(Color color)
|
||||||
|
@ -1099,19 +1100,13 @@ Matrix GetCameraMatrix(Camera camera)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Definition - Input (Keyboard, Mouse, Gamepad) Functions
|
// Module Functions Definition - Input (Keyboard, Mouse, Gamepad) Functions
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
|
||||||
// Detect if a key has been pressed once
|
// Detect if a key has been pressed once
|
||||||
bool IsKeyPressed(int key)
|
bool IsKeyPressed(int key)
|
||||||
{
|
{
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
|
||||||
if ((currentButtonState[key] != previousButtonState[key]) && (currentButtonState[key] == 0)) pressed = true;
|
|
||||||
else pressed = false;
|
|
||||||
#else
|
|
||||||
if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) pressed = true;
|
if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) pressed = true;
|
||||||
else pressed = false;
|
else pressed = false;
|
||||||
#endif
|
|
||||||
|
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
@ -1128,13 +1123,8 @@ bool IsKeyReleased(int key)
|
||||||
{
|
{
|
||||||
bool released = false;
|
bool released = false;
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
|
||||||
if ((currentButtonState[button] != previousButtonState[button]) && (currentButtonState[button] == 1)) released = true;
|
|
||||||
else released = false;
|
|
||||||
#else
|
|
||||||
if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 0)) released = true;
|
if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 0)) released = true;
|
||||||
else released = false;
|
else released = false;
|
||||||
#endif
|
|
||||||
|
|
||||||
return released;
|
return released;
|
||||||
}
|
}
|
||||||
|
@ -1161,6 +1151,7 @@ void SetExitKey(int key)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||||
// NOTE: Gamepad support not implemented in emscripten GLFW3 (PLATFORM_WEB)
|
// NOTE: Gamepad support not implemented in emscripten GLFW3 (PLATFORM_WEB)
|
||||||
|
|
||||||
// Detect if a gamepad is available
|
// Detect if a gamepad is available
|
||||||
|
|
|
@ -77,10 +77,6 @@
|
||||||
#define PLATFORM_DESKTOP
|
#define PLATFORM_DESKTOP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
|
||||||
typedef struct android_app; // Define android_app struct (android_native_app_glue.h)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(BUILDING_DLL)
|
#if defined(_WIN32) && defined(BUILDING_DLL)
|
||||||
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 DLL
|
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 DLL
|
||||||
#elif defined(_WIN32) && defined(RAYLIB_DLL)
|
#elif defined(_WIN32) && defined(RAYLIB_DLL)
|
||||||
|
@ -591,7 +587,7 @@ extern "C" { // Prevents name mangling of functions
|
||||||
// Window and Graphics Device Functions (Module: core)
|
// Window and Graphics Device Functions (Module: core)
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
RLAPI void InitWindow(int width, int height, struct android_app *state); // Init Android Activity and OpenGL Graphics
|
RLAPI void InitWindow(int width, int height, void *state); // Init Android Activity and OpenGL Graphics (struct android_app)
|
||||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize Window and OpenGL Graphics
|
RLAPI void InitWindow(int width, int height, const char *title); // Initialize Window and OpenGL Graphics
|
||||||
#endif
|
#endif
|
||||||
|
@ -603,11 +599,13 @@ RLAPI void ToggleFullscreen(void); // Fullscreen
|
||||||
RLAPI int GetScreenWidth(void); // Get current screen width
|
RLAPI int GetScreenWidth(void); // Get current screen width
|
||||||
RLAPI int GetScreenHeight(void); // Get current screen height
|
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||||
|
|
||||||
|
#if !defined(PLATFORM_ANDROID)
|
||||||
RLAPI void ShowCursor(void); // Shows cursor
|
RLAPI void ShowCursor(void); // Shows cursor
|
||||||
RLAPI void HideCursor(void); // Hides cursor
|
RLAPI void HideCursor(void); // Hides cursor
|
||||||
RLAPI bool IsCursorHidden(void); // Returns true if cursor is not visible
|
RLAPI bool IsCursorHidden(void); // Returns true if cursor is not visible
|
||||||
RLAPI void EnableCursor(void); // Enables cursor
|
RLAPI void EnableCursor(void); // Enables cursor
|
||||||
RLAPI void DisableCursor(void); // Disables cursor
|
RLAPI void DisableCursor(void); // Disables cursor
|
||||||
|
#endif
|
||||||
|
|
||||||
RLAPI void ClearBackground(Color color); // Sets Background Color
|
RLAPI void ClearBackground(Color color); // Sets Background Color
|
||||||
RLAPI void BeginDrawing(void); // Setup drawing canvas to start drawing
|
RLAPI void BeginDrawing(void); // Setup drawing canvas to start drawing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue