mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
MouseSettings: Add option to reverse buttons
Add option to reverse primary and secondary buttons in Mouse Settings. - WindowServer.ini: add default entry - switch-mouse-buttons.png: new icon for settings entry - Mouse.gml/MouseWidget.*: new settings dialog - ClientConnection/WindowManager/Server: window message for settings - EventLoop.cpp: swap buttons 1 and 2 if settings are on
This commit is contained in:
parent
5599d22744
commit
0e68550c05
11 changed files with 90 additions and 0 deletions
|
@ -106,6 +106,20 @@ void EventLoop::drain_mouse()
|
|||
if (packet.buttons != state.buttons) {
|
||||
state.buttons = packet.buttons;
|
||||
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse Button Event");
|
||||
|
||||
// Swap primary (1) and secondary (2) buttons if checked in Settings.
|
||||
// Doing the swap here avoids all emulator and hardware issues.
|
||||
if (WindowManager::the().get_buttons_switched()) {
|
||||
bool has_primary = state.buttons & MousePacket::Button::LeftButton;
|
||||
bool has_secondary = state.buttons & MousePacket::Button::RightButton;
|
||||
state.buttons = state.buttons & ~(MousePacket::Button::LeftButton | MousePacket::Button::RightButton);
|
||||
// Invert the buttons:
|
||||
if (has_primary)
|
||||
state.buttons |= MousePacket::Button::RightButton;
|
||||
if (has_secondary)
|
||||
state.buttons |= MousePacket::Button::LeftButton;
|
||||
}
|
||||
|
||||
screen_input.on_receive_mouse_data(state);
|
||||
state_is_sent = true;
|
||||
if (state.is_relative) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue