mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Rename XButton1 and XButton2 into Extra1 and Extra2
This is to avoid repeating Button when using those values now that the sf::Mouse::Button enumeration is a scoped enumeration.
This commit is contained in:
parent
eab8f426e7
commit
b20376813c
@ -51,8 +51,8 @@ enum class Button
|
|||||||
Left, //!< The left mouse button
|
Left, //!< The left mouse button
|
||||||
Right, //!< The right mouse button
|
Right, //!< The right mouse button
|
||||||
Middle, //!< The middle (wheel) mouse button
|
Middle, //!< The middle (wheel) mouse button
|
||||||
XButton1, //!< The first extra mouse button
|
Extra1, //!< The first extra mouse button
|
||||||
XButton2 //!< The second extra mouse button
|
Extra2 //!< The second extra mouse button
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||||
@ -71,8 +71,8 @@ enum class Wheel
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Check if a mouse button is pressed
|
/// \brief Check if a mouse button is pressed
|
||||||
///
|
///
|
||||||
/// \warning Checking the state of buttons Mouse::Button::XButton1 and
|
/// \warning Checking the state of buttons Mouse::Button::Extra1 and
|
||||||
/// Mouse::Button::XButton2 is not supported on Linux with X11.
|
/// Mouse::Button::Extra2 is not supported on Linux with X11.
|
||||||
///
|
///
|
||||||
/// \param button Button to check
|
/// \param button Button to check
|
||||||
///
|
///
|
||||||
|
@ -177,9 +177,9 @@ std::optional<sf::Mouse::Button> toMouseButton(int code)
|
|||||||
case BTN_MIDDLE:
|
case BTN_MIDDLE:
|
||||||
return sf::Mouse::Button::Middle;
|
return sf::Mouse::Button::Middle;
|
||||||
case BTN_SIDE:
|
case BTN_SIDE:
|
||||||
return sf::Mouse::Button::XButton1;
|
return sf::Mouse::Button::Extra1;
|
||||||
case BTN_EXTRA:
|
case BTN_EXTRA:
|
||||||
return sf::Mouse::Button::XButton2;
|
return sf::Mouse::Button::Extra2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
@ -103,15 +103,15 @@ bool isMouseButtonPressed(Mouse::Button button)
|
|||||||
|
|
||||||
// Buttons 4 and 5 are the vertical wheel and 6 and 7 the horizontal wheel.
|
// Buttons 4 and 5 are the vertical wheel and 6 and 7 the horizontal wheel.
|
||||||
// There is no mask for buttons 8 and 9, so checking the state of buttons
|
// There is no mask for buttons 8 and 9, so checking the state of buttons
|
||||||
// Mouse::Button::XButton1 and Mouse::Button::XButton2 is not supported.
|
// Mouse::Button::Extra1 and Mouse::Button::Extra2 is not supported.
|
||||||
// clang-format off
|
// clang-format off
|
||||||
switch (button)
|
switch (button)
|
||||||
{
|
{
|
||||||
case Mouse::Button::Left: return buttons & Button1Mask;
|
case Mouse::Button::Left: return buttons & Button1Mask;
|
||||||
case Mouse::Button::Right: return buttons & Button3Mask;
|
case Mouse::Button::Right: return buttons & Button3Mask;
|
||||||
case Mouse::Button::Middle: return buttons & Button2Mask;
|
case Mouse::Button::Middle: return buttons & Button2Mask;
|
||||||
case Mouse::Button::XButton1: return false; // not supported by X
|
case Mouse::Button::Extra1: return false; // not supported by X
|
||||||
case Mouse::Button::XButton2: return false; // not supported by X
|
case Mouse::Button::Extra2: return false; // not supported by X
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -1940,8 +1940,8 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||||||
case Button1: event.mouseButton.button = Mouse::Button::Left; break;
|
case Button1: event.mouseButton.button = Mouse::Button::Left; break;
|
||||||
case Button2: event.mouseButton.button = Mouse::Button::Middle; break;
|
case Button2: event.mouseButton.button = Mouse::Button::Middle; break;
|
||||||
case Button3: event.mouseButton.button = Mouse::Button::Right; break;
|
case Button3: event.mouseButton.button = Mouse::Button::Right; break;
|
||||||
case 8: event.mouseButton.button = Mouse::Button::XButton1; break;
|
case 8: event.mouseButton.button = Mouse::Button::Extra1; break;
|
||||||
case 9: event.mouseButton.button = Mouse::Button::XButton2; break;
|
case 9: event.mouseButton.button = Mouse::Button::Extra2; break;
|
||||||
}
|
}
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
@ -1975,10 +1975,10 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||||||
event.mouseButton.button = Mouse::Button::Right;
|
event.mouseButton.button = Mouse::Button::Right;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
event.mouseButton.button = Mouse::Button::XButton1;
|
event.mouseButton.button = Mouse::Button::Extra1;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
event.mouseButton.button = Mouse::Button::XButton2;
|
event.mouseButton.button = Mouse::Button::Extra2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pushEvent(event);
|
pushEvent(event);
|
||||||
|
@ -631,10 +631,10 @@ bool isMouseButtonPressed(Mouse::Button button)
|
|||||||
case Mouse::Button::Middle:
|
case Mouse::Button::Middle:
|
||||||
virtualKey = VK_MBUTTON;
|
virtualKey = VK_MBUTTON;
|
||||||
break;
|
break;
|
||||||
case Mouse::Button::XButton1:
|
case Mouse::Button::Extra1:
|
||||||
virtualKey = VK_XBUTTON1;
|
virtualKey = VK_XBUTTON1;
|
||||||
break;
|
break;
|
||||||
case Mouse::Button::XButton2:
|
case Mouse::Button::Extra2:
|
||||||
virtualKey = VK_XBUTTON2;
|
virtualKey = VK_XBUTTON2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1027,7 +1027,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
Event event;
|
Event event;
|
||||||
event.type = Event::MouseButtonPressed;
|
event.type = Event::MouseButtonPressed;
|
||||||
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::Button::XButton1 : Mouse::Button::XButton2;
|
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::Button::Extra1 : Mouse::Button::Extra2;
|
||||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||||
pushEvent(event);
|
pushEvent(event);
|
||||||
@ -1039,7 +1039,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
Event event;
|
Event event;
|
||||||
event.type = Event::MouseButtonReleased;
|
event.type = Event::MouseButtonReleased;
|
||||||
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::Button::XButton1 : Mouse::Button::XButton2;
|
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::Button::Extra1 : Mouse::Button::Extra2;
|
||||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||||
pushEvent(event);
|
pushEvent(event);
|
||||||
|
@ -418,9 +418,9 @@
|
|||||||
case 2:
|
case 2:
|
||||||
return sf::Mouse::Button::Middle;
|
return sf::Mouse::Button::Middle;
|
||||||
case 3:
|
case 3:
|
||||||
return sf::Mouse::Button::XButton1;
|
return sf::Mouse::Button::Extra1;
|
||||||
case 4:
|
case 4:
|
||||||
return sf::Mouse::Button::XButton2;
|
return sf::Mouse::Button::Extra2;
|
||||||
default:
|
default:
|
||||||
return std::nullopt; // Never happens! (hopefully)
|
return std::nullopt; // Never happens! (hopefully)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user