@@ -6420,24 +6420,6 @@ bool CStaticFunctionDefinitions::BindKey(const char* szKey, const char* szHitSta
6420
6420
return bSuccess;
6421
6421
}
6422
6422
6423
- static inline void BindKeyAtHitState (CKeyBindsInterface* pKeyBinds, const char * szKey, const char * szCommandName, const char * szArguments, const char * szResource, const bool bHitState, bool & bSuccess)
6424
- {
6425
- // Check if its binded already (dont rebind)
6426
- if (!pKeyBinds->CommandExists (szKey, szCommandName, true , bHitState, szArguments, szResource, true , true ))
6427
- {
6428
- if (pKeyBinds->AddCommand (szKey, szCommandName, szArguments, bHitState, szResource, true ))
6429
- {
6430
- pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState, szArguments, szResource, true , true );
6431
- bSuccess = true ;
6432
- }
6433
- }
6434
- else
6435
- {
6436
- pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState, szArguments, szResource, true , true );
6437
- bSuccess = true ;
6438
- }
6439
- }
6440
-
6441
6423
bool CStaticFunctionDefinitions::BindKey (const char * szKey, const char * szHitState, const char * szCommandName, const char * szArguments, const char * szResource)
6442
6424
{
6443
6425
assert (szKey);
@@ -6449,13 +6431,30 @@ bool CStaticFunctionDefinitions::BindKey(const char* szKey, const char* szHitSta
6449
6431
bool bKey = pKeyBinds->IsKey (szKey);
6450
6432
if (bKey)
6451
6433
{
6452
- if (!stricmp (szHitState, " down" ) || !stricmp (szHitState, " both" ))
6434
+ bool bHitState = true ;
6435
+ // Activate all keys for this command
6436
+ pKeyBinds->SetAllCommandsActive (szResource, true , szCommandName, bHitState, szArguments, true );
6437
+ // Check if its binded already (dont rebind)
6438
+ if (pKeyBinds->CommandExists (szKey, szCommandName, true , bHitState, szArguments, szResource, true , true ))
6439
+ return true ;
6440
+
6441
+ if ((!stricmp (szHitState, " down" ) || !stricmp (szHitState, " both" )) &&
6442
+ pKeyBinds->AddCommand (szKey, szCommandName, szArguments, bHitState, szResource, true ))
6453
6443
{
6454
- BindKeyAtHitState (pKeyBinds, szKey, szCommandName, szArguments, szResource, true , bSuccess);
6444
+ pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState, szArguments, szResource, true , true );
6445
+ bSuccess = true ;
6455
6446
}
6456
- if (!stricmp (szHitState, " up" ) || !stricmp (szHitState, " both" ))
6447
+
6448
+ bHitState = false ;
6449
+ pKeyBinds->SetAllCommandsActive (szResource, true , szCommandName, bHitState, szArguments, true );
6450
+ if (pKeyBinds->CommandExists (szKey, szCommandName, true , bHitState, szArguments, szResource, true , true ))
6451
+ return true ;
6452
+
6453
+ if ((!stricmp (szHitState, " up" ) || !stricmp (szHitState, " both" )) &&
6454
+ pKeyBinds->AddCommand (szKey, szCommandName, szArguments, bHitState, szResource, true ))
6457
6455
{
6458
- BindKeyAtHitState (pKeyBinds, szKey, szCommandName, szArguments, szResource, false , bSuccess);
6456
+ pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState, szArguments, szResource, true , true );
6457
+ bSuccess = true ;
6459
6458
}
6460
6459
}
6461
6460
return bSuccess;
@@ -6511,14 +6510,29 @@ bool CStaticFunctionDefinitions::UnbindKey(const char* szKey, const char* szHitS
6511
6510
bool bKey = pKeyBinds->IsKey (szKey);
6512
6511
if (bKey)
6513
6512
{
6513
+ bool bCheckHitState = false , bHitState = true ;
6514
+ if (szHitState)
6515
+ {
6516
+ if (stricmp (szHitState, " down" ) == 0 )
6517
+ {
6518
+ bCheckHitState = true , bHitState = true ;
6519
+ }
6520
+ else if (stricmp (szHitState, " up" ) == 0 )
6521
+ {
6522
+ bCheckHitState = true , bHitState = false ;
6523
+ }
6524
+ }
6514
6525
if ((!stricmp (szHitState, " down" ) || !stricmp (szHitState, " both" )) &&
6515
- pKeyBinds->SetCommandActive (szKey, szCommandName, true , NULL , szResource, false , true ))
6526
+ pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState , NULL , szResource, false , true ))
6516
6527
{
6528
+ pKeyBinds->SetAllCommandsActive (szResource, false , szCommandName, bHitState, NULL , true );
6517
6529
bSuccess = true ;
6518
6530
}
6531
+ bHitState = false ;
6519
6532
if ((!stricmp (szHitState, " up" ) || !stricmp (szHitState, " both" )) &&
6520
- pKeyBinds->SetCommandActive (szKey, szCommandName, false , NULL , szResource, false , true ))
6533
+ pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState , NULL , szResource, false , true ))
6521
6534
{
6535
+ pKeyBinds->SetAllCommandsActive (szResource, false , szCommandName, bHitState, NULL , true );
6522
6536
bSuccess = true ;
6523
6537
}
6524
6538
}
0 commit comments