File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -144,9 +144,11 @@ pub mut:
144
144
scroll_x int
145
145
scroll_y int
146
146
//
147
- key_modifiers Modifier
148
- key_repeat bool
149
- pressed_keys [key_code_max]bool
147
+ key_modifiers Modifier // the current key modifiers
148
+ key_repeat bool // whether the pressed key was an autorepeated one
149
+ pressed_keys [key_code_max]bool // an array representing all currently pressed keys
150
+ pressed_keys_edge [key_code_max]bool // true when the previous state of pressed_keys,
151
+ // *before* the current event was different
150
152
}
151
153
152
154
pub struct Size {
@@ -311,7 +313,10 @@ fn gg_event_fn(ce &C.sapp_event, user_data voidptr) {
311
313
g.key_repeat = e.key_repeat
312
314
if e.typ in [.key_down, .key_up] {
313
315
key_idx := int (e.key_code) % key_code_max
314
- g.pressed_keys[key_idx] = e.typ == .key_down
316
+ prev := g.pressed_keys[key_idx]
317
+ next := e.typ == .key_down
318
+ g.pressed_keys[key_idx] = next
319
+ g.pressed_keys_edge[key_idx] = prev != next
315
320
}
316
321
if g.config.event_fn != voidptr (0 ) {
317
322
g.config.event_fn (e, g.config.user_data)
You can’t perform that action at this time.
0 commit comments