mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
use info provided by sdl for mouse double clicks
This commit is contained in:
parent
3557bea32d
commit
bbc194ce2a
|
@ -40,8 +40,7 @@ CInput::CInput()
|
|||
m_InputCounter = 1;
|
||||
m_InputGrabbed = 0;
|
||||
|
||||
m_LastRelease = 0;
|
||||
m_ReleaseDelta = -1;
|
||||
m_MouseDoubleClick = false;
|
||||
|
||||
m_NumEvents = 0;
|
||||
m_MouseFocus = true;
|
||||
|
@ -126,10 +125,9 @@ bool CInput::NativeMousePressed(int index)
|
|||
|
||||
int CInput::MouseDoubleClick()
|
||||
{
|
||||
if(m_ReleaseDelta >= 0 && m_ReleaseDelta < (time_freq() / 3))
|
||||
if(m_MouseDoubleClick)
|
||||
{
|
||||
m_LastRelease = 0;
|
||||
m_ReleaseDelta = -1;
|
||||
m_MouseDoubleClick = false;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -311,12 +309,6 @@ int CInput::Update()
|
|||
case SDL_MOUSEBUTTONUP:
|
||||
Action = IInput::FLAG_RELEASE;
|
||||
|
||||
if(Event.button.button == 1) // ignore_convention
|
||||
{
|
||||
m_ReleaseDelta = time_get() - m_LastRelease;
|
||||
m_LastRelease = time_get();
|
||||
}
|
||||
|
||||
// fall through
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if(Event.button.button == SDL_BUTTON_LEFT)
|
||||
|
@ -337,6 +329,8 @@ int CInput::Update()
|
|||
Scancode = KEY_MOUSE_8; // ignore_convention
|
||||
if(Event.button.button == 9)
|
||||
Scancode = KEY_MOUSE_9; // ignore_convention
|
||||
if(Event.button.clicks % 2 == 0 && Event.button.button == SDL_BUTTON_LEFT)
|
||||
m_MouseDoubleClick = true;
|
||||
break;
|
||||
|
||||
case SDL_MOUSEWHEEL:
|
||||
|
|
|
@ -19,10 +19,9 @@ class CInput : public IEngineInput
|
|||
int m_InputGrabbed;
|
||||
char *m_pClipboardText;
|
||||
|
||||
int64_t m_LastRelease;
|
||||
int64_t m_ReleaseDelta;
|
||||
|
||||
bool m_MouseFocus;
|
||||
bool m_MouseDoubleClick;
|
||||
|
||||
int m_VideoRestartNeeded;
|
||||
|
||||
void AddEvent(char *pText, int Key, int Flags);
|
||||
|
|
Loading…
Reference in a new issue