mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 08:59:02 -06:00
Prevent mapping the same key to two controls (fixes #20)
This commit is contained in:
parent
2cb0416548
commit
61d5410f22
@ -88,7 +88,7 @@ function KeyConfigScene:onInputPress(e)
|
||||
elseif e.scancode == "tab" then
|
||||
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
|
||||
self.input_state = self.input_state + 1
|
||||
elseif e.scancode ~= "escape" then
|
||||
elseif e.scancode ~= "escape" and not self.new_input[e.scancode] then
|
||||
-- all other keys can be configured
|
||||
self.set_inputs[configurable_inputs[self.input_state]] = "key " .. love.keyboard.getKeyFromScancode(e.scancode) .. " (" .. e.scancode .. ")"
|
||||
self.new_input[e.scancode] = configurable_inputs[self.input_state]
|
||||
|
@ -104,6 +104,7 @@ function StickConfigScene:onInputPress(e)
|
||||
if not self.new_input[e.name].buttons then
|
||||
self.new_input[e.name].buttons = {}
|
||||
end
|
||||
if self.new_input[e.name].buttons[e.button] then return end
|
||||
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||
"jbtn " ..
|
||||
e.button ..
|
||||
@ -119,6 +120,9 @@ function StickConfigScene:onInputPress(e)
|
||||
if not self.new_input[e.name].axes[e.axis] then
|
||||
self.new_input[e.name].axes[e.axis] = {}
|
||||
end
|
||||
if (
|
||||
self.new_input[e.name].axes[e.axis][e.value >= 1 and "positive" or "negative"]
|
||||
) then return end
|
||||
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||
"jaxis " ..
|
||||
(e.value >= 1 and "+" or "-") .. e.axis ..
|
||||
@ -137,6 +141,9 @@ function StickConfigScene:onInputPress(e)
|
||||
if not self.new_input[e.name].hats[e.hat] then
|
||||
self.new_input[e.name].hats[e.hat] = {}
|
||||
end
|
||||
if self.new_input[e.name].hats[e.hat][e.direction] then
|
||||
return
|
||||
end
|
||||
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||
"jhat " ..
|
||||
e.hat .. " " .. e.direction ..
|
||||
|
Loading…
Reference in New Issue
Block a user