Additional Left Handed Control Scheme

Switched Sticks for alternative left hand control
Reduced the supersampling default
This commit is contained in:
Simon 2021-01-24 15:34:15 +00:00
parent f39d4ebde2
commit cb1c8d1397
9 changed files with 124 additions and 75 deletions

View file

@ -4,8 +4,8 @@
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":VrSamples:Quake2Quest:Projects:Android" />
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" value="3.2.0" />
<option name="LAST_KNOWN_AGP_VERSION" value="3.2.0" />
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" value="3.5.3" />
<option name="LAST_KNOWN_AGP_VERSION" value="3.5.3" />
</configuration>
</facet>
<facet type="native-android-gradle" name="Native-Android-Gradle">
@ -30,8 +30,8 @@
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/compileDebugUnitTestJavaWithJavac/classes" />
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/jni/SupportLibs/SDL2/SDL2/src" isTestSource="false" />
@ -122,19 +122,19 @@
<sourceFolder url="file://$MODULE_DIR$/jni/quake2/src/game/savegame" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/jni/quake2/src/client/refresh/files" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/jni/quake2/src/client/refresh/gl1" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />

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.quake2quest"
android:versionCode="17"
android:versionName="1.0.6" android:installLocation="auto" >
android:versionCode="18"
android:versionName="1.0.7" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>

View file

@ -80,7 +80,7 @@ PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
int CPU_LEVEL = 4;
int GPU_LEVEL = 4;
int NUM_MULTI_SAMPLES = 1;
float SS_MULTIPLIER = 1.25f;
float SS_MULTIPLIER = 1.2f;
vec2_t cylinderSize = {1280, 720};
@ -109,6 +109,7 @@ extern cvar_t *cl_paused;
enum control_scheme {
RIGHT_HANDED_DEFAULT = 0,
LEFT_HANDED_DEFAULT = 10,
LEFT_HANDED_SWITCH_STICKS = 11,
GAMEPAD = 20 //Not implemented, someone else can do this!
};
@ -1645,12 +1646,16 @@ void * AppThreadFunction( void * parm )
ovrButton_A, ovrButton_B, ovrButton_X, ovrButton_Y);
break;
case LEFT_HANDED_DEFAULT:
case LEFT_HANDED_SWITCH_STICKS:
HandleInput_Default(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, &leftRemoteTracking_new,
&rightTrackedRemoteState_new, &rightTrackedRemoteState_old, &rightRemoteTracking_new,
ovrButton_X, ovrButton_Y, ovrButton_A, ovrButton_B);
break;
}
rightTrackedRemoteState_old = rightTrackedRemoteState_new;
leftTrackedRemoteState_old = leftTrackedRemoteState_new;
static bool usingScreenLayer = true; //Starts off using the screen layer
if (usingScreenLayer != useScreenLayer())
{

View file

@ -61,6 +61,6 @@ bool between(float min, float val, float max);
void rotateAboutOrigin(float v1, float v2, float rotation, vec2_t out);
void QuatToYawPitchRoll(ovrQuatf q, float pitchAdjust, vec3_t out);
bool useScreenLayer();
void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteState, ovrInputStateTrackedRemote * prevTrackedRemoteState, uint32_t button, int key);
void handleTrackedControllerButton(u_int32_t buttonsNew, u_int32_t buttonsOld, uint32_t button, int key);
#endif //vrcommon_h

View file

@ -18,11 +18,11 @@ Authors : Simon Brown
//keys.h
void Key_Event (int key, qboolean down, unsigned time);
void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteState, ovrInputStateTrackedRemote * prevTrackedRemoteState, uint32_t button, int key)
void handleTrackedControllerButton(u_int32_t buttonsNew, u_int32_t buttonsOld, uint32_t button, int key)
{
if ((trackedRemoteState->Buttons & button) != (prevTrackedRemoteState->Buttons & button))
if ((buttonsNew & button) != (buttonsOld & button))
{
Key_Event(key, (trackedRemoteState->Buttons & button) != 0, global_time);
Key_Event(key, (buttonsNew & button) != 0, global_time);
}
}

View file

@ -23,6 +23,7 @@ cvar_t *sv_cheats;
extern cvar_t *vr_weapon_stabilised;
void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
int domButton1, int domButton2, int offButton1, int offButton2 )
@ -31,6 +32,55 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Ensure handedness is set correctly
Cvar_Set("hand", vr_control_scheme->value < 10 ? "0" : "1");
//All this to allow stick and button switching!
ovrVector2f primaryJoystickNew;
ovrVector2f primaryJoystickOld;
ovrVector2f secondaryJoystickNew;
ovrVector2f secondaryJoystickOld;
uint32_t primaryButtonsNew;
uint32_t primaryButtonsOld;
uint32_t secondaryButtonsNew;
uint32_t secondaryButtonsOld;
int primaryButton1;
int primaryButton2;
int secondaryButton1;
int secondaryButton2;
if (vr_control_scheme->value == 11) // Left handed (swtiched sticks)
{
primaryJoystickNew = pOffTrackedRemoteNew->Joystick;
primaryJoystickOld = pOffTrackedRemoteOld->Joystick;
secondaryJoystickNew = pDominantTrackedRemoteNew->Joystick;
secondaryJoystickOld = pDominantTrackedRemoteOld->Joystick;
primaryButtonsNew = pOffTrackedRemoteNew->Buttons;
primaryButtonsOld = pOffTrackedRemoteOld->Buttons;
secondaryButtonsNew = pDominantTrackedRemoteNew->Buttons;
secondaryButtonsOld = pDominantTrackedRemoteOld->Buttons;
primaryButton1 = offButton1;
primaryButton2 = offButton2;
secondaryButton1 = domButton1;
secondaryButton2 = domButton2;
}
else // Left and right handed
{
primaryJoystickNew = pDominantTrackedRemoteNew->Joystick;
primaryJoystickOld = pDominantTrackedRemoteOld->Joystick;
secondaryJoystickNew = pOffTrackedRemoteNew->Joystick;
secondaryJoystickOld = pOffTrackedRemoteOld->Joystick;
primaryButtonsNew = pDominantTrackedRemoteNew->Buttons;
primaryButtonsOld = pDominantTrackedRemoteOld->Buttons;
secondaryButtonsNew = pOffTrackedRemoteNew->Buttons;
secondaryButtonsOld = pOffTrackedRemoteOld->Buttons;
primaryButton1 = domButton1;
primaryButton2 = domButton2;
secondaryButton1 = offButton1;
secondaryButton2 = offButton2;
}
//Get the cvar
sv_cheats = Cvar_Get("cheats", "0", CVAR_ARCHIVE);
@ -38,31 +88,32 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
static float dominantGripPushTime = 0.0f;
static qboolean inventoryManagementMode = false;
//Menu button
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, K_ESCAPE);
//Menu button - _can_ appear on either controller if user has switched them in the oculus menu
handleTrackedControllerButton(primaryButtonsNew, primaryButtonsOld, ovrButton_Enter, K_ESCAPE);
handleTrackedControllerButton(secondaryButtonsNew, secondaryButtonsOld, ovrButton_Enter, K_ESCAPE);
if (cls.key_dest == key_menu)
{
int leftJoyState = (pOffTrackedRemoteNew->Joystick.x > 0.7f ? 1 : 0);
if (leftJoyState != (pOffTrackedRemoteOld->Joystick.x > 0.7f ? 1 : 0)) {
int leftJoyState = (secondaryJoystickNew.x > 0.7f ? 1 : 0);
if (leftJoyState != (secondaryJoystickOld.x > 0.7f ? 1 : 0)) {
Key_Event(K_RIGHTARROW, leftJoyState, global_time);
}
leftJoyState = (pOffTrackedRemoteNew->Joystick.x < -0.7f ? 1 : 0);
if (leftJoyState != (pOffTrackedRemoteOld->Joystick.x < -0.7f ? 1 : 0)) {
leftJoyState = (secondaryJoystickNew.x < -0.7f ? 1 : 0);
if (leftJoyState != (secondaryJoystickOld.x < -0.7f ? 1 : 0)) {
Key_Event(K_LEFTARROW, leftJoyState, global_time);
}
leftJoyState = (pOffTrackedRemoteNew->Joystick.y < -0.7f ? 1 : 0);
if (leftJoyState != (pOffTrackedRemoteOld->Joystick.y < -0.7f ? 1 : 0)) {
leftJoyState = (secondaryJoystickNew.y < -0.7f ? 1 : 0);
if (leftJoyState != (secondaryJoystickOld.y < -0.7f ? 1 : 0)) {
Key_Event(K_DOWNARROW, leftJoyState, global_time);
}
leftJoyState = (pOffTrackedRemoteNew->Joystick.y > 0.7f ? 1 : 0);
if (leftJoyState != (pOffTrackedRemoteOld->Joystick.y > 0.7f ? 1 : 0)) {
leftJoyState = (secondaryJoystickNew.y > 0.7f ? 1 : 0);
if (leftJoyState != (secondaryJoystickOld.y > 0.7f ? 1 : 0)) {
Key_Event(K_UPARROW, leftJoyState, global_time);
}
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton1, K_ENTER);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_ENTER);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, K_ESCAPE);
handleTrackedControllerButton(primaryButtonsNew, primaryButtonsOld, primaryButton1, K_ENTER);
handleTrackedControllerButton(primaryButtonsNew, primaryButtonsOld, ovrButton_Trigger, K_ENTER);
handleTrackedControllerButton(primaryButtonsNew, primaryButtonsOld, primaryButton2, K_ESCAPE);
}
else
{
@ -120,11 +171,11 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
}
if ((pOffTrackedRemoteNew->Buttons & offButton2) !=
(pOffTrackedRemoteOld->Buttons & offButton2))
if ((secondaryButtonsNew & secondaryButton2) !=
(secondaryButtonsOld & secondaryButton2))
{
sendButtonActionSimple("inven");
inventoryManagementMode = (pOffTrackedRemoteNew->Buttons & offButton2) > 0;
inventoryManagementMode = (secondaryButtonsNew & secondaryButton2) > 0;
}
}
@ -153,13 +204,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
}
//Right-hand specific stuff
{
ALOGV(" Right-Controller-Position: %f, %f, %f",
pDominantTracking->HeadPose.Pose.Position.x,
pDominantTracking->HeadPose.Pose.Position.y,
pDominantTracking->HeadPose.Pose.Position.z);
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the
//player is facing for positional tracking
float multiplier = (vr_positional_factor->value) / (cl_forwardspeed->value *
@ -176,8 +221,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
positional_movementForward);
//Jump (B Button)
handleTrackedControllerButton(pDominantTrackedRemoteNew,
pDominantTrackedRemoteOld, domButton2, K_SPACE);
handleTrackedControllerButton(primaryButtonsNew,
primaryButtonsOld, primaryButton2, K_SPACE);
//We need to record if we have started firing primary so that releasing trigger will stop firing, if user has pushed grip
//in meantime, then it wouldn't stop the gun firing and it would get stuck
@ -203,21 +248,21 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
//Duck with A
if ((pDominantTrackedRemoteNew->Buttons & domButton1) !=
(pDominantTrackedRemoteOld->Buttons & domButton1) &&
if ((primaryButtonsNew & primaryButton1) !=
(primaryButtonsOld & primaryButton1) &&
ducked != DUCK_CROUCHED) {
ducked = (pDominantTrackedRemoteNew->Buttons & domButton1) ? DUCK_BUTTON : DUCK_NOTDUCKED;
sendButtonAction("+movedown", (pDominantTrackedRemoteNew->Buttons & domButton1));
ducked = (primaryButtonsNew & primaryButton1) ? DUCK_BUTTON : DUCK_NOTDUCKED;
sendButtonAction("+movedown", (primaryButtonsNew & primaryButton1));
}
//Weapon/Inventory Chooser
static qboolean itemSwitched = false;
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, primaryJoystickNew.x, 0.2f) &&
(between(0.8f, primaryJoystickNew.y, 1.0f) ||
between(-1.0f, primaryJoystickNew.y, -0.8f)))
{
if (!itemSwitched) {
if (between(0.8f, pDominantTrackedRemoteNew->Joystick.y, 1.0f))
if (between(0.8f, primaryJoystickNew.y, 1.0f))
{
if (inventoryManagementMode)
{
@ -247,13 +292,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
}
//Left-hand specific stuff
{
ALOGV(" Left-Controller-Position: %f, %f, %f",
pOffTracking->HeadPose.Pose.Position.x,
pOffTracking->HeadPose.Pose.Position.y,
pOffTracking->HeadPose.Pose.Position.z);
//Laser-sight
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Joystick)
@ -268,10 +307,10 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
//Apply a filter and quadratic scaler so small movements are easier to make
float dist = length(pOffTrackedRemoteNew->Joystick.x, pOffTrackedRemoteNew->Joystick.y);
float dist = length(secondaryJoystickNew.x, secondaryJoystickNew.y);
float nlf = nonLinearFilter(dist);
float x = nlf * pOffTrackedRemoteNew->Joystick.x;
float y = nlf * pOffTrackedRemoteNew->Joystick.y;
float x = nlf * secondaryJoystickNew.x;
float y = nlf * secondaryJoystickNew.y;
player_moving = (fabs(x) + fabs(y)) > 0.05f;
@ -287,8 +326,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//show help computer while X/A pressed
if ((pOffTrackedRemoteNew->Buttons & offButton1) !=
(pOffTrackedRemoteOld->Buttons & offButton1)) {
if ((secondaryButtonsNew & secondaryButton1) !=
(secondaryButtonsOld & secondaryButton1)) {
sendButtonActionSimple("cmd help");
}
@ -307,15 +346,14 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//We need to record if we have started firing primary so that releasing trigger will stop definitely firing, if user has pushed grip
//in meantime, then it wouldn't stop the gun firing and it would get stuck
static bool firingPrimary = false;
//Run
handleTrackedControllerButton(pOffTrackedRemoteNew,
pOffTrackedRemoteOld,
handleTrackedControllerButton(pOffTrackedRemoteNew->Buttons,
pOffTrackedRemoteOld->Buttons,
ovrButton_Trigger, K_SHIFT);
static int increaseSnap = true;
if (pDominantTrackedRemoteNew->Joystick.x > 0.6f)
if (primaryJoystickNew.x > 0.6f)
{
if (increaseSnap)
{
@ -329,12 +367,12 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
snapTurn += 360.f;
}
}
} else if (pDominantTrackedRemoteNew->Joystick.x < 0.4f) {
} else if (primaryJoystickNew.x < 0.4f) {
increaseSnap = true;
}
static int decreaseSnap = true;
if (pDominantTrackedRemoteNew->Joystick.x < -0.6f)
if (primaryJoystickNew.x < -0.6f)
{
if (decreaseSnap)
{
@ -350,14 +388,10 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
snapTurn -= 360.f;
}
}
} else if (pDominantTrackedRemoteNew->Joystick.x > -0.4f)
} else if (primaryJoystickNew.x > -0.4f)
{
decreaseSnap = true;
}
}
}
//Save state
rightTrackedRemoteState_old = rightTrackedRemoteState_new;
leftTrackedRemoteState_old = leftTrackedRemoteState_new;
}

View file

@ -1149,7 +1149,16 @@ ControlsResetDefaultsFunc(void *unused)
static void
HandednessFunc(void *unused)
{
Cvar_SetValue("vr_control_scheme", s_options_handedness_box.curvalue == 0 ? 0 : 10);
float value = 0;
if (s_options_handedness_box.curvalue == 1)
{
value = 10;
}
else if (s_options_handedness_box.curvalue == 2)
{
value = 11;
}
Cvar_SetValue("vr_control_scheme", value);
}
static void
@ -1366,6 +1375,7 @@ Options_MenuInit(void)
static const char *handedness[] = {
"Right-Handed",
"Left-Handed",
"Left-Handed (Switched Sticks)",
0
};

View file

@ -32,7 +32,7 @@
#include "shared.h"
#include "crc.h"
#define Q2QVERSION "1.0.6"
#define Q2QVERSION "1.0.7"
#define YQ2VERSION "7.41"
#define BASEDIRNAME "Quake2Quest"

View file

@ -1 +1 @@
quake2 --supersampling 1.4
quake2