comparison modules/sdl.tp @ 332:ead24192ed45

Initial work on a UI module
author Michael Pavone <pavone@retrodev.com>
date Sat, 28 Mar 2015 14:21:22 -0700
parents 4c669942c30d
children 577406b25f89
comparison
equal deleted inserted replaced
331:61f5b794d939 332:ead24192ed45
118 timeStampO castTo: (object ptr)) (eventPtr castTo: (object ptr))) 118 timeStampO castTo: (object ptr)) (eventPtr castTo: (object ptr)))
119 } else: { 119 } else: {
120 mcall: none 1 option 120 mcall: none 1 option
121 } 121 }
122 } 122 }
123
124 llMessage: waitEvent withVars: {
125 constructor <- lambda ptr
126 event <- SDL_Event
127 eventPtr <- cpointer ptr
128 eventType <- obj_uint32 ptr
129 timeStampO <- obj_uint32 ptr
130 } andCode: :constructor {
131 if: (SDL_WaitEvent: (addr_of: event)) {
132 eventType <- make_object: (addr_of: obj_uint32_meta) NULL 0
133 timeStampO <- make_object: (addr_of: obj_uint32_meta) NULL 0
134 eventType num!: ((addr_of: event) type)
135 timeStampO num!: ((addr_of: ((addr_of: event) common)) timestamp)
136 eventPtr <- make_object: (addr_of: cpointer_meta) NULL 0
137 eventPtr val!: (addr_of: event)
138 mcall: value 2 option (ccall: constructor 3 (eventType castTo: (object ptr)) (
139 timeStampO castTo: (object ptr)) (eventPtr castTo: (object ptr)))
140 } else: {
141 mcall: none 1 option
142 }
143 }
123 144
124 llMessage: populateWindowEvent withVars: { 145 llMessage: populateWindowEvent withVars: {
125 eventPtr <- cpointer ptr 146 eventPtr <- cpointer ptr
126 empty <- object ptr 147 empty <- object ptr
127 winEvent <- SDL_WindowEvent ptr 148 winEvent <- SDL_WindowEvent ptr
128 ou32 <- obj_uint32 ptr 149 ou32 <- obj_uint32 ptr
129 ou8 <- obj_uint8 ptr
130 oi32 <- obj_int32 ptr 150 oi32 <- obj_int32 ptr
131 } andCode: :eventPtr empty { 151 } andCode: :eventPtr empty {
132 winEvent <- eventPtr val 152 winEvent <- eventPtr val
133 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0 153 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
134 ou32 num!: (winEvent windowID) 154 ou32 num!: (winEvent windowID)
135 mcall: windowID! 2 empty ou32 155 mcall: windowID! 2 empty ou32
136 ou8 <- make_object: (addr_of: obj_uint8_meta) NULL 0 156 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
137 ou8 num!: (winEvent event) 157 ou32 num!: (winEvent event)
138 mcall: event! 2 empty ou8 158 mcall: event! 2 empty ou32
139 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0 159 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
140 oi32 num!: (winEvent data1) 160 oi32 num!: (winEvent data1)
141 mcall: data1! 2 empty oi32 161 mcall: data1! 2 empty oi32
142 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0 162 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
143 oi32 num!: (winEvent data2) 163 oi32 num!: (winEvent data2)
310 _constant: controllerDeviceAdded SDL_CONTROLLERDEVICEADDED 330 _constant: controllerDeviceAdded SDL_CONTROLLERDEVICEADDED
311 _constant: controllerDeviceRemoved SDL_CONTROLLERDEVICEREMOVED 331 _constant: controllerDeviceRemoved SDL_CONTROLLERDEVICEREMOVED
312 _constant: controllerDeviceRemapped SDL_CONTROLLERDEVICEREMAPPED 332 _constant: controllerDeviceRemapped SDL_CONTROLLERDEVICEREMAPPED
313 _constant: dropFile SDL_DROPFILE 333 _constant: dropFile SDL_DROPFILE
314 //TODO: Add mobile/touch/gesture events 334 //TODO: Add mobile/touch/gesture events
335 }
336
337 _windowEvents <- #{
338 _constant: shown SDL_WINDOWEVENT_SHOWN
339 _constant: hidden SDL_WINDOWEVENT_HIDDEN
340 _constant: exposed SDL_WINDOWEVENT_EXPOSED
341 _constant: moved SDL_WINDOWEVENT_MOVED
342 _constant: resized SDL_WINDOWEVENT_RESIZED
343 _constant: sizeChanged SDL_WINDOWEVENT_SIZE_CHANGED
344 _constant: minimized SDL_WINDOWEVENT_MINIMIZED
345 _constant: maximized SDL_WINDOWEVENT_MAXIMIZED
346 _constant: restored SDL_WINDOWEVENT_RESTORED
347 _constant: enter SDL_WINDOWEVENT_ENTER
348 _constant: leave SDL_WINDOWEVENT_LEAVE
349 _constant: focusGained SDL_WINDOWEVENT_FOCUS_GAINED
350 _constant: focusLost SDL_WINDOWEVENT_FOCUS_LOST
351 _constant: close SDL_WINDOWEVENT_CLOSE
315 } 352 }
316 353
317 _textureAccess <- #{ 354 _textureAccess <- #{
318 _constant: static SDL_TEXTUREACCESS_STATIC 355 _constant: static SDL_TEXTUREACCESS_STATIC
319 _constant: streaming SDL_TEXTUREACCESS_STREAMING 356 _constant: streaming SDL_TEXTUREACCESS_STREAMING
368 _eventConstructors set: (_events window) :typ tstamp eventPtr { 405 _eventConstructors set: (_events window) :typ tstamp eventPtr {
369 _helper populateWindowEvent: eventPtr #{ 406 _helper populateWindowEvent: eventPtr #{
370 type <- typ 407 type <- typ
371 timeStamp <- tstamp 408 timeStamp <- tstamp
372 windowID <- 0u32 409 windowID <- 0u32
373 event <- 0u8 410 event <- 0u32
374 data1 <- 0 411 data1 <- 0
375 data2 <- 0 412 data2 <- 0
376 } 413 }
377 } 414 }
378 keyEvent <- :typ tstamp eventPtr { 415 keyEvent <- :typ tstamp eventPtr {
809 timeStamp <- tstamp 846 timeStamp <- tstamp
810 } 847 }
811 } 848 }
812 } 849 }
813 } 850 }
851
852 waitEvent <- {
853 _helper pollEvent: :typ tstamp eventPtr {
854 _eventConstructors ifget: typ :handler {
855 handler: typ tstamp eventPtr
856 } else: {
857 //fallback event
858 #{
859 type <- typ
860 timeStamp <- tstamp
861 }
862 }
863 }
864 }
814 865
815 subsystems <- { _subsystems } 866 subsystems <- { _subsystems }
816 windowOpts <- { _windowOpts } 867 windowOpts <- { _windowOpts }
817 eventTypes <- { _events } 868 eventTypes <- { _events }
869 windowEventTypes <- { _windowEvents }
818 textureAccess <- { _textureAccess } 870 textureAccess <- { _textureAccess }
819 pixelFormats <- { _pixelFormats } 871 pixelFormats <- { _pixelFormats }
820 blendModes <- { _blendModes } 872 blendModes <- { _blendModes }
821 } 873 }
822 } 874 }