Skip to content

Commit

Permalink
Stash, implementing settings option
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed Jul 16, 2023
1 parent 239c5bf commit f0206ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions data/pigui/modules/settings-window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,17 @@ 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

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

Expand Down
4 changes: 4 additions & 0 deletions src/Input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -244,6 +247,7 @@ class Input::Manager {
bool m_capturingMouse;

bool joystickEnabled;
bool mouseMiddleButton;
bool mouseYInvert;

std::map<std::string, BindingPage> bindingPages;
Expand Down
14 changes: 14 additions & 0 deletions src/lua/LuaInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(l, Pi::input->IsCapturingMouse());
Expand Down Expand Up @@ -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 },

Expand Down

0 comments on commit f0206ff

Please sign in to comment.