mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-04-15 14:02:30 +03:00
Fix Buttons not working on Linux with newer gcc
The button mask is created by shifting a bit according to the MouseCode, which is just a renamed ButtonCode_t. Mouse buttons start at 107, which is way out of range for our ints. To fix this, introduce MouseButtonBit(), which checks if a button code corresponds to a mouse button at all and returns a usable bitmask for the corresponding mouse button code. This is then used for the button mask.
This commit is contained in:
parent
718186f165
commit
e0091261ed
@ -18,6 +18,15 @@
|
|||||||
namespace vgui
|
namespace vgui
|
||||||
{
|
{
|
||||||
typedef ButtonCode_t MouseCode;
|
typedef ButtonCode_t MouseCode;
|
||||||
|
|
||||||
|
static inline int MouseButtonBit(MouseCode code)
|
||||||
|
{
|
||||||
|
if (code < MOUSE_FIRST || code > MOUSE_LAST) {
|
||||||
|
Assert(false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1 << (code - MOUSE_FIRST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MOUSECODE_H
|
#endif // MOUSECODE_H
|
||||||
|
@ -695,12 +695,12 @@ void Button::SetMouseClickEnabled(MouseCode code,bool state)
|
|||||||
if(state)
|
if(state)
|
||||||
{
|
{
|
||||||
//set bit to 1
|
//set bit to 1
|
||||||
_mouseClickMask|=1<<((int)(code+1));
|
_mouseClickMask|=MouseButtonBit(code);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//set bit to 0
|
//set bit to 0
|
||||||
_mouseClickMask&=~(1<<((int)(code+1)));
|
_mouseClickMask&=~MouseButtonBit(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ void Button::SetMouseClickEnabled(MouseCode code,bool state)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Button::IsMouseClickEnabled(MouseCode code)
|
bool Button::IsMouseClickEnabled(MouseCode code)
|
||||||
{
|
{
|
||||||
if(_mouseClickMask&(1<<((int)(code+1))))
|
if(_mouseClickMask&MouseButtonBit(code))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user