Couple of improvement

- Clean exit (no crash)
- Menu option to switch thumbstick function (for left handers who like right-hander thumbsticks)
This commit is contained in:
Simon 2020-04-15 20:48:44 +01:00
parent c893d99b6c
commit 46c9900185
9 changed files with 66 additions and 18 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.questzdoom"
android:versionCode="4"
android:versionName="0.3.0" android:installLocation="auto" >
android:versionCode="5"
android:versionName="0.4.0" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>

View file

@ -59,6 +59,7 @@ bool weaponStabilised;
float vr_weapon_pitchadjust;
bool vr_moveuseoffhand;
float vr_snapturn_angle;
bool vr_switchsticks;
float vr_use_teleport;
vec3_t offhandangles;
vec3_t offhandoffset;

View file

@ -50,6 +50,7 @@ extern vec3_t weaponoffset;
extern bool weaponStabilised;
extern float vr_weapon_pitchadjust;
extern bool vr_moveuseoffhand;
extern bool vr_switchsticks;
extern float vr_snapturn_angle;
extern float vr_use_teleport;

View file

@ -30,7 +30,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Menu button - invoke menu
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, KEY_ESCAPE);
if (getGameState() != 0 || getMenuState() != 0) // If getMenuState returns 2, then we are waiting for a key mapping input, so send normal keymappings
if (getGameState() != 0 || getMenuState() == 1) // If getMenuState returns 2, then we are waiting for a key mapping input, so send normal keymappings, don't send these
{
Joy_GenerateButtonEvents((pOffTrackedRemoteOld->Joystick.x > 0.7f ? 1 : 0), (pOffTrackedRemoteNew->Joystick.x > 0.7f ? 1 : 0), 1, KEY_PAD_DPAD_RIGHT);
Joy_GenerateButtonEvents((pDominantTrackedRemoteOld->Joystick.x > 0.7f ? 1 : 0), (pDominantTrackedRemoteNew->Joystick.x > 0.7f ? 1 : 0), 1, KEY_PAD_DPAD_RIGHT);
@ -52,6 +52,22 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
(pDominantTrackedRemoteNew->Buttons & ovrButton_GripTrigger) != 0;
ovrInputStateTrackedRemote *pPrimaryTrackedRemoteNew, *pPrimaryTrackedRemoteOld, *pSecondaryTrackedRemoteNew, *pSecondaryTrackedRemoteOld;
if (vr_switchsticks)
{
pPrimaryTrackedRemoteNew = pOffTrackedRemoteNew;
pPrimaryTrackedRemoteOld = pOffTrackedRemoteOld;
pSecondaryTrackedRemoteNew = pDominantTrackedRemoteNew;
pSecondaryTrackedRemoteOld = pDominantTrackedRemoteOld;
}
else
{
pPrimaryTrackedRemoteNew = pDominantTrackedRemoteNew;
pPrimaryTrackedRemoteOld = pDominantTrackedRemoteOld;
pSecondaryTrackedRemoteNew = pOffTrackedRemoteNew;
pSecondaryTrackedRemoteOld = pOffTrackedRemoteOld;
}
// Only do the following if we are definitely not in the menu
if (getMenuState() == 0)
{
@ -166,9 +182,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Teleport - only does anything if vr_teleport cvar is true
if (vr_use_teleport) {
if (pOffTrackedRemoteOld->Joystick.y > 0.7f && !ready_teleport) {
if (pSecondaryTrackedRemoteOld->Joystick.y > 0.7f && !ready_teleport) {
ready_teleport = true;
} else if (pOffTrackedRemoteOld->Joystick.y < 0.7f & ready_teleport) {
} else if (pSecondaryTrackedRemoteOld->Joystick.y < 0.7f & ready_teleport) {
ready_teleport = false;
trigger_teleport = true;
resetDoomYaw = true;
@ -177,10 +193,10 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Apply a filter and quadratic scaler so small movements are easier to make
//and we don't get movement jitter when the joystick doesn't quite center properly
float dist = length(pOffTrackedRemoteNew->Joystick.x, pOffTrackedRemoteNew->Joystick.y);
float dist = length(pSecondaryTrackedRemoteNew->Joystick.x, pSecondaryTrackedRemoteNew->Joystick.y);
float nlf = nonLinearFilter(dist);
float x = nlf * pOffTrackedRemoteNew->Joystick.x;
float y = nlf * pOffTrackedRemoteNew->Joystick.y;
float x = nlf * pSecondaryTrackedRemoteNew->Joystick.x;
float y = nlf * pSecondaryTrackedRemoteNew->Joystick.y;
//Apply a simple deadzone
player_moving = (fabs(x) + fabs(y)) > 0.05f;
@ -199,7 +215,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
// Turning logic
static int increaseSnap = true;
if (pDominantTrackedRemoteNew->Joystick.x > 0.6f) {
if (pPrimaryTrackedRemoteNew->Joystick.x > 0.6f) {
if (increaseSnap) {
resetDoomYaw = true;
snapTurn -= vr_snapturn_angle;
@ -211,12 +227,12 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
snapTurn += 360.f;
}
}
} else if (pDominantTrackedRemoteNew->Joystick.x < 0.4f) {
} else if (pPrimaryTrackedRemoteNew->Joystick.x < 0.4f) {
increaseSnap = true;
}
static int decreaseSnap = true;
if (pDominantTrackedRemoteNew->Joystick.x < -0.6f) {
if (pPrimaryTrackedRemoteNew->Joystick.x < -0.6f) {
if (decreaseSnap) {
resetDoomYaw = true;
snapTurn += vr_snapturn_angle;
@ -230,7 +246,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
snapTurn -= 360.f;
}
}
} else if (pDominantTrackedRemoteNew->Joystick.x > -0.4f) {
} else if (pPrimaryTrackedRemoteNew->Joystick.x > -0.4f) {
decreaseSnap = true;
}
}
@ -239,13 +255,13 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Now handle all the buttons - irrespective of menu state - we might be trying to remap stuff
{
{
//Weapon Chooser - This _could_ be remapped
//Default this is Weapon Chooser - This _could_ be remapped
static int itemSwitched = 0;
if (between(-0.2f, pDominantTrackedRemoteNew->Joystick.x, 0.2f) &&
(between(0.8f, pDominantTrackedRemoteNew->Joystick.y, 1.0f) ||
between(-1.0f, pDominantTrackedRemoteNew->Joystick.y, -0.8f))) {
if (between(-0.2f, pPrimaryTrackedRemoteNew->Joystick.x, 0.2f) &&
(between(0.8f, pPrimaryTrackedRemoteNew->Joystick.y, 1.0f) ||
between(-1.0f, pPrimaryTrackedRemoteNew->Joystick.y, -0.8f))) {
if (itemSwitched == 0) {
if (between(0.8f, pDominantTrackedRemoteNew->Joystick.y, 1.0f)) {
if (between(0.8f, pPrimaryTrackedRemoteNew->Joystick.y, 1.0f)) {
Joy_GenerateButtonEvents(0, 1, 1, KEY_MWHEELDOWN);
itemSwitched = 1;
} else {
@ -261,6 +277,32 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
itemSwitched = 0;
}
}
//If snap turn set to 0, then we can use left/right on the stick as mappable functions
if (vr_snapturn_angle == 0.0)
{
static int invSwitched = 0;
if (between(-0.2f, pPrimaryTrackedRemoteNew->Joystick.y, 0.2f) &&
(between(0.8f, pPrimaryTrackedRemoteNew->Joystick.x, 1.0f) ||
between(-1.0f, pPrimaryTrackedRemoteNew->Joystick.x, -0.8f))) {
if (invSwitched == 0) {
if (between(0.8f, pPrimaryTrackedRemoteNew->Joystick.x, 1.0f)) {
Joy_GenerateButtonEvents(0, 1, 1, KEY_MWHEELLEFT);
invSwitched = 1;
} else {
Joy_GenerateButtonEvents(0, 1, 1, KEY_MWHEELRIGHT);
invSwitched = 2;
}
}
} else {
if (invSwitched == 1) {
Joy_GenerateButtonEvents(1, 0, 1, KEY_MWHEELLEFT);
} else if (invSwitched == 2) {
Joy_GenerateButtonEvents(1, 0, 1, KEY_MWHEELRIGHT);
}
invSwitched = 0;
}
}

View file

@ -66,6 +66,7 @@ EXTERN_CVAR(Float, vr_snapTurn);
EXTERN_CVAR(Float, vr_ipd);
EXTERN_CVAR(Float, vr_weaponScale);
EXTERN_CVAR(Bool, vr_teleport);
EXTERN_CVAR(Bool, vr_switch_sticks);
//HUD control
EXTERN_CVAR(Float, vr_hud_scale);
@ -421,6 +422,7 @@ namespace s3d
//set some variables - lazy, should do it properly..
vr_weapon_pitchadjust = vr_weaponRotate;
vr_snapturn_angle = vr_snapTurn;
vr_switchsticks = vr_switch_sticks;
vr_moveuseoffhand = !vr_move_use_offhand;
vr_use_teleport = vr_teleport;
QzDoom_getTrackedRemotesOrientation(vr_control_scheme);

View file

@ -66,6 +66,7 @@ CVAR(Float, vr_weaponScale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_snapTurn, 45.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, vr_move_speed, 24, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_run_multiplier, 1.6, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_switch_sticks, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_pickup_haptic_level, 0.2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_quake_haptic_level, 0.8, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)

View file

@ -41,7 +41,7 @@ const char *GetVersionString();
/** Lots of different version numbers **/
#define VERSIONSTR "QuestZDoom Beta-0.3 - LZDoom 3.83a"
#define VERSIONSTR "QuestZDoom Beta-0.4 - LZDoom 3.83a"
// The version as seen in the Windows resource
#define RC_FILEVERSION 3,83,1

View file

@ -2281,6 +2281,7 @@ OptionMenu VROptionsMenu protected
StaticText " "
Option "Control Scheme", "vr_control_scheme", "ControlScheme"
Option "Switch Thumsticks", "vr_switch_sticks", "OnOff"
Option "Off-hand Move Direction", "vr_move_use_offhand", "OffOn"
Option "Use Teleport", "vr_teleport", "OnOff"
Slider "Snap-turn Angle", "vr_snapTurn", 0.0, 90.0, 1.0, 2

Binary file not shown.