Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Add rotary input support for Android platform #88490

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

AlekseyKapustyanenko
Copy link
Contributor

This PR adds Rotary input support for wear os devices. It converts RotaryInput to vertical mouse wheel event. Without it Godot does not recognise this event at all. The same feature wich implemented #88130 , but for Godot 3.x.

Proposal: godotengine/godot-proposals#9062

@@ -352,6 +352,8 @@ protected void onGodotSetupCompleted() {
if (godotHost != null) {
godotHost.onGodotSetupCompleted();
}
int rotaryInputAxis = java.lang.Integer.parseInt(GodotLib.getGlobal("input_devices/pointing/android/rotary_input_scroll_axis"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this below boolean panScaleEnabled = ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -352,6 +352,8 @@ protected void onGodotSetupCompleted() {
if (godotHost != null) {
godotHost.onGodotSetupCompleted();
}
int rotaryInputAxis = java.lang.Integer.parseInt(GodotLib.getGlobal("input_devices/pointing/android/rotary_input_scroll_axis"));
GodotInputHandler.setRotaryInputAxis(rotaryInputAxis);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this logic within the runOnUiThread(... block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

main/main.cpp Outdated
Comment on lines 1332 to 1337
GLOBAL_DEF("input_devices/pointing/android/rotary_input_scroll_axis", 1);
ProjectSettings::get_singleton()->set_custom_property_info("input_devices/pointing/android/rotary_input_scroll_axis",
PropertyInfo(Variant::INT,
"input_devices/pointing/android/rotary_input_scroll_axis",
PROPERTY_HINT_ENUM, "Horizontal,Vertical"));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep this with the other set of input_devices/pointing/android settings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@m4gr3d m4gr3d changed the title Rotary input for 3.x [3.x] Rotary input for 3.x Feb 18, 2024
Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third time's the charm

@@ -342,6 +342,8 @@ protected void onGodotSetupCompleted() {
if (inputHandler != null) {
inputHandler.enableLongPress(longPressEnabled);
inputHandler.enablePanningAndScalingGestures(panScaleEnabled);
int rotaryInputAxis = java.lang.Integer.parseInt(GodotLib.getGlobal("input_devices/pointing/android/rotary_input_scroll_axis"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic should be outside of the runOnUiThread block (and below boolean panScaleEnabled = ...) because the settings are being retrieved on the render thread.
Only the line below should remain within this block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -342,6 +342,8 @@ protected void onGodotSetupCompleted() {
if (inputHandler != null) {
inputHandler.enableLongPress(longPressEnabled);
inputHandler.enablePanningAndScalingGestures(panScaleEnabled);
int rotaryInputAxis = java.lang.Integer.parseInt(GodotLib.getGlobal("input_devices/pointing/android/rotary_input_scroll_axis"));
GodotInputHandler.setRotaryInputAxis(rotaryInputAxis);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move this outside of the if block since it's setting a static variable using a static method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

@m4gr3d m4gr3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@m4gr3d m4gr3d modified the milestones: 3.x, 3.6 Feb 18, 2024
@akien-mga akien-mga changed the title [3.x] Rotary input for 3.x [3.x] Add rotary input support for Android platform Feb 22, 2024
@lawnjelly lawnjelly merged commit 758daac into godotengine:3.x Mar 8, 2024
13 checks passed
@lawnjelly
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants