Improved dual saber haptics

This commit is contained in:
Simon 2023-04-20 19:55:48 +01:00
parent 34bb30d714
commit 9202d2896e
6 changed files with 161 additions and 108 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.jkxr"
android:versionCode="51"
android:versionName="1.0.1" android:installLocation="auto" >
android:versionCode="52"
android:versionName="1.1.0" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030002" android:required="true"/>

View File

@ -504,10 +504,7 @@ void VR_HapticEvent(const char* event, int position, int flags, int intensity, f
//Controller Haptic Support
int weaponFireChannel = vr.weapon_stabilised ? 3 : (vr_control_scheme->integer ? 2 : 1);
if (cl.frame.ps.weapon == WP_SABER && vr.dualsabers)
{
weaponFireChannel = 3;
}
if (flags != 0)
{
weaponFireChannel = flags;
@ -530,8 +527,34 @@ void VR_HapticEvent(const char* event, int position, int flags, int intensity, f
{
TBXR_Vibrate(150, 3, fIntensity);
}
else if (strcmp(event, "chainsaw_fire") == 0 ||
strcmp(event, "RTCWQuest:fire_tesla") == 0)
else if (strcmp(event, "chainsaw_fire") == 0) // Saber
{
//Special handling for dual sabers
if (vr.dualsabers)
{
if (position == 4 ||
position == 0) // both hands
{
weaponFireChannel = 3;
}
else if (position == 1) // left hand
{
weaponFireChannel = 2;
}
else if (position == 2) // right hand
{
weaponFireChannel = 1;
}
else
{
//no longer need to trigger haptic
return;
}
}
TBXR_Vibrate(200, weaponFireChannel, fIntensity);
}
else if (strcmp(event, "RTCWQuest:fire_tesla") == 0) // Weapon power build up
{
TBXR_Vibrate(500, weaponFireChannel, fIntensity);
}

View File

@ -42,8 +42,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
vr_control_scheme->value == 99; // Always right-handed for weapon calibration
static bool dominantGripPushed = false;
static bool canUseBackpack = false;
static bool canUseQuickSave = false;
//Need this for the touch screen
ovrTrackedController * pWeapon = pDominantTracking;
@ -829,22 +827,18 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
remote_movementForward);
if (!canUseQuickSave) {
if (((secondaryButtonsNew & secondaryButton1) !=
(secondaryButtonsOld & secondaryButton1)) &&
(secondaryButtonsNew & secondaryButton1)) {
//Toggle walk/run somehow?!
vr.move_speed = (++vr.move_speed) % 3;
}
if (((secondaryButtonsNew & secondaryButton1) !=
(secondaryButtonsOld & secondaryButton1)) &&
(secondaryButtonsNew & secondaryButton1)) {
//Toggle walk/run somehow?!
vr.move_speed = (++vr.move_speed) % 3;
}
//Open the datapad
if (!canUseQuickSave) {
if (((secondaryButtonsNew & secondaryButton2) !=
(secondaryButtonsOld & secondaryButton2)) &&
(secondaryButtonsNew & secondaryButton2)) {
Sys_QueEvent(0, SE_KEY, A_TAB, true, 0, NULL);
}
if (((secondaryButtonsNew & secondaryButton2) !=
(secondaryButtonsOld & secondaryButton2)) &&
(secondaryButtonsNew & secondaryButton2)) {
Sys_QueEvent(0, SE_KEY, A_TAB, true, 0, NULL);
}
//Use Force - off hand trigger

View File

@ -1460,8 +1460,8 @@ void CG_AddViewWeapon( playerState_t *ps )
val = 1.0f;
}
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2);
cgi_HapticEvent("chainsaw_fire", position, 0, 60 * val, 0, 0);
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 2 : 1);
cgi_HapticEvent("RTCWQuest:fire_tesla", position, 0, 60 * val, 0, 0);
val += Q_flrand(0.0f, 1.0f) * 0.5f;
@ -3454,92 +3454,119 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire )
//Are we the player?
if (cent->gent->client->ps.clientNum == 0)
{
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2);
/*
These are specific to external haptics vest/arms/face combinations
position values:
0 - Will play on vest and both arms if pattern files present for both
1 - Will play on (left) vest and on left arm only if pattern files present for left
2 - Will play on (right) vest and on right arm only if pattern files present for right
3 - Will play on head only (if present)
4 - Will play on all devices (that have a pattern defined for them)
*/
int position = vr->weapon_stabilised ? 0 : (vr->right_handed ? 2 : 1);
//Haptics
switch (ent->weapon) {
case WP_SABER:
if (cent->gent->client->ps.dualSabers) position = 4;
cgi_HapticEvent("chainsaw_fire", position, 0, 40, 0, 0);
break;
case WP_BRYAR_PISTOL:
case WP_BOWCASTER:
case WP_BLASTER:
case WP_ATST_MAIN:
cgi_HapticEvent("machinegun_fire", position, 0, (ent->weapon == WP_BRYAR_PISTOL) ? 60 : 100, 0, 0);
break;
case WP_BLASTER_PISTOL:
cgi_HapticEvent("shotgun_fire", position, 0, 100, 0, 0);
break;
case WP_THERMAL:
case WP_DET_PACK:
case WP_TRIP_MINE:
cgi_HapticEvent("handgrenade_fire", position, 0, 80, 0, 0);
break;
case WP_ROCKET_LAUNCHER:
case WP_ATST_SIDE:
cgi_HapticEvent("rocket_fire", position, 0, 100, 0, 0);
break;
case WP_DISRUPTOR:
cgi_HapticEvent("RTCWQuest:fire_sniper", position, 0, 100, 0, 0);
break;
case WP_FLECHETTE:
case WP_REPEATER:
cgi_HapticEvent("plasmagun_fire", position, 0, 100, 0, 0);
break;
case WP_DEMP2:
case WP_EMPLACED_GUN:
cgi_HapticEvent("bfg_fire", position, 0, 100, 0, 0);
break;
}
//Haptics
switch (ent->weapon) {
case WP_SABER:
if (cent->gent->client->ps.dualSabers)
{
if (vr->primaryVelocityTriggeredAttack && vr->secondaryVelocityTriggeredAttack)
{
position = 4;
}
else if (vr->primaryVelocityTriggeredAttack)
{
position = (vr->right_handed ? 2 : 1);
}
else if (vr->secondaryVelocityTriggeredAttack) // secondary triggered
{
position = (vr->right_handed ? 1 : 2);
}
else
{
position = -1;
}
}
cgi_HapticEvent("chainsaw_fire", position, 0, 40, 0, 0);
break;
case WP_BRYAR_PISTOL:
case WP_BOWCASTER:
case WP_BLASTER:
case WP_ATST_MAIN:
cgi_HapticEvent("machinegun_fire", position, 0, (ent->weapon == WP_BRYAR_PISTOL) ? 60 : 100, 0, 0);
break;
case WP_BLASTER_PISTOL:
cgi_HapticEvent("shotgun_fire", position, 0, 100, 0, 0);
break;
case WP_THERMAL:
case WP_DET_PACK:
case WP_TRIP_MINE:
cgi_HapticEvent("handgrenade_fire", position, 0, 80, 0, 0);
break;
case WP_ROCKET_LAUNCHER:
case WP_ATST_SIDE:
cgi_HapticEvent("rocket_fire", position, 0, 100, 0, 0);
break;
case WP_DISRUPTOR:
cgi_HapticEvent("RTCWQuest:fire_sniper", position, 0, 100, 0, 0);
break;
case WP_FLECHETTE:
case WP_REPEATER:
cgi_HapticEvent("plasmagun_fire", position, 0, 100, 0, 0);
break;
case WP_DEMP2:
case WP_EMPLACED_GUN:
cgi_HapticEvent("bfg_fire", position, 0, 100, 0, 0);
break;
}
}
}
// Do overcharge sound that get's added to the top
/* if (( ent->powerups & ( 1<<PW_WEAPON_OVERCHARGE )))
{
if ( alt_fire )
{
switch( ent->weapon )
{
case WP_THERMAL:
case WP_DET_PACK:
case WP_TRIP_MINE:
case WP_ROCKET_LAUNCHER:
case WP_FLECHETTE:
// these weapon fires don't overcharge
break;
// Do overcharge sound that get's added to the top
/* if (( ent->powerups & ( 1<<PW_WEAPON_OVERCHARGE )))
{
if ( alt_fire )
{
switch( ent->weapon )
{
case WP_THERMAL:
case WP_DET_PACK:
case WP_TRIP_MINE:
case WP_ROCKET_LAUNCHER:
case WP_FLECHETTE:
// these weapon fires don't overcharge
break;
case WP_BLASTER:
cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeFastSound );
break;
case WP_BLASTER:
cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeFastSound );
break;
default:
cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeSlowSound );
break;
}
}
else
{
switch( ent->weapon )
{
case WP_THERMAL:
case WP_DET_PACK:
case WP_TRIP_MINE:
case WP_ROCKET_LAUNCHER:
// these weapon fires don't overcharge
break;
default:
cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeSlowSound );
break;
}
}
else
{
switch( ent->weapon )
{
case WP_THERMAL:
case WP_DET_PACK:
case WP_TRIP_MINE:
case WP_ROCKET_LAUNCHER:
// these weapon fires don't overcharge
break;
case WP_REPEATER:
cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeFastSound );
break;
case WP_REPEATER:
cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeFastSound );
break;
default:
cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeSlowSound );
break;
}
}
}*/
default:
cgi_S_StartSound( NULL, ent->number, CHAN_AUTO, cgs.media.overchargeSlowSound );
break;
}
}
}*/
}
/*

View File

@ -23,7 +23,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
// Current version of the single player game
#include "../win32/AutoVersion.h"
#define JKXR_VERSION "1.0.1-ea"
#define JKXR_VERSION "1.1.0-ea"
#ifdef _DEBUG
#define Q3_VERSION "(debug)OpenJK: v" VERSION_STRING_DOTTED " JKXR: " JKXR_VERSION

View File

@ -1349,8 +1349,8 @@ void CG_AddViewWeapon( playerState_t *ps )
val = 1.0f;
}
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2);
cgi_HapticEvent("chainsaw_fire", position, 0, 60 * val, 0, 0);
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 2 : 1);
cgi_HapticEvent("RTCWQuest:fire_tesla", position, 0, 60 * val, 0, 0);
val += Q_flrand(0.0f, 1.0f) * 0.5f;
@ -3295,7 +3295,16 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire )
//Are we the player?
if (cent->gent->client->ps.clientNum == 0)
{
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2);
/*
These are specific to external haptics vest/arms/face combinations
position values:
0 - Will play on vest and both arms if pattern files present for both
1 - Will play on (left) vest and on left arm only if pattern files present for left
2 - Will play on (right) vest and on right arm only if pattern files present for right
3 - Will play on head only (if present)
4 - Will play on all devices (that have a pattern defined for them)
*/
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 2 : 1);
//Haptics
switch (ent->weapon) {