Commit e167af37 by PouleyKetchoupp

Display Server support

parent af424b1c
......@@ -7,7 +7,12 @@ env.add_source_files(env.drivers_sources, "*.cpp")
if env["platform"] == "android":
# Use NDK Vulkan headers
thirdparty_dir = env["ANDROID_NDK_ROOT"] + "/sources/third_party/vulkan/src"
thirdparty_includes = [thirdparty_dir, thirdparty_dir + "/include", thirdparty_dir + "/layers", thirdparty_dir + "/layers/generated"]
thirdparty_includes = [
thirdparty_dir,
thirdparty_dir + "/include",
thirdparty_dir + "/layers",
thirdparty_dir + "/layers/generated",
]
env.Prepend(CPPPATH=thirdparty_includes)
elif env["builtin_vulkan"]:
# Use bundled Vulkan headers
......
......@@ -1564,7 +1564,10 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
image_create_info.pNext = nullptr;
image_create_info.flags = 0;
// TODO: vkCreateImage fails with format list on Android (VK_ERROR_OUT_OF_HOST_MEMORY)
#ifndef _MSC_VER
#warning TODO check for support via RenderingDevice to enable on mobile when possible
#endif
// vkCreateImage fails with format list on Android (VK_ERROR_OUT_OF_HOST_MEMORY)
#ifndef ANDROID_ENABLED
if (p_format.shareable_formats.size()) {
image_create_info.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
......
......@@ -37,8 +37,10 @@
#include "servers/rendering/rendering_device.h"
#ifdef DEBUG_ENABLED
#ifndef _DEBUG
#define _DEBUG
#endif
#endif
#include "vk_mem_alloc.h"
#include <vulkan/vulkan.h>
//todo:
......
......@@ -17,8 +17,8 @@ android_files = [
"java_godot_io_wrapper.cpp",
"jni_utils.cpp",
"android_keys_utils.cpp",
"plugin/godot_plugin_jni.cpp",
"vulkan/vulkan_context_android.cpp"
"display_server_android.cpp",
"vulkan/vulkan_context_android.cpp",
]
env_android = env.Clone()
......
/*************************************************************************/
/* display_server_android.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 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 DISPLAY_SERVER_ANDROID_H
#define DISPLAY_SERVER_ANDROID_H
#include "servers/display_server.h"
#if defined(VULKAN_ENABLED)
class VulkanContextAndroid;
class RenderingDeviceVulkan;
#endif
class DisplayServerAndroid : public DisplayServer {
public:
struct TouchPos {
int id;
Point2 pos;
};
enum {
JOY_EVENT_BUTTON = 0,
JOY_EVENT_AXIS = 1,
JOY_EVENT_HAT = 2
};
struct JoypadEvent {
int device;
int type;
int index;
bool pressed;
float value;
int hat;
};
private:
String rendering_driver;
bool keep_screen_on;
Vector<TouchPos> touch;
Point2 hover_prev_pos; // needed to calculate the relative position on hover events
Point2 scroll_prev_pos; // needed to calculate the relative position on scroll events
#if defined(VULKAN_ENABLED)
VulkanContextAndroid *context_vulkan;
RenderingDeviceVulkan *rendering_device_vulkan;
#endif
ObjectID window_attached_instance_id;
Callable window_event_callback;
Callable input_event_callback;
Callable input_text_callback;
void _window_callback(const Callable &p_callable, const Variant &p_arg) const;
static void _dispatch_input_events(const Ref<InputEvent> &p_event);
public:
static DisplayServerAndroid *get_singleton();
virtual bool has_feature(Feature p_feature) const;
virtual String get_name() const;
virtual void clipboard_set(const String &p_text);
virtual String clipboard_get() const;
virtual void screen_set_keep_on(bool p_enable);
virtual bool screen_is_kept_on() const;
virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW);
virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual int get_screen_count() const;
virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_length = -1);
virtual void virtual_keyboard_hide();
virtual int virtual_keyboard_get_height() const;
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
void send_window_event(WindowEvent p_event) const;
void send_input_event(const Ref<InputEvent> &p_event) const;
void send_input_text(const String &p_text) const;
virtual Vector<WindowID> get_window_list() const;
virtual WindowID get_window_at_screen_position(const Point2i &p_position) const;
virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID);
virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const;
virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID);
virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const;
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID);
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const;
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID);
virtual void window_set_transient(WindowID p_window, WindowID p_parent);
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const;
virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const;
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const;
virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const;
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID);
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const;
virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const;
virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID);
virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const;
virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID);
virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID);
virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const;
virtual bool can_any_window_draw() const;
virtual void alert(const String &p_alert, const String &p_title);
virtual void process_events();
void process_accelerometer(const Vector3 &p_accelerometer);
void process_gravity(const Vector3 &p_gravity);
void process_magnetometer(const Vector3 &p_magnetometer);
void process_gyroscope(const Vector3 &p_gyroscope);
void process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points);
void process_hover(int p_type, Point2 p_pos);
void process_double_tap(Point2 p_pos);
void process_scroll(Point2 p_pos);
void process_joy_event(JoypadEvent p_event);
void process_key_event(int p_keycode, int p_scancode, int p_unicode_char, bool p_pressed);
static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
static Vector<String> get_rendering_drivers_func();
static void register_android_driver();
DisplayServerAndroid(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
~DisplayServerAndroid();
};
#endif // DISPLAY_SERVER_ANDROID_H
......@@ -53,8 +53,6 @@ public class GodotIO {
Godot activity;
GodotEditText edit;
MediaPlayer mediaPlayer;
final int SCREEN_LANDSCAPE = 0;
final int SCREEN_PORTRAIT = 1;
final int SCREEN_REVERSE_LANDSCAPE = 2;
......@@ -530,44 +528,14 @@ public class GodotIO {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
} break;
}
};
public void setEdit(GodotEditText _edit) {
edit = _edit;
}
public void playVideo(String p_path) {
Uri filePath = Uri.parse(p_path);
mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(activity.getApplicationContext(), filePath);
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IOException e) {
System.out.println("IOError while playing video");
}
}
public boolean isVideoPlaying() {
if (mediaPlayer != null) {
return mediaPlayer.isPlaying();
}
return false;
public int getScreenOrientation() {
return activity.getRequestedOrientation();
}
public void pauseVideo() {
if (mediaPlayer != null) {
mediaPlayer.pause();
}
}
public void stopVideo() {
if (mediaPlayer != null) {
mediaPlayer.release();
mediaPlayer = null;
}
public void setEdit(GodotEditText _edit) {
edit = _edit;
}
public static final int SYSTEM_DIR_DESKTOP = 0;
......
......@@ -56,11 +56,8 @@ GodotIOJavaWrapper::GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instanc
_show_keyboard = p_env->GetMethodID(cls, "showKeyboard", "(Ljava/lang/String;I)V");
_hide_keyboard = p_env->GetMethodID(cls, "hideKeyboard", "()V");
_set_screen_orientation = p_env->GetMethodID(cls, "setScreenOrientation", "(I)V");
_get_screen_orientation = p_env->GetMethodID(cls, "getScreenOrientation", "()I");
_get_system_dir = p_env->GetMethodID(cls, "getSystemDir", "(I)Ljava/lang/String;");
_play_video = p_env->GetMethodID(cls, "playVideo", "(Ljava/lang/String;)V");
_is_video_playing = p_env->GetMethodID(cls, "isVideoPlaying", "()Z");
_pause_video = p_env->GetMethodID(cls, "pauseVideo", "()V");
_stop_video = p_env->GetMethodID(cls, "stopVideo", "()V");
}
}
......@@ -157,40 +154,22 @@ void GodotIOJavaWrapper::set_screen_orientation(int p_orient) {
}
}
String GodotIOJavaWrapper::get_system_dir(int p_dir) {
if (_get_system_dir) {
int GodotIOJavaWrapper::get_screen_orientation() {
if (_get_screen_orientation) {
JNIEnv *env = ThreadAndroid::get_env();
jstring s = (jstring)env->CallObjectMethod(godot_io_instance, _get_system_dir, p_dir);
return jstring_to_string(s, env);
return env->CallIntMethod(godot_io_instance, _get_screen_orientation);
} else {
return String(".");
return 0;
}
}
void GodotIOJavaWrapper::play_video(const String &p_path) {
// Why is this not here?!?!
}
bool GodotIOJavaWrapper::is_video_playing() {
if (_is_video_playing) {
String GodotIOJavaWrapper::get_system_dir(int p_dir) {
if (_get_system_dir) {
JNIEnv *env = ThreadAndroid::get_env();
return env->CallBooleanMethod(godot_io_instance, _is_video_playing);
jstring s = (jstring)env->CallObjectMethod(godot_io_instance, _get_system_dir, p_dir);
return jstring_to_string(s, env);
} else {
return false;
}
}
void GodotIOJavaWrapper::pause_video() {
if (_pause_video) {
JNIEnv *env = ThreadAndroid::get_env();
env->CallVoidMethod(godot_io_instance, _pause_video);
}
}
void GodotIOJavaWrapper::stop_video() {
if (_stop_video) {
JNIEnv *env = ThreadAndroid::get_env();
env->CallVoidMethod(godot_io_instance, _stop_video);
return String(".");
}
}
......
......@@ -54,11 +54,8 @@ private:
jmethodID _show_keyboard = 0;
jmethodID _hide_keyboard = 0;
jmethodID _set_screen_orientation = 0;
jmethodID _get_screen_orientation = 0;
jmethodID _get_system_dir = 0;
jmethodID _play_video = 0;
jmethodID _is_video_playing = 0;
jmethodID _pause_video = 0;
jmethodID _stop_video = 0;
public:
GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instance);
......@@ -78,11 +75,8 @@ public:
int get_vk_height();
void set_vk_height(int p_height);
void set_screen_orientation(int p_orient);
int get_screen_orientation();
String get_system_dir(int p_dir);
void play_video(const String &p_path);
bool is_video_playing();
void pause_video();
void stop_video();
};
#endif /* !JAVA_GODOT_IO_WRAPPER_H */
......@@ -34,13 +34,13 @@
#include "java_godot_wrapper.h"
#include "android/asset_manager_jni.h"
#include "android_keys_utils.h"
#include "api/java_class_wrapper.h"
#include "audio_driver_jandroid.h"
#include "core/engine.h"
#include "core/input/input_filter.h"
#include "core/project_settings.h"
#include "dir_access_jandroid.h"
#include "display_server_android.h"
#include "file_access_android.h"
#include "file_access_jandroid.h"
#include "jni_utils.h"
......@@ -167,7 +167,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jc
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jint width, jint height) {
if (os_android)
os_android->set_display_size(Size2(width, height));
os_android->set_display_size(Size2i(width, height));
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface, jboolean p_32_bits) {
......@@ -200,7 +200,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl
return;
if (step == 0) {
// Since Godot is initialized on the UI thread, _main_thread_id was set to that thread's id,
// but for Godot purposes, the main thread is the one running the game loop
Main::setup2(Thread::get_caller_id());
......@@ -218,10 +217,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl
++step;
}
os_android->process_accelerometer(accelerometer);
os_android->process_gravity(gravity);
os_android->process_magnetometer(magnetometer);
os_android->process_gyroscope(gyroscope);
DisplayServerAndroid::get_singleton()->process_accelerometer(accelerometer);
DisplayServerAndroid::get_singleton()->process_gravity(gravity);
DisplayServerAndroid::get_singleton()->process_magnetometer(magnetometer);
DisplayServerAndroid::get_singleton()->process_gyroscope(gyroscope);
if (os_android->main_loop_iterate()) {
......@@ -234,18 +233,18 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch(JNIEnv *env, jc
if (step == 0)
return;
Vector<OS_Android::TouchPos> points;
Vector<DisplayServerAndroid::TouchPos> points;
for (int i = 0; i < count; i++) {
jint p[3];
env->GetIntArrayRegion(positions, i * 3, 3, p);
OS_Android::TouchPos tp;
DisplayServerAndroid::TouchPos tp;
tp.pos = Point2(p[1], p[2]);
tp.id = p[0];
points.push_back(tp);
}
os_android->process_touch(ev, pointer, points);
DisplayServerAndroid::get_singleton()->process_touch(ev, pointer, points);
/*
if (os_android)
......@@ -257,78 +256,78 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_hover(JNIEnv *env, jc
if (step == 0)
return;
os_android->process_hover(p_type, Point2(p_x, p_y));
DisplayServerAndroid::get_singleton()->process_hover(p_type, Point2(p_x, p_y));
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_doubletap(JNIEnv *env, jclass clazz, jint p_x, jint p_y) {
if (step == 0)
return;
os_android->process_double_tap(Point2(p_x, p_y));
DisplayServerAndroid::get_singleton()->process_double_tap(Point2(p_x, p_y));
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_scroll(JNIEnv *env, jclass clazz, jint p_x, jint p_y) {
if (step == 0)
return;
os_android->process_scroll(Point2(p_x, p_y));
DisplayServerAndroid::get_singleton()->process_scroll(Point2(p_x, p_y));
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed) {
if (step == 0)
return;
OS_Android::JoypadEvent jevent;
DisplayServerAndroid::JoypadEvent jevent;
jevent.device = p_device;
jevent.type = OS_Android::JOY_EVENT_BUTTON;
jevent.type = DisplayServerAndroid::JOY_EVENT_BUTTON;
jevent.index = p_button;
jevent.pressed = p_pressed;
os_android->process_joy_event(jevent);
DisplayServerAndroid::get_singleton()->process_joy_event(jevent);
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jclass clazz, jint p_device, jint p_axis, jfloat p_value) {
if (step == 0)
return;
OS_Android::JoypadEvent jevent;
DisplayServerAndroid::JoypadEvent jevent;
jevent.device = p_device;
jevent.type = OS_Android::JOY_EVENT_AXIS;
jevent.type = DisplayServerAndroid::JOY_EVENT_AXIS;
jevent.index = p_axis;
jevent.value = p_value;
os_android->process_joy_event(jevent);
DisplayServerAndroid::get_singleton()->process_joy_event(jevent);
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, jclass clazz, jint p_device, jint p_hat_x, jint p_hat_y) {
if (step == 0)
return;
OS_Android::JoypadEvent jevent;
DisplayServerAndroid::JoypadEvent jevent;
jevent.device = p_device;
jevent.type = OS_Android::JOY_EVENT_HAT;
jevent.type = DisplayServerAndroid::JOY_EVENT_HAT;
int hat = 0;
if (p_hat_x != 0) {
if (p_hat_x < 0)
hat |= InputDefault::HAT_MASK_LEFT;
hat |= InputFilter::HAT_MASK_LEFT;
else
hat |= InputDefault::HAT_MASK_RIGHT;
hat |= InputFilter::HAT_MASK_RIGHT;
}
if (p_hat_y != 0) {
if (p_hat_y < 0)
hat |= InputDefault::HAT_MASK_UP;
hat |= InputFilter::HAT_MASK_UP;
else
hat |= InputDefault::HAT_MASK_DOWN;
hat |= InputFilter::HAT_MASK_DOWN;
}
jevent.hat = hat;
os_android->process_joy_event(jevent);
DisplayServerAndroid::get_singleton()->process_joy_event(jevent);
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv *env, jclass clazz, jint p_device, jboolean p_connected, jstring p_name) {
if (os_android) {
String name = jstring_to_string(p_name, env);
os_android->joy_connection_changed(p_device, p_connected, name);
InputFilter::get_singleton()->joy_connection_changed(p_device, p_connected, name);
}
}
......@@ -336,29 +335,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jcla
if (step == 0)
return;
Ref<InputEventKey> ievent;
ievent.instance();
int val = p_unicode_char;
int keycode = android_get_keysym(p_keycode);
int phy_keycode = android_get_keysym(p_scancode);
ievent->set_keycode(keycode);
ievent->set_physical_keycode(phy_keycode);
ievent->set_unicode(val);
ievent->set_pressed(p_pressed);
if (val == '\n') {
ievent->set_keycode(KEY_ENTER);
} else if (val == 61448) {
ievent->set_keycode(KEY_BACKSPACE);
ievent->set_unicode(KEY_BACKSPACE);
} else if (val == 61453) {
ievent->set_keycode(KEY_ENTER);
ievent->set_unicode(KEY_ENTER);
} else if (p_keycode == 4) {
os_android->main_loop_request_go_back();
}
os_android->process_event(ievent);
DisplayServerAndroid::get_singleton()->process_key_event(p_keycode, p_scancode, p_unicode_char, p_pressed);
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
......
......@@ -33,87 +33,45 @@
#include "audio_driver_jandroid.h"
#include "audio_driver_opensl.h"
#include "core/input/input_filter.h"
#include "core/os/main_loop.h"
#include "drivers/unix/os_unix.h"
#include "servers/audio_server.h"
#include "servers/rendering/rasterizer.h"
class GodotJavaWrapper;
class GodotIOJavaWrapper;
#if defined(VULKAN_ENABLED)
class VulkanContextAndroid;
class RenderingDeviceVulkan;
#endif
struct ANativeWindow;
class OS_Android : public OS_Unix {
public:
struct TouchPos {
int id;
Point2 pos;
};
enum {
JOY_EVENT_BUTTON = 0,
JOY_EVENT_AXIS = 1,
JOY_EVENT_HAT = 2
};
struct JoypadEvent {
int device;
int type;
int index;
bool pressed;
float value;
int hat;
};
private:
Vector<TouchPos> touch;
Point2 hover_prev_pos; // needed to calculate the relative position on hover events
Point2 scroll_prev_pos; // needed to calculate the relative position on scroll events
Size2i display_size;
bool use_gl2;
bool use_apk_expansion;
#if defined(OPENGL_ENABLED)
bool use_16bits_fbo;
const char *gl_extensions;
#endif
#if defined(VULKAN_ENABLED)
VulkanContextAndroid *context_vulkan;
RenderingDeviceVulkan *rendering_device_vulkan;
ANativeWindow *native_window;
#endif
RenderingServer *rendering_server;
mutable String data_dir_cache;
//AudioDriverAndroid audio_driver_android;
AudioDriverOpenSL audio_driver_android;
const char *gl_extensions;
InputDefault *input;
VideoMode default_videomode;
MainLoop *main_loop;
GodotJavaWrapper *godot_java;
GodotIOJavaWrapper *godot_io_java;
int video_driver_index;
public:
virtual int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const;
virtual int get_current_video_driver() const;
virtual void initialize_core();
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
virtual void initialize();
virtual void initialize_joypads();
virtual void set_main_loop(MainLoop *p_main_loop);
virtual void delete_main_loop();
......@@ -122,37 +80,19 @@ public:
typedef int64_t ProcessID;
static OS *get_singleton();
static OS_Android *get_singleton();
GodotJavaWrapper *get_godot_java();
GodotIOJavaWrapper *get_godot_io_java();
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
virtual bool request_permission(const String &p_name);
virtual bool request_permissions();
virtual Vector<String> get_granted_permissions() const;
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
virtual void set_mouse_show(bool p_show);
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;
virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
virtual VideoMode get_video_mode(int p_screen = 0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
virtual void set_keep_screen_on(bool p_enabled);
virtual Size2 get_window_size() const;
virtual String get_name() const;
virtual MainLoop *get_main_loop() const;
virtual bool can_draw() const;
void main_loop_begin();
bool main_loop_iterate();
void main_loop_request_go_back();
......@@ -160,55 +100,25 @@ public:
void main_loop_focusout();
void main_loop_focusin();
virtual bool has_touchscreen_ui_hint() const;
virtual bool has_virtual_keyboard() const;
virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_input_length = -1);
virtual void hide_virtual_keyboard();
virtual int get_virtual_keyboard_height() const;
void set_opengl_extensions(const char *p_gl_extensions);
void set_display_size(Size2 p_size);
void set_display_size(const Size2i &p_size);
Size2i get_display_size() const;
void set_context_is_16_bits(bool p_is_16);
void set_opengl_extensions(const char *p_gl_extensions);
void set_native_window(ANativeWindow *p_native_window);
virtual void set_screen_orientation(ScreenOrientation p_orientation);
ANativeWindow *get_native_window() const;
virtual Error shell_open(String p_uri);
virtual String get_user_data_dir() const;
virtual String get_resource_dir() const;
virtual String get_locale() const;
virtual void set_clipboard(const String &p_text);
virtual String get_clipboard() const;
virtual String get_model_name() const;
virtual int get_screen_dpi(int p_screen = 0) const;
virtual String get_unique_id() const;
virtual String get_system_dir(SystemDir p_dir) const;
void process_accelerometer(const Vector3 &p_accelerometer);
void process_gravity(const Vector3 &p_gravity);
void process_magnetometer(const Vector3 &p_magnetometer);
void process_gyroscope(const Vector3 &p_gyroscope);
void process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points);
void process_hover(int p_type, Point2 p_pos);
void process_double_tap(Point2 p_pos);
void process_scroll(Point2 p_pos);
void process_joy_event(JoypadEvent p_event);
void process_event(Ref<InputEvent> p_event);
void init_video_mode(int p_video_width, int p_video_height);
virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
virtual bool native_video_is_playing() const;
virtual void native_video_pause();
virtual void native_video_stop();
virtual bool is_joy_known(int p_device);
virtual String get_joy_guid(int p_device) const;
void joy_connection_changed(int p_device, bool p_connected, String p_name);
void vibrate_handheld(int p_duration_ms);
virtual bool _check_internal_feature_support(const String &p_feature);
......
......@@ -33,7 +33,7 @@
#define VMA_IMPLEMENTATION
#ifdef DEBUG_ENABLED
#ifndef _MSC_VER
#ifndef _DEBUG
#define _DEBUG
#endif
#endif
......@@ -46,17 +46,17 @@ const char *VulkanContextAndroid::_get_platform_surface_extension() const {
int VulkanContextAndroid::window_create(ANativeWindow *p_window, int p_width, int p_height) {
VkAndroidSurfaceCreateInfoKHR createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
createInfo.pNext = NULL;
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.window = p_window;
VkSurfaceKHR surface;
VkResult err = vkCreateAndroidSurfaceKHR(_get_instance(), &createInfo, NULL, &surface);
VkResult err = vkCreateAndroidSurfaceKHR(_get_instance(), &createInfo, nullptr, &surface);
if (err != VK_SUCCESS) {
ERR_FAIL_V_MSG(-1, "vkCreateAndroidSurfaceKHR failed with error " + itos(err));
}
return _window_create(surface, p_width, p_height);
return _window_create(DisplayServer::MAIN_WINDOW_ID, surface, p_width, p_height);
}
VulkanContextAndroid::VulkanContextAndroid() {
......
......@@ -180,7 +180,7 @@ public:
};
virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW);
ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual void screen_set_keep_on(bool p_enable); //disable screensaver
virtual bool screen_is_kept_on() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment