summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--chickadee/input/keyboard.scm29
-rw-r--r--doc/api.texi18
3 files changed, 48 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 5dfbbb9..0103c2b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,6 +43,7 @@ SOURCES = \
chickadee/utils.scm \
chickadee/audio.scm \
chickadee/input/controller.scm \
+ chickadee/input/keyboard.scm \
chickadee/math.scm \
chickadee/math/vector.scm \
chickadee/math/matrix.scm \
diff --git a/chickadee/input/keyboard.scm b/chickadee/input/keyboard.scm
new file mode 100644
index 0000000..afc0435
--- /dev/null
+++ b/chickadee/input/keyboard.scm
@@ -0,0 +1,29 @@
+;;; Chickadee Game Toolkit
+;;; Copyright © 2017 David Thompson <davet@gnu.org>
+;;;
+;;; Chickadee is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published
+;;; by the Free Software Foundation, either version 3 of the License,
+;;; or (at your option) any later version.
+;;;
+;;; Chickadee is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (chickadee input keyboard)
+ #:use-module ((sdl2 input keyboard) #:prefix sdl2:)
+ #:export (key-pressed?
+ key-released?))
+
+(define (key-pressed? key)
+ "Return #t if KEY is currently being pressed."
+ (sdl2:key-pressed? key))
+
+(define (key-released? key)
+ "Return #t if KEY is not currently being pressed."
+ (sdl2:key-released? key))
diff --git a/doc/api.texi b/doc/api.texi
index 126d7dd..74ccfff 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -378,6 +378,24 @@ values are:
@node Input
@section Input
+Chickadee can handle input events from the keyboard, mouse, and game
+controllers.
+
+@menu
+* Keyboard:: Keyboard input.
+@end menu
+
+@node Keyboard
+@subsection Keyboard
+
+@deffn {Scheme Procedure} key-pressed? @var{key}
+Return @code{#t} if @var{key} is currently being pressed.
+@end deffn
+
+@deffn {Scheme Procedure} key-released? @var{key}
+Return @code{#t} if @var{key} is not currently being pressed.
+@end deffn
+
@node Math
@section Math