Fix jerky mouse delta on web
This commit is contained in:
parent
a958c1f50a
commit
6e600e9e6d
@ -898,20 +898,23 @@ collect_camera_input :: proc() -> (delta: rl.Vector2, sense: f32, is_mouse: bool
|
||||
}
|
||||
|
||||
should_capture_mouse := rl.IsMouseButtonDown(.RIGHT)
|
||||
@(static) last_mouse_pos: rl.Vector2
|
||||
@(static) first_delta := true
|
||||
if g_mem.mouse_captured != should_capture_mouse {
|
||||
if should_capture_mouse {
|
||||
rl.DisableCursor()
|
||||
last_mouse_pos = rl.GetMousePosition()
|
||||
first_delta = true
|
||||
} else {
|
||||
rl.EnableCursor()
|
||||
}
|
||||
g_mem.mouse_captured = should_capture_mouse
|
||||
}
|
||||
|
||||
mouse_pos := rl.GetMousePosition()
|
||||
mouse_delta := g_mem.mouse_captured ? mouse_pos - last_mouse_pos : 0
|
||||
last_mouse_pos = mouse_pos
|
||||
mouse_delta := g_mem.mouse_captured ? rl.GetMouseDelta() : 0
|
||||
|
||||
if mouse_delta != 0 && first_delta {
|
||||
mouse_delta = 0
|
||||
first_delta = false
|
||||
}
|
||||
|
||||
MOUSE_SENSE :: 0.005
|
||||
GAMEPAD_SENSE :: 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user