From 80a99a67d9f04a1ed4d6e66f67c97d497394dd3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 31 Aug 2023 11:41:34 +0200 Subject: [PATCH] Control: Change internal interfaces to batch-process input axis updates These naturally come in bunches on many platforms like Android, so lay some groundwork to also handle them in bunches to minimize locking in the future. Linux buildfix --- Common/System/NativeApp.h | 2 +- Common/VR/PPSSPPVR.cpp | 58 ++++++++++++++++++------------------- Common/VR/PPSSPPVR.h | 4 ++- Qt/QtMain.cpp | 24 +++++++-------- SDL/SDLJoystick.cpp | 2 +- SDL/SDLMain.cpp | 17 +++++------ UI/NativeApp.cpp | 29 ++++++++++--------- Windows/DinputDevice.cpp | 3 +- Windows/WindowsHost.cpp | 17 +++++------ Windows/XinputDevice.cpp | 17 +++++++---- android/jni/app-android.cpp | 28 +++++++++--------- ios/ViewController.mm | 12 ++++---- 12 files changed, 110 insertions(+), 103 deletions(-) diff --git a/Common/System/NativeApp.h b/Common/System/NativeApp.h index 490d35c83d..41b9e5a0a6 100644 --- a/Common/System/NativeApp.h +++ b/Common/System/NativeApp.h @@ -54,7 +54,7 @@ bool NativeIsRestarting(); // input latency - assuming your main loop is architected properly (NativeFrame called from a different thread than input event handling). void NativeTouch(const TouchInput &touch); bool NativeKey(const KeyInput &key); -void NativeAxis(const AxisInput &axis); +void NativeAxis(const AxisInput *axis, size_t count); // Called when it's process a frame, including rendering. If the device can keep up, this // will be called sixty times per second. Main thread. diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 187fe5759a..bf07b9e68e 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -56,9 +56,9 @@ static bool vrMirroring[VR_MIRRORING_COUNT]; static int vrMirroringVariant = 0; static XrView vrView[2]; -static void (*NativeAxis)(const AxisInput &axis); -static bool (*NativeKey)(const KeyInput &key); -static void (*NativeTouch)(const TouchInput &touch); +static void (*cbNativeAxis)(const AxisInput *axis, size_t count); +static bool (*cbNativeKey)(const KeyInput &key); +static void (*cbNativeTouch)(const TouchInput &touch); /* ================================================================================ @@ -205,10 +205,10 @@ void GetVRResolutionPerEye(int* width, int* height) { } } -void SetVRCallbacks(void (*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), void (*touch)(const TouchInput &touch)) { - NativeAxis = axis; - NativeKey = key; - NativeTouch = touch; +void SetVRCallbacks(void (*axis)(const AxisInput *axis, size_t count), bool(*key)(const KeyInput &key), void (*touch)(const TouchInput &touch)) { + cbNativeAxis = axis; + cbNativeKey = key; + cbNativeTouch = touch; } /* @@ -226,20 +226,20 @@ void SetVRAppMode(VRAppMode mode) { void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { //axis if (pspKeys[(int)VIRTKEY_VR_CAMERA_ADJUST]) { - AxisInput axis = {}; + AxisInput axis[2] = {}; + axis[0].deviceId = DEVICE_ID_DEFAULT; + axis[1].deviceId = DEVICE_ID_DEFAULT; for (int j = 0; j < 2; j++) { XrVector2f joystick = IN_VRGetJoystickState(j); - axis.deviceId = DEVICE_ID_DEFAULT; //horizontal - axis.axisId = j == 0 ? JOYSTICK_AXIS_X : JOYSTICK_AXIS_Z; - axis.value = joystick.x; - NativeAxis(axis); + axis[0].axisId = j == 0 ? JOYSTICK_AXIS_X : JOYSTICK_AXIS_Z; + axis[0].value = joystick.x; //vertical - axis.axisId = j == 0 ? JOYSTICK_AXIS_Y : JOYSTICK_AXIS_RZ; - axis.value = -joystick.y; - NativeAxis(axis); + axis[1].axisId = j == 0 ? JOYSTICK_AXIS_Y : JOYSTICK_AXIS_RZ; + axis[1].value = -joystick.y; + cbNativeAxis(axis, 2); } } @@ -261,12 +261,12 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { if (pressed && haptics) { INVR_Vibrate(100, j, 1000); } - NativeKey(keyInput); + cbNativeKey(keyInput); m.pressed = pressed; m.repeat = 0; } else if (pressed && (m.repeat > 30)) { keyInput.flags |= KEY_IS_REPEAT; - NativeKey(keyInput); + cbNativeKey(keyInput); m.repeat = 0; } else { m.repeat++; @@ -289,7 +289,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { keyInput.flags = activate ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_MOTION_UP; keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][0] != activate) NativeKey(keyInput); + if (controllerMotion[j][0] != activate) cbNativeKey(keyInput); controllerMotion[j][0] = activate; //down @@ -297,7 +297,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { keyInput.flags = activate ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_MOTION_DOWN; keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][1] != activate) NativeKey(keyInput); + if (controllerMotion[j][1] != activate) cbNativeKey(keyInput); controllerMotion[j][1] = activate; //left @@ -305,7 +305,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { keyInput.flags = activate ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_MOTION_LEFT; keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][2] != activate) NativeKey(keyInput); + if (controllerMotion[j][2] != activate) cbNativeKey(keyInput); controllerMotion[j][2] = activate; //right @@ -313,7 +313,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { keyInput.flags = activate ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_MOTION_RIGHT; keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][3] != activate) NativeKey(keyInput); + if (controllerMotion[j][3] != activate) cbNativeKey(keyInput); controllerMotion[j][3] = activate; //forward @@ -321,7 +321,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { keyInput.flags = activate ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_MOTION_FORWARD; keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][4] != activate) NativeKey(keyInput); + if (controllerMotion[j][4] != activate) cbNativeKey(keyInput); controllerMotion[j][4] = activate; } } @@ -358,7 +358,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { activate = !disable && yaw < -limit; keyInput.flags = activate ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_ROTATION_LEFT; - if (hmdMotion[2] != activate) NativeKey(keyInput); + if (hmdMotion[2] != activate) cbNativeKey(keyInput); if (isVR && activate) hmdMotionDiff[1] += limit; hmdMotion[2] = activate; @@ -366,7 +366,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { activate = !disable && yaw > limit; keyInput.flags = activate ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_ROTATION_RIGHT; - if (hmdMotion[3] != activate) NativeKey(keyInput); + if (hmdMotion[3] != activate) cbNativeKey(keyInput); if (isVR && activate) hmdMotionDiff[1] -= limit; hmdMotion[3] = activate; } @@ -449,9 +449,9 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { if (mousePressed != pressed) { if (pressed) { touch.flags = TOUCH_DOWN; - NativeTouch(touch); + cbNativeTouch(touch); touch.flags = TOUCH_UP; - NativeTouch(touch); + cbNativeTouch(touch); } mousePressed = pressed; } @@ -463,10 +463,10 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { float scroll = -IN_VRGetJoystickState(j).y; keyInput.flags = scroll < -0.5f ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_MOUSEWHEEL_UP; - NativeKey(keyInput); + cbNativeKey(keyInput); keyInput.flags = scroll > 0.5f ? KEY_DOWN : KEY_UP; keyInput.keyCode = NKCODE_EXT_MOUSEWHEEL_DOWN; - NativeKey(keyInput); + cbNativeKey(keyInput); } } else { VR_SetConfig(VR_CONFIG_MOUSE_SIZE, 0); @@ -525,7 +525,7 @@ bool UpdateVRKeys(const KeyInput &key) { for (auto& pspKey : pspKeys) { if (pspKey.second) { keyUp.keyCode = (InputKeyCode)pspKey.first; - NativeKey(keyUp); + cbNativeKey(keyUp); } } pspKeys[VIRTKEY_VR_CAMERA_ADJUST] = true; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 9ece2f2ab8..489e70bdd7 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -1,5 +1,7 @@ #pragma once +#include + struct AxisInput; struct TouchInput; struct KeyInput; @@ -30,7 +32,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(void(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), void(*touch)(const TouchInput &touch)); +void SetVRCallbacks(void(*axis)(const AxisInput *axis, size_t count), bool(*key)(const KeyInput &key), void(*touch)(const TouchInput &touch)); // VR input integration void SetVRAppMode(VRAppMode mode); diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index db09b3a87f..ea99d78ff5 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -731,20 +731,18 @@ void MainUI::updateAccelerometer() { // TODO: Toggle it depending on whether it is enabled QAccelerometerReading *reading = acc->reading(); if (reading) { - AxisInput axis; - axis.deviceId = DEVICE_ID_ACCELEROMETER; + AxisInput axis[3]; + for (int i = 0; i < 3; i++) { + axis[i].deviceId = DEVICE_ID_ACCELEROMETER; + } - axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_X; - axis.value = reading->x(); - NativeAxis(axis); - - axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_Y; - axis.value = reading->y(); - NativeAxis(axis); - - axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_Z; - axis.value = reading->z(); - NativeAxis(axis); + axis[0].axisId = JOYSTICK_AXIS_ACCELEROMETER_X; + axis[0].value = reading->x(); + axis[1].axisId = JOYSTICK_AXIS_ACCELEROMETER_Y; + axis[1].value = reading->y(); + axis[2].axisId = JOYSTICK_AXIS_ACCELEROMETER_Z; + axis[2].value = reading->z(); + NativeAxis(axis, 3); } #endif } diff --git a/SDL/SDLJoystick.cpp b/SDL/SDLJoystick.cpp index 2d41e363eb..bcaf616c7d 100644 --- a/SDL/SDLJoystick.cpp +++ b/SDL/SDLJoystick.cpp @@ -189,7 +189,7 @@ void SDLJoystick::ProcessInput(const SDL_Event &event){ if (axis.value > 1.0f) axis.value = 1.0f; if (axis.value < -1.0f) axis.value = -1.0f; axis.deviceId = DEVICE_ID_PAD_0 + getDeviceIndex(event.caxis.which); - NativeAxis(axis); + NativeAxis(&axis, 1); break; case SDL_CONTROLLERDEVICEREMOVED: // for removal events, "which" is the instance ID for SDL_CONTROLLERDEVICEREMOVED diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index a9d7bb1bd8..8d8e97011a 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -724,17 +724,16 @@ struct InputStateTracker { float scaleFactor_x = g_display.dpi_scale_x * 0.1 * g_Config.fMouseSensitivity; float scaleFactor_y = g_display.dpi_scale_y * 0.1 * g_Config.fMouseSensitivity; - AxisInput axisX, axisY; - axisX.axisId = JOYSTICK_AXIS_MOUSE_REL_X; - axisX.deviceId = DEVICE_ID_MOUSE; - axisX.value = std::max(-1.0f, std::min(1.0f, mouseDeltaX * scaleFactor_x)); - axisY.axisId = JOYSTICK_AXIS_MOUSE_REL_Y; - axisY.deviceId = DEVICE_ID_MOUSE; - axisY.value = std::max(-1.0f, std::min(1.0f, mouseDeltaY * scaleFactor_y)); + AxisInput axis[2]; + axis[0].axisId = JOYSTICK_AXIS_MOUSE_REL_X; + axis[0].deviceId = DEVICE_ID_MOUSE; + axis[0].value = std::max(-1.0f, std::min(1.0f, mouseDeltaX * scaleFactor_x)); + axis[1].axisId = JOYSTICK_AXIS_MOUSE_REL_Y; + axis[1].deviceId = DEVICE_ID_MOUSE; + axis[1].value = std::max(-1.0f, std::min(1.0f, mouseDeltaY * scaleFactor_y)); if (GetUIState() == UISTATE_INGAME || g_Config.bMapMouse) { - NativeAxis(axisX); - NativeAxis(axisY); + NativeAxis(axis, 2); } mouseDeltaX *= g_Config.fMouseSmoothing; mouseDeltaY *= g_Config.fMouseSmoothing; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 76b7cf5faa..6f1ffc5f73 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1319,7 +1319,7 @@ bool NativeKey(const KeyInput &key) { return retval; } -void NativeAxis(const AxisInput &axis) { +static void ProcessOneAxisEvent(const AxisInput &axis) { // VR actions if (IsVREnabled() && !UpdateVRAxis(axis)) { return; @@ -1330,28 +1330,31 @@ void NativeAxis(const AxisInput &axis) { return; } - using namespace TiltEventProcessor; - // only do special handling of tilt events if tilt is enabled. HLEPlugins::PluginDataAxis[axis.axisId] = axis.value; g_screenManager->axis(axis); +} - if (g_Config.iTiltInputType == TILT_NULL) { - // if tilt events are disabled, don't do anything special. - return; - } - +void NativeAxis(const AxisInput *axes, size_t count) { // figure out what the current tilt orientation is by checking the axis event // This is static, since we need to remember where we last were (in terms of orientation) static float tiltX; static float tiltY; static float tiltZ; - switch (axis.axisId) { - case JOYSTICK_AXIS_ACCELEROMETER_X: tiltX = axis.value; break; - case JOYSTICK_AXIS_ACCELEROMETER_Y: tiltY = axis.value; break; - case JOYSTICK_AXIS_ACCELEROMETER_Z: tiltZ = axis.value; break; + for (size_t i = 0; i < count; i++) { + ProcessOneAxisEvent(axes[i]); + switch (axes[i].axisId) { + case JOYSTICK_AXIS_ACCELEROMETER_X: tiltX = axes[i].value; break; + case JOYSTICK_AXIS_ACCELEROMETER_Y: tiltY = axes[i].value; break; + case JOYSTICK_AXIS_ACCELEROMETER_Z: tiltZ = axes[i].value; break; default: break; + } + } + + if (g_Config.iTiltInputType == TILT_NULL) { + // if tilt events are disabled, don't do anything special. + return; } // create the base coordinate tilt system from the calibration data. @@ -1371,7 +1374,7 @@ void NativeAxis(const AxisInput &axis) { // see [http://developer.android.com/guide/topics/sensors/sensors_overview.html] for details bool landscape = g_display.dp_yres < g_display.dp_xres; // now transform out current tilt to the calibrated coordinate system - ProcessTilt(landscape, tiltBaseAngleY, tiltX, tiltY, tiltZ, + TiltEventProcessor::ProcessTilt(landscape, tiltBaseAngleY, tiltX, tiltY, tiltZ, g_Config.bInvertTiltX, g_Config.bInvertTiltY, xSensitivity, ySensitivity); } diff --git a/Windows/DinputDevice.cpp b/Windows/DinputDevice.cpp index b9ec91a391..2115d857f7 100644 --- a/Windows/DinputDevice.cpp +++ b/Windows/DinputDevice.cpp @@ -208,7 +208,7 @@ void SendNativeAxis(InputDeviceID deviceId, int value, int &lastValue, InputAxis axis.deviceId = deviceId; axis.axisId = axisId; axis.value = (float)value * (1.0f / 10000.0f); // Convert axis to normalised float - NativeAxis(axis); + NativeAxis(&axis, 1); lastValue = value; } @@ -241,6 +241,7 @@ int DinputDevice::UpdateState() { ApplyButtons(js); if (analog) { + // TODO: Use the batched interface. AxisInput axis; axis.deviceId = DEVICE_ID_PAD_0 + pDevNum; diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 8a2d877bf9..ef0e715740 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -107,17 +107,16 @@ void WindowsInputManager::PollControllers() { float mx = std::max(-1.0f, std::min(1.0f, mouseDeltaX_ * scaleFactor_x)); float my = std::max(-1.0f, std::min(1.0f, mouseDeltaY_ * scaleFactor_y)); - AxisInput axisX{}, axisY{}; - axisX.axisId = JOYSTICK_AXIS_MOUSE_REL_X; - axisX.deviceId = DEVICE_ID_MOUSE; - axisX.value = mx; - axisY.axisId = JOYSTICK_AXIS_MOUSE_REL_Y; - axisY.deviceId = DEVICE_ID_MOUSE; - axisY.value = my; + AxisInput axis[2]; + axis[0].axisId = JOYSTICK_AXIS_MOUSE_REL_X; + axis[0].deviceId = DEVICE_ID_MOUSE; + axis[0].value = mx; + axis[1].axisId = JOYSTICK_AXIS_MOUSE_REL_Y; + axis[1].deviceId = DEVICE_ID_MOUSE; + axis[1].value = my; if (GetUIState() == UISTATE_INGAME || g_Config.bMapMouse) { - NativeAxis(axisX); - NativeAxis(axisY); + NativeAxis(axis, 2); } } diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index b1cffa5bfe..cf525679d9 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -218,14 +218,17 @@ void XinputDevice::UpdatePad(int pad, const XINPUT_STATE &state, XINPUT_VIBRATIO ApplyButtons(pad, state); ApplyVibration(pad, vibration); - AxisInput axis; - axis.deviceId = (InputDeviceID)(DEVICE_ID_XINPUT_0 + pad); + AxisInput axis[6]; + int axisCount = 0; + for (int i = 0; i < ARRAY_SIZE(axis); i++) { + axis[i].deviceId = (InputDeviceID)(DEVICE_ID_XINPUT_0 + pad); + } auto sendAxis = [&](InputAxis axisId, float value, int axisIndex) { if (value != prevAxisValue_[pad][axisIndex]) { prevAxisValue_[pad][axisIndex] = value; - axis.axisId = axisId; - axis.value = value; - NativeAxis(axis); + axis[axisCount].axisId = axisId; + axis[axisCount].value = value; + axisCount++; } }; @@ -242,6 +245,10 @@ void XinputDevice::UpdatePad(int pad, const XINPUT_STATE &state, XINPUT_VIBRATIO sendAxis(JOYSTICK_AXIS_RTRIGGER, (float)state.Gamepad.bRightTrigger / 255.0f, 5); } + if (axisCount) { + NativeAxis(axis, axisCount); + } + prevState[pad] = state; check_delay[pad] = 0; } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 4dcaff2145..7b8a889c95 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1210,6 +1210,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyUp(JNIEnv *, jclass, jin return NativeKey(keyInput); } +// TODO: Make a batched interface, since we get these in batches on the Android side. extern "C" void Java_org_ppsspp_ppsspp_NativeApp_joystickAxis( JNIEnv *env, jclass, jint deviceId, jint axisId, jfloat value) { if (!renderer_inited) @@ -1219,7 +1220,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_joystickAxis( axis.deviceId = (InputDeviceID)deviceId; axis.axisId = (InputAxis)axisId; axis.value = value; - NativeAxis(axis); + NativeAxis(&axis, 1); } extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_mouseWheelEvent( @@ -1234,20 +1235,17 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_accelerometer(JNIEnv *, if (!renderer_inited) return; - AxisInput axis; - axis.deviceId = DEVICE_ID_ACCELEROMETER; - - axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_X; - axis.value = x; - NativeAxis(axis); - - axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_Y; - axis.value = y; - NativeAxis(axis); - - axis.axisId = JOYSTICK_AXIS_ACCELEROMETER_Z; - axis.value = z; - NativeAxis(axis); + AxisInput axis[3]; + for (int i = 0; i < 3; i++) { + axis[i].deviceId = DEVICE_ID_ACCELEROMETER; + } + axis[0].axisId = JOYSTICK_AXIS_ACCELEROMETER_X; + axis[0].value = x; + axis[1].axisId = JOYSTICK_AXIS_ACCELEROMETER_Y; + axis[1].value = y; + axis[2].axisId = JOYSTICK_AXIS_ACCELEROMETER_Z; + axis[2].value = z; + NativeAxis(axis, 3); } extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessageFromJava(JNIEnv *env, jclass, jstring message, jstring param) { diff --git a/ios/ViewController.mm b/ios/ViewController.mm index c768ef2dc5..c85b8b5eff 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -462,7 +462,7 @@ int ToTouchID(UITouch *uiTouch, bool allowAllocate) { break; } axis.deviceId = DEVICE_ID_PAD_0; - NativeAxis(axis); + NativeAxis(&axis, 1); } else { KeyInput key; key.flags = KEY_DOWN; @@ -531,7 +531,7 @@ int ToTouchID(UITouch *uiTouch, bool allowAllocate) { break; } axis.deviceId = DEVICE_ID_PAD_0; - NativeAxis(axis); + NativeAxis(&axis, 1); } else { KeyInput key; key.flags = KEY_UP; @@ -689,7 +689,7 @@ int ToTouchID(UITouch *uiTouch, bool allowAllocate) { axisInput.deviceId = DEVICE_ID_PAD_0; axisInput.axisId = JOYSTICK_AXIS_X; axisInput.value = value; - NativeAxis(axisInput); + NativeAxis(&axisInput, 1); }; extendedProfile.leftThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value) { @@ -697,7 +697,7 @@ int ToTouchID(UITouch *uiTouch, bool allowAllocate) { axisInput.deviceId = DEVICE_ID_PAD_0; axisInput.axisId = JOYSTICK_AXIS_Y; axisInput.value = -value; - NativeAxis(axisInput); + NativeAxis(&axisInput, 1); }; // Map right thumbstick as another analog stick, particularly useful for controllers like the DualShock 3/4 when connected to an iOS device @@ -706,7 +706,7 @@ int ToTouchID(UITouch *uiTouch, bool allowAllocate) { axisInput.deviceId = DEVICE_ID_PAD_0; axisInput.axisId = JOYSTICK_AXIS_Z; axisInput.value = value; - NativeAxis(axisInput); + NativeAxis(&axisInput, 1); }; extendedProfile.rightThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value) { @@ -714,7 +714,7 @@ int ToTouchID(UITouch *uiTouch, bool allowAllocate) { axisInput.deviceId = DEVICE_ID_PAD_0; axisInput.axisId = JOYSTICK_AXIS_RZ; axisInput.value = -value; - NativeAxis(axisInput); + NativeAxis(&axisInput, 1); }; } #endif