Skip to content

Commit

Permalink
Fix free look not working with controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
Waterdish committed Nov 24, 2024
1 parent ef7780f commit 821dd70
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Android/app/src/main/java/com/dishii/mm/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ private boolean isExternalStorageWritable() {


public native void attachController();
public native void detachController();
// Native method for setting button state
public native void setButton(int button, boolean value);
public native void setCameraState(int axis, float value);
Expand Down Expand Up @@ -290,14 +291,19 @@ private void setupControllerOverlay() {
private void setupToggleButton(Button button, ViewGroup uiGroup){
boolean isHidden = preferences.getBoolean("controlsVisible", false); // Default to 'false' (visible)
uiGroup.setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE); // Set the initial visibility based on the saved state
/*if(isHidden){
detachController();
}*/
button.setOnClickListener(new View.OnClickListener() {
boolean isHidden = false;
@Override
public void onClick(View v) {
if (isHidden) {
uiGroup.setVisibility(View.VISIBLE); // Show UI elements
//attachController();
} else {
uiGroup.setVisibility(View.INVISIBLE); // Hide UI elements
//detachController();
}
preferences.edit().putBoolean("controlsVisible", !isHidden).apply();
isHidden = !isHidden; // Toggle state
Expand Down
2 changes: 1 addition & 1 deletion libultraship
4 changes: 2 additions & 2 deletions mm/2s2h/Enhancements/Camera/FreeLook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ bool Camera_FreeLook(Camera* camera) {

#ifdef __ANDROID__
if(Ship::Mobile::IsUsingTouchscreenControls()) {
yawDiff = -Ship::Mobile::GetCameraYaw()*10.0f;
pitchDiff = Ship::Mobile::GetCameraPitch()*10.0f;
yawDiff += -Ship::Mobile::GetCameraYaw()*10.0f;
pitchDiff += Ship::Mobile::GetCameraPitch()*10.0f;
}
#endif

Expand Down

0 comments on commit 821dd70

Please sign in to comment.