diff --git a/eid_config.lua b/eid_config.lua index 8df70c28..e50ed837 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -424,6 +424,10 @@ EID.UserConfig = { -- Of note are Controller.STICK_LEFT and Controller.STICK_RIGHT (pushing the sticks in), which aren't used in-game with default controls -- Default = none (-1) ["CraftingResultButton"] = -1, + -- Set the keybinding to toggle the search feature on and off + -- Look into the AB+ or Repentance documentation for the key names here: https://wofsauge.github.io/IsaacDocs/rep/enums/Keyboard.html + -- Default = Keyboard.KEY_ENTER + ["CraftingSearchKey"] = Keyboard.KEY_ENTER, ---------- Save Game Options ------------ @@ -603,6 +607,7 @@ EID.DefaultConfig = { ["CraftingHideButton"] = -1, ["CraftingResultKey"] = Keyboard.KEY_F4, ["CraftingResultButton"] = -1, + ["CraftingSearchKey"] = Keyboard.KEY_ENTER, ["ItemReminderEnabled"] = true, ["ItemReminderDisplayMode"] = "All", diff --git a/features/eid_bagofcrafting_search.lua b/features/eid_bagofcrafting_search.lua index de79b518..4290c67b 100644 --- a/features/eid_bagofcrafting_search.lua +++ b/features/eid_bagofcrafting_search.lua @@ -126,7 +126,7 @@ local function handleSearchInput() return end - if Input.IsButtonTriggered(Keyboard.KEY_ESCAPE, EID.bagPlayer.ControllerIndex, true) then + if Input.IsButtonTriggered(Keyboard.KEY_ESCAPE, 0, true) then EID:BoCSSetSearchInputEnabled(false) EID:BoCSSetSearchValue("") return @@ -140,9 +140,9 @@ local function handleSearchInput() -- enum values are integers for i=Keyboard.KEY_SPACE,Keyboard.KEY_RIGHT_BRACKET do index = index + 1 - if Input.IsButtonTriggered(i, EID.bagPlayer.ControllerIndex, true) then + if Input.IsButtonTriggered(i, 0, true) then local toAppend = indexCharMapping:sub(index, index) - local isShiftPressed = (Input.IsButtonPressed(Keyboard.KEY_LEFT_SHIFT, EID.bagPlayer.ControllerIndex, true) or Input.IsButtonPressed(Keyboard.KEY_RIGHT_SHIFT, EID.bagPlayer.ControllerIndex, true)) + local isShiftPressed = (Input.IsButtonPressed(Keyboard.KEY_LEFT_SHIFT, 0, true) or Input.IsButtonPressed(Keyboard.KEY_RIGHT_SHIFT, 0, true)) if isShiftPressed then toAppend = shiftCharMapping:sub(index, index) end newValue = newValue .. toAppend @@ -157,7 +157,7 @@ local function handleSearchInput() end end - if Input.IsButtonTriggered(Keyboard.KEY_BACKSPACE, EID.bagPlayer.ControllerIndex, true) then + if Input.IsButtonTriggered(Keyboard.KEY_BACKSPACE, 0, true) then lastBackspaceTrigger = 0 backspaceStep = 0 return @@ -166,7 +166,7 @@ local function handleSearchInput() local currentFrame = game:GetFrameCount() -- 30 Frames = 1 second -- 15 = 500ms - if Input.IsButtonPressed(Keyboard.KEY_BACKSPACE, EID.bagPlayer.ControllerIndex, true) and ( + if Input.IsButtonPressed(Keyboard.KEY_BACKSPACE, 0, true) and ( backspaceStep == 0 or (backspaceStep == 1 and currentFrame - lastBackspaceTrigger >= 15) -- we delay the second deletion a little bit more @@ -174,9 +174,9 @@ local function handleSearchInput() (backspaceStep >= 2 and currentFrame - lastBackspaceTrigger >= 1) ) then local isControlPressed = ( - Input.IsButtonPressed(Keyboard.KEY_LEFT_CONTROL, EID.bagPlayer.ControllerIndex, true) + Input.IsButtonPressed(Keyboard.KEY_LEFT_CONTROL, 0, true) or - Input.IsButtonPressed(Keyboard.KEY_RIGHT_CONTROL, EID.bagPlayer.ControllerIndex, true) + Input.IsButtonPressed(Keyboard.KEY_RIGHT_CONTROL, 0, true) ) if isControlPressed then @@ -207,15 +207,13 @@ function EID:BoCSHandleInput() end -- Clear the previous search when Enter is pressed - -- TODO: make this a modifiable hotkey - if Input.IsButtonTriggered(Keyboard.KEY_ENTER, EID.bagPlayer.ControllerIndex, true) then + if Input.IsButtonTriggered(EID.Config["CraftingSearchKey"], 0, true) then if not searchInputEnabled then EID:BoCSSetSearchValue("") end end -- Start a new search when Enter is pressed - -- TODO: make this a modifiable hotkey -- by default, both are Enter, but for instance clearing could be Backspace and then you could modify a search term with Enter - if Input.IsButtonTriggered(Keyboard.KEY_ENTER, EID.bagPlayer.ControllerIndex, true) then + if Input.IsButtonTriggered(EID.Config["CraftingSearchKey"], 0, true) then EID:BoCSSetSearchInputEnabled(not searchInputEnabled) return end @@ -262,7 +260,7 @@ function EID:BoCSHookInputIsButtonTriggered() end end - if bagPlayer == nil or controller ~= bagPlayer.ControllerIndex then + if bagPlayer == nil or controller ~= 0 then -- only execute for keyboard return oldInputIsButtonTriggered(key, controller) end @@ -286,7 +284,7 @@ function EID:BoCSHookInputIsButtonPressed() end end - if bagPlayer == nil or controller ~= bagPlayer.ControllerIndex then + if bagPlayer == nil or controller ~= 0 then -- only execute for keyboard return oldInputIsButtonPressed(key, controller) end @@ -310,7 +308,7 @@ function EID:BoCSHookInputIsActionPressed() end end - if bagPlayer == nil or controller ~= bagPlayer.ControllerIndex then + if bagPlayer == nil or controller ~= 0 then -- only execute for keyboard return oldInputIsActionPressed(key, controller) end @@ -334,8 +332,8 @@ function EID:BoCSHookInputIsActionTriggered() end end - if bagPlayer == nil or controller ~= bagPlayer.ControllerIndex then - return oldInputIsActionTriggered(key, controller) + if bagPlayer == nil or controller ~= 0 then + return oldInputIsActionTriggered(key, controller) -- only execute for keyboard end return false diff --git a/features/eid_mcm.lua b/features/eid_mcm.lua index a5a02692..b7249970 100644 --- a/features/eid_mcm.lua +++ b/features/eid_mcm.lua @@ -688,6 +688,9 @@ if MCMLoaded then EID:AddHotkeySetting("Crafting", "CraftingResultButton", "Result Toggle (Controller)", "Press this button to toggle the description of the item ready to be crafted (Left Stick or Right Stick recommended; most other buttons will not work)", true) + EID:AddHotkeySetting("Crafting", + "CraftingSearchKey", "Search Toggle (Keyboard only)", + "Press this key to toggle the search feature", false) MCM.AddSpace("EID", "Crafting") --------Clear bag---------