mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-01 18:23:43 +01:00
Merge pull request #16310 from lvonasek/feature_openxr_motion
OpenXR - Map controller gestures
This commit is contained in:
6 files changed
+82
-6
No files matched your search
@@ -78,6 +78,7 @@ static std::vector<ButtonMapping> controllerMapping[2] = {
|
||||
leftControllerMapping,
|
||||
rightControllerMapping
|
||||
};
|
||||
static bool controllerMotion[2][5] = {};
|
||||
static int mouseController = -1;
|
||||
static bool mousePressed[] = {false, false};
|
||||
|
||||
@@ -218,6 +219,58 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con
|
||||
}
|
||||
}
|
||||
|
||||
//motion control
|
||||
if (g_Config.bEnableMotions) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
bool activate;
|
||||
float limit = g_Config.fMotionLength; //length of needed movement in meters
|
||||
XrVector3f axis = {0, 1, 0};
|
||||
float center = ToRadians((float)VR_GetConfig(VR_CONFIG_MENU_YAW));
|
||||
XrQuaternionf orientation = XrQuaternionf_CreateFromVectorAngle(axis, center);
|
||||
XrVector3f position = XrQuaternionf_Rotate(orientation, IN_VRGetPose(j).position);
|
||||
|
||||
//up
|
||||
activate = position.y > limit;
|
||||
keyInput.flags = activate ? KEY_DOWN : KEY_UP;
|
||||
keyInput.keyCode = NKCODE_EXT_MOTION_UP;
|
||||
keyInput.deviceId = controllerIds[j];
|
||||
if (controllerMotion[j][0] != activate) NativeKey(keyInput);
|
||||
controllerMotion[j][0] = activate;
|
||||
|
||||
//down
|
||||
activate = position.y < -limit * 1.5f;
|
||||
keyInput.flags = activate ? KEY_DOWN : KEY_UP;
|
||||
keyInput.keyCode = NKCODE_EXT_MOTION_DOWN;
|
||||
keyInput.deviceId = controllerIds[j];
|
||||
if (controllerMotion[j][1] != activate) NativeKey(keyInput);
|
||||
controllerMotion[j][1] = activate;
|
||||
|
||||
//left
|
||||
activate = position.x < -limit * (j == 0 ? 1.0f : 0.25f);
|
||||
keyInput.flags = activate ? KEY_DOWN : KEY_UP;
|
||||
keyInput.keyCode = NKCODE_EXT_MOTION_LEFT;
|
||||
keyInput.deviceId = controllerIds[j];
|
||||
if (controllerMotion[j][2] != activate) NativeKey(keyInput);
|
||||
controllerMotion[j][2] = activate;
|
||||
|
||||
//right
|
||||
activate = position.x > limit * (j == 1 ? 1.0f : 0.25f);
|
||||
keyInput.flags = activate ? KEY_DOWN : KEY_UP;
|
||||
keyInput.keyCode = NKCODE_EXT_MOTION_RIGHT;
|
||||
keyInput.deviceId = controllerIds[j];
|
||||
if (controllerMotion[j][3] != activate) NativeKey(keyInput);
|
||||
controllerMotion[j][3] = activate;
|
||||
|
||||
//forward
|
||||
activate = position.z < -limit;
|
||||
keyInput.flags = activate ? KEY_DOWN : KEY_UP;
|
||||
keyInput.keyCode = NKCODE_EXT_MOTION_FORWARD;
|
||||
keyInput.deviceId = controllerIds[j];
|
||||
if (controllerMotion[j][4] != activate) NativeKey(keyInput);
|
||||
controllerMotion[j][4] = activate;
|
||||
}
|
||||
}
|
||||
|
||||
//mouse cursor
|
||||
if (mouseController >= 0) {
|
||||
//get position on screen
|
||||
|
||||
Reference in new issue
Block a user