2013-01-09 05:12:56 +01:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 17:46:50 +01:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
2013-01-09 05:12:56 +01:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2012-11-03 07:17:55 +01:00
|
|
|
*
|
2013-01-09 05:12:56 +01:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2012-11-03 07:17:55 +01:00
|
|
|
*
|
2013-01-09 05:12:56 +01:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2012-11-03 07:17:55 +01:00
|
|
|
*/
|
|
|
|
|
2013-11-03 17:02:40 +01:00
|
|
|
#ifndef _PLATFORM_ANDROID_H
|
|
|
|
#define _PLATFORM_ANDROID_H
|
2012-10-29 02:34:27 +01:00
|
|
|
|
2014-06-10 22:15:23 +02:00
|
|
|
#include <jni.h>
|
2012-10-29 02:34:27 +01:00
|
|
|
|
2015-05-01 23:52:36 +02:00
|
|
|
#include "android_native_app_glue.h"
|
2012-11-30 13:13:19 -05:00
|
|
|
#include <android/window.h>
|
2013-11-22 21:12:13 +01:00
|
|
|
#include <android/sensor.h>
|
2012-10-29 02:34:27 +01:00
|
|
|
|
2015-05-01 17:25:26 +02:00
|
|
|
#ifndef MAX_AXIS
|
|
|
|
#define MAX_AXIS 10
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MAX_PADS
|
|
|
|
#define MAX_PADS 8
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MAX_TOUCH
|
|
|
|
#define MAX_TOUCH 16
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef AKEYCODE_ASSIST
|
|
|
|
#define AKEYCODE_ASSIST 219
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LAST_KEYCODE AKEYCODE_ASSIST
|
|
|
|
|
|
|
|
typedef struct state_device
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
int port;
|
|
|
|
char name[256];
|
|
|
|
} state_device_t;
|
|
|
|
|
|
|
|
struct input_pointer
|
|
|
|
{
|
|
|
|
int16_t x, y;
|
|
|
|
int16_t full_x, full_y;
|
|
|
|
};
|
|
|
|
|
2015-05-01 18:11:34 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
} sensor_t;
|
|
|
|
|
2015-05-01 17:25:26 +02:00
|
|
|
typedef struct android_input_state
|
|
|
|
{
|
|
|
|
int16_t analog_state[MAX_PADS][MAX_AXIS];
|
|
|
|
int8_t hat_state[MAX_PADS][2];
|
|
|
|
uint8_t pad_state[MAX_PADS][(LAST_KEYCODE + 7) / 8];
|
|
|
|
unsigned pads_connected;
|
|
|
|
state_device_t pad_states[MAX_PADS];
|
|
|
|
struct input_pointer pointer[MAX_TOUCH];
|
2015-05-01 18:11:34 +02:00
|
|
|
sensor_t accelerometer_state;
|
2015-05-01 17:25:26 +02:00
|
|
|
unsigned pointer_count;
|
|
|
|
} android_input_state_t;
|
|
|
|
|
2015-05-01 20:21:52 +02:00
|
|
|
struct android_app_userdata
|
|
|
|
{
|
2013-11-22 21:12:13 +01:00
|
|
|
unsigned accelerometer_event_rate;
|
|
|
|
const ASensor* accelerometerSensor;
|
|
|
|
uint64_t sensor_state_mask;
|
2015-01-17 05:47:33 +01:00
|
|
|
char current_ime[PATH_MAX_LENGTH];
|
2013-11-24 17:24:41 +01:00
|
|
|
jmethodID getIntent;
|
|
|
|
jmethodID getStringExtra;
|
2013-11-24 22:02:57 +01:00
|
|
|
jmethodID clearPendingIntent;
|
|
|
|
jmethodID hasPendingIntent;
|
|
|
|
jmethodID getPendingIntentConfigPath;
|
|
|
|
jmethodID getPendingIntentLibretroPath;
|
|
|
|
jmethodID getPendingIntentFullPath;
|
|
|
|
jmethodID getPendingIntentIME;
|
2015-05-01 17:25:26 +02:00
|
|
|
android_input_state_t thread_state;
|
2015-05-01 19:56:44 +02:00
|
|
|
ASensorManager *sensorManager;
|
|
|
|
ASensorEventQueue *sensorEventQueue;
|
2012-11-03 07:17:55 +01:00
|
|
|
};
|
|
|
|
|
2014-06-10 22:15:23 +02:00
|
|
|
#define JNI_EXCEPTION(env) \
|
|
|
|
if ((*env)->ExceptionOccurred(env)) \
|
|
|
|
{ \
|
|
|
|
(*env)->ExceptionDescribe(env); \
|
|
|
|
(*env)->ExceptionClear(env); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FIND_CLASS(env, var, classname) \
|
|
|
|
var = (*env)->FindClass(env, classname); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define GET_OBJECT_CLASS(env, var, clazz_obj) \
|
|
|
|
var = (*env)->GetObjectClass(env, clazz_obj); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define GET_FIELD_ID(env, var, clazz, fieldName, fieldDescriptor) \
|
|
|
|
var = (*env)->GetFieldID(env, clazz, fieldName, fieldDescriptor); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define GET_METHOD_ID(env, var, clazz, methodName, fieldDescriptor) \
|
|
|
|
var = (*env)->GetMethodID(env, clazz, methodName, fieldDescriptor); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define GET_STATIC_METHOD_ID(env, var, clazz, methodName, fieldDescriptor) \
|
|
|
|
var = (*env)->GetStaticMethodID(env, clazz, methodName, fieldDescriptor); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define CALL_OBJ_METHOD(env, var, clazz_obj, methodId) \
|
|
|
|
var = (*env)->CallObjectMethod(env, clazz_obj, methodId); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define CALL_OBJ_STATIC_METHOD(env, var, clazz, methodId) \
|
|
|
|
var = (*env)->CallStaticObjectMethod(env, clazz, methodId); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define CALL_OBJ_STATIC_METHOD_PARAM(env, var, clazz, methodId, ...) \
|
|
|
|
var = (*env)->CallStaticObjectMethod(env, clazz, methodId, __VA_ARGS__); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define CALL_OBJ_METHOD_PARAM(env, var, clazz_obj, methodId, ...) \
|
|
|
|
var = (*env)->CallObjectMethod(env, clazz_obj, methodId, __VA_ARGS__); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define CALL_VOID_METHOD(env, clazz_obj, methodId) \
|
|
|
|
(*env)->CallVoidMethod(env, clazz_obj, methodId); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define CALL_VOID_METHOD_PARAM(env, clazz_obj, methodId, ...) \
|
|
|
|
(*env)->CallVoidMethod(env, clazz_obj, methodId, __VA_ARGS__); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define CALL_BOOLEAN_METHOD(env, var, clazz_obj, methodId) \
|
|
|
|
var = (*env)->CallBooleanMethod(env, clazz_obj, methodId); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
|
|
|
#define CALL_DOUBLE_METHOD(env, var, clazz_obj, methodId) \
|
|
|
|
var = (*env)->CallDoubleMethod(env, clazz_obj, methodId); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
2014-09-30 12:31:28 -05:00
|
|
|
#define CALL_INT_METHOD(env, var, clazz_obj, methodId) \
|
|
|
|
var = (*env)->CallIntMethod(env, clazz_obj, methodId); \
|
|
|
|
JNI_EXCEPTION(env)
|
|
|
|
|
2015-05-01 18:20:52 +02:00
|
|
|
bool (*engine_lookup_name)(char *buf,
|
|
|
|
int *vendorId, int *productId, size_t size, int id);
|
|
|
|
|
2015-05-01 19:56:44 +02:00
|
|
|
JNIEnv *jni_thread_getenv(void);
|
|
|
|
|
|
|
|
void android_app_write_cmd(struct android_app *android_app, int8_t cmd);
|
2012-10-29 02:34:27 +01:00
|
|
|
|
2013-01-06 06:10:07 +01:00
|
|
|
extern struct android_app *g_android;
|
2015-05-01 20:21:52 +02:00
|
|
|
extern struct android_app_userdata *g_android_userdata;
|
2013-01-06 06:10:07 +01:00
|
|
|
|
2015-05-01 23:46:55 +02:00
|
|
|
void android_main(struct android_app *android_app);
|
|
|
|
|
2015-05-02 01:05:21 +02:00
|
|
|
int android_main_poll(void *data);
|
|
|
|
|
2013-11-03 17:02:40 +01:00
|
|
|
#endif /* _PLATFORM_ANDROID_H */
|