Skip to content

Commit

Permalink
allow disabling added controller binds
Browse files Browse the repository at this point in the history
  • Loading branch information
bgkillas committed Dec 4, 2024
1 parent be81e3b commit 3843685
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion quant.ew/data/scripts/buildings/racing_cart_move.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion quant.ew/files/system/notplayer_ai/notplayer_ai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion quant.ew/files/system/player_ping/player_ping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions quant.ew/files/system/spectate/spectate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,15 @@ 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
end

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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions quant.ew/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
}
Expand Down

0 comments on commit 3843685

Please sign in to comment.