Fixed an issue where axes would not detect left or up

This commit is contained in:
Ishaan Bhardwaj
2021-03-07 16:03:02 -05:00
parent dc764b9177
commit 6ecea7edb1
3 changed files with 4 additions and 184 deletions

View File

@@ -109,7 +109,7 @@ function StickConfigScene:onInputPress(e)
self.new_input[e.name].buttons[e.button] = configurable_inputs[self.input_state]
self.input_state = self.input_state + 1
elseif e.type == "joyaxis" then
if (e.axis ~= self.last_axis or self.axis_timer > 30) and e.value >= 1 then
if (e.axis ~= self.last_axis or self.axis_timer > 30) and math.abs(e.value) >= 1 then
addJoystick(self.new_input, e.name)
if not self.new_input[e.name].axes then
self.new_input[e.name].axes = {}
@@ -119,9 +119,9 @@ function StickConfigScene:onInputPress(e)
end
self.set_inputs[configurable_inputs[self.input_state]] =
"jaxis " ..
e.axis ..
(e.value >= 1 and "+" or "-") .. e.axis ..
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
self.new_input[e.name].axes[e.axis]["positive"] = configurable_inputs[self.input_state]
self.new_input[e.name].axes[e.axis][e.value >= 1 and "positive" or "negative"] = configurable_inputs[self.input_state]
self.input_state = self.input_state + 1
self.last_axis = e.axis
self.axis_timer = 0