45 lines
937 B
Plaintext
45 lines
937 B
Plaintext
extern "grogs"
|
|
|
|
struct -keyTracker
|
|
init &keys -list
|
|
init &pressed -list
|
|
endstruct
|
|
|
|
init &keyTracker -keyTracker
|
|
setlist *keyTracker.keys 1073741904 1073741903 1073741906 1073741905
|
|
setlist *keyTracker.pressed false false false false
|
|
|
|
pusharg "My Awesome Window" 480 360
|
|
!grogs:initSDL &result
|
|
|
|
fun -int !keyPressed -keyTracker &keyTracker
|
|
# A key was just pressed means there is a mismatch between what is stored and the actual key presses
|
|
set &idx 0
|
|
set &ans -1
|
|
!grogs:getLastKey &key
|
|
|
|
getlistsize *keyTracker.keys &len
|
|
@loop
|
|
equal $idx $len &cond
|
|
if $cond %end
|
|
|
|
getlistat *keyTracker.keys $idx &store
|
|
inequal $key $store &cond
|
|
if $cond %increment
|
|
|
|
getlistat *keyTracker.pressed &cond
|
|
if $cond %increment
|
|
|
|
set &ans $store
|
|
|
|
@increment
|
|
add $idx 1 &idx
|
|
jump %loop
|
|
|
|
@end
|
|
return $ans
|
|
endfun
|
|
|
|
@loop
|
|
|
|
jump %loop |