From 3843685ff9bff22f516c3860990d0b47b3115569 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Tue, 3 Dec 2024 20:45:42 -0500 Subject: [PATCH] allow disabling added controller binds --- quant.ew/data/scripts/buildings/racing_cart_move.lua | 2 +- quant.ew/files/system/notplayer_ai/notplayer_ai.lua | 2 +- quant.ew/files/system/player_ping/player_ping.lua | 2 +- quant.ew/files/system/spectate/spectate.lua | 6 +++--- quant.ew/settings.lua | 7 +++++++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/quant.ew/data/scripts/buildings/racing_cart_move.lua b/quant.ew/data/scripts/buildings/racing_cart_move.lua index d6ffbd7d..28eabe92 100644 --- a/quant.ew/data/scripts/buildings/racing_cart_move.lua +++ b/quant.ew/data/scripts/buildings/racing_cart_move.lua @@ -58,7 +58,7 @@ edit_component( entity_id, "VelocityComponent", function(comp,vars) local controls_comp = EntityGetFirstComponent(player, "ControlsComponent") local is_dead = EntityHasTag(player, "ew_notplayer") local is_thrusting = (not is_dead and controls_comp ~= nil and ComponentGetValue2( controls_comp, "mButtonDownFly")) - or (is_dead and (InputIsKeyDown(44) or InputIsJoystickButtonDown(0, 23))) + or (is_dead and (InputIsKeyDown(44) or (not ModSettingGet("quant.ew.no_gamepad") and InputIsJoystickButtonDown(0, 23)))) if is_thrusting then vx = speed vx, vy = vec_rotate(vx, vy, dir) diff --git a/quant.ew/files/system/notplayer_ai/notplayer_ai.lua b/quant.ew/files/system/notplayer_ai/notplayer_ai.lua index 46960b1c..e63236a3 100644 --- a/quant.ew/files/system/notplayer_ai/notplayer_ai.lua +++ b/quant.ew/files/system/notplayer_ai/notplayer_ai.lua @@ -1393,7 +1393,7 @@ local function update() state.dtype = ComponentGetValue2(var, "value_int") -- No taking control back, even after pressing esc. ComponentSetValue2(state.control_component, "enabled", false) - if InputIsKeyJustDown(43) or InputIsJoystickButtonJustDown(0, 16) then + if InputIsKeyJustDown(43) or (not ModSettingGet("quant.ew.no_gamepad") and InputIsJoystickButtonJustDown(0, 16)) then local active = not ComponentGetValue2(state.inv_component, "mActive") ComponentSetValue2(state.inv_component, "mActive", active) spectate.disable_throwing(active) diff --git a/quant.ew/files/system/player_ping/player_ping.lua b/quant.ew/files/system/player_ping/player_ping.lua index 298d5369..c099ff64 100644 --- a/quant.ew/files/system/player_ping/player_ping.lua +++ b/quant.ew/files/system/player_ping/player_ping.lua @@ -45,7 +45,7 @@ function module.on_world_update() and ( ((rebind == 42 and InputIsMouseButtonJustDown(3)) or (rebind ~= 42 and InputIsKeyJustDown(rebind))) - or InputIsJoystickButtonJustDown(0, 18)) then + or (not ModSettingGet("quant.ew.no_gamepad") and InputIsJoystickButtonJustDown(0, 18))) then local x,y if GameGetIsGamepadConnected() then local tx, ty diff --git a/quant.ew/files/system/spectate/spectate.lua b/quant.ew/files/system/spectate/spectate.lua index 03f71ec0..c1caad24 100644 --- a/quant.ew/files/system/spectate/spectate.lua +++ b/quant.ew/files/system/spectate/spectate.lua @@ -318,7 +318,7 @@ function spectate.on_world_update() return end - if InputIsKeyJustDown(tonumber(ModSettingGet("quant.ew.rebind_lspectate"))) or InputIsJoystickButtonJustDown(0, 13) then + if InputIsKeyJustDown(tonumber(ModSettingGet("quant.ew.rebind_lspectate"))) or (not ModSettingGet("quant.ew.no_gamepad") and InputIsJoystickButtonJustDown(0, 13)) then camera_player = camera_player - 1 if camera_player < 1 then camera_player = last_len @@ -326,7 +326,7 @@ function spectate.on_world_update() has_switched = true re_cam = true - elseif InputIsKeyJustDown(tonumber(ModSettingGet("quant.ew.rebind_rspectate"))) or InputIsJoystickButtonJustDown(0, 14) then + elseif InputIsKeyJustDown(tonumber(ModSettingGet("quant.ew.rebind_rspectate"))) or (not ModSettingGet("quant.ew.no_gamepad") and InputIsJoystickButtonJustDown(0, 14)) then camera_player = camera_player + 1 if camera_player > last_len then camera_player = 1 @@ -366,7 +366,7 @@ function spectate.on_world_update() local inv_me = EntityGetFirstComponent(ctx.my_player.entity, "InventoryGuiComponent") if inv_spec ~= nil then if inv_me == nil then - if InputIsKeyJustDown(43) or InputIsJoystickButtonJustDown(0, 16) then + if InputIsKeyJustDown(43) or (not ModSettingGet("quant.ew.no_gamepad") and InputIsJoystickButtonJustDown(0, 16)) then attached = not ComponentGetValue2(inv_spec, "mActive") ComponentSetValue2(inv_spec, "mActive", attached) end diff --git a/quant.ew/settings.lua b/quant.ew/settings.lua index 785a9018..a90abcf3 100755 --- a/quant.ew/settings.lua +++ b/quant.ew/settings.lua @@ -196,6 +196,13 @@ local function build_settings() value_default = "0", scope = MOD_SETTING_SCOPE_RUNTIME, }, + { + id = "no_gamepad", + ui_name = "dont add keybinds for gamepad", + ui_description = ":(", + value_default = false, + scope = MOD_SETTING_SCOPE_RUNTIME, + }, }, }, }