summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/android_input_handler.cpp76
-rw-r--r--platform/android/android_input_handler.h6
-rw-r--r--platform/android/android_keys_utils.cpp6
-rw-r--r--platform/android/android_keys_utils.h184
-rw-r--r--platform/android/display_server_android.cpp4
-rw-r--r--platform/android/export/export_plugin.cpp61
-rw-r--r--platform/android/export/gradle_export_util.cpp22
-rw-r--r--platform/android/export/gradle_export_util.h15
-rw-r--r--platform/android/java/app/AndroidManifest.xml5
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.java14
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java23
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotIO.java29
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java2
-rw-r--r--platform/android/java_godot_lib_jni.cpp26
15 files changed, 273 insertions, 201 deletions
diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp
index e03375e8d9..52f80b3080 100644
--- a/platform/android/android_input_handler.cpp
+++ b/platform/android/android_input_handler.cpp
@@ -45,7 +45,7 @@ void AndroidInputHandler::process_joy_event(AndroidInputHandler::JoypadEvent p_e
Input::get_singleton()->joy_axis(p_event.device, (JoyAxis)p_event.index, value);
break;
case JOY_EVENT_HAT:
- Input::get_singleton()->joy_hat(p_event.device, (HatMask)p_event.hat);
+ Input::get_singleton()->joy_hat(p_event.device, p_event.hat);
break;
default:
return;
@@ -82,37 +82,37 @@ void AndroidInputHandler::process_key_event(int p_keycode, int p_scancode, int p
Ref<InputEventKey> ev;
ev.instantiate();
int val = unicode;
- int keycode = android_get_keysym(p_keycode);
- int phy_keycode = android_get_keysym(p_scancode);
+ Key keycode = android_get_keysym(p_keycode);
+ Key phy_keycode = android_get_keysym(p_scancode);
- if (keycode == KEY_SHIFT) {
+ if (keycode == Key::SHIFT) {
shift_mem = p_pressed;
}
- if (keycode == KEY_ALT) {
+ if (keycode == Key::ALT) {
alt_mem = p_pressed;
}
- if (keycode == KEY_CTRL) {
+ if (keycode == Key::CTRL) {
control_mem = p_pressed;
}
- if (keycode == KEY_META) {
+ if (keycode == Key::META) {
meta_mem = p_pressed;
}
- ev->set_keycode((Key)keycode);
- ev->set_physical_keycode((Key)phy_keycode);
+ 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);
+ ev->set_keycode(Key::ENTER);
} else if (val == 61448) {
- ev->set_keycode(KEY_BACKSPACE);
- ev->set_unicode(KEY_BACKSPACE);
+ ev->set_keycode(Key::BACKSPACE);
+ ev->set_unicode((char32_t)Key::BACKSPACE);
} else if (val == 61453) {
- ev->set_keycode(KEY_ENTER);
- ev->set_unicode(KEY_ENTER);
+ ev->set_keycode(Key::ENTER);
+ ev->set_unicode((char32_t)Key::ENTER);
} else if (p_keycode == 4) {
if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) {
dsa->send_window_event(DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST, true);
@@ -223,7 +223,7 @@ void AndroidInputHandler::process_touch(int p_event, int p_pointer, const Vector
ev->set_pressed(false);
ev->set_position(touch[i].pos);
Input::get_singleton()->parse_input_event(ev);
- touch.remove(i);
+ touch.remove_at(i);
break;
}
@@ -305,15 +305,15 @@ void AndroidInputHandler::process_mouse_event(int input_device, int event_action
ev->set_pressed(true);
buttons_state = event_buttons_mask;
if (event_vertical_factor > 0) {
- _wheel_button_click(event_buttons_mask, ev, MOUSE_BUTTON_WHEEL_UP, event_vertical_factor);
+ _wheel_button_click(event_buttons_mask, ev, MouseButton::WHEEL_UP, event_vertical_factor);
} else if (event_vertical_factor < 0) {
- _wheel_button_click(event_buttons_mask, ev, MOUSE_BUTTON_WHEEL_DOWN, -event_vertical_factor);
+ _wheel_button_click(event_buttons_mask, ev, MouseButton::WHEEL_DOWN, -event_vertical_factor);
}
if (event_horizontal_factor > 0) {
- _wheel_button_click(event_buttons_mask, ev, MOUSE_BUTTON_WHEEL_RIGHT, event_horizontal_factor);
+ _wheel_button_click(event_buttons_mask, ev, MouseButton::WHEEL_RIGHT, event_horizontal_factor);
} else if (event_horizontal_factor < 0) {
- _wheel_button_click(event_buttons_mask, ev, MOUSE_BUTTON_WHEEL_LEFT, -event_horizontal_factor);
+ _wheel_button_click(event_buttons_mask, ev, MouseButton::WHEEL_LEFT, -event_horizontal_factor);
}
} break;
}
@@ -323,7 +323,7 @@ void AndroidInputHandler::_wheel_button_click(MouseButton event_buttons_mask, co
Ref<InputEventMouseButton> evd = ev->duplicate();
_set_key_modifier_state(evd);
evd->set_button_index(wheel_button);
- evd->set_button_mask(MouseButton(event_buttons_mask ^ (1 << (wheel_button - 1))));
+ evd->set_button_mask(MouseButton(event_buttons_mask ^ mouse_button_to_mask(wheel_button)));
evd->set_factor(factor);
Input::get_singleton()->parse_input_event(evd);
Ref<InputEventMouseButton> evdd = evd->duplicate();
@@ -339,7 +339,7 @@ void AndroidInputHandler::process_double_tap(int event_android_button_mask, Poin
_set_key_modifier_state(ev);
ev->set_position(p_pos);
ev->set_global_position(p_pos);
- ev->set_pressed(event_button_mask != 0);
+ ev->set_pressed(event_button_mask != MouseButton::NONE);
ev->set_button_index(_button_index_from_mask(event_button_mask));
ev->set_button_mask(event_button_mask);
ev->set_double_click(true);
@@ -348,37 +348,37 @@ void AndroidInputHandler::process_double_tap(int event_android_button_mask, Poin
MouseButton AndroidInputHandler::_button_index_from_mask(MouseButton button_mask) {
switch (button_mask) {
- case MOUSE_BUTTON_MASK_LEFT:
- return MOUSE_BUTTON_LEFT;
- case MOUSE_BUTTON_MASK_RIGHT:
- return MOUSE_BUTTON_RIGHT;
- case MOUSE_BUTTON_MASK_MIDDLE:
- return MOUSE_BUTTON_MIDDLE;
- case MOUSE_BUTTON_MASK_XBUTTON1:
- return MOUSE_BUTTON_XBUTTON1;
- case MOUSE_BUTTON_MASK_XBUTTON2:
- return MOUSE_BUTTON_XBUTTON2;
+ case MouseButton::MASK_LEFT:
+ return MouseButton::LEFT;
+ case MouseButton::MASK_RIGHT:
+ return MouseButton::RIGHT;
+ case MouseButton::MASK_MIDDLE:
+ return MouseButton::MIDDLE;
+ case MouseButton::MASK_XBUTTON1:
+ return MouseButton::MB_XBUTTON1;
+ case MouseButton::MASK_XBUTTON2:
+ return MouseButton::MB_XBUTTON2;
default:
- return MOUSE_BUTTON_NONE;
+ return MouseButton::NONE;
}
}
MouseButton AndroidInputHandler::_android_button_mask_to_godot_button_mask(int android_button_mask) {
- MouseButton godot_button_mask = MOUSE_BUTTON_NONE;
+ MouseButton godot_button_mask = MouseButton::NONE;
if (android_button_mask & AMOTION_EVENT_BUTTON_PRIMARY) {
- godot_button_mask |= MOUSE_BUTTON_MASK_LEFT;
+ godot_button_mask |= MouseButton::MASK_LEFT;
}
if (android_button_mask & AMOTION_EVENT_BUTTON_SECONDARY) {
- godot_button_mask |= MOUSE_BUTTON_MASK_RIGHT;
+ godot_button_mask |= MouseButton::MASK_RIGHT;
}
if (android_button_mask & AMOTION_EVENT_BUTTON_TERTIARY) {
- godot_button_mask |= MOUSE_BUTTON_MASK_MIDDLE;
+ godot_button_mask |= MouseButton::MASK_MIDDLE;
}
if (android_button_mask & AMOTION_EVENT_BUTTON_BACK) {
- godot_button_mask |= MOUSE_BUTTON_MASK_XBUTTON1;
+ godot_button_mask |= MouseButton::MASK_XBUTTON1;
}
if (android_button_mask & AMOTION_EVENT_BUTTON_FORWARD) {
- godot_button_mask |= MOUSE_BUTTON_MASK_XBUTTON2;
+ godot_button_mask |= MouseButton::MASK_XBUTTON2;
}
return godot_button_mask;
diff --git a/platform/android/android_input_handler.h b/platform/android/android_input_handler.h
index 2918ca300b..e0b4196f14 100644
--- a/platform/android/android_input_handler.h
+++ b/platform/android/android_input_handler.h
@@ -53,10 +53,10 @@ public:
struct JoypadEvent {
int device = 0;
int type = 0;
- int index = 0;
+ int index = 0; // Can be either JoyAxis or JoyButton.
bool pressed = false;
float value = 0;
- int hat = 0;
+ HatMask hat = HatMask::CENTER;
};
private:
@@ -65,7 +65,7 @@ private:
bool control_mem = false;
bool meta_mem = false;
- MouseButton buttons_state = MOUSE_BUTTON_NONE;
+ MouseButton buttons_state = MouseButton::NONE;
Vector<TouchPos> touch;
Point2 hover_prev_pos; // needed to calculate the relative position on hover events
diff --git a/platform/android/android_keys_utils.cpp b/platform/android/android_keys_utils.cpp
index 5aa546c17b..0cea0589ce 100644
--- a/platform/android/android_keys_utils.cpp
+++ b/platform/android/android_keys_utils.cpp
@@ -30,12 +30,12 @@
#include "android_keys_utils.h"
-unsigned int android_get_keysym(unsigned int p_code) {
- for (int i = 0; _ak_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
+Key android_get_keysym(unsigned int p_code) {
+ for (int i = 0; _ak_to_keycode[i].keysym != Key::UNKNOWN; i++) {
if (_ak_to_keycode[i].keycode == p_code) {
return _ak_to_keycode[i].keysym;
}
}
- return KEY_UNKNOWN;
+ return Key::UNKNOWN;
}
diff --git a/platform/android/android_keys_utils.h b/platform/android/android_keys_utils.h
index de6f48d33a..bac9bab6db 100644
--- a/platform/android/android_keys_utils.h
+++ b/platform/android/android_keys_utils.h
@@ -35,101 +35,101 @@
#include <core/os/keyboard.h>
struct _WinTranslatePair {
- unsigned int keysym = 0;
+ Key keysym = Key::NONE;
unsigned int keycode = 0;
};
static _WinTranslatePair _ak_to_keycode[] = {
- { KEY_TAB, AKEYCODE_TAB },
- { KEY_ENTER, AKEYCODE_ENTER },
- { KEY_SHIFT, AKEYCODE_SHIFT_LEFT },
- { KEY_SHIFT, AKEYCODE_SHIFT_RIGHT },
- { KEY_ALT, AKEYCODE_ALT_LEFT },
- { KEY_ALT, AKEYCODE_ALT_RIGHT },
- { KEY_MENU, AKEYCODE_MENU },
- { KEY_PAUSE, AKEYCODE_MEDIA_PLAY_PAUSE },
- { KEY_ESCAPE, AKEYCODE_BACK },
- { KEY_SPACE, AKEYCODE_SPACE },
- { KEY_PAGEUP, AKEYCODE_PAGE_UP },
- { KEY_PAGEDOWN, AKEYCODE_PAGE_DOWN },
- { KEY_HOME, AKEYCODE_HOME }, //(0x24)
- { KEY_LEFT, AKEYCODE_DPAD_LEFT },
- { KEY_UP, AKEYCODE_DPAD_UP },
- { KEY_RIGHT, AKEYCODE_DPAD_RIGHT },
- { KEY_DOWN, AKEYCODE_DPAD_DOWN },
- { KEY_PERIODCENTERED, AKEYCODE_DPAD_CENTER },
- { KEY_BACKSPACE, AKEYCODE_DEL },
- { KEY_0, AKEYCODE_0 }, ////0 key
- { KEY_1, AKEYCODE_1 }, ////1 key
- { KEY_2, AKEYCODE_2 }, ////2 key
- { KEY_3, AKEYCODE_3 }, ////3 key
- { KEY_4, AKEYCODE_4 }, ////4 key
- { KEY_5, AKEYCODE_5 }, ////5 key
- { KEY_6, AKEYCODE_6 }, ////6 key
- { KEY_7, AKEYCODE_7 }, ////7 key
- { KEY_8, AKEYCODE_8 }, ////8 key
- { KEY_9, AKEYCODE_9 }, ////9 key
- { KEY_A, AKEYCODE_A }, ////A key
- { KEY_B, AKEYCODE_B }, ////B key
- { KEY_C, AKEYCODE_C }, ////C key
- { KEY_D, AKEYCODE_D }, ////D key
- { KEY_E, AKEYCODE_E }, ////E key
- { KEY_F, AKEYCODE_F }, ////F key
- { KEY_G, AKEYCODE_G }, ////G key
- { KEY_H, AKEYCODE_H }, ////H key
- { KEY_I, AKEYCODE_I }, ////I key
- { KEY_J, AKEYCODE_J }, ////J key
- { KEY_K, AKEYCODE_K }, ////K key
- { KEY_L, AKEYCODE_L }, ////L key
- { KEY_M, AKEYCODE_M }, ////M key
- { KEY_N, AKEYCODE_N }, ////N key
- { KEY_O, AKEYCODE_O }, ////O key
- { KEY_P, AKEYCODE_P }, ////P key
- { KEY_Q, AKEYCODE_Q }, ////Q key
- { KEY_R, AKEYCODE_R }, ////R key
- { KEY_S, AKEYCODE_S }, ////S key
- { KEY_T, AKEYCODE_T }, ////T key
- { KEY_U, AKEYCODE_U }, ////U key
- { KEY_V, AKEYCODE_V }, ////V key
- { KEY_W, AKEYCODE_W }, ////W key
- { KEY_X, AKEYCODE_X }, ////X key
- { KEY_Y, AKEYCODE_Y }, ////Y key
- { KEY_Z, AKEYCODE_Z }, ////Z key
- { KEY_HOMEPAGE, AKEYCODE_EXPLORER },
- { KEY_LAUNCH0, AKEYCODE_BUTTON_A },
- { KEY_LAUNCH1, AKEYCODE_BUTTON_B },
- { KEY_LAUNCH2, AKEYCODE_BUTTON_C },
- { KEY_LAUNCH3, AKEYCODE_BUTTON_X },
- { KEY_LAUNCH4, AKEYCODE_BUTTON_Y },
- { KEY_LAUNCH5, AKEYCODE_BUTTON_Z },
- { KEY_LAUNCH6, AKEYCODE_BUTTON_L1 },
- { KEY_LAUNCH7, AKEYCODE_BUTTON_R1 },
- { KEY_LAUNCH8, AKEYCODE_BUTTON_L2 },
- { KEY_LAUNCH9, AKEYCODE_BUTTON_R2 },
- { KEY_LAUNCHA, AKEYCODE_BUTTON_THUMBL },
- { KEY_LAUNCHB, AKEYCODE_BUTTON_THUMBR },
- { KEY_LAUNCHC, AKEYCODE_BUTTON_START },
- { KEY_LAUNCHD, AKEYCODE_BUTTON_SELECT },
- { KEY_LAUNCHE, AKEYCODE_BUTTON_MODE },
- { KEY_VOLUMEMUTE, AKEYCODE_MUTE },
- { KEY_VOLUMEDOWN, AKEYCODE_VOLUME_DOWN },
- { KEY_VOLUMEUP, AKEYCODE_VOLUME_UP },
- { KEY_BACK, AKEYCODE_MEDIA_REWIND },
- { KEY_FORWARD, AKEYCODE_MEDIA_FAST_FORWARD },
- { KEY_MEDIANEXT, AKEYCODE_MEDIA_NEXT },
- { KEY_MEDIAPREVIOUS, AKEYCODE_MEDIA_PREVIOUS },
- { KEY_MEDIASTOP, AKEYCODE_MEDIA_STOP },
- { KEY_PLUS, AKEYCODE_PLUS },
- { KEY_EQUAL, AKEYCODE_EQUALS }, // the '+' key
- { KEY_COMMA, AKEYCODE_COMMA }, // the ',' key
- { KEY_MINUS, AKEYCODE_MINUS }, // the '-' key
- { KEY_SLASH, AKEYCODE_SLASH }, // the '/?' key
- { KEY_BACKSLASH, AKEYCODE_BACKSLASH },
- { KEY_BRACKETLEFT, AKEYCODE_LEFT_BRACKET },
- { KEY_BRACKETRIGHT, AKEYCODE_RIGHT_BRACKET },
- { KEY_CTRL, AKEYCODE_CTRL_LEFT },
- { KEY_CTRL, AKEYCODE_CTRL_RIGHT },
- { KEY_UNKNOWN, 0 }
+ { Key::TAB, AKEYCODE_TAB },
+ { Key::ENTER, AKEYCODE_ENTER },
+ { Key::SHIFT, AKEYCODE_SHIFT_LEFT },
+ { Key::SHIFT, AKEYCODE_SHIFT_RIGHT },
+ { Key::ALT, AKEYCODE_ALT_LEFT },
+ { Key::ALT, AKEYCODE_ALT_RIGHT },
+ { Key::MENU, AKEYCODE_MENU },
+ { Key::PAUSE, AKEYCODE_MEDIA_PLAY_PAUSE },
+ { Key::ESCAPE, AKEYCODE_BACK },
+ { Key::SPACE, AKEYCODE_SPACE },
+ { Key::PAGEUP, AKEYCODE_PAGE_UP },
+ { Key::PAGEDOWN, AKEYCODE_PAGE_DOWN },
+ { Key::HOME, AKEYCODE_HOME }, //(0x24)
+ { Key::LEFT, AKEYCODE_DPAD_LEFT },
+ { Key::UP, AKEYCODE_DPAD_UP },
+ { Key::RIGHT, AKEYCODE_DPAD_RIGHT },
+ { Key::DOWN, AKEYCODE_DPAD_DOWN },
+ { Key::PERIODCENTERED, AKEYCODE_DPAD_CENTER },
+ { Key::BACKSPACE, AKEYCODE_DEL },
+ { Key::KEY_0, AKEYCODE_0 },
+ { Key::KEY_1, AKEYCODE_1 },
+ { Key::KEY_2, AKEYCODE_2 },
+ { Key::KEY_3, AKEYCODE_3 },
+ { Key::KEY_4, AKEYCODE_4 },
+ { Key::KEY_5, AKEYCODE_5 },
+ { Key::KEY_6, AKEYCODE_6 },
+ { Key::KEY_7, AKEYCODE_7 },
+ { Key::KEY_8, AKEYCODE_8 },
+ { Key::KEY_9, AKEYCODE_9 },
+ { Key::A, AKEYCODE_A },
+ { Key::B, AKEYCODE_B },
+ { Key::C, AKEYCODE_C },
+ { Key::D, AKEYCODE_D },
+ { Key::E, AKEYCODE_E },
+ { Key::F, AKEYCODE_F },
+ { Key::G, AKEYCODE_G },
+ { Key::H, AKEYCODE_H },
+ { Key::I, AKEYCODE_I },
+ { Key::J, AKEYCODE_J },
+ { Key::K, AKEYCODE_K },
+ { Key::L, AKEYCODE_L },
+ { Key::M, AKEYCODE_M },
+ { Key::N, AKEYCODE_N },
+ { Key::O, AKEYCODE_O },
+ { Key::P, AKEYCODE_P },
+ { Key::Q, AKEYCODE_Q },
+ { Key::R, AKEYCODE_R },
+ { Key::S, AKEYCODE_S },
+ { Key::T, AKEYCODE_T },
+ { Key::U, AKEYCODE_U },
+ { Key::V, AKEYCODE_V },
+ { Key::W, AKEYCODE_W },
+ { Key::X, AKEYCODE_X },
+ { Key::Y, AKEYCODE_Y },
+ { Key::Z, AKEYCODE_Z },
+ { Key::HOMEPAGE, AKEYCODE_EXPLORER },
+ { Key::LAUNCH0, AKEYCODE_BUTTON_A },
+ { Key::LAUNCH1, AKEYCODE_BUTTON_B },
+ { Key::LAUNCH2, AKEYCODE_BUTTON_C },
+ { Key::LAUNCH3, AKEYCODE_BUTTON_X },
+ { Key::LAUNCH4, AKEYCODE_BUTTON_Y },
+ { Key::LAUNCH5, AKEYCODE_BUTTON_Z },
+ { Key::LAUNCH6, AKEYCODE_BUTTON_L1 },
+ { Key::LAUNCH7, AKEYCODE_BUTTON_R1 },
+ { Key::LAUNCH8, AKEYCODE_BUTTON_L2 },
+ { Key::LAUNCH9, AKEYCODE_BUTTON_R2 },
+ { Key::LAUNCHA, AKEYCODE_BUTTON_THUMBL },
+ { Key::LAUNCHB, AKEYCODE_BUTTON_THUMBR },
+ { Key::LAUNCHC, AKEYCODE_BUTTON_START },
+ { Key::LAUNCHD, AKEYCODE_BUTTON_SELECT },
+ { Key::LAUNCHE, AKEYCODE_BUTTON_MODE },
+ { Key::VOLUMEMUTE, AKEYCODE_MUTE },
+ { Key::VOLUMEDOWN, AKEYCODE_VOLUME_DOWN },
+ { Key::VOLUMEUP, AKEYCODE_VOLUME_UP },
+ { Key::BACK, AKEYCODE_MEDIA_REWIND },
+ { Key::FORWARD, AKEYCODE_MEDIA_FAST_FORWARD },
+ { Key::MEDIANEXT, AKEYCODE_MEDIA_NEXT },
+ { Key::MEDIAPREVIOUS, AKEYCODE_MEDIA_PREVIOUS },
+ { Key::MEDIASTOP, AKEYCODE_MEDIA_STOP },
+ { Key::PLUS, AKEYCODE_PLUS },
+ { Key::EQUAL, AKEYCODE_EQUALS }, // the '+' key
+ { Key::COMMA, AKEYCODE_COMMA }, // the ',' key
+ { Key::MINUS, AKEYCODE_MINUS }, // the '-' key
+ { Key::SLASH, AKEYCODE_SLASH }, // the '/?' key
+ { Key::BACKSLASH, AKEYCODE_BACKSLASH },
+ { Key::BRACKETLEFT, AKEYCODE_LEFT_BRACKET },
+ { Key::BRACKETRIGHT, AKEYCODE_RIGHT_BRACKET },
+ { Key::CTRL, AKEYCODE_CTRL_LEFT },
+ { Key::CTRL, AKEYCODE_CTRL_RIGHT },
+ { Key::UNKNOWN, 0 }
};
/*
TODO: map these android key:
@@ -157,6 +157,6 @@ TODO: map these android key:
AKEYCODE_SWITCH_CHARSET = 95,
*/
-unsigned int android_get_keysym(unsigned int p_code);
+Key android_get_keysym(unsigned int p_code);
#endif // ANDROID_KEYS_UTILS_H
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index 34f0064a5e..505e7ac0eb 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -119,7 +119,9 @@ DisplayServer::ScreenOrientation DisplayServerAndroid::screen_get_orientation(in
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
ERR_FAIL_COND_V(!godot_io_java, SCREEN_LANDSCAPE);
- return (ScreenOrientation)godot_io_java->get_screen_orientation();
+ const int orientation = godot_io_java->get_screen_orientation();
+ ERR_FAIL_INDEX_V_MSG(orientation, 7, SCREEN_LANDSCAPE, "Unrecognized screen orientation");
+ return (ScreenOrientation)orientation;
}
int DisplayServerAndroid::get_screen_count() const {
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 4c45be5210..c5d3cbd966 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -751,9 +751,9 @@ void EditorExportPlatformAndroid::_get_permissions(const Ref<EditorExportPreset>
}
int xr_mode_index = p_preset->get("xr_features/xr_mode");
- if (xr_mode_index == 1 /* XRMode.OVR */) {
+ if (xr_mode_index == XR_MODE_OPENXR) {
int hand_tracking_index = p_preset->get("xr_features/hand_tracking"); // 0: none, 1: optional, 2: required
- if (hand_tracking_index > 0) {
+ if (hand_tracking_index > XR_HAND_TRACKING_NONE) {
if (r_permissions.find("com.oculus.permission.HAND_TRACKING") == -1) {
r_permissions.push_back("com.oculus.permission.HAND_TRACKING");
}
@@ -964,6 +964,20 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p
}
}
+ if (tname == "meta-data" && attrname == "name" && value == "xr_mode_metadata_name") {
+ // Update the meta-data 'android:name' attribute based on the selected XR mode.
+ if (xr_mode_index == XR_MODE_OPENXR) {
+ string_table.write[attr_value] = "com.samsung.android.vr.application.mode";
+ }
+ }
+
+ if (tname == "meta-data" && attrname == "value" && value == "xr_mode_metadata_value") {
+ // Update the meta-data 'android:value' attribute based on the selected XR mode.
+ if (xr_mode_index == XR_MODE_OPENXR) {
+ string_table.write[attr_value] = "vr_only";
+ }
+ }
+
iofs += 20;
}
@@ -978,7 +992,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p
Vector<bool> feature_required_list;
Vector<int> feature_versions;
- if (xr_mode_index == 1 /* XRMode.OVR */) {
+ if (xr_mode_index == XR_MODE_OPENXR) {
// Set degrees of freedom
feature_names.push_back("android.hardware.vr.headtracking");
feature_required_list.push_back(true);
@@ -986,11 +1000,19 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p
// Check for hand tracking
int hand_tracking_index = p_preset->get("xr_features/hand_tracking"); // 0: none, 1: optional, 2: required
- if (hand_tracking_index > 0) {
+ if (hand_tracking_index > XR_HAND_TRACKING_NONE) {
feature_names.push_back("oculus.software.handtracking");
- feature_required_list.push_back(hand_tracking_index == 2);
+ feature_required_list.push_back(hand_tracking_index == XR_HAND_TRACKING_REQUIRED);
feature_versions.push_back(-1); // no version attribute should be added.
}
+
+ // Check for passthrough
+ int passthrough_mode = p_preset->get("xr_features/passthrough");
+ if (passthrough_mode > XR_PASSTHROUGH_NONE) {
+ feature_names.push_back("com.oculus.feature.PASSTHROUGH");
+ feature_required_list.push_back(passthrough_mode == XR_PASSTHROUGH_REQUIRED);
+ feature_versions.push_back(-1);
+ }
}
if (feature_names.size() > 0) {
@@ -1667,11 +1689,11 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_background_option, PROPERTY_HINT_FILE, "*.png"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/depth_buffer_bits", PROPERTY_HINT_ENUM, "16 bits,24 bits [default],32 bits"), 1));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/opengl_debug"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,OpenXR"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/hand_tracking", PROPERTY_HINT_ENUM, "None,Optional,Required"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/passthrough", PROPERTY_HINT_ENUM, "None,Optional,Required"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/immersive_mode"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_small"), true));
@@ -2138,10 +2160,17 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
// Validate the Xr features are properly populated
int xr_mode_index = p_preset->get("xr_features/xr_mode");
int hand_tracking = p_preset->get("xr_features/hand_tracking");
- if (xr_mode_index != /* XRMode.OVR*/ 1) {
- if (hand_tracking > 0) {
+ int passthrough_mode = p_preset->get("xr_features/passthrough");
+ if (xr_mode_index != XR_MODE_OPENXR) {
+ if (hand_tracking > XR_HAND_TRACKING_NONE) {
valid = false;
- err += TTR("\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\".");
+ err += TTR("\"Hand Tracking\" is only valid when \"Xr Mode\" is \"OpenXR\".");
+ err += "\n";
+ }
+
+ if (passthrough_mode > XR_PASSTHROUGH_NONE) {
+ valid = false;
+ err += TTR("\"Passthrough\" is only valid when \"Xr Mode\" is \"OpenXR\".");
err += "\n";
}
}
@@ -2183,7 +2212,7 @@ void EditorExportPlatformAndroid::get_command_line_flags(const Ref<EditorExportP
Vector<String> command_line_strings = cmdline.strip_edges().split(" ");
for (int i = 0; i < command_line_strings.size(); i++) {
if (command_line_strings[i].strip_edges().length() == 0) {
- command_line_strings.remove(i);
+ command_line_strings.remove_at(i);
i--;
}
}
@@ -2203,18 +2232,12 @@ void EditorExportPlatformAndroid::get_command_line_flags(const Ref<EditorExportP
}
int xr_mode_index = p_preset->get("xr_features/xr_mode");
- if (xr_mode_index == 1) {
- command_line_strings.push_back("--xr_mode_ovr");
+ if (xr_mode_index == XR_MODE_OPENXR) {
+ command_line_strings.push_back("--xr_mode_openxr");
} else { // XRMode.REGULAR is the default.
command_line_strings.push_back("--xr_mode_regular");
}
- int depth_buffer_bits_index = p_preset->get("graphics/depth_buffer_bits");
- if (depth_buffer_bits_index >= 0 && depth_buffer_bits_index <= 2) {
- int depth_buffer_bits = 16 + depth_buffer_bits_index * 8;
- command_line_strings.push_back(vformat("--use_depth=%d", depth_buffer_bits));
- }
-
bool immersive = p_preset->get("screen/immersive_mode");
if (immersive) {
command_line_strings.push_back("--use_immersive");
diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp
index b0d623827e..658c0ecd0a 100644
--- a/platform/android/export/gradle_export_util.cpp
+++ b/platform/android/export/gradle_export_util.cpp
@@ -211,16 +211,24 @@ String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset) {
String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset) {
String manifest_xr_features;
- bool uses_xr = (int)(p_preset->get("xr_features/xr_mode")) == 1;
+ int xr_mode_index = (int)(p_preset->get("xr_features/xr_mode"));
+ bool uses_xr = xr_mode_index == XR_MODE_OPENXR;
if (uses_xr) {
manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"android.hardware.vr.headtracking\" android:required=\"true\" android:version=\"1\" />\n";
int hand_tracking_index = p_preset->get("xr_features/hand_tracking"); // 0: none, 1: optional, 2: required
- if (hand_tracking_index == 1) {
+ if (hand_tracking_index == XR_HAND_TRACKING_OPTIONAL) {
manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"oculus.software.handtracking\" android:required=\"false\" />\n";
- } else if (hand_tracking_index == 2) {
+ } else if (hand_tracking_index == XR_HAND_TRACKING_REQUIRED) {
manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"oculus.software.handtracking\" android:required=\"true\" />\n";
}
+
+ int passthrough_mode = p_preset->get("xr_features/passthrough");
+ if (passthrough_mode == XR_PASSTHROUGH_OPTIONAL) {
+ manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"com.oculus.feature.PASSTHROUGH\" android:required=\"false\" />\n";
+ } else if (passthrough_mode == XR_PASSTHROUGH_REQUIRED) {
+ manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"com.oculus.feature.PASSTHROUGH\" android:required=\"true\" />\n";
+ }
}
return manifest_xr_features;
}
@@ -239,7 +247,8 @@ String _get_instrumentation_tag(const Ref<EditorExportPreset> &p_preset) {
}
String _get_activity_tag(const Ref<EditorExportPreset> &p_preset) {
- bool uses_xr = (int)(p_preset->get("xr_features/xr_mode")) == 1;
+ int xr_mode_index = (int)(p_preset->get("xr_features/xr_mode"));
+ bool uses_xr = xr_mode_index == XR_MODE_OPENXR;
String orientation = _get_android_orientation_label(DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation"))));
String manifest_activity_text = vformat(
" <activity android:name=\"com.godot.game.GodotApp\" "
@@ -256,6 +265,8 @@ String _get_activity_tag(const Ref<EditorExportPreset> &p_preset) {
}
String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_storage_permission) {
+ int xr_mode_index = (int)(p_preset->get("xr_features/xr_mode"));
+ bool uses_xr = xr_mode_index == XR_MODE_OPENXR;
String manifest_application_text = vformat(
" <application android:label=\"@string/godot_project_name_string\"\n"
" android:allowBackup=\"%s\"\n"
@@ -270,6 +281,9 @@ String _get_application_tag(const Ref<EditorExportPreset> &p_preset, bool p_has_
bool_to_string(p_preset->get("package/retain_data_on_uninstall")),
bool_to_string(p_has_storage_permission));
+ if (uses_xr) {
+ manifest_application_text += " <meta-data tools:node=\"replace\" android:name=\"com.samsung.android.vr.application.mode\" android:value=\"vr_only\" />\n";
+ }
manifest_application_text += _get_activity_tag(p_preset);
manifest_application_text += " </application>\n";
return manifest_application_text;
diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h
index 744022f1f9..db05c7534c 100644
--- a/platform/android/export/gradle_export_util.h
+++ b/platform/android/export/gradle_export_util.h
@@ -44,6 +44,21 @@ const String godot_project_name_xml_string = R"(<?xml version="1.0" encoding="ut
</resources>
)";
+// Supported XR modes.
+// This should match the entries in 'platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java'
+static const int XR_MODE_REGULAR = 0;
+static const int XR_MODE_OPENXR = 1;
+
+// Supported XR hand tracking modes.
+static const int XR_HAND_TRACKING_NONE = 0;
+static const int XR_HAND_TRACKING_OPTIONAL = 1;
+static const int XR_HAND_TRACKING_REQUIRED = 2;
+
+// Supported XR passthrough modes.
+static const int XR_PASSTHROUGH_NONE = 0;
+static const int XR_PASSTHROUGH_OPTIONAL = 1;
+static const int XR_PASSTHROUGH_REQUIRED = 2;
+
struct CustomExportData {
String assets_directory;
bool debug;
diff --git a/platform/android/java/app/AndroidManifest.xml b/platform/android/java/app/AndroidManifest.xml
index d7bf6cef30..9ae6367b42 100644
--- a/platform/android/java/app/AndroidManifest.xml
+++ b/platform/android/java/app/AndroidManifest.xml
@@ -33,6 +33,11 @@
<!-- The following metadata values are replaced when Godot exports, modifying them here has no effect. -->
<!-- Do these changes in the export preset. Adding new ones is fine. -->
+ <!-- XR mode metadata. This is modified by the exporter based on the selected xr mode. DO NOT CHANGE the values here. -->
+ <meta-data
+ android:name="xr_mode_metadata_name"
+ android:value="xr_mode_metadata_value" />
+
<activity
android:name=".GodotApp"
android:label="@string/godot_project_name_string"
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
index d872d5ed8a..17ff3c75c0 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
@@ -119,7 +119,6 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
private Button mWiFiSettingsButton;
private XRMode xrMode = XRMode.REGULAR;
- private int depth_buffer_bits = 24;
private boolean use_immersive = false;
private boolean use_debug_opengl = false;
private boolean mStatePaused;
@@ -266,8 +265,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
if (videoDriver.equals("vulkan")) {
mRenderView = new GodotVulkanRenderView(activity, this);
} else {
- mRenderView = new GodotGLRenderView(activity, this, xrMode, depth_buffer_bits,
- use_debug_opengl);
+ mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl);
}
View view = mRenderView.getView();
@@ -504,14 +502,8 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
boolean has_extra = i < command_line.length - 1;
if (command_line[i].equals(XRMode.REGULAR.cmdLineArg)) {
xrMode = XRMode.REGULAR;
- } else if (command_line[i].equals(XRMode.OVR.cmdLineArg)) {
- xrMode = XRMode.OVR;
- } else if (command_line[i].startsWith("--use_depth=")) {
- try {
- depth_buffer_bits = Integer.parseInt(command_line[i].split("=")[1]);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ } else if (command_line[i].equals(XRMode.OPENXR.cmdLineArg)) {
+ xrMode = XRMode.OPENXR;
} else if (command_line[i].equals("--debug_opengl")) {
use_debug_opengl = true;
} else if (command_line[i].equals("--use_immersive")) {
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
index 8b77302491..d5b0b67903 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
@@ -78,10 +78,8 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
private final GodotRenderer godotRenderer;
private PointerIcon pointerIcon;
- public GodotGLRenderView(Context context, Godot godot, XRMode xrMode, int p_depth_buffer_bits,
- boolean p_use_debug_opengl) {
+ public GodotGLRenderView(Context context, Godot godot, XRMode xrMode, boolean p_use_debug_opengl) {
super(context);
- GLUtils.depth_buffer_bits = p_depth_buffer_bits;
GLUtils.use_debug_opengl = p_use_debug_opengl;
this.godot = godot;
@@ -91,7 +89,7 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
pointerIcon = PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_DEFAULT);
}
- init(xrMode, false, 16, 0);
+ init(xrMode, false);
}
@Override
@@ -172,11 +170,11 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
return pointerIcon;
}
- private void init(XRMode xrMode, boolean translucent, int depth, int stencil) {
+ private void init(XRMode xrMode, boolean translucent) {
setPreserveEGLContextOnPause(true);
setFocusableInTouchMode(true);
switch (xrMode) {
- case OVR:
+ case OPENXR:
// Replace the default egl config chooser.
setEGLConfigChooser(new OvrConfigChooser());
@@ -209,16 +207,9 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
* below.
*/
- RegularConfigChooser configChooser =
- new RegularFallbackConfigChooser(8, 8, 8, 8, 16, stencil,
- new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
- if (GLUtils.depth_buffer_bits >= 24) {
- configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, configChooser);
- if (GLUtils.depth_buffer_bits >= 32) {
- configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 32, stencil, configChooser);
- }
- }
- setEGLConfigChooser(configChooser);
+ setEGLConfigChooser(
+ new RegularFallbackConfigChooser(8, 8, 8, 8, 24, 0,
+ new RegularConfigChooser(8, 8, 8, 8, 16, 0)));
break;
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
index d85d88ec6c..5f354b6b4c 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
@@ -288,7 +288,34 @@ public class GodotIO {
}
public int getScreenOrientation() {
- return activity.getRequestedOrientation();
+ int orientation = activity.getRequestedOrientation();
+ switch (orientation) {
+ case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
+ return SCREEN_LANDSCAPE;
+ case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
+ return SCREEN_PORTRAIT;
+ case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
+ return SCREEN_REVERSE_LANDSCAPE;
+ case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT:
+ return SCREEN_REVERSE_PORTRAIT;
+ case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
+ case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE:
+ return SCREEN_SENSOR_LANDSCAPE;
+ case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT:
+ case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT:
+ return SCREEN_SENSOR_PORTRAIT;
+ case ActivityInfo.SCREEN_ORIENTATION_SENSOR:
+ case ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR:
+ case ActivityInfo.SCREEN_ORIENTATION_FULL_USER:
+ return SCREEN_SENSOR;
+ case ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED:
+ case ActivityInfo.SCREEN_ORIENTATION_USER:
+ case ActivityInfo.SCREEN_ORIENTATION_BEHIND:
+ case ActivityInfo.SCREEN_ORIENTATION_NOSENSOR:
+ case ActivityInfo.SCREEN_ORIENTATION_LOCKED:
+ default:
+ return -1;
+ }
}
public void setEdit(GodotEditText _edit) {
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
index 0d581785ab..09820fad5f 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
@@ -44,7 +44,6 @@ public class GLUtils {
public static final boolean DEBUG = false;
- public static int depth_buffer_bits; // No need to reiterate the default here
public static boolean use_debug_opengl = false;
private static final String[] ATTRIBUTES_NAMES = new String[] {
diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java b/platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java
index 0995477baf..58f02b0396 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java
@@ -35,7 +35,7 @@ package org.godotengine.godot.xr;
*/
public enum XRMode {
REGULAR(0, "Regular", "--xr_mode_regular", "Default Android Gamepad"), // Regular/flatscreen
- OVR(1, "Oculus Mobile VR", "--xr_mode_ovr", "");
+ OPENXR(1, "OpenXR", "--xr_mode_openxr", "");
final int index;
final String label;
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index c7f19e4be2..3236512f5c 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -317,8 +317,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env
// Called on the UI thread
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jclass clazz, jint p_device, jint p_axis, jfloat p_value) {
- if (step.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
AndroidInputHandler::JoypadEvent jevent;
jevent.device = p_device;
@@ -331,24 +332,27 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env,
// Called on the UI thread
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.get() <= 0)
+ if (step.get() <= 0) {
return;
+ }
AndroidInputHandler::JoypadEvent jevent;
jevent.device = p_device;
jevent.type = AndroidInputHandler::JOY_EVENT_HAT;
- int hat = 0;
+ HatMask hat = HatMask::CENTER;
if (p_hat_x != 0) {
- if (p_hat_x < 0)
- hat |= HatMask::HAT_MASK_LEFT;
- else
- hat |= HatMask::HAT_MASK_RIGHT;
+ if (p_hat_x < 0) {
+ hat |= HatMask::LEFT;
+ } else {
+ hat |= HatMask::RIGHT;
+ }
}
if (p_hat_y != 0) {
- if (p_hat_y < 0)
- hat |= HatMask::HAT_MASK_UP;
- else
- hat |= HatMask::HAT_MASK_DOWN;
+ if (p_hat_y < 0) {
+ hat |= HatMask::UP;
+ } else {
+ hat |= HatMask::DOWN;
+ }
}
jevent.hat = hat;