diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /sp/src/public/haptics | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'sp/src/public/haptics')
| -rw-r--r-- | sp/src/public/haptics/haptic_msgs.cpp | 384 | ||||
| -rw-r--r-- | sp/src/public/haptics/haptic_msgs.h | 68 | ||||
| -rw-r--r-- | sp/src/public/haptics/haptic_utils.cpp | 886 | ||||
| -rw-r--r-- | sp/src/public/haptics/haptic_utils.h | 206 | ||||
| -rw-r--r-- | sp/src/public/haptics/ihaptics.h | 286 |
5 files changed, 915 insertions, 915 deletions
diff --git a/sp/src/public/haptics/haptic_msgs.cpp b/sp/src/public/haptics/haptic_msgs.cpp index 717e5e24..57b4bed2 100644 --- a/sp/src/public/haptics/haptic_msgs.cpp +++ b/sp/src/public/haptics/haptic_msgs.cpp @@ -1,192 +1,192 @@ -#include "cbase.h"
-
-#ifdef CLIENT_DLL
- #include "tier3/tier3.h"
- #include "iviewrender.h"
- #include "inputsystem/iinputsystem.h"
- #include "vgui/IInputInternal.h"
- #include "c_basecombatweapon.h"
- #include "c_baseplayer.h"
- #include "hud_macros.h"
- #include "iclientvehicle.h"
- #include "c_prop_vehicle.h"
- #include "prediction.h"
- #include "activitylist.h"
-#ifdef TERROR
- #include "ClientTerrorPlayer.h"
-#endif
-extern vgui::IInputInternal *g_InputInternal;
-#else
- #include "usermessages.h"
-#endif
-
-#include "haptics/haptic_msgs.h"
-
-void RegisterHapticMessages(void)
-{
- usermessages->Register( "SPHapWeapEvent", 4 );
- usermessages->Register( "HapDmg", -1 );
- usermessages->Register( "HapPunch", -1 );
- usermessages->Register( "HapSetDrag", -1 );
- usermessages->Register( "HapSetConst", -1 );
- usermessages->Register( "HapMeleeContact", 0);
-}
-
-//-----------------------------------------------------------------------------
-// Server
-//-----------------------------------------------------------------------------
-#ifndef CLIENT_DLL
-
-void HapticMsg_SendWeaponAnim( CBasePlayer *pPlayer, int iActivity )
-{
- //Send the haptics message
- CSingleUserRecipientFilter user( pPlayer );
- user.MakeReliable();
- UserMessageBegin( user, "SPHapWeapEvent" );
- WRITE_LONG(iActivity);
- MessageEnd();
-}
-
-void HapticMsg_SetDrag(CBasePlayer* pPlayer, float drag)
-{
- CSingleUserRecipientFilter user( pPlayer );
- user.MakeReliable();
- UserMessageBegin( user, "HapSetDrag" );
- WRITE_FLOAT(drag);
- MessageEnd();
-}
-
-void HapticMsg_SetConstantForce(CBasePlayer* pPlayer, Vector force)
-{
- // portal does not network this.
- CSingleUserRecipientFilter user( pPlayer );
- user.MakeReliable();
- UserMessageBegin( user, "HapSetConst" );
- WRITE_SHORT(force.x);
- WRITE_SHORT(force.y);
- WRITE_SHORT(force.z);
- MessageEnd();
-}
-
-void HapticMsg_HapDmg(CBasePlayer* pPlayer, float pitch, float yaw, float dmg, float dmgType )
-{
- CSingleUserRecipientFilter user(pPlayer);
- user.MakeReliable();
- UserMessageBegin(user,"HapDmg");
-
- WRITE_FLOAT(pitch);
- WRITE_FLOAT(yaw);
- WRITE_FLOAT(dmg);
- WRITE_LONG(dmgType);
- MessageEnd();
-}
-
-void HapticMsg_Punch(CBasePlayer* pPlayer, float x, float y, float z)
-{
- CSingleUserRecipientFilter user(pPlayer);
- user.MakeReliable();
- UserMessageBegin(user,"HapPunch");
-
- WRITE_FLOAT(x);
- WRITE_FLOAT(y);
- WRITE_FLOAT(z);
- MessageEnd();
-}
-
-void HapticMsg_MeleeContact(CBasePlayer* pPlayer)
-{
- CSingleUserRecipientFilter user(pPlayer);
- user.MakeReliable();
- UserMessageBegin(user,"HapMeleeContact");
- MessageEnd();
-}
-
-#endif //!CLIENT_DLL
-
-//-----------------------------------------------------------------------------
-// Client
-//-----------------------------------------------------------------------------
-#ifdef CLIENT_DLL
-void HookHapticMessages(void)
-{
- HOOK_MESSAGE(SPHapWeapEvent);
- HOOK_MESSAGE(HapDmg);
- HOOK_MESSAGE(HapPunch);
- HOOK_MESSAGE(HapSetDrag);
- HOOK_MESSAGE(HapSetConst);
- HOOK_MESSAGE(HapMeleeContact);
-
-}
-
-// Defined in haptics_utils
-#ifdef WIN32
-void HapticsHandleMsg_HapSetDrag( float drag );
-void HapticsHandleMsg_HapSetConst( Vector const &constant );
-void HapticsHandleMsg_SPHapWeapEvent( int iActivity );
-void HapticsHandleMsg_HapPunch( QAngle const &angle );
-void HapticsHandleMsg_HapDmg( float pitch, float yaw, float damage, int damageType );
-void HapticsHandleMsg_HapMeleeContact();
-#endif // WIN32
-
-void __MsgFunc_HapSetDrag( bf_read &msg )
-{
-#ifdef WIN32
- float drag = msg.ReadFloat();
- HapticsHandleMsg_HapSetDrag( drag );
-#endif // WIN32
-}
-
-//Might be able to handle this better...
-void __MsgFunc_HapSetConst( bf_read &msg )
-{
-#ifdef WIN32
- Vector constant;
- constant.x = msg.ReadShort();
- constant.y = msg.ReadShort();
- constant.z = msg.ReadShort();
-
- HapticsHandleMsg_HapSetConst( constant );
-#endif // WIN32
-}
-
-void __MsgFunc_SPHapWeapEvent( bf_read &msg )
-{
-#ifdef WIN32
- int iActivity = msg.ReadLong();
-
- HapticsHandleMsg_SPHapWeapEvent( iActivity );
-#endif // WIN32
-}
-
-void __MsgFunc_HapPunch( bf_read &msg )
-{
-#ifdef WIN32
- float x = msg.ReadFloat();
- float y = msg.ReadFloat();
- float z = msg.ReadFloat();
-
- HapticsHandleMsg_HapPunch( QAngle(x,y,z) );
-#endif // WIN32
-}
-
-void __MsgFunc_HapDmg( bf_read &msg )
-{
-#ifdef WIN32
- float pitch = msg.ReadFloat();
- float yaw = msg.ReadFloat();
- float damage = msg.ReadFloat();
- int damageType = msg.ReadLong();
-
- HapticsHandleMsg_HapDmg( pitch, yaw, damage, damageType );
-#endif // WIN32
-}
-
-void __MsgFunc_HapMeleeContact( bf_read &msg )
-{
-#ifdef WIN32
- HapticsHandleMsg_HapMeleeContact();
-#endif // WIN32
-}
-#endif // CLIENT_DLL
-
-
+#include "cbase.h" + +#ifdef CLIENT_DLL + #include "tier3/tier3.h" + #include "iviewrender.h" + #include "inputsystem/iinputsystem.h" + #include "vgui/IInputInternal.h" + #include "c_basecombatweapon.h" + #include "c_baseplayer.h" + #include "hud_macros.h" + #include "iclientvehicle.h" + #include "c_prop_vehicle.h" + #include "prediction.h" + #include "activitylist.h" +#ifdef TERROR + #include "ClientTerrorPlayer.h" +#endif +extern vgui::IInputInternal *g_InputInternal; +#else + #include "usermessages.h" +#endif + +#include "haptics/haptic_msgs.h" + +void RegisterHapticMessages(void) +{ + usermessages->Register( "SPHapWeapEvent", 4 ); + usermessages->Register( "HapDmg", -1 ); + usermessages->Register( "HapPunch", -1 ); + usermessages->Register( "HapSetDrag", -1 ); + usermessages->Register( "HapSetConst", -1 ); + usermessages->Register( "HapMeleeContact", 0); +} + +//----------------------------------------------------------------------------- +// Server +//----------------------------------------------------------------------------- +#ifndef CLIENT_DLL + +void HapticMsg_SendWeaponAnim( CBasePlayer *pPlayer, int iActivity ) +{ + //Send the haptics message + CSingleUserRecipientFilter user( pPlayer ); + user.MakeReliable(); + UserMessageBegin( user, "SPHapWeapEvent" ); + WRITE_LONG(iActivity); + MessageEnd(); +} + +void HapticMsg_SetDrag(CBasePlayer* pPlayer, float drag) +{ + CSingleUserRecipientFilter user( pPlayer ); + user.MakeReliable(); + UserMessageBegin( user, "HapSetDrag" ); + WRITE_FLOAT(drag); + MessageEnd(); +} + +void HapticMsg_SetConstantForce(CBasePlayer* pPlayer, Vector force) +{ + // portal does not network this. + CSingleUserRecipientFilter user( pPlayer ); + user.MakeReliable(); + UserMessageBegin( user, "HapSetConst" ); + WRITE_SHORT(force.x); + WRITE_SHORT(force.y); + WRITE_SHORT(force.z); + MessageEnd(); +} + +void HapticMsg_HapDmg(CBasePlayer* pPlayer, float pitch, float yaw, float dmg, float dmgType ) +{ + CSingleUserRecipientFilter user(pPlayer); + user.MakeReliable(); + UserMessageBegin(user,"HapDmg"); + + WRITE_FLOAT(pitch); + WRITE_FLOAT(yaw); + WRITE_FLOAT(dmg); + WRITE_LONG(dmgType); + MessageEnd(); +} + +void HapticMsg_Punch(CBasePlayer* pPlayer, float x, float y, float z) +{ + CSingleUserRecipientFilter user(pPlayer); + user.MakeReliable(); + UserMessageBegin(user,"HapPunch"); + + WRITE_FLOAT(x); + WRITE_FLOAT(y); + WRITE_FLOAT(z); + MessageEnd(); +} + +void HapticMsg_MeleeContact(CBasePlayer* pPlayer) +{ + CSingleUserRecipientFilter user(pPlayer); + user.MakeReliable(); + UserMessageBegin(user,"HapMeleeContact"); + MessageEnd(); +} + +#endif //!CLIENT_DLL + +//----------------------------------------------------------------------------- +// Client +//----------------------------------------------------------------------------- +#ifdef CLIENT_DLL +void HookHapticMessages(void) +{ + HOOK_MESSAGE(SPHapWeapEvent); + HOOK_MESSAGE(HapDmg); + HOOK_MESSAGE(HapPunch); + HOOK_MESSAGE(HapSetDrag); + HOOK_MESSAGE(HapSetConst); + HOOK_MESSAGE(HapMeleeContact); + +} + +// Defined in haptics_utils +#ifdef WIN32 +void HapticsHandleMsg_HapSetDrag( float drag ); +void HapticsHandleMsg_HapSetConst( Vector const &constant ); +void HapticsHandleMsg_SPHapWeapEvent( int iActivity ); +void HapticsHandleMsg_HapPunch( QAngle const &angle ); +void HapticsHandleMsg_HapDmg( float pitch, float yaw, float damage, int damageType ); +void HapticsHandleMsg_HapMeleeContact(); +#endif // WIN32 + +void __MsgFunc_HapSetDrag( bf_read &msg ) +{ +#ifdef WIN32 + float drag = msg.ReadFloat(); + HapticsHandleMsg_HapSetDrag( drag ); +#endif // WIN32 +} + +//Might be able to handle this better... +void __MsgFunc_HapSetConst( bf_read &msg ) +{ +#ifdef WIN32 + Vector constant; + constant.x = msg.ReadShort(); + constant.y = msg.ReadShort(); + constant.z = msg.ReadShort(); + + HapticsHandleMsg_HapSetConst( constant ); +#endif // WIN32 +} + +void __MsgFunc_SPHapWeapEvent( bf_read &msg ) +{ +#ifdef WIN32 + int iActivity = msg.ReadLong(); + + HapticsHandleMsg_SPHapWeapEvent( iActivity ); +#endif // WIN32 +} + +void __MsgFunc_HapPunch( bf_read &msg ) +{ +#ifdef WIN32 + float x = msg.ReadFloat(); + float y = msg.ReadFloat(); + float z = msg.ReadFloat(); + + HapticsHandleMsg_HapPunch( QAngle(x,y,z) ); +#endif // WIN32 +} + +void __MsgFunc_HapDmg( bf_read &msg ) +{ +#ifdef WIN32 + float pitch = msg.ReadFloat(); + float yaw = msg.ReadFloat(); + float damage = msg.ReadFloat(); + int damageType = msg.ReadLong(); + + HapticsHandleMsg_HapDmg( pitch, yaw, damage, damageType ); +#endif // WIN32 +} + +void __MsgFunc_HapMeleeContact( bf_read &msg ) +{ +#ifdef WIN32 + HapticsHandleMsg_HapMeleeContact(); +#endif // WIN32 +} +#endif // CLIENT_DLL + + diff --git a/sp/src/public/haptics/haptic_msgs.h b/sp/src/public/haptics/haptic_msgs.h index 4b2daf83..a7e4df17 100644 --- a/sp/src/public/haptics/haptic_msgs.h +++ b/sp/src/public/haptics/haptic_msgs.h @@ -1,34 +1,34 @@ -#ifndef HAPTIC_MSGS_H
-#define HAPTIC_MSGS_H
-
-void RegisterHapticMessages(void);
-
-//-----------------------------------------------------------------------------
-// Server
-//-----------------------------------------------------------------------------
-#ifndef CLIENT_DLL
- void HapticMsg_SendWeaponAnim( CBasePlayer *pPlayer, int iActivity );
- void HapticMsg_SetDrag(CBasePlayer* pPlayer, float drag);
- void HapticMsg_SetConstantForce(CBasePlayer* pPlayer, Vector force);
- void HapticMsg_HapDmg(CBasePlayer* pPlayer, float pitch, float yaw, float dmg, float dmgType );
- void HapticMsg_Punch(CBasePlayer* pPlayer, float x, float y, float z);
- void HapticMsg_MeleeContact(CBasePlayer* pPlayer);
-#endif // !CLIENT_DLL
-
-//-----------------------------------------------------------------------------
-// Client
-//-----------------------------------------------------------------------------
-#ifdef CLIENT_DLL
- void HookHapticMessages(void);
-
- void __MsgFunc_SPHapWeapEvent( bf_read &HapticMsg );
- void __MsgFunc_HapDmg( bf_read &HapticMsg );
- void __MsgFunc_HapSetConst( bf_read &HapticMsg );
- void __MsgFunc_HapPunch( bf_read &HapticMsg );
- void __MsgFunc_HapGeneric( bf_read &HapticMsg );
- void __MsgFunc_HapSetDrag( bf_read &HapticMsg );
- void __MsgFunc_HapSetDrag( bf_read &HapticMsg );
- void __MsgFunc_HapMeleeContact( bf_read &HapticMsg );
-#endif // CLIENT_DLL
-
-#endif // HAPTIC_MSGS_H
+#ifndef HAPTIC_MSGS_H +#define HAPTIC_MSGS_H + +void RegisterHapticMessages(void); + +//----------------------------------------------------------------------------- +// Server +//----------------------------------------------------------------------------- +#ifndef CLIENT_DLL + void HapticMsg_SendWeaponAnim( CBasePlayer *pPlayer, int iActivity ); + void HapticMsg_SetDrag(CBasePlayer* pPlayer, float drag); + void HapticMsg_SetConstantForce(CBasePlayer* pPlayer, Vector force); + void HapticMsg_HapDmg(CBasePlayer* pPlayer, float pitch, float yaw, float dmg, float dmgType ); + void HapticMsg_Punch(CBasePlayer* pPlayer, float x, float y, float z); + void HapticMsg_MeleeContact(CBasePlayer* pPlayer); +#endif // !CLIENT_DLL + +//----------------------------------------------------------------------------- +// Client +//----------------------------------------------------------------------------- +#ifdef CLIENT_DLL + void HookHapticMessages(void); + + void __MsgFunc_SPHapWeapEvent( bf_read &HapticMsg ); + void __MsgFunc_HapDmg( bf_read &HapticMsg ); + void __MsgFunc_HapSetConst( bf_read &HapticMsg ); + void __MsgFunc_HapPunch( bf_read &HapticMsg ); + void __MsgFunc_HapGeneric( bf_read &HapticMsg ); + void __MsgFunc_HapSetDrag( bf_read &HapticMsg ); + void __MsgFunc_HapSetDrag( bf_read &HapticMsg ); + void __MsgFunc_HapMeleeContact( bf_read &HapticMsg ); +#endif // CLIENT_DLL + +#endif // HAPTIC_MSGS_H diff --git a/sp/src/public/haptics/haptic_utils.cpp b/sp/src/public/haptics/haptic_utils.cpp index c6298b14..b9c72b2f 100644 --- a/sp/src/public/haptics/haptic_utils.cpp +++ b/sp/src/public/haptics/haptic_utils.cpp @@ -1,443 +1,443 @@ -#include "cbase.h"
-
-#ifdef CLIENT_DLL
- #include "tier3/tier3.h"
- #include "iviewrender.h"
- #include "inputsystem/iinputsystem.h"
- #include "vgui/IInputInternal.h"
- #include "c_basecombatweapon.h"
- #include "c_baseplayer.h"
- #include "haptics/ihaptics.h"
- #include "hud_macros.h"
- #include "iclientvehicle.h"
- #include "c_prop_vehicle.h"
- #include "prediction.h"
- #include "activitylist.h"
-#ifdef TERROR
- #include "ClientTerrorPlayer.h"
-#endif
-extern vgui::IInputInternal *g_InputInternal;
-#else
- #include "usermessages.h"
-#endif
-
-#include "haptics/haptic_utils.h"
-#include "haptics/haptic_msgs.h"
-
-#ifndef TERROR
-#ifndef FCVAR_RELEASE
-#define FCVAR_RELEASE 0
-#endif
-#endif
-
-#ifdef CLIENT_DLL
-ConVar hap_HasDevice ( "hap_HasDevice", "0", FCVAR_USERINFO/*|FCVAR_HIDDEN*/, "falcon is connected" );
-// damage scale on a title basis. Convar referenced in the haptic dll.
-#ifdef PORTAL
-#define HAP_DEFAULT_DAMAGE_SCALE_GAME "0.75"
-#elif TF_CLIENT_DLL
-#define HAP_DEFAULT_DAMAGE_SCALE_GAME "0.3"
-#else
-#define HAP_DEFAULT_DAMAGE_SCALE_GAME "1.0"
-#endif
-ConVar hap_damagescale_game("hap_damagescale_game", HAP_DEFAULT_DAMAGE_SCALE_GAME);
-#undef HAP_DEFAULT_DAMAGE_SCALE_GAME
-
-#endif
-
-void HapticSendWeaponAnim(CBaseCombatWeapon* weapon, int iActivity)
-{
- //ignore idle
- if(iActivity == ACT_VM_IDLE)
- return;
-
- #if defined( CLIENT_DLL )
- //if(hap_PrintEvents.GetBool())
- // Msg("Client Activity :%s %s %s\n",weapon->GetName(),"Activities",VarArgs("%i",iActivity));
- if ( weapon->IsPredicted() )
- haptics->ProcessHapticWeaponActivity(weapon->GetName(),iActivity);
- #else
- if( !weapon->IsPredicted() && weapon->GetOwner() && weapon->GetOwner()->IsPlayer())
- {
- HapticMsg_SendWeaponAnim( ToBasePlayer(weapon->GetOwner()), iActivity );
- }
- #endif
-}
-
-
-void HapticSetDrag(CBasePlayer* pPlayer, float drag)
-{
-#ifdef CLIENT_DLL
- haptics->SetDrag(drag);
-#else
- HapticMsg_SetDrag( pPlayer, drag );
-#endif
-}
-
-#ifdef CLIENT_DLL
-void HapticsHandleMsg_HapSetDrag( float drag )
-{
- haptics->SetDrag(drag);
-}
-#endif
-
-void HapticSetConstantForce(CBasePlayer* pPlayer, Vector force)
-{
-#ifdef CLIENT_DLL
- haptics->SetConstantForce(force);
-#else
- HapticMsg_SetConstantForce( pPlayer, force );
-#endif
-}
-
-#ifdef CLIENT_DLL
-
-#ifndef HAPTICS_TEST_PREFIX
-#define HAPTICS_TEST_PREFIX
-#endif
-static CSysModule *pFalconModule =0;
-void ConnectHaptics(CreateInterfaceFn appFactory)
-{
- bool success = false;
- // NVNT load haptics module
- pFalconModule = Sys_LoadModule( HAPTICS_TEST_PREFIX HAPTICS_DLL_NAME );
- if(pFalconModule)
- {
- CreateInterfaceFn factory = Sys_GetFactory( pFalconModule );
- if(factory)
- {
- haptics = reinterpret_cast< IHaptics* >( factory( HAPTICS_INTERFACE_VERSION, NULL ) );
- if(haptics &&
- haptics->Initialize(engine,
- view,
- g_InputInternal,
- gpGlobals,
- appFactory,
- g_pVGuiInput->GetIMEWindow(),
- filesystem,
- enginevgui,
- ActivityList_IndexForName,
- ActivityList_NameForIndex))
- {
- success = true;
- hap_HasDevice.SetValue(1);
- }
- }
- }
- if(!success)
- {
- Sys_UnloadModule(pFalconModule);
- pFalconModule = 0;
- haptics = new CHapticsStubbed;
- }
-
- if(haptics->HasDevice())
- {
- Assert( (void*)haptics == inputsystem->GetHapticsInterfaceAddress() );
- }
- HookHapticMessages();
-}
-
-void DisconnectHaptics()
-{
- haptics->ShutdownHaptics();
- if(pFalconModule)
- {
- Sys_UnloadModule(pFalconModule);
- pFalconModule = 0;
- }else{
- // delete the stub.
- delete haptics;
- }
- haptics = NULL;
-}
-//Might be able to handle this better...
-void HapticsHandleMsg_HapSetConst( Vector const &constant )
-{
- //Msg("__MsgFunc_HapSetConst: %f %f %f\n",constant.x,constant.y,constant.z);
- haptics->SetConstantForce(constant);
- //C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
-}
-
-
-//Might be able to handle this better...
-void HapticsHandleMsg_SPHapWeapEvent( int iActivity )
-{
- C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
- C_BaseCombatWeapon* weap = NULL;
- if(pPlayer)
- weap = pPlayer->GetActiveWeapon();
- if(weap)
- haptics->ProcessHapticEvent(4,"Weapons",weap->GetName(),"Activities",VarArgs("%i",iActivity));
-}
-
-void HapticsHandleMsg_HapPunch( QAngle const &angle )
-{
- haptics->HapticsPunch(1,angle);
-
-}
-#ifdef TERROR
-ConVar hap_zombie_damage_scale("hap_zombie_damage_scale", "0.25", FCVAR_RELEASE|FCVAR_NEVER_AS_STRING);
-#endif
-void HapticsHandleMsg_HapDmg( float pitch, float yaw, float damage, int damageType )
-{
- if(!haptics->HasDevice())
- return;
-
-#ifdef TERROR
- C_TerrorPlayer *pPlayer = C_TerrorPlayer::GetLocalTerrorPlayer();
-#else
- C_BasePlayer *pPlayer = CBasePlayer::GetLocalPlayer();
-#endif
-
- if(pPlayer)
- {
- Vector damageDirection;
-
- damageDirection.x = cos(pitch*M_PI/180.0)*sin(yaw*M_PI/180.0);
- damageDirection.y = -sin(pitch*M_PI/180.0);
- damageDirection.z = -(cos(pitch*M_PI/180.0)*cos(yaw*M_PI/180.0));
-#ifdef TERROR
- if(pPlayer->GetTeamNumber()==TEAM_ZOMBIE)
- {
- damageDirection *= hap_zombie_damage_scale.GetFloat();
- }
-#endif
-
- haptics->ApplyDamageEffect(damage, damageType, damageDirection);
- }
-}
-
-ConVar hap_melee_scale("hap_melee_scale", "0.8", FCVAR_RELEASE|FCVAR_NEVER_AS_STRING);
-void HapticsHandleMsg_HapMeleeContact()
-{
- haptics->HapticsPunch(hap_melee_scale.GetFloat(), QAngle(0,0,0));
-}
-ConVar hap_noclip_avatar_scale("hap_noclip_avatar_scale", "0.10f", FCVAR_RELEASE|FCVAR_NEVER_AS_STRING);
-void UpdateAvatarEffect(void)
-{
- if(!haptics->HasDevice())
- return;
-
- Vector vel;
- Vector vvel;
- Vector evel;
- QAngle eye;
- C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
- if(!pPlayer)
- return;
-
- eye = pPlayer->GetAbsAngles();
-
- if(pPlayer->IsInAVehicle() && pPlayer->GetVehicle())
- {
- pPlayer->GetVehicle()->GetVehicleEnt()->EstimateAbsVelocity(vvel);
- eye = pPlayer->GetVehicle()->GetVehicleEnt()->EyeAngles();
-
- if(!Q_stristr(pPlayer->GetVehicle()->GetVehicleEnt()->GetClassname(),"choreo"))
- {
- eye[YAW] += 90;
- }
-
-
-
- }
- else
- {
- vel = pPlayer->GetAbsVelocity();
- }
-
- Vector PlayerVel = pPlayer->GetAbsVelocity();
-
- //Choreo vehicles use player avatar and don't produce their own velocity
- if(!pPlayer->GetVehicle() || abs(vvel.Length()) == 0 )
- {
- vel = PlayerVel;
- }
- else
- vel = vvel;
-
-
-
- VectorYawRotate(vel, -90 -eye[YAW], vel );
-
- vel.y = -vel.y;
- vel.z = -vel.z;
-
- switch(pPlayer->GetMoveType()) {
- case MOVETYPE_NOCLIP:
- vel *= hap_noclip_avatar_scale.GetFloat();
- break;
- default:
- break;
- }
-
- haptics->UpdateAvatarVelocity(vel);
-}
-
-#endif
-
-
-#ifndef CLIENT_DLL
-void HapticsDamage(CBasePlayer* pPlayer, const CTakeDamageInfo &info)
-{
-#if !defined(TF_DLL) && !defined(CSTRIKE_DLL)
- if(!pPlayer->HasHaptics())
- return;// do not send to non haptic users.
-
- Vector DamageDirection(0,0,0);
- CBaseEntity *eInflictor = info.GetInflictor();
- // Pat: nuero toxix crash fix
- if(!eInflictor) {
- return;
- }
- // Player Data
- Vector playerPosition = pPlayer->GetLocalOrigin();
- Vector inflictorPosition = eInflictor->GetLocalOrigin();
-
- Vector posWithDir = playerPosition + (playerPosition - inflictorPosition);
- pPlayer->WorldToEntitySpace(posWithDir, &DamageDirection);
- QAngle dir(0,0,0);
- VectorAngles(DamageDirection, dir);
- float yawAngle = dir[YAW];
- float pitchAngle = dir[PITCH];
-
- int bitDamageType = info.GetDamageType();
-
- if(bitDamageType & DMG_FALL)
- {
- pitchAngle = ((float)-90.0); // coming from beneath
- }
- else if(bitDamageType & DMG_BURN && (bitDamageType & ~DMG_BURN)==0)
- {
- // just burn, use the z axis here.
- pitchAngle = 0.0;
- }
-#ifdef TERROR
- else if(
- (bitDamageType & ( DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_ACID | DMG_SLOWBURN ) ) &&
- (bitDamageType & ~( DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_ACID | DMG_SLOWBURN ) )==0 )
- {
- // it is time based. and should not really do a punch.
- return;
- }
-#endif
-
- float sendDamage = info.GetDamage();
-
- if(sendDamage>0.0f)
- {
- HapticMsg_HapDmg( pPlayer, pitchAngle, -yawAngle, sendDamage, bitDamageType );
- }
-#endif
-}
-
-void HapticPunch(CBasePlayer* pPlayer, float x, float y, float z)
-{
- HapticMsg_Punch( pPlayer, x, y, z );
-}
-
-void HapticMeleeContact(CBasePlayer* pPlayer)
-{
- HapticMsg_MeleeContact( pPlayer );
-}
-
-
-
-#endif // NOT CLIENT_DLL
-
-void HapticProcessSound(const char* soundname, int entIndex)
-{
-#ifdef CLIENT_DLL
- if (prediction->InPrediction() && prediction->IsFirstTimePredicted())
- {
- bool local = false;
- C_BaseEntity *ent = C_BaseEntity::Instance( entIndex );
- if(ent)
- local = (entIndex == -1 || ent == C_BasePlayer::GetLocalPlayer() || ent == C_BasePlayer::GetLocalPlayer()->GetActiveWeapon());
-
- haptics->ProcessHapticEvent(2,"Sounds",soundname);
- }
-#endif
-}
-
-#ifdef CLIENT_DLL
-
-// NVNT add || defined(OTHER_DEFINITION) if your game uses vehicles.
-#if defined( HL2_CLIENT_DLL )
-#define HAPTIC_VEHICLE_DEFAULT "1"
-#else
-#define HAPTIC_VEHICLE_DEFAULT "0"
-#endif
-
-// determines weather the vehicles control box option is faded
-ConVar hap_ui_vehicles( "hap_ui_vehicles",
- HAPTIC_VEHICLE_DEFAULT,
- 0
- );
-
-#undef HAPTIC_VEHICLE_DEFAULT
-
-void HapticsEnteredVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger )
-{
- if(!vehicle)
- return;
-
- // NVNT notify haptics system of navigation change.
-
- C_PropVehicleDriveable* drivable = dynamic_cast<C_PropVehicleDriveable*>(vehicle);
- bool hasgun = false;
- if(drivable)
- hasgun = drivable->HasGun();
-
-
-
-
-
- if(Q_stristr(vehicle->GetClassname(),"airboat"))
- {
- haptics->ProcessHapticEvent(2,"Movement","airboat");
- if(hasgun)
- haptics->SetNavigationClass("vehicle_gun");
- else
- haptics->SetNavigationClass("vehicle_airboat");
- }
- else if(Q_stristr(vehicle->GetClassname(),"jeepepisodic"))
- {
- haptics->ProcessHapticEvent(2,"Movement","BaseVehicle");
- haptics->SetNavigationClass("vehicle_nogun");
- }
- else if(Q_stristr(vehicle->GetClassname(),"jeep"))
- {
- haptics->ProcessHapticEvent(2,"Movement","BaseVehicle");
- haptics->SetNavigationClass("vehicle_gun");
- }
- else if(Q_stristr(vehicle->GetClassname(),"choreo"))
- {
- haptics->ProcessHapticEvent(2,"Movement","ChoreoVehicle");
- haptics->SetNavigationClass("vehicle_gun_nofix");//Give this a bit of aiming
- }
- else
- {
- haptics->ProcessHapticEvent(2,"Movement","BaseVehicle");
- haptics->SetNavigationClass("vehicle_nogun");
- }
-
- Msg("VehicleType:%s:\n",vehicle->GetClassname());
-}
-
-void HapticsExitedVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger )
-{
- // NVNT notify haptics system of navigation change.
- haptics->SetNavigationClass("on_foot");
- haptics->ProcessHapticEvent(2,"Movement","BasePlayer");
-}
-#endif
-
-
-
-
-
-
-
-
+#include "cbase.h" + +#ifdef CLIENT_DLL + #include "tier3/tier3.h" + #include "iviewrender.h" + #include "inputsystem/iinputsystem.h" + #include "vgui/IInputInternal.h" + #include "c_basecombatweapon.h" + #include "c_baseplayer.h" + #include "haptics/ihaptics.h" + #include "hud_macros.h" + #include "iclientvehicle.h" + #include "c_prop_vehicle.h" + #include "prediction.h" + #include "activitylist.h" +#ifdef TERROR + #include "ClientTerrorPlayer.h" +#endif +extern vgui::IInputInternal *g_InputInternal; +#else + #include "usermessages.h" +#endif + +#include "haptics/haptic_utils.h" +#include "haptics/haptic_msgs.h" + +#ifndef TERROR +#ifndef FCVAR_RELEASE +#define FCVAR_RELEASE 0 +#endif +#endif + +#ifdef CLIENT_DLL +ConVar hap_HasDevice ( "hap_HasDevice", "0", FCVAR_USERINFO/*|FCVAR_HIDDEN*/, "falcon is connected" ); +// damage scale on a title basis. Convar referenced in the haptic dll. +#ifdef PORTAL +#define HAP_DEFAULT_DAMAGE_SCALE_GAME "0.75" +#elif TF_CLIENT_DLL +#define HAP_DEFAULT_DAMAGE_SCALE_GAME "0.3" +#else +#define HAP_DEFAULT_DAMAGE_SCALE_GAME "1.0" +#endif +ConVar hap_damagescale_game("hap_damagescale_game", HAP_DEFAULT_DAMAGE_SCALE_GAME); +#undef HAP_DEFAULT_DAMAGE_SCALE_GAME + +#endif + +void HapticSendWeaponAnim(CBaseCombatWeapon* weapon, int iActivity) +{ + //ignore idle + if(iActivity == ACT_VM_IDLE) + return; + + #if defined( CLIENT_DLL ) + //if(hap_PrintEvents.GetBool()) + // Msg("Client Activity :%s %s %s\n",weapon->GetName(),"Activities",VarArgs("%i",iActivity)); + if ( weapon->IsPredicted() ) + haptics->ProcessHapticWeaponActivity(weapon->GetName(),iActivity); + #else + if( !weapon->IsPredicted() && weapon->GetOwner() && weapon->GetOwner()->IsPlayer()) + { + HapticMsg_SendWeaponAnim( ToBasePlayer(weapon->GetOwner()), iActivity ); + } + #endif +} + + +void HapticSetDrag(CBasePlayer* pPlayer, float drag) +{ +#ifdef CLIENT_DLL + haptics->SetDrag(drag); +#else + HapticMsg_SetDrag( pPlayer, drag ); +#endif +} + +#ifdef CLIENT_DLL +void HapticsHandleMsg_HapSetDrag( float drag ) +{ + haptics->SetDrag(drag); +} +#endif + +void HapticSetConstantForce(CBasePlayer* pPlayer, Vector force) +{ +#ifdef CLIENT_DLL + haptics->SetConstantForce(force); +#else + HapticMsg_SetConstantForce( pPlayer, force ); +#endif +} + +#ifdef CLIENT_DLL + +#ifndef HAPTICS_TEST_PREFIX +#define HAPTICS_TEST_PREFIX +#endif +static CSysModule *pFalconModule =0; +void ConnectHaptics(CreateInterfaceFn appFactory) +{ + bool success = false; + // NVNT load haptics module + pFalconModule = Sys_LoadModule( HAPTICS_TEST_PREFIX HAPTICS_DLL_NAME ); + if(pFalconModule) + { + CreateInterfaceFn factory = Sys_GetFactory( pFalconModule ); + if(factory) + { + haptics = reinterpret_cast< IHaptics* >( factory( HAPTICS_INTERFACE_VERSION, NULL ) ); + if(haptics && + haptics->Initialize(engine, + view, + g_InputInternal, + gpGlobals, + appFactory, + g_pVGuiInput->GetIMEWindow(), + filesystem, + enginevgui, + ActivityList_IndexForName, + ActivityList_NameForIndex)) + { + success = true; + hap_HasDevice.SetValue(1); + } + } + } + if(!success) + { + Sys_UnloadModule(pFalconModule); + pFalconModule = 0; + haptics = new CHapticsStubbed; + } + + if(haptics->HasDevice()) + { + Assert( (void*)haptics == inputsystem->GetHapticsInterfaceAddress() ); + } + HookHapticMessages(); +} + +void DisconnectHaptics() +{ + haptics->ShutdownHaptics(); + if(pFalconModule) + { + Sys_UnloadModule(pFalconModule); + pFalconModule = 0; + }else{ + // delete the stub. + delete haptics; + } + haptics = NULL; +} +//Might be able to handle this better... +void HapticsHandleMsg_HapSetConst( Vector const &constant ) +{ + //Msg("__MsgFunc_HapSetConst: %f %f %f\n",constant.x,constant.y,constant.z); + haptics->SetConstantForce(constant); + //C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); +} + + +//Might be able to handle this better... +void HapticsHandleMsg_SPHapWeapEvent( int iActivity ) +{ + C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); + C_BaseCombatWeapon* weap = NULL; + if(pPlayer) + weap = pPlayer->GetActiveWeapon(); + if(weap) + haptics->ProcessHapticEvent(4,"Weapons",weap->GetName(),"Activities",VarArgs("%i",iActivity)); +} + +void HapticsHandleMsg_HapPunch( QAngle const &angle ) +{ + haptics->HapticsPunch(1,angle); + +} +#ifdef TERROR +ConVar hap_zombie_damage_scale("hap_zombie_damage_scale", "0.25", FCVAR_RELEASE|FCVAR_NEVER_AS_STRING); +#endif +void HapticsHandleMsg_HapDmg( float pitch, float yaw, float damage, int damageType ) +{ + if(!haptics->HasDevice()) + return; + +#ifdef TERROR + C_TerrorPlayer *pPlayer = C_TerrorPlayer::GetLocalTerrorPlayer(); +#else + C_BasePlayer *pPlayer = CBasePlayer::GetLocalPlayer(); +#endif + + if(pPlayer) + { + Vector damageDirection; + + damageDirection.x = cos(pitch*M_PI/180.0)*sin(yaw*M_PI/180.0); + damageDirection.y = -sin(pitch*M_PI/180.0); + damageDirection.z = -(cos(pitch*M_PI/180.0)*cos(yaw*M_PI/180.0)); +#ifdef TERROR + if(pPlayer->GetTeamNumber()==TEAM_ZOMBIE) + { + damageDirection *= hap_zombie_damage_scale.GetFloat(); + } +#endif + + haptics->ApplyDamageEffect(damage, damageType, damageDirection); + } +} + +ConVar hap_melee_scale("hap_melee_scale", "0.8", FCVAR_RELEASE|FCVAR_NEVER_AS_STRING); +void HapticsHandleMsg_HapMeleeContact() +{ + haptics->HapticsPunch(hap_melee_scale.GetFloat(), QAngle(0,0,0)); +} +ConVar hap_noclip_avatar_scale("hap_noclip_avatar_scale", "0.10f", FCVAR_RELEASE|FCVAR_NEVER_AS_STRING); +void UpdateAvatarEffect(void) +{ + if(!haptics->HasDevice()) + return; + + Vector vel; + Vector vvel; + Vector evel; + QAngle eye; + C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); + if(!pPlayer) + return; + + eye = pPlayer->GetAbsAngles(); + + if(pPlayer->IsInAVehicle() && pPlayer->GetVehicle()) + { + pPlayer->GetVehicle()->GetVehicleEnt()->EstimateAbsVelocity(vvel); + eye = pPlayer->GetVehicle()->GetVehicleEnt()->EyeAngles(); + + if(!Q_stristr(pPlayer->GetVehicle()->GetVehicleEnt()->GetClassname(),"choreo")) + { + eye[YAW] += 90; + } + + + + } + else + { + vel = pPlayer->GetAbsVelocity(); + } + + Vector PlayerVel = pPlayer->GetAbsVelocity(); + + //Choreo vehicles use player avatar and don't produce their own velocity + if(!pPlayer->GetVehicle() || abs(vvel.Length()) == 0 ) + { + vel = PlayerVel; + } + else + vel = vvel; + + + + VectorYawRotate(vel, -90 -eye[YAW], vel ); + + vel.y = -vel.y; + vel.z = -vel.z; + + switch(pPlayer->GetMoveType()) { + case MOVETYPE_NOCLIP: + vel *= hap_noclip_avatar_scale.GetFloat(); + break; + default: + break; + } + + haptics->UpdateAvatarVelocity(vel); +} + +#endif + + +#ifndef CLIENT_DLL +void HapticsDamage(CBasePlayer* pPlayer, const CTakeDamageInfo &info) +{ +#if !defined(TF_DLL) && !defined(CSTRIKE_DLL) + if(!pPlayer->HasHaptics()) + return;// do not send to non haptic users. + + Vector DamageDirection(0,0,0); + CBaseEntity *eInflictor = info.GetInflictor(); + // Pat: nuero toxix crash fix + if(!eInflictor) { + return; + } + // Player Data + Vector playerPosition = pPlayer->GetLocalOrigin(); + Vector inflictorPosition = eInflictor->GetLocalOrigin(); + + Vector posWithDir = playerPosition + (playerPosition - inflictorPosition); + pPlayer->WorldToEntitySpace(posWithDir, &DamageDirection); + QAngle dir(0,0,0); + VectorAngles(DamageDirection, dir); + float yawAngle = dir[YAW]; + float pitchAngle = dir[PITCH]; + + int bitDamageType = info.GetDamageType(); + + if(bitDamageType & DMG_FALL) + { + pitchAngle = ((float)-90.0); // coming from beneath + } + else if(bitDamageType & DMG_BURN && (bitDamageType & ~DMG_BURN)==0) + { + // just burn, use the z axis here. + pitchAngle = 0.0; + } +#ifdef TERROR + else if( + (bitDamageType & ( DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_ACID | DMG_SLOWBURN ) ) && + (bitDamageType & ~( DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_ACID | DMG_SLOWBURN ) )==0 ) + { + // it is time based. and should not really do a punch. + return; + } +#endif + + float sendDamage = info.GetDamage(); + + if(sendDamage>0.0f) + { + HapticMsg_HapDmg( pPlayer, pitchAngle, -yawAngle, sendDamage, bitDamageType ); + } +#endif +} + +void HapticPunch(CBasePlayer* pPlayer, float x, float y, float z) +{ + HapticMsg_Punch( pPlayer, x, y, z ); +} + +void HapticMeleeContact(CBasePlayer* pPlayer) +{ + HapticMsg_MeleeContact( pPlayer ); +} + + + +#endif // NOT CLIENT_DLL + +void HapticProcessSound(const char* soundname, int entIndex) +{ +#ifdef CLIENT_DLL + if (prediction->InPrediction() && prediction->IsFirstTimePredicted()) + { + bool local = false; + C_BaseEntity *ent = C_BaseEntity::Instance( entIndex ); + if(ent) + local = (entIndex == -1 || ent == C_BasePlayer::GetLocalPlayer() || ent == C_BasePlayer::GetLocalPlayer()->GetActiveWeapon()); + + haptics->ProcessHapticEvent(2,"Sounds",soundname); + } +#endif +} + +#ifdef CLIENT_DLL + +// NVNT add || defined(OTHER_DEFINITION) if your game uses vehicles. +#if defined( HL2_CLIENT_DLL ) +#define HAPTIC_VEHICLE_DEFAULT "1" +#else +#define HAPTIC_VEHICLE_DEFAULT "0" +#endif + +// determines weather the vehicles control box option is faded +ConVar hap_ui_vehicles( "hap_ui_vehicles", + HAPTIC_VEHICLE_DEFAULT, + 0 + ); + +#undef HAPTIC_VEHICLE_DEFAULT + +void HapticsEnteredVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger ) +{ + if(!vehicle) + return; + + // NVNT notify haptics system of navigation change. + + C_PropVehicleDriveable* drivable = dynamic_cast<C_PropVehicleDriveable*>(vehicle); + bool hasgun = false; + if(drivable) + hasgun = drivable->HasGun(); + + + + + + if(Q_stristr(vehicle->GetClassname(),"airboat")) + { + haptics->ProcessHapticEvent(2,"Movement","airboat"); + if(hasgun) + haptics->SetNavigationClass("vehicle_gun"); + else + haptics->SetNavigationClass("vehicle_airboat"); + } + else if(Q_stristr(vehicle->GetClassname(),"jeepepisodic")) + { + haptics->ProcessHapticEvent(2,"Movement","BaseVehicle"); + haptics->SetNavigationClass("vehicle_nogun"); + } + else if(Q_stristr(vehicle->GetClassname(),"jeep")) + { + haptics->ProcessHapticEvent(2,"Movement","BaseVehicle"); + haptics->SetNavigationClass("vehicle_gun"); + } + else if(Q_stristr(vehicle->GetClassname(),"choreo")) + { + haptics->ProcessHapticEvent(2,"Movement","ChoreoVehicle"); + haptics->SetNavigationClass("vehicle_gun_nofix");//Give this a bit of aiming + } + else + { + haptics->ProcessHapticEvent(2,"Movement","BaseVehicle"); + haptics->SetNavigationClass("vehicle_nogun"); + } + + Msg("VehicleType:%s:\n",vehicle->GetClassname()); +} + +void HapticsExitedVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger ) +{ + // NVNT notify haptics system of navigation change. + haptics->SetNavigationClass("on_foot"); + haptics->ProcessHapticEvent(2,"Movement","BasePlayer"); +} +#endif + + + + + + + + diff --git a/sp/src/public/haptics/haptic_utils.h b/sp/src/public/haptics/haptic_utils.h index 68c5c8d7..18a05ab2 100644 --- a/sp/src/public/haptics/haptic_utils.h +++ b/sp/src/public/haptics/haptic_utils.h @@ -1,104 +1,104 @@ -#ifndef HAPTIC_UTILS_H
-#define HAPTIC_UTILS_H
-
-
-#ifdef CLIENT_DLL
-
-#include "haptics/ihaptics.h"
-
-// forward decl.
-class C_BaseEntity;
-class C_BaseCombatCharacter;
-class C_BasePlayer;
-class bf_read;
-
-// use client side versions.
-#ifndef CBasePlayer
-#define CBasePlayer C_BasePlayer;
-#endif
-#ifndef CBaseCombatWeapon
-#define CBaseCombatWeapon C_BaseCombatWeapon
-#endif
-
-// stubbed version of haptics interface. Used when haptics is not available.
-class CHapticsStubbed : public IHaptics
-{
-public:
-public: // Initialization.
- virtual bool Initialize(IVEngineClient* newengine,
- IViewRender *newview,
- vgui::IInputInternal* newinput,
- CGlobalVarsBase* newgpGlobals,
- CreateInterfaceFn newengineFactory,
- void *IMEWindow,
- IFileSystem* filesystem,
- IEngineVGui* newvgui,
- ActivityList_IndexForName_t actIndexForName,
- ActivityList_NameForIndex_t actNameForIndex)
- {return false;};
-
-public: // Device methods
- virtual bool HasDevice(){return false;};
- virtual void ShutdownHaptics(){};
-
-public: // Game input handling
- virtual void CalculateMove(float &forward_move, float &side_move, float delta){};
- virtual void OnPlayerChanged(){}
- virtual void SetNavigationClass(const char *defaultNavigationName){};
- virtual const char *GetNavigationClass(){ return 0; };
- virtual void GameProcess(){}
- virtual void MenuProcess(){}
-
-public: // Effect methods
- virtual void ProcessHapticEvent(int numArgs, ...){}
- virtual void ProcessHapticWeaponActivity(const char *weapon, int activity){}
- virtual void HapticsPunch(float strength, const QAngle &angle){}
- virtual void ApplyDamageEffect(float damage, int damagetype, const Vector &angle){}
- virtual void UpdateAvatarVelocity(const Vector &vel){}
- virtual void RemoveAvatarEffect(){}
- virtual void SetConstantForce(const Vector &force){}
- virtual Vector GetConstantForce(){return Vector(0,0,0);}
- virtual void SetDrag(float amount){}
- virtual void SetShake(float scalar, float currentamount){}
- virtual void SetHeld(float amount){}
- virtual void SetMoveSurface(HapticSurfaceType_t surface){}
- virtual HapticSurfaceType_t GetMoveSurface(){ return HST_NONE; }
- virtual void SetDangling(float amount){};
-
-public: // Notify methods
- virtual void LocalPlayerReset(){};
- virtual void UpdatePlayerFOV(float fov){};
- virtual void WorldPrecache() {};
-};
-#else
-// forward decl.
-class CBasePlayer;
-class CBaseCombatWeapon;
-class CTakeDamageInfo;
-
-#endif // CLIENT_DLL
-
-void HapticSendWeaponAnim(class CBaseCombatWeapon* weapon, int iActivity);
-void HapticSetConstantForce(class CBasePlayer* pPlayer,Vector force);
-void HapticSetDrag(class CBasePlayer* pPlayer, float drag);
-
-// note: does nothing on server.
-void HapticProcessSound(const char* soundname, int entIndex);
-
-#ifdef CLIENT_DLL
- void ConnectHaptics(CreateInterfaceFn appFactory);
- void DisconnectHaptics();
-
- void UpdateAvatarEffect(void);
- void HapticsExitedVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger );
- void HapticsEnteredVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger );
-
- //bool value true if user is using a haptic device.
- extern ConVar hap_HasDevice;
-#else
- void HapticsDamage(CBasePlayer* pPlayer, const CTakeDamageInfo &info);
- void HapticPunch(CBasePlayer* pPlayer, float amount, float x, float y);
- void HapticMeleeContact(CBasePlayer* pPlayer);
-#endif
-
+#ifndef HAPTIC_UTILS_H +#define HAPTIC_UTILS_H + + +#ifdef CLIENT_DLL + +#include "haptics/ihaptics.h" + +// forward decl. +class C_BaseEntity; +class C_BaseCombatCharacter; +class C_BasePlayer; +class bf_read; + +// use client side versions. +#ifndef CBasePlayer +#define CBasePlayer C_BasePlayer; +#endif +#ifndef CBaseCombatWeapon +#define CBaseCombatWeapon C_BaseCombatWeapon +#endif + +// stubbed version of haptics interface. Used when haptics is not available. +class CHapticsStubbed : public IHaptics +{ +public: +public: // Initialization. + virtual bool Initialize(IVEngineClient* newengine, + IViewRender *newview, + vgui::IInputInternal* newinput, + CGlobalVarsBase* newgpGlobals, + CreateInterfaceFn newengineFactory, + void *IMEWindow, + IFileSystem* filesystem, + IEngineVGui* newvgui, + ActivityList_IndexForName_t actIndexForName, + ActivityList_NameForIndex_t actNameForIndex) + {return false;}; + +public: // Device methods + virtual bool HasDevice(){return false;}; + virtual void ShutdownHaptics(){}; + +public: // Game input handling + virtual void CalculateMove(float &forward_move, float &side_move, float delta){}; + virtual void OnPlayerChanged(){} + virtual void SetNavigationClass(const char *defaultNavigationName){}; + virtual const char *GetNavigationClass(){ return 0; }; + virtual void GameProcess(){} + virtual void MenuProcess(){} + +public: // Effect methods + virtual void ProcessHapticEvent(int numArgs, ...){} + virtual void ProcessHapticWeaponActivity(const char *weapon, int activity){} + virtual void HapticsPunch(float strength, const QAngle &angle){} + virtual void ApplyDamageEffect(float damage, int damagetype, const Vector &angle){} + virtual void UpdateAvatarVelocity(const Vector &vel){} + virtual void RemoveAvatarEffect(){} + virtual void SetConstantForce(const Vector &force){} + virtual Vector GetConstantForce(){return Vector(0,0,0);} + virtual void SetDrag(float amount){} + virtual void SetShake(float scalar, float currentamount){} + virtual void SetHeld(float amount){} + virtual void SetMoveSurface(HapticSurfaceType_t surface){} + virtual HapticSurfaceType_t GetMoveSurface(){ return HST_NONE; } + virtual void SetDangling(float amount){}; + +public: // Notify methods + virtual void LocalPlayerReset(){}; + virtual void UpdatePlayerFOV(float fov){}; + virtual void WorldPrecache() {}; +}; +#else +// forward decl. +class CBasePlayer; +class CBaseCombatWeapon; +class CTakeDamageInfo; + +#endif // CLIENT_DLL + +void HapticSendWeaponAnim(class CBaseCombatWeapon* weapon, int iActivity); +void HapticSetConstantForce(class CBasePlayer* pPlayer,Vector force); +void HapticSetDrag(class CBasePlayer* pPlayer, float drag); + +// note: does nothing on server. +void HapticProcessSound(const char* soundname, int entIndex); + +#ifdef CLIENT_DLL + void ConnectHaptics(CreateInterfaceFn appFactory); + void DisconnectHaptics(); + + void UpdateAvatarEffect(void); + void HapticsExitedVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger ); + void HapticsEnteredVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger ); + + //bool value true if user is using a haptic device. + extern ConVar hap_HasDevice; +#else + void HapticsDamage(CBasePlayer* pPlayer, const CTakeDamageInfo &info); + void HapticPunch(CBasePlayer* pPlayer, float amount, float x, float y); + void HapticMeleeContact(CBasePlayer* pPlayer); +#endif + #endif
\ No newline at end of file diff --git a/sp/src/public/haptics/ihaptics.h b/sp/src/public/haptics/ihaptics.h index 407d86c0..d99017bc 100644 --- a/sp/src/public/haptics/ihaptics.h +++ b/sp/src/public/haptics/ihaptics.h @@ -1,144 +1,144 @@ -#ifndef HAPTICS_INTERFACE_H
-#define HAPTICS_INTERFACE_H
-
-#ifdef GAME_DLL
-#pragma warning("IHaptics.h is only for client ussage");
-#endif
-
-#include "tier0/platform.h"
-#include "appframework/IAppSystem.h"
-
-#define HAPTICS_INTERFACE_VERSION "HapticsInterface001"
-#define HAPTICS_DLL_NAME "haptics"
-
-// systems forward decl.
-class IVEngineClient;
-class IViewRender;
-class IInputInternal;
-class CGlobalVarsBase;
-class IFileSystem;
-class IEngineVGui;
-
-// vgui forward decl
-namespace vgui{
- class IInputInternal;
-}
-
-// math types forward decl
-class QAngle;
-class Vector;
-
-typedef enum {
- HST_NONE = 0,
- HST_ROPE,
-} HapticSurfaceType_t;
-
-typedef int (*ActivityList_IndexForName_t)( const char *pszActivityName );
-typedef const char *(*ActivityList_NameForIndex_t)( int iActivityIndex );
-// NVNT haptic system interface declaration
-abstract_class IHaptics
-{
-public: // Initialization.
- virtual bool Initialize(IVEngineClient* newengine,
- IViewRender *newview,
- vgui::IInputInternal* newinput,
- CGlobalVarsBase* newgpGlobals,
- CreateInterfaceFn newengineFactory,
- void *IMEWindow,
- IFileSystem* filesystem,
- IEngineVGui* newvgui,
- ActivityList_IndexForName_t actIndexForName,
- ActivityList_NameForIndex_t actNameForIndex) = 0;
-
-public: // Device methods
-
- // returns true if there is at least one device connected.
- virtual bool HasDevice() = 0;
-
- // closes all haptic devices and effect processing
- virtual void ShutdownHaptics() = 0;
-
-public: // Game input handling
-
- // computes view angles and adjusts forward_move and side_move
- virtual void CalculateMove(float &forward_move, float &side_move, float delta) = 0;
-
- virtual void OnPlayerChanged()=0;
-
- // Sets the internal navigation class.
- virtual void SetNavigationClass(const char *defaultNavigationName) = 0;
-
- // Turns the internal navigation off. ( clears navigation class )
- inline void ClearNavigationClass();
-
- // Returns the active navigation class ( if none returns NULL )
- virtual const char *GetNavigationClass() = 0;
-
- // Should be called by the game input class after CalculateMove (when not in menu)
- virtual void GameProcess() = 0;
-
- // Should be called by the game input class when in a menu
- virtual void MenuProcess() = 0;
-
-
-public: // Effect methods
-
- // process a haptic event.
- virtual void ProcessHapticEvent(int numArgs, ...) = 0;
- virtual void ProcessHapticWeaponActivity(const char *weapon, int activity) = 0;
-
- // send a haptic punch effect
- virtual void HapticsPunch(float strength, const QAngle &angle) = 0;
-
- // trigger a damage effect
- virtual void ApplyDamageEffect(float damage, int damagetype, const Vector &angle) = 0;
-
- // update the avatar ( acceleration ) effect by a velocity sample
- virtual void UpdateAvatarVelocity(const Vector &velocity) = 0;
-
- // stop processing any running avatar effects
- virtual void RemoveAvatarEffect() = 0;
-
- // sets the device's constant force effect to force vector
- virtual void SetConstantForce(const Vector &force) = 0;
-
- // returns the last sent constant force
- virtual Vector GetConstantForce() = 0;
-
- // set the amount of drag (viscosity) on the haptic devices
- virtual void SetDrag(float amount) = 0;
-
- // set the values to the screen shake effect
- virtual void SetShake(float scalar, float currentamount) = 0;
-
- // enable/disable device position lock.
- virtual void SetHeld(float amount) = 0;
-
- // set anchor weight mass scaler.
- virtual void SetMoveSurface(HapticSurfaceType_t surface) = 0;
-
- virtual HapticSurfaceType_t GetMoveSurface() = 0;
-
- // set dangling ( being hung, holding onto ledges )
- virtual void SetDangling(float amount) = 0;
-
-public: // Notify methods
-
- // notify the haptics system that we have been respawned.
- virtual void LocalPlayerReset()=0;
-
- // notify the haptics system of the player's field of view angle
- virtual void UpdatePlayerFOV(float fov)=0;
-
- virtual void WorldPrecache() = 0;
-
-};
-
-inline void IHaptics::ClearNavigationClass( void )
-{
- SetNavigationClass(0);
-}
-
-extern IHaptics* haptics;
-
+#ifndef HAPTICS_INTERFACE_H +#define HAPTICS_INTERFACE_H + +#ifdef GAME_DLL +#pragma warning("IHaptics.h is only for client ussage"); +#endif + +#include "tier0/platform.h" +#include "appframework/IAppSystem.h" + +#define HAPTICS_INTERFACE_VERSION "HapticsInterface001" +#define HAPTICS_DLL_NAME "haptics" + +// systems forward decl. +class IVEngineClient; +class IViewRender; +class IInputInternal; +class CGlobalVarsBase; +class IFileSystem; +class IEngineVGui; + +// vgui forward decl +namespace vgui{ + class IInputInternal; +} + +// math types forward decl +class QAngle; +class Vector; + +typedef enum { + HST_NONE = 0, + HST_ROPE, +} HapticSurfaceType_t; + +typedef int (*ActivityList_IndexForName_t)( const char *pszActivityName ); +typedef const char *(*ActivityList_NameForIndex_t)( int iActivityIndex ); +// NVNT haptic system interface declaration +abstract_class IHaptics +{ +public: // Initialization. + virtual bool Initialize(IVEngineClient* newengine, + IViewRender *newview, + vgui::IInputInternal* newinput, + CGlobalVarsBase* newgpGlobals, + CreateInterfaceFn newengineFactory, + void *IMEWindow, + IFileSystem* filesystem, + IEngineVGui* newvgui, + ActivityList_IndexForName_t actIndexForName, + ActivityList_NameForIndex_t actNameForIndex) = 0; + +public: // Device methods + + // returns true if there is at least one device connected. + virtual bool HasDevice() = 0; + + // closes all haptic devices and effect processing + virtual void ShutdownHaptics() = 0; + +public: // Game input handling + + // computes view angles and adjusts forward_move and side_move + virtual void CalculateMove(float &forward_move, float &side_move, float delta) = 0; + + virtual void OnPlayerChanged()=0; + + // Sets the internal navigation class. + virtual void SetNavigationClass(const char *defaultNavigationName) = 0; + + // Turns the internal navigation off. ( clears navigation class ) + inline void ClearNavigationClass(); + + // Returns the active navigation class ( if none returns NULL ) + virtual const char *GetNavigationClass() = 0; + + // Should be called by the game input class after CalculateMove (when not in menu) + virtual void GameProcess() = 0; + + // Should be called by the game input class when in a menu + virtual void MenuProcess() = 0; + + +public: // Effect methods + + // process a haptic event. + virtual void ProcessHapticEvent(int numArgs, ...) = 0; + virtual void ProcessHapticWeaponActivity(const char *weapon, int activity) = 0; + + // send a haptic punch effect + virtual void HapticsPunch(float strength, const QAngle &angle) = 0; + + // trigger a damage effect + virtual void ApplyDamageEffect(float damage, int damagetype, const Vector &angle) = 0; + + // update the avatar ( acceleration ) effect by a velocity sample + virtual void UpdateAvatarVelocity(const Vector &velocity) = 0; + + // stop processing any running avatar effects + virtual void RemoveAvatarEffect() = 0; + + // sets the device's constant force effect to force vector + virtual void SetConstantForce(const Vector &force) = 0; + + // returns the last sent constant force + virtual Vector GetConstantForce() = 0; + + // set the amount of drag (viscosity) on the haptic devices + virtual void SetDrag(float amount) = 0; + + // set the values to the screen shake effect + virtual void SetShake(float scalar, float currentamount) = 0; + + // enable/disable device position lock. + virtual void SetHeld(float amount) = 0; + + // set anchor weight mass scaler. + virtual void SetMoveSurface(HapticSurfaceType_t surface) = 0; + + virtual HapticSurfaceType_t GetMoveSurface() = 0; + + // set dangling ( being hung, holding onto ledges ) + virtual void SetDangling(float amount) = 0; + +public: // Notify methods + + // notify the haptics system that we have been respawned. + virtual void LocalPlayerReset()=0; + + // notify the haptics system of the player's field of view angle + virtual void UpdatePlayerFOV(float fov)=0; + + virtual void WorldPrecache() = 0; + +}; + +inline void IHaptics::ClearNavigationClass( void ) +{ + SetNavigationClass(0); +} + +extern IHaptics* haptics; + #endif// HAPTICS_INTERFACE_H
\ No newline at end of file |