mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 14:39: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
|
elseif e.scancode == "tab" then
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
|
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
|
||||||
self.input_state = self.input_state + 1
|
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
|
-- all other keys can be configured
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] = "key " .. love.keyboard.getKeyFromScancode(e.scancode) .. " (" .. e.scancode .. ")"
|
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]
|
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
|
if not self.new_input[e.name].buttons then
|
||||||
self.new_input[e.name].buttons = {}
|
self.new_input[e.name].buttons = {}
|
||||||
end
|
end
|
||||||
|
if self.new_input[e.name].buttons[e.button] then return end
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] =
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
"jbtn " ..
|
"jbtn " ..
|
||||||
e.button ..
|
e.button ..
|
||||||
@ -119,6 +120,9 @@ function StickConfigScene:onInputPress(e)
|
|||||||
if not self.new_input[e.name].axes[e.axis] then
|
if not self.new_input[e.name].axes[e.axis] then
|
||||||
self.new_input[e.name].axes[e.axis] = {}
|
self.new_input[e.name].axes[e.axis] = {}
|
||||||
end
|
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]] =
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
"jaxis " ..
|
"jaxis " ..
|
||||||
(e.value >= 1 and "+" or "-") .. e.axis ..
|
(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
|
if not self.new_input[e.name].hats[e.hat] then
|
||||||
self.new_input[e.name].hats[e.hat] = {}
|
self.new_input[e.name].hats[e.hat] = {}
|
||||||
end
|
end
|
||||||
|
if self.new_input[e.name].hats[e.hat][e.direction] then
|
||||||
|
return
|
||||||
|
end
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] =
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
"jhat " ..
|
"jhat " ..
|
||||||
e.hat .. " " .. e.direction ..
|
e.hat .. " " .. e.direction ..
|
||||||
|
Loading…
Reference in New Issue
Block a user