diff --git a/android/godot_android.h b/android/godot_android.h new file mode 100644 index 0000000..832dac9 --- /dev/null +++ b/android/godot_android.h @@ -0,0 +1,54 @@ +/*************************************************************************/ +/* godot_android.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef GODOT_ANDROID_GDN_H +#define GODOT_ANDROID_GDN_H + +#include + +#ifdef __ANDROID__ +#include +#else +#define JNIEnv void +#define jobject void * +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEnv *GDAPI godot_android_get_env(); +jobject GDAPI godot_android_get_activity(); + +#ifdef __cplusplus +} +#endif + +#endif /* !GODOT_ANDROID_GDN_H */ diff --git a/gdnative_api.json b/gdnative_api.json index 9fcf61a..217fd87 100644 --- a/gdnative_api.json +++ b/gdnative_api.json @@ -5961,12 +5961,35 @@ } ] }, + { + "name": "android", + "type": "ANDROID", + "version": { + "major": 1, + "minor": 0 + }, + "next": null, + "api": [ + { + "name": "godot_android_get_env", + "return_type": "JNIEnv*", + "arguments": [ + ] + }, + { + "name": "godot_android_get_activity", + "return_type": "jobject", + "arguments": [ + ] + } + ] + }, { "name": "arvr", "type": "ARVR", "version": { "major": 1, - "minor": 0 + "minor": 1 }, "next": null, "api": [ diff --git a/gdnative_api_struct.gen.h b/gdnative_api_struct.gen.h index b16459e..0d69c8e 100644 --- a/gdnative_api_struct.gen.h +++ b/gdnative_api_struct.gen.h @@ -3,6 +3,7 @@ #define GODOT_GDNATIVE_API_STRUCT_H #include +#include #include #include #include @@ -11,6 +12,7 @@ extern const godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct; \ extern const godot_gdnative_ext_nativescript_api_struct *_gdnative_wrapper_nativescript_api_struct; \ extern const godot_gdnative_ext_pluginscript_api_struct *_gdnative_wrapper_pluginscript_api_struct; \ + extern const godot_gdnative_ext_android_api_struct *_gdnative_wrapper_android_api_struct; \ extern const godot_gdnative_ext_arvr_api_struct *_gdnative_wrapper_arvr_api_struct; \ _gdnative_wrapper_api_struct = options->api_struct; \ for (unsigned int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { \ @@ -21,6 +23,9 @@ case GDNATIVE_EXT_PLUGINSCRIPT: \ _gdnative_wrapper_pluginscript_api_struct = (godot_gdnative_ext_pluginscript_api_struct *) _gdnative_wrapper_api_struct->extensions[i]; \ break; \ + case GDNATIVE_EXT_ANDROID: \ + _gdnative_wrapper_android_api_struct = (godot_gdnative_ext_android_api_struct *) _gdnative_wrapper_api_struct->extensions[i]; \ + break; \ case GDNATIVE_EXT_ARVR: \ _gdnative_wrapper_arvr_api_struct = (godot_gdnative_ext_arvr_api_struct *) _gdnative_wrapper_api_struct->extensions[i]; \ break; \ @@ -36,6 +41,7 @@ enum GDNATIVE_API_TYPES { GDNATIVE_CORE, GDNATIVE_EXT_NATIVESCRIPT, GDNATIVE_EXT_PLUGINSCRIPT, + GDNATIVE_EXT_ANDROID, GDNATIVE_EXT_ARVR, }; @@ -76,6 +82,14 @@ typedef struct godot_gdnative_ext_pluginscript_api_struct { void (*godot_pluginscript_register_language)(const godot_pluginscript_language_desc *language_desc); } godot_gdnative_ext_pluginscript_api_struct; +typedef struct godot_gdnative_ext_android_api_struct { + unsigned int type; + godot_gdnative_api_version version; + const godot_gdnative_api_struct *next; + JNIEnv*(*godot_android_get_env)(); + jobject (*godot_android_get_activity)(); +} godot_gdnative_ext_android_api_struct; + typedef struct godot_gdnative_ext_arvr_api_struct { unsigned int type; godot_gdnative_api_version version;