diff options
author | David Thompson <dthompson2@worcester.edu> | 2013-06-25 19:31:43 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2013-06-25 19:31:43 -0400 |
commit | 3d4dba9f2533c28146eac5a66050be1daf4ead38 (patch) | |
tree | 4fe3a4c720dcf52e7a0381bf3161992ca04ce84a /2d | |
parent | 0410eda4a37a123c173f971d2050b41f79eb74fc (diff) |
Add mouse-button and keymod enums and a couple of convenience procedures.
Diffstat (limited to '2d')
-rw-r--r-- | 2d/input.scm | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/2d/input.scm b/2d/input.scm index fcc1195..f929347 100644 --- a/2d/input.scm +++ b/2d/input.scm @@ -22,8 +22,13 @@ ;;; Code: (define-module (2d input) + #:use-module (srfi srfi-1) #:use-module (figl runtime) ;; For the define-enumeration macro - #:export (keycode)) + #:export (keycode + any-keycode? + keymod + all-keymods? + mouse-button)) ;;; ;;; Keyboard @@ -263,3 +268,34 @@ (power 320) (euro 321) (undo 322)) + +(define (any-keycode? keycode . keycodes) + "Returns true if keycode equals any of the keycodes provided and +returns false otherwise." + (any (lambda (key) (= keycode key)) keycodes)) + +;; Modifier keys +(define-enumeration + keymod + (none 0) + (shift 3) + (ctrl 192) + (alt 768) + (meta 3072) + (num 4096 ) + (caps 8192)) + +(define (all-keymods? mod . expected) + "Returns true if all expected modifier bits are set and returns +false otherwise." + (not (zero? (apply logand mod expected)))) + +;;; +;;; Mouse +;;; + +(define-enumeration + mouse-button + (left 1) + (middle 2) + (right 4)) |