diff --git a/Common/System/NativeApp.h b/Common/System/NativeApp.h index e484d8207e..6788642eb4 100644 --- a/Common/System/NativeApp.h +++ b/Common/System/NativeApp.h @@ -65,7 +65,7 @@ void NativeUpdate(); // time is not yet implemented. finger can be from 0 to 7, inclusive. void NativeTouch(const TouchInput &touch); bool NativeKey(const KeyInput &key); -bool NativeAxis(const AxisInput &axis); +void NativeAxis(const AxisInput &axis); // Called when it's time to render. If the device can keep up, this // will also be called sixty times per second. Main thread. diff --git a/Common/UI/Screen.cpp b/Common/UI/Screen.cpp index 1657253ace..866959ebe7 100644 --- a/Common/UI/Screen.cpp +++ b/Common/UI/Screen.cpp @@ -92,7 +92,7 @@ void ScreenManager::touch(const TouchInput &touch) { bool ScreenManager::key(const KeyInput &key) { std::lock_guard guard(inputLock_); bool result = false; - // Send key up to every screen layer. + // Send key up to every screen layer, to avoid stuck keys. if (key.flags & KEY_UP) { for (auto &layer : stack_) { result = layer.screen->key(key); @@ -103,7 +103,7 @@ bool ScreenManager::key(const KeyInput &key) { return result; } -bool ScreenManager::axis(const AxisInput &axis) { +void ScreenManager::axis(const AxisInput &axis) { std::lock_guard guard(inputLock_); // Ignore duplicate values to prevent axis values overwriting each other. @@ -112,20 +112,18 @@ bool ScreenManager::axis(const AxisInput &axis) { // PSP games can't see higher resolution than this. int value = 128 + ceilf(axis.value * 127.5f + 127.5f); if (lastAxis_[key] == value) { - return false; + return; } lastAxis_[key] = value; - bool result = false; // Send center axis to every screen layer. if (axis.value == 0) { for (auto &layer : stack_) { - result = layer.screen->axis(axis); + layer.screen->axis(axis); } } else if (!stack_.empty()) { - result = stack_.back().screen->axis(axis); + stack_.back().screen->axis(axis); } - return result; } void ScreenManager::deviceLost() { diff --git a/Common/UI/Screen.h b/Common/UI/Screen.h index c39fd79f49..2db57f1156 100644 --- a/Common/UI/Screen.h +++ b/Common/UI/Screen.h @@ -57,7 +57,7 @@ public: virtual void dialogFinished(const Screen *dialog, DialogResult result) {} virtual void touch(const TouchInput &touch) {} virtual bool key(const KeyInput &key) { return false; } - virtual bool axis(const AxisInput &touch) { return false; } + virtual void axis(const AxisInput &touch) {} virtual void sendMessage(const char *msg, const char *value) {} virtual void deviceLost() {} virtual void deviceRestored() {} @@ -134,7 +134,7 @@ public: // Instant touch, separate from the update() mechanism. void touch(const TouchInput &touch); bool key(const KeyInput &key); - bool axis(const AxisInput &touch); + void axis(const AxisInput &touch); // Generic facility for gross hacks :P void sendMessage(const char *msg, const char *value); diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 0764b3c30c..25997b52eb 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -199,12 +199,10 @@ void UIDialogScreen::sendMessage(const char *msg, const char *value) { } } -bool UIScreen::axis(const AxisInput &axis) { +void UIScreen::axis(const AxisInput &axis) { if (root_) { UI::AxisEvent(axis, root_); - return true; } - return false; } UI::EventReturn UIScreen::OnBack(UI::EventParams &e) { diff --git a/Common/UI/UIScreen.h b/Common/UI/UIScreen.h index 113acd15ef..959a246c48 100644 --- a/Common/UI/UIScreen.h +++ b/Common/UI/UIScreen.h @@ -27,7 +27,7 @@ public: void touch(const TouchInput &touch) override; bool key(const KeyInput &touch) override; - bool axis(const AxisInput &touch) override; + void axis(const AxisInput &touch) override; TouchInput transformTouch(const TouchInput &touch) override; diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 47e2d78bf7..37a505d0e1 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -46,7 +46,7 @@ static bool vrFlatGame = false; static float vrMatrix[VR_MATRIX_COUNT][16]; static bool vrMirroring[VR_MIRRORING_COUNT]; -static bool (*NativeAxis)(const AxisInput &axis); +static void (*NativeAxis)(const AxisInput &axis); static bool (*NativeKey)(const KeyInput &key); static void (*NativeTouch)(const TouchInput &touch); @@ -189,7 +189,7 @@ void GetVRResolutionPerEye(int* width, int* height) { } } -void SetVRCallbacks(bool(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), void (*touch)(const TouchInput &touch)) { +void SetVRCallbacks(void (*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), void (*touch)(const TouchInput &touch)) { NativeAxis = axis; NativeKey = key; NativeTouch = touch; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index eb83c118fe..c4dadabf75 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -29,7 +29,7 @@ bool IsVREnabled(); void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name); void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); -void SetVRCallbacks(bool(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), void(*touch)(const TouchInput &touch)); +void SetVRCallbacks(void(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), void(*touch)(const TouchInput &touch)); // VR input integration void SetVRAppMode(VRAppMode mode); diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index 8cc14209d7..9970c282e5 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -117,20 +117,16 @@ bool ControlMapper::Key(const KeyInput &key, bool *pauseTrigger) { return pspKeys.size() > 0; } -bool ControlMapper::Axis(const AxisInput &axis) { +void ControlMapper::Axis(const AxisInput &axis) { if (axis.value > 0) { processAxis(axis, 1); - return true; } else if (axis.value < 0) { processAxis(axis, -1); - return true; } else if (axis.value == 0) { // Both directions! Prevents sticking for digital input devices that are axises (like HAT) processAxis(axis, 1); processAxis(axis, -1); - return true; } - return false; } void ControlMapper::Update() { diff --git a/Core/ControlMapper.h b/Core/ControlMapper.h index c3215cb8c8..bc45007228 100644 --- a/Core/ControlMapper.h +++ b/Core/ControlMapper.h @@ -17,7 +17,7 @@ public: bool Key(const KeyInput &key, bool *pauseTrigger); void pspKey(int deviceId, int pspKeyCode, int flags); - bool Axis(const AxisInput &axis); + void Axis(const AxisInput &axis); // Required callbacks void SetCallbacks( diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 3896d19ac9..680a21a48c 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -407,11 +407,11 @@ static bool IgnoreAxisForMapping(int axis) { } -bool KeyMappingNewKeyDialog::axis(const AxisInput &axis) { +void KeyMappingNewKeyDialog::axis(const AxisInput &axis) { if (mapped_ || time_now_d() < delayUntil_) - return false; + return; if (IgnoreAxisForMapping(axis.axisId)) - return false; + return; if (axis.value > AXIS_BIND_THRESHOLD) { mapped_ = true; @@ -428,14 +428,13 @@ bool KeyMappingNewKeyDialog::axis(const AxisInput &axis) { if (callback_) callback_(kdf); } - return true; } -bool KeyMappingNewMouseKeyDialog::axis(const AxisInput &axis) { +void KeyMappingNewMouseKeyDialog::axis(const AxisInput &axis) { if (mapped_) - return false; + return; if (IgnoreAxisForMapping(axis.axisId)) - return false; + return; if (axis.value > AXIS_BIND_THRESHOLD) { mapped_ = true; @@ -452,7 +451,6 @@ bool KeyMappingNewMouseKeyDialog::axis(const AxisInput &axis) { if (callback_) callback_(kdf); } - return true; } enum class StickHistoryViewType { @@ -619,12 +617,12 @@ bool AnalogSetupScreen::key(const KeyInput &key) { return retval; } -bool AnalogSetupScreen::axis(const AxisInput &axis) { +void AnalogSetupScreen::axis(const AxisInput &axis) { // We DON'T call UIScreen::Axis here! Otherwise it'll try to move the UI focus around. // UIScreen::axis(axis); // Instead we just send the input directly to the mapper, that we'll visualize. - return mapper_.Axis(axis); + mapper_.Axis(axis); } void AnalogSetupScreen::CreateViews() { @@ -778,13 +776,12 @@ bool TouchTestScreen::key(const KeyInput &key) { return true; } -bool TouchTestScreen::axis(const AxisInput &axis) { - +void TouchTestScreen::axis(const AxisInput &axis) { // This is mainly to catch axis events that would otherwise get translated // into arrow keys, since seeing keyboard arrow key events appear when using // a controller would be confusing for the user. if (IgnoreAxisForMapping(axis.axisId)) - return false; + return; const float AXIS_LOG_THRESHOLD = AXIS_BIND_THRESHOLD * 0.5f; if (axis.value > AXIS_LOG_THRESHOLD || axis.value < -AXIS_LOG_THRESHOLD) { @@ -797,7 +794,6 @@ bool TouchTestScreen::axis(const AxisInput &axis) { lastKeyEvent_->SetText(buf); } } - return true; } void TouchTestScreen::render() { diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index 0ddc8105c1..a54a53afe3 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -62,7 +62,7 @@ public: const char *tag() const override { return "KeyMappingNewKey"; } bool key(const KeyInput &key) override; - bool axis(const AxisInput &axis) override; + void axis(const AxisInput &axis) override; void SetDelay(float t); @@ -88,7 +88,7 @@ public: const char *tag() const override { return "KeyMappingNewMouseKey"; } bool key(const KeyInput &key) override; - bool axis(const AxisInput &axis) override; + void axis(const AxisInput &axis) override; protected: void CreatePopupContents(UI::ViewGroup *parent) override; @@ -110,7 +110,7 @@ public: AnalogSetupScreen(const Path &gamePath); bool key(const KeyInput &key) override; - bool axis(const AxisInput &axis) override; + void axis(const AxisInput &axis) override; void update() override; @@ -144,7 +144,7 @@ public: void render() override; bool key(const KeyInput &key) override; - bool axis(const AxisInput &axis) override; + void axis(const AxisInput &axis) override; const char *tag() const override { return "TouchTest"; } diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 0d2456583e..c600b94ac8 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -788,7 +788,7 @@ bool EmuScreen::key(const KeyInput &key) { return controlMapper_.Key(key, &pauseTrigger_); } -bool EmuScreen::axis(const AxisInput &axis) { +void EmuScreen::axis(const AxisInput &axis) { Core_NotifyActivity(); return controlMapper_.Axis(axis); diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 128b730ddf..c3e34369fa 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -52,7 +52,7 @@ public: void touch(const TouchInput &touch) override; bool key(const KeyInput &key) override; - bool axis(const AxisInput &axis) override; + void axis(const AxisInput &axis) override; private: void CreateViews() override; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index e20e1424b4..306cc91746 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1353,15 +1353,15 @@ bool NativeKey(const KeyInput &key) { return retval; } -bool NativeAxis(const AxisInput &axis) { +void NativeAxis(const AxisInput &axis) { // VR actions if (IsVREnabled() && !UpdateVRAxis(axis)) { - return false; + return; } if (!screenManager) { // Too early. - return false; + return; } using namespace TiltEventProcessor; @@ -1369,11 +1369,8 @@ bool NativeAxis(const AxisInput &axis) { // only handle tilt events if tilt is enabled. if (g_Config.iTiltInputType == TILT_NULL) { // if tilt events are disabled, then run it through the usual way. - if (screenManager) { - return screenManager->axis(axis); - } else { - return false; - } + screenManager->axis(axis); + return; } // create the base coordinate tilt system from the calibration data. @@ -1404,7 +1401,7 @@ bool NativeAxis(const AxisInput &axis) { if (fabs(axis.value) < 0.8f && g_Config.iTiltOrientation == 2) // Auto tilt switch verticalTilt = false; else - return false; // Tilt on Z instead + return; // Tilt on Z instead } if (portrait) { currentTilt.x_ = axis.value; @@ -1426,7 +1423,7 @@ bool NativeAxis(const AxisInput &axis) { if (fabs(axis.value) < 0.8f && g_Config.iTiltOrientation == 2) // Auto tilt switch verticalTilt = true; else - return false; // Tilt on X instead + return; // Tilt on X instead } if (portrait) { currentTilt.x_ = -axis.value; @@ -1442,13 +1439,12 @@ bool NativeAxis(const AxisInput &axis) { //Don't know how to handle these. Someone should figure it out. //Does the Ouya even have an accelerometer / gyro? I can't find any reference to these //in the Ouya docs... - return false; + return; default: // Don't take over completely! - if (!screenManager) - return false; - return screenManager->axis(axis); + screenManager->axis(axis); + return; } //figure out the sensitivity of the tilt. (sensitivity is originally 0 - 100) @@ -1463,7 +1459,6 @@ bool NativeAxis(const AxisInput &axis) { Tilt trueTilt = GenTilt(baseTilt, currentTilt, g_Config.bInvertTiltX, g_Config.bInvertTiltY, g_Config.fDeadzoneRadius, xSensitivity, ySensitivity); TranslateTiltToInput(trueTilt); - return true; } void NativeMessageReceived(const char *message, const char *value) { diff --git a/UI/TiltAnalogSettingsScreen.cpp b/UI/TiltAnalogSettingsScreen.cpp index 0176eb3824..bcf8559f07 100644 --- a/UI/TiltAnalogSettingsScreen.cpp +++ b/UI/TiltAnalogSettingsScreen.cpp @@ -58,7 +58,7 @@ void TiltAnalogSettingsScreen::CreateViews() { settings->Add(new Choice(di->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); } -bool TiltAnalogSettingsScreen::axis(const AxisInput &axis) { +void TiltAnalogSettingsScreen::axis(const AxisInput &axis) { if (axis.deviceId == DEVICE_ID_ACCELEROMETER) { // Historically, we've had X and Y swapped, likely due to portrait vs landscape. // TODO: We may want to configure this based on screen orientation. @@ -69,7 +69,6 @@ bool TiltAnalogSettingsScreen::axis(const AxisInput &axis) { currentTiltX_ = axis.value; } } - return false; } UI::EventReturn TiltAnalogSettingsScreen::OnCalibrate(UI::EventParams &e) { diff --git a/UI/TiltAnalogSettingsScreen.h b/UI/TiltAnalogSettingsScreen.h index 832a436842..567ed73ae0 100644 --- a/UI/TiltAnalogSettingsScreen.h +++ b/UI/TiltAnalogSettingsScreen.h @@ -25,7 +25,7 @@ public: TiltAnalogSettingsScreen() {} void CreateViews() override; - bool axis(const AxisInput &axis) override; + void axis(const AxisInput &axis) override; const char *tag() const override { return "TiltAnalogSettings"; } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index b572a4e0ca..ae99cd1054 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1147,17 +1147,17 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyUp(JNIEnv *, jclass, jin return NativeKey(keyInput); } -extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_joystickAxis( +extern "C" void Java_org_ppsspp_ppsspp_NativeApp_joystickAxis( JNIEnv *env, jclass, jint deviceId, jint axisId, jfloat value) { if (!renderer_inited) - return false; + return; AxisInput axis; axis.axisId = axisId; axis.deviceId = deviceId; axis.value = value; - return NativeAxis(axis); + NativeAxis(axis); } extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_mouseWheelEvent( @@ -1169,9 +1169,9 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_mouseWheelEvent( return true; } -extern "C" jboolean JNICALL Java_org_ppsspp_ppsspp_NativeApp_accelerometer(JNIEnv *, jclass, float x, float y, float z) { +extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_accelerometer(JNIEnv *, jclass, float x, float y, float z) { if (!renderer_inited) - return false; + return; AxisInput axis; axis.deviceId = DEVICE_ID_ACCELEROMETER; @@ -1179,17 +1179,15 @@ extern "C" jboolean JNICALL Java_org_ppsspp_ppsspp_NativeApp_accelerometer(JNIEn axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_X; axis.value = x; - bool retvalX = NativeAxis(axis); + NativeAxis(axis); axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_Y; axis.value = y; - bool retvalY = NativeAxis(axis); + NativeAxis(axis); axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_Z; axis.value = z; - bool retvalZ = NativeAxis(axis); - - return retvalX || retvalY || retvalZ; + NativeAxis(axis); } extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessage(JNIEnv *env, jclass, jstring message, jstring param) { diff --git a/android/src/org/ppsspp/ppsspp/NativeApp.java b/android/src/org/ppsspp/ppsspp/NativeApp.java index 22d3ebf45e..65fa15500f 100644 --- a/android/src/org/ppsspp/ppsspp/NativeApp.java +++ b/android/src/org/ppsspp/ppsspp/NativeApp.java @@ -48,7 +48,7 @@ public class NativeApp { // Sensor/input data. These are asynchronous, beware! public static native void touch(float x, float y, int data, int pointerId); - public static native boolean accelerometer(float x, float y, float z); + public static native void accelerometer(float x, float y, float z); public static native void sendMessage(String msg, String arg); public static native void sendInputBox(String seqID, boolean result, String value);