mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-10-07 19:03:29 +00:00
OpenXR - UI controls integrated
This commit is contained in:
parent
a08325e52f
commit
29ff6af7da
@ -579,6 +579,14 @@ void IN_VRInputFrame( engine_t* engine )
|
||||
//thumbstick
|
||||
moveJoystickState[0] = GetActionStateVector2(moveOnLeftJoystickAction);
|
||||
moveJoystickState[1] = GetActionStateVector2(moveOnRightJoystickAction);
|
||||
if (moveJoystickState[0].currentState.x > 0.5) lButtons |= ovrButton_Right;
|
||||
if (moveJoystickState[0].currentState.x < -0.5) lButtons |= ovrButton_Left;
|
||||
if (moveJoystickState[0].currentState.y > 0.5) lButtons |= ovrButton_Up;
|
||||
if (moveJoystickState[0].currentState.y < -0.5) lButtons |= ovrButton_Down;
|
||||
if (moveJoystickState[1].currentState.x > 0.5) rButtons |= ovrButton_Right;
|
||||
if (moveJoystickState[1].currentState.x < -0.5) rButtons |= ovrButton_Left;
|
||||
if (moveJoystickState[1].currentState.y > 0.5) rButtons |= ovrButton_Up;
|
||||
if (moveJoystickState[1].currentState.y < -0.5) rButtons |= ovrButton_Down;
|
||||
|
||||
lastframetime = in_vrEventTime;
|
||||
in_vrEventTime = milliseconds( );
|
||||
|
@ -226,12 +226,6 @@ void VR_DestroyRenderer( engine_t* engine )
|
||||
initialized = GL_FALSE;
|
||||
}
|
||||
|
||||
void VR_ReInitRenderer()
|
||||
{
|
||||
VR_DestroyRenderer( VR_GetEngine() );
|
||||
VR_InitRenderer( VR_GetEngine() );
|
||||
}
|
||||
|
||||
void VR_ClearFrameBuffer( int width, int height)
|
||||
{
|
||||
glEnable( GL_SCISSOR_TEST );
|
||||
|
@ -8,7 +8,6 @@ void VR_InitRenderer( engine_t* engine );
|
||||
void VR_DestroyRenderer( engine_t* engine );
|
||||
void VR_BeginFrame( engine_t* engine );
|
||||
void VR_DrawFrame( engine_t* engine );
|
||||
void VR_ReInitRenderer();
|
||||
unsigned int VR_Framebuffer( engine_t* engine, int eye );
|
||||
|
||||
#endif
|
||||
|
@ -97,6 +97,41 @@ struct JNIEnv {};
|
||||
#include "VR/VRBase.h"
|
||||
#include "VR/VRInput.h"
|
||||
#include "VR/VRRenderer.h"
|
||||
|
||||
struct ButtonMapping
|
||||
{
|
||||
ovrButton ovr;
|
||||
int keycode;
|
||||
bool pressed;
|
||||
|
||||
ButtonMapping(int keycode, ovrButton ovr)
|
||||
{
|
||||
this->keycode = keycode;
|
||||
this->ovr = ovr;
|
||||
pressed = false;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<ButtonMapping> leftControllerMapping = {
|
||||
ButtonMapping(19, ovrButton_Up),
|
||||
ButtonMapping(20, ovrButton_Down),
|
||||
ButtonMapping(21, ovrButton_Left),
|
||||
ButtonMapping(22, ovrButton_Right),
|
||||
ButtonMapping(66, ovrButton_Trigger),
|
||||
};
|
||||
|
||||
std::vector<ButtonMapping> rightControllerMapping = {
|
||||
ButtonMapping(19, ovrButton_Up),
|
||||
ButtonMapping(20, ovrButton_Down),
|
||||
ButtonMapping(21, ovrButton_Left),
|
||||
ButtonMapping(22, ovrButton_Right),
|
||||
ButtonMapping(66, ovrButton_Trigger),
|
||||
};
|
||||
|
||||
std::vector<ButtonMapping> controllerMapping[2] = {
|
||||
leftControllerMapping,
|
||||
rightControllerMapping
|
||||
};
|
||||
#endif
|
||||
|
||||
#include "app-android.h"
|
||||
@ -1068,6 +1103,30 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env,
|
||||
} else {
|
||||
UpdateRunLoopAndroid(env);
|
||||
}
|
||||
|
||||
#ifdef OPENXR
|
||||
KeyInput keyInput = {};
|
||||
for (int j = 0; j < 2; j++) {
|
||||
int status = IN_VRGetButtonState(j);
|
||||
for (ButtonMapping& m : controllerMapping[j]) {
|
||||
keyInput.flags = status & m.ovr ? KEY_DOWN : KEY_UP;
|
||||
keyInput.keyCode = m.keycode;
|
||||
keyInput.deviceId = j;
|
||||
|
||||
if (status & m.ovr) {
|
||||
if (m.pressed) {
|
||||
keyInput.flags |= KEY_IS_REPEAT;
|
||||
}
|
||||
m.pressed = true;
|
||||
} else {
|
||||
m.pressed = false;
|
||||
}
|
||||
if (!(keyInput.flags & KEY_IS_REPEAT)) {
|
||||
NativeKey(keyInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void System_AskForPermission(SystemPermission permission) {
|
||||
|
Loading…
Reference in New Issue
Block a user