-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinpututils.odin
More file actions
30 lines (24 loc) · 812 Bytes
/
inpututils.odin
File metadata and controls
30 lines (24 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package extra
import rl "vendor:raylib"
IsMouseButtonDoubleClicked :: proc(button: rl.MouseButton) -> bool {
@(static) lastClickTimes: [rl.MouseButton]f64
if !rl.IsMouseButtonPressed(button) do return false
doubleClicked := false
currentTime := rl.GetTime()
if (currentTime - lastClickTimes[button] < 0.3) { // 0.3 seconds threshold
doubleClicked = true
}
lastClickTimes[button] = currentTime
return doubleClicked
}
IsKeyboardKeyDoublePressed :: proc(key: rl.KeyboardKey) -> bool{
@(static) lastClickTimes: #sparse[rl.KeyboardKey]f64
if !rl.IsKeyPressed(key) do return false
doubleClicked := false
currentTime := rl.GetTime()
if (currentTime - lastClickTimes[key] < 0.3) { // 0.3 seconds threshold
doubleClicked = true
}
lastClickTimes[key] = currentTime
return doubleClicked
}