mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cleanup SDL event system
This commit is contained in:

committed by
Alexander Medvednikov

parent
8581c11900
commit
75c01dec30
@ -9,9 +9,9 @@ fn main() {
|
||||
|
||||
mut should_close := false
|
||||
for {
|
||||
ev := sdl.Event{}
|
||||
for 0 < sdl.poll_event(&ev) {
|
||||
match int(ev._type) {
|
||||
evt := SDL_Event{}
|
||||
for 0 < sdl.poll_event(&evt) {
|
||||
match int(evt.@type) {
|
||||
C.SDL_QUIT { should_close = true }
|
||||
else {}
|
||||
}
|
||||
|
@ -151,8 +151,7 @@ mut:
|
||||
}
|
||||
|
||||
struct SdlContext {
|
||||
pub:
|
||||
mut:
|
||||
pub mut:
|
||||
// VIDEO
|
||||
w int
|
||||
h int
|
||||
@ -374,12 +373,12 @@ fn main() {
|
||||
g.draw_end()
|
||||
|
||||
// game.handle_events() // CRASHES if done in function ???
|
||||
ev := sdl.Event{}
|
||||
for 0 < sdl.poll_event(&ev) {
|
||||
match int(ev._type) {
|
||||
evt := SDL_Event{}
|
||||
for 0 < sdl.poll_event(&evt) {
|
||||
match int(evt.@type) {
|
||||
C.SDL_QUIT { should_close = true }
|
||||
C.SDL_KEYDOWN {
|
||||
key := ev.key.keysym.sym
|
||||
key := evt.key.keysym.sym
|
||||
if key == C.SDLK_ESCAPE {
|
||||
should_close = true
|
||||
break
|
||||
@ -388,16 +387,16 @@ fn main() {
|
||||
game2.handle_key(key)
|
||||
}
|
||||
C.SDL_JOYBUTTONDOWN {
|
||||
jb := int(ev.jbutton.button)
|
||||
joyid := ev.jbutton.which
|
||||
jb := int(evt.jbutton.button)
|
||||
joyid := evt.jbutton.which
|
||||
// println('JOY BUTTON $jb $joyid')
|
||||
game.handle_jbutton(jb, joyid)
|
||||
game2.handle_jbutton(jb, joyid)
|
||||
}
|
||||
C.SDL_JOYHATMOTION {
|
||||
jh := int(ev.jhat.hat)
|
||||
jv := int(ev.jhat.value)
|
||||
joyid := ev.jhat.which
|
||||
jh := int(evt.jhat.hat)
|
||||
jv := int(evt.jhat.value)
|
||||
joyid := evt.jhat.which
|
||||
// println('JOY HAT $jh $jv $joyid')
|
||||
game.handle_jhat(jh, jv, joyid)
|
||||
game2.handle_jhat(jh, jv, joyid)
|
||||
|
Reference in New Issue
Block a user