Alexander 'z33ky' Hirsch e0091261ed 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.
2021-03-20 13:58:23 +01:00

33 lines
652 B
C++

//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: names mouse button inputs
// NOTE: Button codes also contain key codes, but we won't worry about that
//
// $NoKeywords: $
//===========================================================================//
#ifndef MOUSECODE_H
#define MOUSECODE_H
#ifdef _WIN32
#pragma once
#endif
#include "inputsystem/ButtonCode.h"
namespace vgui
{
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