summaryrefslogtreecommitdiff
path: root/platform/android/display_server_android.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/display_server_android.cpp')
-rw-r--r--platform/android/display_server_android.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index 1436d832de..7193519a52 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -360,7 +360,11 @@ Vector<String> DisplayServerAndroid::get_rendering_drivers_func() {
}
DisplayServer *DisplayServerAndroid::create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
- return memnew(DisplayServerAndroid(p_rendering_driver, p_mode, p_flags, p_resolution, r_error));
+ DisplayServer *ds = memnew(DisplayServerAndroid(p_rendering_driver, p_mode, p_flags, p_resolution, r_error));
+ if (r_error != OK) {
+ ds->alert("Your video card driver does not support any of the supported Vulkan versions.", "Unable to initialize Video driver");
+ }
+ return ds;
}
void DisplayServerAndroid::register_android_driver() {
@@ -444,6 +448,8 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
#endif
Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
+
+ r_error = OK;
}
DisplayServerAndroid::~DisplayServerAndroid() {
@@ -480,17 +486,40 @@ void DisplayServerAndroid::process_joy_event(DisplayServerAndroid::JoypadEvent p
}
}
+void DisplayServerAndroid::_set_key_modifier_state(Ref<InputEventWithModifiers> ev) {
+ ev->set_shift(shift_mem);
+ ev->set_alt(alt_mem);
+ ev->set_metakey(meta_mem);
+ ev->set_control(control_mem);
+}
+
void DisplayServerAndroid::process_key_event(int p_keycode, int p_scancode, int p_unicode_char, bool p_pressed) {
Ref<InputEventKey> ev;
ev.instance();
int val = p_unicode_char;
int keycode = android_get_keysym(p_keycode);
int phy_keycode = android_get_keysym(p_scancode);
+
+ if (keycode == KEY_SHIFT) {
+ shift_mem = p_pressed;
+ }
+ if (keycode == KEY_ALT) {
+ alt_mem = p_pressed;
+ }
+ if (keycode == KEY_CONTROL) {
+ control_mem = p_pressed;
+ }
+ if (keycode == KEY_META) {
+ meta_mem = p_pressed;
+ }
+
ev->set_keycode(keycode);
ev->set_physical_keycode(phy_keycode);
ev->set_unicode(val);
ev->set_pressed(p_pressed);
+ _set_key_modifier_state(ev);
+
if (val == '\n') {
ev->set_keycode(KEY_ENTER);
} else if (val == 61448) {
@@ -623,6 +652,7 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) {
case 10: { // hover exit
Ref<InputEventMouseMotion> ev;
ev.instance();
+ _set_key_modifier_state(ev);
ev->set_position(p_pos);
ev->set_global_position(p_pos);
ev->set_relative(p_pos - hover_prev_pos);
@@ -635,6 +665,7 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) {
void DisplayServerAndroid::process_double_tap(Point2 p_pos) {
Ref<InputEventMouseButton> ev;
ev.instance();
+ _set_key_modifier_state(ev);
ev->set_position(p_pos);
ev->set_global_position(p_pos);
ev->set_pressed(false);
@@ -645,6 +676,7 @@ void DisplayServerAndroid::process_double_tap(Point2 p_pos) {
void DisplayServerAndroid::process_scroll(Point2 p_pos) {
Ref<InputEventPanGesture> ev;
ev.instance();
+ _set_key_modifier_state(ev);
ev->set_position(p_pos);
ev->set_delta(p_pos - scroll_prev_pos);
Input::get_singleton()->parse_input_event(ev);