mirror of
https://github.com/DrBeef/Quake2Quest.git
synced 2025-03-01 06:30:52 +00:00
Haptic Feedback
This commit is contained in:
parent
5f58850ba4
commit
e02d468904
11 changed files with 121 additions and 10 deletions
|
@ -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="3"
|
||||
android:versionName="0.3.0" android:installLocation="auto" >
|
||||
android:versionCode="4"
|
||||
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"/>
|
||||
|
|
|
@ -838,6 +838,29 @@ qboolean isMultiplayer()
|
|||
return Cvar_VariableValue("maxclients") > 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================
|
||||
Android_Vibrate
|
||||
========================
|
||||
*/
|
||||
|
||||
//0 = left, 1 = right
|
||||
float vibration_channel_duration[2] = {0.0f, 0.0f};
|
||||
float vibration_channel_intensity[2] = {0.0f, 0.0f};
|
||||
|
||||
void Android_Vibrate( float duration, int channel, float intensity )
|
||||
{
|
||||
if (vibration_channel_duration[channel] > 0.0f)
|
||||
return;
|
||||
|
||||
if (vibration_channel_duration[channel] == -1.0f && duration != 0.0f)
|
||||
return;
|
||||
|
||||
vibration_channel_duration[channel] = duration;
|
||||
vibration_channel_intensity[channel] = intensity;
|
||||
}
|
||||
|
||||
void Qcommon_BeginFrame (int time);
|
||||
void Qcommon_Frame (int eye);
|
||||
void Qcommon_EndFrame (int time);
|
||||
|
@ -1319,13 +1342,10 @@ void VR_Init()
|
|||
vr_walkdirection = Cvar_Get( "vr_walkdirection", "0", CVAR_ARCHIVE);
|
||||
vr_weapon_pitchadjust = Cvar_Get( "vr_weapon_pitchadjust", "-20.0", CVAR_ARCHIVE);
|
||||
vr_weapon_recoil = Cvar_Get( "vr_weapon_recoil", "0", CVAR_ARCHIVE);
|
||||
vr_weapon_stabilised = Cvar_Get( "vr_weapon_stabilised", "0", 0);
|
||||
vr_lasersight = Cvar_Get( "vr_lasersight", "0", CVAR_ARCHIVE);
|
||||
vr_control_scheme = Cvar_Get( "vr_control_scheme", "0", CVAR_ARCHIVE);
|
||||
vr_enable_crouching = Cvar_Get( "vr_enable_crouching", "0.85", CVAR_ARCHIVE);
|
||||
vr_height_adjust = Cvar_Get( "vr_height_adjust", "0.0", CVAR_ARCHIVE);
|
||||
vr_flashlight_model = Cvar_Get( "vr_flashlight_model", "1", CVAR_ARCHIVE);
|
||||
vr_mirror_weapons = Cvar_Get( "vr_mirror_weapons", "0", CVAR_ARCHIVE);
|
||||
vr_weaponscale = Cvar_Get( "vr_weaponscale", "0.6", CVAR_ARCHIVE);
|
||||
|
||||
//The Engine (which is a derivative of Quake) uses a very specific unit size:
|
||||
|
@ -1505,6 +1525,31 @@ void * AppThreadFunction( void * parm )
|
|||
vrapi_SubmitFrame2( appState.Ovr, &frameDesc );
|
||||
}
|
||||
|
||||
//Handle haptics
|
||||
static float lastFrameTime = 0.0f;
|
||||
float timestamp = (float)(GetTimeInMilliSeconds());
|
||||
float frametime = timestamp - lastFrameTime;
|
||||
lastFrameTime = timestamp;
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (vibration_channel_duration[i] > 0.0f ||
|
||||
vibration_channel_duration[i] == -1.0f) {
|
||||
vrapi_SetHapticVibrationSimple(appState.Ovr, controllerIDs[i],
|
||||
vibration_channel_intensity[i]);
|
||||
|
||||
if (vibration_channel_duration[i] != -1.0f) {
|
||||
vibration_channel_duration[i] -= frametime;
|
||||
|
||||
if (vibration_channel_duration[i] < 0.0f) {
|
||||
vibration_channel_duration[i] = 0.0f;
|
||||
vibration_channel_intensity[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
vrapi_SetHapticVibrationSimple(appState.Ovr, controllerIDs[i], 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
if (runStatus == -1) {
|
||||
#ifndef NDEBUG
|
||||
if (appState.FrameIndex > 10800)
|
||||
|
|
|
@ -4,12 +4,9 @@ cvar_t *vr_positional_factor;
|
|||
cvar_t *vr_walkdirection;
|
||||
cvar_t *vr_weapon_pitchadjust;
|
||||
cvar_t *vr_weapon_recoil;
|
||||
cvar_t *vr_weapon_stabilised;
|
||||
cvar_t *vr_lasersight;
|
||||
cvar_t *vr_control_scheme;
|
||||
cvar_t *vr_enable_crouching;
|
||||
cvar_t *vr_height_adjust;
|
||||
cvar_t *vr_flashlight_model;
|
||||
cvar_t *vr_mirror_weapons;
|
||||
cvar_t *vr_worldscale;
|
||||
cvar_t *vr_weaponscale;
|
||||
|
|
|
@ -15,6 +15,8 @@ ovrInputStateTrackedRemote rightTrackedRemoteState_old;
|
|||
ovrInputStateTrackedRemote rightTrackedRemoteState_new;
|
||||
ovrTracking rightRemoteTracking_new;
|
||||
|
||||
ovrDeviceID controllerIDs[2];
|
||||
|
||||
float remote_movementSideways;
|
||||
float remote_movementForward;
|
||||
float remote_movementUp;
|
||||
|
|
|
@ -128,9 +128,11 @@ void acquireTrackedRemotesData(const ovrMobile *Ovr, double displayTime) {//The
|
|||
if (remoteCapabilities.ControllerCapabilities & ovrControllerCaps_RightHand) {
|
||||
rightTrackedRemoteState_new = trackedRemoteState;
|
||||
rightRemoteTracking_new = remoteTracking;
|
||||
controllerIDs[1] = cap.DeviceID;
|
||||
} else{
|
||||
leftTrackedRemoteState_new = trackedRemoteState;
|
||||
leftRemoteTracking_new = remoteTracking;
|
||||
controllerIDs[0] = cap.DeviceID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
static qboolean dominantGripPushed = false;
|
||||
static float dominantGripPushTime = 0.0f;
|
||||
static qboolean inventoryManagementMode = false;
|
||||
static qboolean vr_weapon_stabilised = false;
|
||||
|
||||
//Show screen view (if in multiplayer toggle scoreboard)
|
||||
if (((pOffTrackedRemoteNew->Buttons & offButton2) !=
|
||||
|
@ -74,6 +75,28 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
}
|
||||
else
|
||||
{
|
||||
//If distance to off-hand remote is less than 35cm and user pushes grip, then we enable weapon stabilisation
|
||||
float distance = sqrtf(powf(pOffTracking->HeadPose.Pose.Position.x - pDominantTracking->HeadPose.Pose.Position.x, 2) +
|
||||
powf(pOffTracking->HeadPose.Pose.Position.y - pDominantTracking->HeadPose.Pose.Position.y, 2) +
|
||||
powf(pOffTracking->HeadPose.Pose.Position.z - pDominantTracking->HeadPose.Pose.Position.z, 2));
|
||||
|
||||
//Turn on weapon stabilisation?
|
||||
if ((pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger) !=
|
||||
(pOffTrackedRemoteOld->Buttons & ovrButton_GripTrigger)) {
|
||||
|
||||
if (pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger)
|
||||
{
|
||||
if (distance < 0.50f)
|
||||
{
|
||||
vr_weapon_stabilised = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vr_weapon_stabilised = false;
|
||||
}
|
||||
}
|
||||
|
||||
//dominant hand stuff first
|
||||
{
|
||||
///Weapon location relative to view
|
||||
|
@ -95,6 +118,20 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
weaponangles[ROLL] *= -1.0f;
|
||||
|
||||
|
||||
if (vr_weapon_stabilised &&
|
||||
//Don't trigger stabilisation if controllers are close together (holding Glock for example)
|
||||
(distance > 0.15f))
|
||||
{
|
||||
float z = pOffTracking->HeadPose.Pose.Position.z - pDominantTracking->HeadPose.Pose.Position.z;
|
||||
float x = pOffTracking->HeadPose.Pose.Position.x - pDominantTracking->HeadPose.Pose.Position.x;
|
||||
float y = pOffTracking->HeadPose.Pose.Position.y - pDominantTracking->HeadPose.Pose.Position.y;
|
||||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
VectorSet(weaponangles, degrees(atanf(y / zxDist)), (cl.refdef.viewangles[YAW] - hmdorientation[YAW]) - degrees(atan2f(x, -z)), weaponangles[ROLL]);
|
||||
}
|
||||
}
|
||||
|
||||
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_GripTrigger) !=
|
||||
(pDominantTrackedRemoteOld->Buttons & ovrButton_GripTrigger)) {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
#include <src/ref_gl/gl_local.h>
|
||||
#include "g_local.h"
|
||||
|
||||
|
||||
|
@ -387,7 +388,7 @@ void fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int spee
|
|||
VectorMA (bolt->s.origin, -10, dir, bolt->s.origin);
|
||||
bolt->touch (bolt, tr.ent, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -647,6 +648,7 @@ void fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed
|
|||
check_dodge (self, rocket->s.origin, dir, speed);
|
||||
|
||||
gi.linkentity (rocket);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -93,6 +93,10 @@ void P_DamageFeedback (edict_t *player)
|
|||
if (count == 0)
|
||||
return; // didn't take any damage
|
||||
|
||||
//Haptic
|
||||
Android_Vibrate(fmin(count * 5, 150), 0, 0.6);
|
||||
Android_Vibrate(fmin(count * 5, 150), 1, 0.6);
|
||||
|
||||
// start a pain animation if still in the player model
|
||||
if (client->anim_priority < ANIM_PAIN && player->s.modelindex == 255)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static qboolean is_quad;
|
||||
static byte is_silenced;
|
||||
extern cvar_t *r_lefthand;
|
||||
|
||||
|
||||
void weapon_grenade_fire (edict_t *ent, qboolean held);
|
||||
|
@ -593,6 +594,9 @@ void weapon_grenade_fire (edict_t *ent, qboolean held)
|
|||
ent->s.frame = FRAME_wave08;
|
||||
ent->client->anim_end = FRAME_wave01;
|
||||
}
|
||||
|
||||
|
||||
Android_Vibrate(120, 1 - r_lefthand->value, 0.6);
|
||||
}
|
||||
|
||||
void Weapon_Grenade (edict_t *ent)
|
||||
|
@ -741,6 +745,9 @@ void weapon_grenadelauncher_fire (edict_t *ent)
|
|||
|
||||
if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) )
|
||||
ent->client->pers.inventory[ent->client->ammo_index]--;
|
||||
|
||||
|
||||
Android_Vibrate(120, 1 - r_lefthand->value, 0.6);
|
||||
}
|
||||
|
||||
void Weapon_GrenadeLauncher (edict_t *ent)
|
||||
|
@ -785,6 +792,8 @@ void Weapon_RocketLauncher_Fire (edict_t *ent)
|
|||
P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
|
||||
fire_rocket (ent, start, forward, damage, 650, damage_radius, radius_damage);
|
||||
|
||||
Android_Vibrate(120, 1 - r_lefthand->value, 1.0);
|
||||
|
||||
// send muzzle flash
|
||||
gi.WriteByte (svc_muzzleflash);
|
||||
gi.WriteShort (ent-g_edicts);
|
||||
|
@ -843,6 +852,8 @@ void Blaster_Fire (edict_t *ent, vec3_t g_offset, int damage, qboolean hyper, in
|
|||
gi.multicast (ent->s.origin, MULTICAST_PVS);
|
||||
|
||||
PlayerNoise(ent, start, PNOISE_WEAPON);
|
||||
|
||||
Android_Vibrate(120, 1 - r_lefthand->value, 0.4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1015,6 +1026,8 @@ void Machinegun_Fire (edict_t *ent)
|
|||
P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
|
||||
fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_MACHINEGUN);
|
||||
|
||||
Android_Vibrate(20, 1 - r_lefthand->value, 0.7);
|
||||
|
||||
gi.WriteByte (svc_muzzleflash);
|
||||
gi.WriteShort (ent-g_edicts);
|
||||
gi.WriteByte (MZ_MACHINEGUN | is_silenced);
|
||||
|
@ -1227,6 +1240,8 @@ void weapon_shotgun_fire (edict_t *ent)
|
|||
|
||||
if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) )
|
||||
ent->client->pers.inventory[ent->client->ammo_index]--;
|
||||
|
||||
Android_Vibrate(120, 1 - r_lefthand->value, 0.6);
|
||||
}
|
||||
|
||||
void Weapon_Shotgun (edict_t *ent)
|
||||
|
@ -1335,6 +1350,8 @@ void weapon_railgun_fire (edict_t *ent)
|
|||
P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
|
||||
fire_rail (ent, start, forward, damage, kick);
|
||||
|
||||
Android_Vibrate(120, 1 - r_lefthand->value, 0.9);
|
||||
|
||||
// send muzzle flash
|
||||
gi.WriteByte (svc_muzzleflash);
|
||||
gi.WriteShort (ent-g_edicts);
|
||||
|
@ -1416,6 +1433,8 @@ void weapon_bfg_fire (edict_t *ent)
|
|||
P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
|
||||
fire_bfg (ent, start, forward, damage, 400, damage_radius);
|
||||
|
||||
Android_Vibrate(120, 1 - r_lefthand->value, 1.0);
|
||||
|
||||
ent->client->ps.gunframe++;
|
||||
|
||||
PlayerNoise(ent, start, PNOISE_WEAPON);
|
||||
|
|
|
@ -159,6 +159,9 @@ extern long Q_ftol( float f );
|
|||
|
||||
void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
|
||||
|
||||
void Android_Vibrate( float duration, int channel, float intensity );
|
||||
|
||||
|
||||
// just in case you do't want to use the macros
|
||||
vec_t _DotProduct (vec3_t v1, vec3_t v2);
|
||||
void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
|
||||
//#define VERSION 3.21
|
||||
#define VERSION 0.3
|
||||
#define VERSION 0.4
|
||||
|
||||
#define BASEDIRNAME "baseq2"
|
||||
|
||||
|
|
Loading…
Reference in a new issue