mirror of
https://github.com/ENSL/NS.git
synced 2024-11-10 07:11:38 +00:00
Fix side mouse buttons registering as left click when using the cursor.
- also allow mouse3/4/5 binds to be accessible as commander.
This commit is contained in:
parent
1363f48d96
commit
92db73eb89
5 changed files with 105 additions and 7 deletions
|
@ -109,6 +109,9 @@ int in_cancel = 0;
|
|||
|
||||
bool pistolHandlerDown = false;
|
||||
|
||||
extern int g_iVisibleMouse;
|
||||
int g_iVguiSideMouse;
|
||||
|
||||
cvar_t *m_pitch;
|
||||
cvar_t *m_yaw;
|
||||
cvar_t *m_forward;
|
||||
|
@ -567,6 +570,38 @@ Return 1 to allow engine to process the key, otherwise, act on it as needed
|
|||
int CL_DLLEXPORT HUD_Key_Event( int down, int keynum, const char *pszCurrentBinding )
|
||||
{
|
||||
// RecClKeyEvent(down, keynum, pszCurrentBinding);
|
||||
|
||||
// 2024 - Check mouse button presses when the cursor is visible to fix issues with VGUI registering mouse4/5 as left click. Previously these were blocked in inputw32.
|
||||
// Also note that g_iVguiSideMouseRelease is set in inputw32, because for some reason side mouse button releases in VGUI mode don't get sent here.
|
||||
if (g_iVisibleMouse && (keynum >= K_MOUSE1 && keynum <= K_MOUSE5))
|
||||
{
|
||||
//gEngfuncs.Con_Printf("mouse event keynum:%d down:%d\n", keynum, down);
|
||||
|
||||
switch (keynum)
|
||||
{
|
||||
case K_MOUSE1:
|
||||
case K_MOUSE2:
|
||||
g_iVguiSideMouse = 0;
|
||||
return 0;
|
||||
case K_MOUSE3:
|
||||
g_iVguiSideMouse = 0;
|
||||
// Allow mouse3 binds while commanding since commander VGUI currently doesn't use it.
|
||||
if (!gHUD.GetInTopDownMode())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case K_MOUSE4:
|
||||
case K_MOUSE5:
|
||||
g_iVguiSideMouse = keynum;
|
||||
|
||||
if (!gHUD.GetInTopDownMode())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if the event has any outlawed commands in it.
|
||||
float theBlockScripts = gHUD.GetServerVariableFloat(kvBlockScripts);
|
||||
|
@ -1194,6 +1229,11 @@ void CL_DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int ac
|
|||
theProcessedMove = true;
|
||||
theIsSendingSpecialEvent = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear the impulse so it doesn't execute once leaving the chair.
|
||||
in_impulse = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(!theProcessedMove && gHUD.GetAndClearSelectionEvent(theMouseNormPos, theTechEvent))
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
// use IN_SetVisibleMouse to set:
|
||||
int g_iVisibleMouse = 0;
|
||||
int g_iVguiSideMouseRelease = 0;
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
||||
|
@ -534,8 +535,9 @@ IN_MouseEvent
|
|||
void CL_DLLEXPORT IN_MouseEvent (int mstate)
|
||||
{
|
||||
int i;
|
||||
g_iVguiSideMouseRelease = 0;
|
||||
|
||||
if ( iMouseInUse || g_iVisibleMouse )
|
||||
if ( iMouseInUse /*|| g_iVisibleMouse */) // Mouse button processing when the cursor is visible moved to HUD_Key_Event.
|
||||
return;
|
||||
|
||||
// perform button actions
|
||||
|
@ -551,9 +553,16 @@ void CL_DLLEXPORT IN_MouseEvent (int mstate)
|
|||
(mouse_oldbuttonstate & (1<<i)) )
|
||||
{
|
||||
gEngfuncs.Key_Event (K_MOUSE1 + i, 0);
|
||||
|
||||
// HACK: When in VGUI mode the mouse4 and mouse5 release events don't show up in HUD_Key_Event for some reason.
|
||||
// This is needed in edge cases while commanding where a side mouse button is pressed before left click, then released before left click is released.
|
||||
if (i >= 3)
|
||||
{
|
||||
g_iVguiSideMouseRelease = K_MOUSE1 + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mouse_oldbuttonstate = mstate;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,10 @@
|
|||
#include "AvHTechImpulsePanel.h"
|
||||
#include "AvHCommandConstants.h"
|
||||
#include "../util/STLUtil.h"
|
||||
//#include "keydefs.h"
|
||||
|
||||
extern int g_iVguiSideMouse;
|
||||
extern int g_iVguiSideMouseRelease;
|
||||
|
||||
AvHCommanderModeHandler::AvHCommanderModeHandler()
|
||||
{
|
||||
|
@ -758,7 +762,7 @@ void AvHCommanderModeHandler::mousePressed(MouseCode code, Panel* inPanel)
|
|||
// if the cursor is no longer on the panel.
|
||||
App::getInstance()->setMouseCapture(inPanel);
|
||||
|
||||
if(code == MOUSE_LEFT)
|
||||
if(code == MOUSE_LEFT && !g_iVguiSideMouse)
|
||||
{
|
||||
this->mMouseOneDown = true;
|
||||
|
||||
|
@ -795,6 +799,22 @@ void AvHCommanderModeHandler::mousePressed(MouseCode code, Panel* inPanel)
|
|||
//this->DefaultOrderToLastMousePosition(theHierarchy);
|
||||
}
|
||||
}
|
||||
//// TO DO: Custom bind cvars for comm side mouse buttons.
|
||||
//else if (code == MOUSE_MIDDLE)
|
||||
//{
|
||||
// this->mLastTechPressed = ;
|
||||
// this->mTechNodePressed = true;
|
||||
//}
|
||||
//else if (code == vgui::MOUSE_LEFT && g_iVguiSideMouse == K_MOUSE4)
|
||||
//{
|
||||
// this->mLastTechPressed = ;
|
||||
// this->mTechNodePressed = true;
|
||||
//}
|
||||
//else if (code == vgui::MOUSE_LEFT && g_iVguiSideMouse == K_MOUSE5)
|
||||
//{
|
||||
// this->mLastTechPressed = ;
|
||||
// this->mTechNodePressed = true;
|
||||
//}
|
||||
}
|
||||
|
||||
void AvHCommanderModeHandler::mouseDoublePressed(MouseCode code, Panel* inPanel)
|
||||
|
@ -856,7 +876,7 @@ void AvHCommanderModeHandler::mouseReleased(MouseCode code, Panel* inPanel)
|
|||
|
||||
App::getInstance()->setMouseCapture(NULL);
|
||||
|
||||
if(code == MOUSE_LEFT)
|
||||
if(code == MOUSE_LEFT && !g_iVguiSideMouse && !g_iVguiSideMouseRelease)
|
||||
{
|
||||
|
||||
if (GetIsPointInPanel(inPanel, mLastMouseX, mLastMouseY))
|
||||
|
|
|
@ -57,6 +57,9 @@ extern int g_weaponselect;
|
|||
extern int in_impulse;
|
||||
bool sTheDebugBool = false;
|
||||
|
||||
extern int g_iVguiSideMouse;
|
||||
//extern int g_iVguiSideMouseRelease;
|
||||
|
||||
PieNode* AvHPieMenuHandler::sLastNodeHighlighted = NULL;
|
||||
string AvHPieMenuHandler::sPieMenuName = "";
|
||||
float AvHPieMenuHandler::sTimeLastNodeHighlighted = 0.0f;
|
||||
|
@ -385,6 +388,12 @@ void AvHPieMenuHandler::cursorExited(Panel* panel)
|
|||
|
||||
void AvHPieMenuHandler::mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
// Don't register side mouse button clicks.
|
||||
if (code == vgui::MOUSE_LEFT && g_iVguiSideMouse)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClosePieMenu();
|
||||
//CenterPrint("AvHPieMenuHandler::mousePressed.\n");
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "AvHScrollPanel.h"
|
||||
#include "AvHActionButtons.h"
|
||||
#include "ui/UIUtil.h"
|
||||
//#include "keydefs.h"
|
||||
|
||||
int AvHScrollHandler::sScrollX = 0;
|
||||
int AvHScrollHandler::sScrollY = 0;
|
||||
|
@ -20,6 +21,9 @@ bool AvHScrollHandler::sMouseOneDown = false;
|
|||
bool AvHScrollHandler::sMouseTwoDown = false;
|
||||
int AvHScrollHandler::sKeyDown = 0;
|
||||
|
||||
extern int g_iVguiSideMouse;
|
||||
extern int g_iVguiSideMouseRelease;
|
||||
|
||||
AvHScrollHandler::AvHScrollHandler()
|
||||
{
|
||||
sKeyDown = 0;
|
||||
|
@ -218,7 +222,7 @@ void AvHScrollHandler::keyPressed(KeyCode inKeyCode, Panel* panel)
|
|||
void AvHScrollHandler::mousePressed(MouseCode code, Panel* panel)
|
||||
{
|
||||
// store this
|
||||
if(code == vgui::MOUSE_LEFT)
|
||||
if(code == vgui::MOUSE_LEFT && !g_iVguiSideMouse)
|
||||
{
|
||||
sMouseOneDown = true;
|
||||
}
|
||||
|
@ -226,12 +230,28 @@ void AvHScrollHandler::mousePressed(MouseCode code, Panel* panel)
|
|||
{
|
||||
sMouseTwoDown = true;
|
||||
}
|
||||
//// TO DO: Custom bind cvars for comm side mouse buttons.
|
||||
//else if (code == MOUSE_MIDDLE)
|
||||
//{
|
||||
// this->mLastTechPressed = ;
|
||||
// this->mTechNodePressed = true;
|
||||
//}
|
||||
//else if (code == vgui::MOUSE_LEFT && g_iVguiSideMouse == K_MOUSE4)
|
||||
//{
|
||||
// this->mLastTechPressed = ;
|
||||
// this->mTechNodePressed = true;
|
||||
//}
|
||||
//else if (code == vgui::MOUSE_LEFT && g_iVguiSideMouse == K_MOUSE5)
|
||||
//{
|
||||
// this->mLastTechPressed = ;
|
||||
// this->mTechNodePressed = true;
|
||||
//}
|
||||
}
|
||||
|
||||
void AvHScrollHandler::mouseReleased(MouseCode code, Panel* panel)
|
||||
{
|
||||
// store this
|
||||
if(code == vgui::MOUSE_LEFT)
|
||||
if(code == vgui::MOUSE_LEFT && !g_iVguiSideMouse && !g_iVguiSideMouseRelease)
|
||||
{
|
||||
sMouseOneDown = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue