Artifact
c8ac5896f5e9bb5da98b212048b597745eec127f:
- File
sdl2/extras.ss
— part of check-in
[27a45ffaf8]
at
2016-12-08 01:27:14
on branch trunk
— eqv? or zero? instead of eq? somewhere
(user:
aldo
size: 1014)
(define (sdl-event-keyboard-keysym-sym e)
(let* ([keyboard (ftype-&ref sdl-event-t (key) e)]
[keysym (ftype-&ref sdl-keyboard-event-t (keysym) keyboard)]
[sym (ftype-ref sdl-keysym-t (sym) keysym)])
sym))
(define (sdl-event-keyboard-keysym-mod e)
(let* ([keyboard (ftype-&ref sdl-event-t (key) e)]
[keysym (ftype-&ref sdl-keyboard-event-t (keysym) keyboard)]
[mod (ftype-ref sdl-keysym-t (mod) keysym)])
mod))
(define (sdl-event-mouse-button e)
(let* ([button (ftype-&ref sdl-event-t (button) e)]
[button* (ftype-ref sdl-mouse-button-event-t (button) button)])
button*))
(define-ftype char-array (array 0 char))
;; THIS IS FOR DECODING sdl-text-input-event text
(define (char*-array->string ptr max)
(let loop ([i 0] [r '()])
(let ([x (ftype-ref char-array (i)
(make-ftype-pointer char-array
(ftype-pointer-address ptr)))])
(if (or (eqv? x #\nul) (>= i max))
(utf8->string (u8-list->bytevector (reverse r)))
(loop (+ i 1) (cons (char->integer x) r))))))