I don’t know if this is a bug or not, so sorry if it isn’t.
I have code in on_input that handles both key presses and mouse movement. However i noticed that anytime I press a key that is registered in inputs I can’t move my cursor for about 1 second or so.
Is there a work around for this or did I set something up wrong or is this a bug?
Absolutely, the on_input function seems to be the one giving the problem. Somethings I’ve notice already is that when I press a key the game’s fps doesn’t drop and other keys will be read and run fine. However the native cursor freezes and wont move until about 1 second later.
Another thing, I did the “My Runner” tutorial and copied the exact same code from the tutorial and then pressed the jump key and the cursor froze even in the tutorial game.
I have tried this on my laptop and desktop computer both having the same issue both running AMD on windows 7 64-bit using Defold 1.2.91
function on_input(self, action_id, action)
local update_vector = vmath.vector3()
-- Left Key
if action_id == hash("input_left") and action.pressed then
update_vector.x = update_vector.x - self.speed
self.direction = -1
elseif action_id == hash("input_left") and action.released then
update_vector.x = update_vector.x + self.speed
end
-- Right Key
if action_id == hash("input_right") and action.pressed then
update_vector.x = update_vector.x + self.speed
self.direction = 1
elseif action_id == hash("input_right") and action.released then
update_vector.x = update_vector.x - self.speed
end
-- Up Key
if action_id == hash("input_up") and action.pressed then
if jumps > 0 then
update_vector.y = jump_speed
if self.velocity.y + jump_speed > jump_speed then
update_vector.y = jump_speed - self.velocity.y
end
jumps = jumps - 1
end
end
-- R Key
if action_id == hash("reset") then
go.set_position(self.pos)
end
-- Spacebar Key
if action_id == hash("loop_back") then
msg.post("#loop_skill", "activate")
self.velocity.y = 0
end
-- F Key
if action_id == hash("tele") and action.pressed then
msg.post("#tele", "activate", {x = mouse.x, y = mouse.y})
end
-- Mouse Movement
if action_id == nil and action.x ~= nil then
mouse.x, mouse.y = action.x, action.y
end
self.velocity = self.velocity + update_vector
end
Well after some more digging and testing i found the problem. It is the driver I’m using for my mouse pad. The driver seems to stop listening for mouse signals once a key is pressed.