mirror of https://github.com/stella-emu/stella.git
added middle mouse button support (emulates double click)
This commit is contained in:
parent
dcc3eebab1
commit
43a67ef224
|
@ -124,19 +124,23 @@ void EventHandlerSDL2::pollEvent()
|
|||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
// ToDo: check support of more buttons and double-click
|
||||
MouseButton b{MouseButton::NONE};
|
||||
switch(myEvent.button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
handleMouseButtonEvent(MouseButton::LEFT, myEvent.button.type == SDL_MOUSEBUTTONDOWN,
|
||||
myEvent.button.x, myEvent.button.y);
|
||||
b = MouseButton::LEFT;
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
handleMouseButtonEvent(MouseButton::RIGHT, myEvent.button.type == SDL_MOUSEBUTTONDOWN,
|
||||
myEvent.button.x, myEvent.button.y);
|
||||
b = MouseButton::RIGHT;
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
b = MouseButton::MIDDLE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
handleMouseButtonEvent(b, myEvent.button.type == SDL_MOUSEBUTTONDOWN,
|
||||
myEvent.button.x, myEvent.button.y);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ enum class EventHandlerState {
|
|||
enum class MouseButton {
|
||||
LEFT,
|
||||
RIGHT,
|
||||
MIDDLE,
|
||||
WHEELDOWN,
|
||||
WHEELUP,
|
||||
NONE
|
||||
|
|
|
@ -256,6 +256,7 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
|
|||
{
|
||||
case MouseButton::LEFT:
|
||||
case MouseButton::RIGHT:
|
||||
case MouseButton::MIDDLE:
|
||||
if(pressed)
|
||||
{
|
||||
// If more than two clicks have been recorded, we start over
|
||||
|
@ -266,7 +267,13 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
|
|||
myLastClick.count = 0;
|
||||
}
|
||||
|
||||
if(myLastClick.count && (myTime < myLastClick.time + _DOUBLE_CLICK_DELAY)
|
||||
if(b == MouseButton::MIDDLE)
|
||||
{
|
||||
// Middle mouse button emulates lef mouse button double click
|
||||
myLastClick.count = 2;
|
||||
b = MouseButton::LEFT;
|
||||
}
|
||||
else if(myLastClick.count && (myTime < myLastClick.time + _DOUBLE_CLICK_DELAY)
|
||||
&& std::abs(myLastClick.x - x) < 3
|
||||
&& std::abs(myLastClick.y - y) < 3)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue