diff --git a/data/pigui/modules/settings-window.lua b/data/pigui/modules/settings-window.lua index 809c840134c..4001826b752 100644 --- a/data/pigui/modules/settings-window.lua +++ b/data/pigui/modules/settings-window.lua @@ -578,6 +578,7 @@ local function showControlsOptions() ui.text(lui.CONTROL_OPTIONS) local mouseYInvert = Input.GetMouseYInverted() + local mouseMiddleButton = Input.GetMouseMiddleButton() local joystickEnabled = Input.GetJoystickEnabled() binding_pages = Input.GetBindingPages() local c @@ -585,6 +586,9 @@ local function showControlsOptions() c,mouseYInvert = checkbox(lui.INVERT_MOUSE_Y, mouseYInvert) if c then Input.SetMouseYInverted(mouseYInvert) end + c,mouseMiddleButton = checkbox(lui.NO_MOUSE_MIDDLE_BUTTON, mouseMiddleButton) + if c then Input.SetMouseMiddleButton(mouseMiddleButton) end + c,joystickEnabled = checkbox(lui.ENABLE_JOYSTICK, joystickEnabled) if c then Input.SetJoystickEnabled(joystickEnabled) end diff --git a/src/Input.h b/src/Input.h index e3c3f45c635..978a14c480d 100644 --- a/src/Input.h +++ b/src/Input.h @@ -194,6 +194,9 @@ class Input::Manager { bool IsMouseYInvert() { return mouseYInvert; } void SetMouseYInvert(bool state); + bool GetMouseMiddleButton() { return mouseMiddleButton; } + void SetMouseMiddleButton(bool state); + bool IsMouseButtonPressed(int button) { return mouseButton[button] == 1; } bool IsMouseButtonReleased(int button) { return mouseButton[button] == 4; } @@ -244,6 +247,7 @@ class Input::Manager { bool m_capturingMouse; bool joystickEnabled; + bool mouseMiddleButton; bool mouseYInvert; std::map bindingPages; diff --git a/src/lua/LuaInput.cpp b/src/lua/LuaInput.cpp index 25beac5d2c3..db218745228 100644 --- a/src/lua/LuaInput.cpp +++ b/src/lua/LuaInput.cpp @@ -565,6 +565,18 @@ static int l_input_set_mouse_y_inverted(lua_State *l) return 0; } +static int l_input_get_mouse_middle_button(lua_State *l) +{ + lua_pushboolean(l, Pi::input->GetMouseMiddleButton()); + return 1; +} + +static int l_input_set_mouse_middle_button(lua_State *l) +{ + //lua_pushboolean(l, Pi::input->IsMouseYInvert()); + return 0; +} + static int l_input_get_mouse_captured(lua_State *l) { LuaPush(l, Pi::input->IsCapturingMouse()); @@ -716,6 +728,8 @@ void LuaInput::Register() { "SaveBinding", l_input_save_binding }, { "GetMouseYInverted", l_input_get_mouse_y_inverted }, { "SetMouseYInverted", l_input_set_mouse_y_inverted }, + { "GetMouseMiddleButton", l_input_get_mouse_middle_button }, + { "SetMouseMiddleButton", l_input_set_mouse_middle_button }, { "GetJoystickEnabled", l_input_get_joystick_enabled }, { "SetJoystickEnabled", l_input_set_joystick_enabled },