Fix free look not working with controllers

This commit is contained in:
Waterdish
2024-11-23 22:58:07 -08:00
parent ef7780ffaa
commit 821dd700ff
3 changed files with 9 additions and 3 deletions
@@ -200,6 +200,7 @@ public class MainActivity extends SDLActivity{
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);
@@ -290,14 +291,19 @@ public class MainActivity extends SDLActivity{
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
+2 -2
View File
@@ -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