Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,4 @@ FodyWeavers.xsd
*.msp

# JetBrains Rider
*.sln.iml
*.sln.iml
1 change: 1 addition & 0 deletions src/game/client/client_hl2mp.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $Configuration
{
$AdditionalIncludeDirectories "$BASE;hl2mp\ui,.\hl2mp,$SRCDIR\game\shared\hl2mp,.\hl2,.\hl2\elements,$SRCDIR\game\shared\hl2"
$PreprocessorDefinitions "$BASE;HL2MP;HL2_CLIENT_DLL;NEXT_BOT"
$PreprocessorDefinitions "$BASE;SIXENSE" [!$SOURCESDK]
}
}

Expand Down
197 changes: 161 additions & 36 deletions src/game/client/sixense/in_sixense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern const char *COM_GetModDirectory();
#include "c_cs_player.h"
#endif

#include <isixense.h>
#include <sixense.h>
#include <sixense_math.hpp>
#include <sixense_utils/interfaces.hpp>

Expand Down Expand Up @@ -68,6 +68,8 @@ using sixenseMath::Line;
#include "tf_hud_menu_engy_build.h"
#include "tf_hud_menu_engy_destroy.h"
#include "tf_hud_menu_spy_disguise.h"
#include "tf_hud_menu_taunt_selection.h"
#include "tf_hud_menu_eureka_teleport.h"
#endif

#ifdef PORTAL2
Expand Down Expand Up @@ -376,30 +378,67 @@ bool SixenseInput::LoadModules()
if( m_bModulesLoaded )
return true;

// Try to load the sixense DLLs
// Try to load the sixense libraries

g_pSixenseModule = Sys_LoadModule( "sixense" );

if( !g_pSixenseModule )
{
Msg("Failed to load sixense.dll\n");
return false;
}

g_pSixenseUtilsModule = Sys_LoadModule( "sixense_utils" );

if( !g_pSixenseUtilsModule )
{
Msg("Failed to load sixense_utils.dll\n");
return false;
}
#if defined(_WIN64)
Msg( "Attempting to load sixense_x64.dll \n" );
g_pSixenseModule = Sys_LoadModule( "sixense_x64.dll" );
if( !g_pSixenseModule )
{
Msg( "Failed to load sixense_x64.dll \n" );
return false;
}
#elif defined(__linux__) && defined(__x86_64__)
Msg( "Attempting to load libsixense_x64.so \n" );
g_pSixenseModule = Sys_LoadModule( "libsixense_x64.so" );
if( !g_pSixenseModule )
{
Msg( "Failed to load libsixense_x64.so \n" );
Msg( "dlerror: %s\n", dlerror() );
return false;
}
#else //WIN32
Msg( "Attempting to load sixense.dll \n" );
g_pSixenseModule = Sys_LoadModule( "sixense.dll" );
if( !g_pSixenseModule )
{
Msg( "Failed to load sixense.dll \n );
return false;
}
#endif

Msg("Successfully loaded sixense modules.\n");
#if defined(_WIN64)
Msg( "Attempting to load sixense_utils_x64.dll \n" );
g_pSixenseUtilsModule = Sys_LoadModule( "sixense_utils_x64.dll" );
if( !g_pSixenseModule )
{
Msg( "Failed to load sixense_utils_x64.dll \n" );
return false;
}
#elif defined(__linux__) && defined(__x86_64__)
Msg( "Attempting to load libsixense_utils_x64.so \n ");
g_pSixenseUtilsModule = Sys_LoadModule( "libsixense_utils_x64.so" );
if( !g_pSixenseModule )
{
Msg( "Failed to load libsixense_utils_x64.so \n" );
Msg( "dlerror: %s\n", dlerror() );
return false;
}
#else //WIN32
Msg( "Attempting to load sixense_utils.dll \n" );
g_pSixenseUtilsModule = Sys_LoadModule( "sixense_utils.dll" );
if( !g_pSixenseModule )
{
Msg( "Failed to load sixense_utils.dll \n" );
return false;
}
#endif

bool found_objects = false;

if(g_pSixenseModule)
{
Msg( "Successfully found sixense module.\n" );
CreateInterfaceFn factory = Sys_GetFactory( g_pSixenseModule );

if( factory )
Expand All @@ -415,7 +454,7 @@ bool SixenseInput::LoadModules()

if( !found_objects )
{
Msg("Failed to find factory in sixense.dll\n");
Msg( "Failed to find factory in sixense module\n" );
return false;
}

Expand All @@ -425,6 +464,7 @@ bool SixenseInput::LoadModules()

if(g_pSixenseUtilsModule)
{
Msg( "Successfully found sixense_utils module.\n" );
CreateInterfaceFn factory = Sys_GetFactory( g_pSixenseUtilsModule );

if( factory )
Expand Down Expand Up @@ -455,7 +495,7 @@ bool SixenseInput::LoadModules()

if( !found_objects )
{
Msg("Failed to find factory in sixense_utils.dll\n");
Msg( "Failed to find factory in sixense_utils module\n" );
return false;
}

Expand All @@ -465,6 +505,7 @@ bool SixenseInput::LoadModules()

// We can't set the mode until modules are loaded, so do it now
SetMode( sixense_mode.GetInt() );
Msg( "Successfully initialized sixense modules.\n" );

return true;
}
Expand Down Expand Up @@ -832,9 +873,10 @@ SixenseInput::SixenseInput()

m_bJustSpawned = false;

// For keeping track of the previous mode when looking down the scope changes it.
// For keeping track of the previous mode when looking down the scope or shield charging changes it.
m_bScopeSwitchedMode = false;
m_nScopeSwitchedPrevSpringViewEnabled = 0;
m_nChargingPrevSpringViewEnabled = 0;

m_pGestureBindings = new SixenseGestureBindings;

Expand Down Expand Up @@ -1746,7 +1788,6 @@ bool SixenseInput::SixenseFrame( float flFrametime, CUserCmd *pCmd )


CheckWeaponForScope();

return true;
}

Expand Down Expand Up @@ -2501,24 +2542,29 @@ void SixenseInput::SetView( float flInputSampleFrametime, CUserCmd *pCmd )


#if defined( TF_CLIENT_DLL )
// Dont turn when charging
if( !charging )
// Identify when the player is/isn't charging. Force view angle to recenter on charge end, then reposition crosshair to where it would be if it were allowed to move during a charge.
// Normal Sixense view angle behavior at all other times.
if ( !charging )
{
engine->SetViewAngles( new_viewangles );
m_nChargingPrevSpringViewEnabled = sixense_spring_view_enabled.GetInt();
}
if( charging )
{
sixense_spring_view_enabled.SetValue(m_nChargingPrevSpringViewEnabled);
m_nChargingPrevSpringViewEnabled = sixense_spring_view_enabled.GetInt();
engine->SetViewAngles( new_viewangles );
}

if( charge_stopped )
{

QAngle engine_angles;
engine->GetViewAngles( engine_angles );

ForceViewAngles( engine_angles );
Msg("charge stopped\n");
}
if( charge_stopped )
{
sixense_spring_view_enabled.SetValue(m_nChargingPrevSpringViewEnabled);
QAngle engine_angles;
engine->GetViewAngles( engine_angles );
ForceViewAngles( engine_angles );
}
#else
// Set the engine's aim direction
engine->SetViewAngles( new_viewangles );
// Set the engine's aim direction
engine->SetViewAngles( new_viewangles );
#endif

if ( pCmd )
Expand Down Expand Up @@ -2815,6 +2861,73 @@ void SixenseInput::SixenseUpdateKeys( float flFrametime, CUserCmd *pCmd )
}
}

CHudEurekaEffectTeleportMenu *pEurekaEffectTeleportMenu = ( CHudEurekaEffectTeleportMenu * )GET_HUDELEMENT( CHudEurekaEffectTeleportMenu );
if (pEurekaEffectTeleportMenu->IsVisible())
{
if( m_pRightButtonStates->buttonJustPressed( SIXENSE_BUTTON_3 ))
{
pEurekaEffectTeleportMenu->HudElementKeyInput( 1, KEY_1, "eureka_teleport 0" );
}
if( m_pRightButtonStates->buttonJustPressed( SIXENSE_BUTTON_4 ))
{
pEurekaEffectTeleportMenu->HudElementKeyInput( 1, KEY_2, "eureka_teleport 1" );
}
if( m_pRightButtonStates->stickJustPressed(sixenseUtils::IButtonStates::DIR_DOWN ) )
{
engine->ClientCmd( "lastinv" );
}
}

CHudMenuTauntSelection *pTauntSelection = ( CHudMenuTauntSelection * )GET_HUDELEMENT( CHudMenuTauntSelection );
if (pTauntSelection->IsVisible())
{
if( m_pLeftButtonStates->buttonJustPressed( SIXENSE_BUTTON_3 ) )
{
pTauntSelection->HudElementKeyInput( 1, KEY_1, "slot1" );
}
if( m_pLeftButtonStates->buttonJustPressed( SIXENSE_BUTTON_1 ) )
{
pTauntSelection->HudElementKeyInput( 1, KEY_2, "slot2" );
}
if( m_pLeftButtonStates->buttonJustPressed( SIXENSE_BUTTON_2 ) )
{
pTauntSelection->HudElementKeyInput( 1, KEY_3, "slot3" );
}
if( m_pLeftButtonStates->buttonJustPressed( SIXENSE_BUTTON_4 ) )
{
pTauntSelection->HudElementKeyInput( 1, KEY_4, "slot4" );
}
if( m_pRightButtonStates->buttonJustPressed( SIXENSE_BUTTON_3 ) )
{
pTauntSelection->HudElementKeyInput( 1, KEY_5, "slot5" );
}
if( m_pRightButtonStates->buttonJustPressed( SIXENSE_BUTTON_1 ) )
{
pTauntSelection->HudElementKeyInput( 1, KEY_6, "slot6" );
}
if( m_pRightButtonStates->buttonJustPressed( SIXENSE_BUTTON_2 ) )
{
pTauntSelection->HudElementKeyInput( 1, KEY_7, "slot7" );
}
if( m_pRightButtonStates->buttonJustPressed( SIXENSE_BUTTON_4 ) )
{
pTauntSelection->HudElementKeyInput( 1, KEY_8, "slot8" );
}
if( m_pRightButtonStates->buttonJustPressed( SIXENSE_BUTTON_BUMPER ) )
{
engine->ExecuteClientCmd( "taunt" );
}
if( m_pRightButtonStates->stickJustPressed( sixenseUtils::IButtonStates::DIR_DOWN ) )
{
// "engine->ExecuteClientCmd("lastinv");" Does not work with taunt menu specifically, so we're doing what the Steam Controller does to close the taunt menu instead.
CTFPlayer* pPlayer = C_TFPlayer::GetLocalTFPlayer();
if (pPlayer)
{
pPlayer->SetShowHudMenuTauntSelection( false );
}
}
}

if ( TFGameRules() && TFGameRules()->IsInTraining() )
{
if( m_pLeftButtonStates->absoluteTiltJustStarted( sixenseUtils::IButtonStates::DIR_UP ) )
Expand Down Expand Up @@ -4035,6 +4148,18 @@ bool SixenseInput::AreBindingsDisabled()
{
return true;
}

CHudMenuTauntSelection* pTauntSelection = (CHudMenuTauntSelection*)GET_HUDELEMENT(CHudMenuTauntSelection);
if (pTauntSelection->IsVisible())
{
return true;
}

CHudEurekaEffectTeleportMenu* pEurekaEffectTeleportMenu = (CHudEurekaEffectTeleportMenu*)GET_HUDELEMENT(CHudEurekaEffectTeleportMenu);
if (pEurekaEffectTeleportMenu->IsVisible())
{
return true;
}
#endif

return false;
Expand Down
40 changes: 35 additions & 5 deletions src/game/client/sixense/in_sixense.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ namespace sixenseUtils {
class IFPSPlayerMovement;
class IFPSEvents;
class IFPSMeleeWeapon;

class IMousePointer;
class IDerivatives;
class IButtonStates;
class ILaserPointer;

class IMouseAndKeyboard;
class IControllerManager;
};

Expand Down Expand Up @@ -197,21 +197,51 @@ class SixenseInput : public CGameEventListener
bool m_bScopeSwitchedMode;
sixenseUtils::IFPSViewAngles::fps_mode m_nScopeSwitchedPrevMode;
int m_nScopeSwitchedPrevSpringViewEnabled;
int m_nChargingPrevSpringViewEnabled;

float m_fTeleportWaitToBlendTime;

class ISixenseAPI *m_pSixenseAPI;
class ISixenseAPI
{
public:
virtual int sixenseInit( void );
virtual int sixenseExit( void );
virtual int sixenseGetMaxBases();
virtual int sixenseSetActiveBase( int i );
virtual int sixenseIsBaseConnected( int i );
virtual int sixenseGetMaxControllers( void );
virtual int sixenseIsControllerEnabled( int which );
virtual int sixenseGetNumActiveControllers();
virtual int sixenseGetHistorySize();
virtual int sixenseGetData( int which, int index_back, sixenseControllerData * );
virtual int sixenseGetAllData( int index_back, sixenseAllControllerData * );
virtual int sixenseGetNewestData( int which, sixenseControllerData * );
virtual int sixenseGetAllNewestData( sixenseAllControllerData * );
virtual int sixenseSetHemisphereTrackingMode( int which_controller, int state );
virtual int sixenseGetHemisphereTrackingMode( int which_controller, int *state );
virtual int sixenseAutoEnableHemisphereTracking( int which_controller );
virtual int sixenseSetHighPriorityBindingEnabled( int on_or_off );
virtual int sixenseGetHighPriorityBindingEnabled( int *on_or_off );
virtual int sixenseTriggerVibration( int controller_id, int duration_100ms, int pattern_id );
virtual int sixenseSetFilterEnabled( int on_or_off );
virtual int sixenseGetFilterEnabled( int *on_or_off );
virtual int sixenseSetFilterParams( float near_range, float near_val, float far_range, float far_val );
virtual int sixenseGetFilterParams( float *near_range, float *near_val, float *far_range, float *far_val );
virtual int sixenseSetBaseColor( unsigned char red, unsigned char green, unsigned char blue );
virtual int sixenseGetBaseColor( unsigned char *red, unsigned char *green, unsigned char *blue );
};
ISixenseAPI *m_pSixenseAPI;

struct _sixenseAllControllerData *m_pACD;

class sixenseUtils::IFPSViewAngles *m_pFPSViewAngles;
class sixenseUtils::IFPSPlayerMovement *m_pFPSPlayerMovement;
class sixenseUtils::IFPSEvents *m_pFPSEvents;

class sixenseUtils::IMousePointer* m_pMousePointer;
class sixenseUtils::IDerivatives *m_pLeftDeriv, *m_pRightDeriv;
class sixenseUtils::IButtonStates *m_pLeftButtonStates, *m_pRightButtonStates;
class sixenseUtils::ILaserPointer *m_pLaserPointer;

class sixenseUtils::IMouseAndKeyboard* m_pMouseAndKeyboard;
class sixenseUtils::IControllerManager *m_pControllerManager;

int m_LastViewMode;
Expand Down
Loading