From imattsson at common-lisp.net Wed Dec 27 16:29:59 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Wed, 27 Dec 2006 16:29:59 +0000 Subject: [gamelib-cvs] stick.html Message-ID: <20061227162959.75EC425002@common-lisp.net> Update of /project/gamelib/cvsroot/source/doc In directory clnet:/tmp/cvs-serv968/doc Added Files: stick.html Log Message: IM Initial check-in --- NEW FILE: stick.html --- Gamelib - games-3d library

Gamelib

The joystick library

Introduction

Having the use of a joystick enhances the sensation of presence in a game. Under linux, the available joystick API is based around periodic reading of events from a device driver file (usually /dev/jsX or /dev/input/jsX).

Gamelib now offers an interface to handle joysticks on the linux platform (code for joystick handling on other platforms is welcome). The joystick is somewhat abstracted from the raw data that the device driver offers.

API

The interface is centred around a JOYSTICK object (created by calling MAKE-STICK with a suitable device name as argument). To read an event from the device driver, call UPDATE-STICK with the joystick object as argument.

Under SBCL (with thread support) there is a "continous poll" support (simply call CONTINOUS-POLL with the joystick object as argument, to terminate the polling thread, call TERMINATE-POLL with the object as argument). All relevant locking is done, keyed on if a joystick is polled or not

There are two arrays that are of interest in a joystick object js. The first is the analog axes, (axes js) and the second is the buttons (buttons js). The library currently supports up to 8 analog axes and up to 24 buttons (and will most likely crash in amusing ways, should these limits be too strict).

From imattsson at common-lisp.net Wed Dec 27 19:14:12 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Wed, 27 Dec 2006 19:14:12 +0000 Subject: [gamelib-cvs] stick-transfers.png Message-ID: <20061227191412.20BBD49021@common-lisp.net> Update of /project/gamelib/cvsroot/source/doc In directory clnet:/tmp/cvs-serv28371 Added Files: stick-transfers.png Log Message: IM Initial check-in. --- NEW FILE: stick-transfers.png --- (This appears to be a binary file; contents omitted.) From imattsson at common-lisp.net Wed Dec 27 19:27:26 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Wed, 27 Dec 2006 19:27:26 +0000 Subject: [gamelib-cvs] stick.html Message-ID: <20061227192726.D343B4D005@common-lisp.net> Update of /project/gamelib/cvsroot/source/doc In directory clnet:/tmp/cvs-serv30530 Modified Files: stick.html Log Message: IM Better documentation and some explanatory graphs. Index: stick.html =================================================================== RCS file: /project/gamelib/cvsroot/source/doc/stick.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** stick.html 27 Dec 2006 16:29:57 -0000 1.1 --- stick.html 27 Dec 2006 19:27:24 -0000 1.2 *************** *** 37,41 **** terminate the polling thread, call TERMINATE-POLL with the object as argument). All relevant locking is done, keyed on if a joystick is ! polled or not

There are two arrays that are of interest in a joystick object --- 37,42 ---- terminate the polling thread, call TERMINATE-POLL with the object as argument). All relevant locking is done, keyed on if a joystick is ! polled or not. Still, the publicly available information will only be ! done after a call to UPDATE-STICK.

There are two arrays that are of interest in a joystick object *************** *** 44,45 **** --- 45,95 ---- supports up to 8 analog axes and up to 24 buttons (and will most likely crash in amusing ways, should these limits be too strict).

+ +

As part of the update and transformation from signed 16-bit integers + to SINGLE-FLOAT, some transformations of the data can be done. The + (currently) available library functions are SIMPLE-TRANSFER (the + default), a simple division by 32768.0s0 and SQUARE-TRANSFER (the + result of a SIMPLE-TRANSFER, squared and multiplied by the + signum).

+ +

A graph displaying these two transfer functions (X axis is raw + joystick data, Y axis is the displacement along the axis available + from GAMES-STICK):
+ Transfer function graph +

+ +

Full STICK package exported symbol list

+
+
(axes joystick) +
Returns an array, with axis 0 at index 0, axis 1 at index 1 and + so on. +
(buttons joystick) +
Returns a bit-vector, with button 0 at index 0, button 1 at + index 1 and so forth. A value of 0 means "not pressed", a value of 1 + means "pressed". +
(make-stick device-file) +
Create a joystick object for the named device. +
(set-transfer joystick axis transfer-fn) +
Set the transfer function for axis to the desired transfer + function. A transfer function should map from [ -32768, 32767 ] to [ + -1.0s0, 1.0s0 ]. +
(simple-transfer value) +
A simple transfer function (linear mapping from the integer + range to the single-float range). +
(square-transfer value) +
A slightly more complex transfer function, causing less + sensitivity in the "close to centred" region and slightly higher + sensitivity in the more extreme regions. +
(update-stick joystick) +
Copy current (hidden) data to teh publicly available data. Also + applies the relevant transfer functions. +
(continous-poll joystick) +
Only available if build with :SB-THREAD available on + *FEATURES*.
Start a separate thread reading from the device. Still + requires UPDATE-STICK to copy from private to pubic data. +
(terminate-poll joystick) +
Only available if build with :SB-THREAD available on + *FEATURES*.
Terminate continous polling for a specific joystick. +
+ + From imattsson at common-lisp.net Wed Dec 27 20:18:37 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Wed, 27 Dec 2006 20:18:37 +0000 Subject: [gamelib-cvs] index.html Message-ID: <20061227201837.2419561046@common-lisp.net> Update of /project/gamelib/cvsroot/source/doc In directory clnet:/tmp/cvs-serv3639 Modified Files: index.html Log Message: IM Added the joystick docs to the main page. Index: index.html =================================================================== RCS file: /project/gamelib/cvsroot/source/doc/index.html,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** index.html 23 Sep 2006 07:46:28 -0000 1.4 --- index.html 27 Dec 2006 20:18:34 -0000 1.5 *************** *** 27,32 ****

Components

!

Gamelib has three components, the AI component, the games-2D component and the ! games-3d component.

Intended use

--- 27,32 ----

Components

!

Gamelib has four components, the AI component, the games-2D component, the ! games-3d component and the joystick component.

Intended use

From imattsson at common-lisp.net Wed Dec 27 20:27:01 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Wed, 27 Dec 2006 20:27:01 +0000 Subject: [gamelib-cvs] stick.html Message-ID: <20061227202701.56E106106F@common-lisp.net> Update of /project/gamelib/cvsroot/source/doc In directory clnet:/tmp/cvs-serv5728 Modified Files: stick.html Log Message: IM Ooops, title still said "3d library", now changed. Index: stick.html =================================================================== RCS file: /project/gamelib/cvsroot/source/doc/stick.html,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** stick.html 27 Dec 2006 19:27:24 -0000 1.2 --- stick.html 27 Dec 2006 20:26:59 -0000 1.3 *************** *** 4,8 **** ! Gamelib - games-3d library --- 4,8 ---- ! Gamelib - games-stick library From imattsson at common-lisp.net Wed Dec 27 21:26:47 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Wed, 27 Dec 2006 21:26:47 +0000 Subject: [gamelib-cvs] stick.html Message-ID: <20061227212647.DAB0049021@common-lisp.net> Update of /project/gamelib/cvsroot/source/doc In directory clnet:/tmp/cvs-serv13839 Modified Files: stick.html Log Message: IM Linked in some demo code. Index: stick.html =================================================================== RCS file: /project/gamelib/cvsroot/source/doc/stick.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** stick.html 27 Dec 2006 20:26:59 -0000 1.3 --- stick.html 27 Dec 2006 21:26:45 -0000 1.4 *************** *** 59,62 **** --- 59,64 ----

+

A quick example using the stick library can be found here.

+

Full STICK package exported symbol list

From imattsson at common-lisp.net Wed Dec 27 21:27:12 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Wed, 27 Dec 2006 21:27:12 +0000 Subject: [gamelib-cvs] demo-stick.lisp Message-ID: <20061227212712.1F31D49021@common-lisp.net> Update of /project/gamelib/cvsroot/source/doc In directory clnet:/tmp/cvs-serv13888/doc Added Files: demo-stick.lisp Log Message: IM Initial check-in. --- NEW FILE: demo-stick.lisp --- (in-package :net.hexapodia.games-stick) (defvar *display* (xlib:open-default-display)) (defvar *screen* (car (xlib:display-roots *display*))) (defvar *win* (xlib:create-window :parent (xlib:screen-root *screen*) :width 200 :x 10 :y 10 :height 150)) (defvar *black* (xlib:screen-black-pixel *screen*)) (defvar *white* (xlib:screen-white-pixel *screen*)) (defvar *js* (net.hexapodia.games-stick:make-stick "/dev/input/js0")) (defun update () (update-stick *js*) (xlib:draw-rectangle *win* *white* 0 0 200 150 t) (xlib:display-force-output *display*) (xlib:draw-rectangle *win* *black* 10 10 100 100) (let ((x-offset (round (+ 60 (* 50 (aref (axes *js*) 0))))) (y-offset (round (+ 60 (* 50 (aref (axes *js*) 1))))) (twist (+ 60 (round (* 50 (aref (axes *js*) 3))))) (throttle (+ 60 (round (* 50 (aref (axes *js*) 2)))))) (xlib:draw-line *win* *black* x-offset (- y-offset 5) x-offset (+ y-offset 5)) (xlib:draw-line *win* *black* (- x-offset 5) y-offset (+ x-offset 5) y-offset) (xlib:draw-line *win* *black* twist 120 twist 130) (xlib:draw-line *win* *black* 120 throttle 130 throttle) (loop for n from 0 for bitt across (buttons *js*) do (multiple-value-bind (y x) ( truncate n 4) (let ((x (+ 135 (* 10 x))) (y (+ 10 (* 10 y)))) (xlib:draw-arc *win* *black* x y 6 6 0 (* 2 pi) (not (zerop bitt)))))) ) (xlib:display-force-output *display*)) From imattsson at common-lisp.net Wed Dec 27 21:28:17 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Wed, 27 Dec 2006 21:28:17 +0000 Subject: [gamelib-cvs] gamelib.asd Message-ID: <20061227212818.06A9349022@common-lisp.net> Update of /project/gamelib/cvsroot/source In directory clnet:/tmp/cvs-serv13995 Modified Files: gamelib.asd Log Message: IM Version update, preparing for release. Index: gamelib.asd =================================================================== RCS file: /project/gamelib/cvsroot/source/gamelib.asd,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gamelib.asd 10 Oct 2006 06:18:24 -0000 1.4 --- gamelib.asd 27 Dec 2006 21:28:15 -0000 1.5 *************** *** 1,4 **** (asdf:defsystem "gamelib" ! :version "0.3" :author "Ingvar Mattsson " ! :depends-on ("games-ai" "games-2d" "games-3d")) --- 1,5 ---- (asdf:defsystem "gamelib" ! :version "0.4" :author "Ingvar Mattsson " ! :depends-on ("games-ai" "games-2d" "games-3d" ! #+linux "games-stick")) From imattsson at common-lisp.net Thu Dec 28 06:15:50 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Thu, 28 Dec 2006 06:15:50 +0000 Subject: [gamelib-cvs] demo-stick.lisp Message-ID: <20061228061550.4C4983904E@common-lisp.net> Update of /project/gamelib/cvsroot/source/doc In directory clnet:/tmp/cvs-serv30770 Modified Files: demo-stick.lisp Log Message: IM Minor update for the joystick demo. Index: demo-stick.lisp =================================================================== RCS file: /project/gamelib/cvsroot/source/doc/demo-stick.lisp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** demo-stick.lisp 27 Dec 2006 21:27:10 -0000 1.1 --- demo-stick.lisp 28 Dec 2006 06:15:47 -0000 1.2 *************** *** 33,34 **** --- 33,41 ---- ) (xlib:display-force-output *display*)) + + (continous-poll *js*) + (loop for n below 1000 do (progn + (update) + (sleep 0.1))) + + \ No newline at end of file From imattsson at common-lisp.net Sat Dec 30 19:12:38 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Sat, 30 Dec 2006 19:12:38 +0000 Subject: [gamelib-cvs] generics.lisp Message-ID: <20061230191238.2F2822D20D@common-lisp.net> Update of /project/gamelib/cvsroot/source In directory clnet:/tmp/cvs-serv15369 Added Files: generics.lisp Log Message: IM First check-in after re-creation. --- NEW FILE: generics.lisp --- (in-package #:net.hexapodia.games-2d) (defgeneric draw (object)) (defgeneric movement (object)) (defgeneric (setf movement) (object)) From imattsson at common-lisp.net Sat Dec 30 19:19:32 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Sat, 30 Dec 2006 19:19:32 +0000 Subject: [gamelib-cvs] generics.lisp Message-ID: <20061230191932.58B0E33044@common-lisp.net> Update of /project/gamelib/cvsroot/source In directory clnet:/tmp/cvs-serv16209 Modified Files: generics.lisp Log Message: IM Now with doc strings! Index: generics.lisp =================================================================== RCS file: /project/gamelib/cvsroot/source/generics.lisp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generics.lisp 30 Dec 2006 19:12:36 -0000 1.1 --- generics.lisp 30 Dec 2006 19:19:29 -0000 1.2 *************** *** 1,5 **** (in-package #:net.hexapodia.games-2d) ! (defgeneric draw (object)) ! (defgeneric movement (object)) ! (defgeneric (setf movement) (object)) --- 1,14 ---- (in-package #:net.hexapodia.games-2d) ! (defgeneric draw (object) ! (:documentation "Draw a graphics object into the relevant window ! (objects that move will have their associated window tied from the object)")) ! ! (defgeneric move (object) ! (:documentation "Make an object move, if it is an animated object, also switch ! to the next animation")) ! ! (defgeneric movement (object) ! (:documentation "Returns movement (dx / dy) for a movable object.")) ! (defgeneric (setf movement) (value object) ! (:documentation "Sets movement (dx / dy) for a movable object.")) From imattsson at common-lisp.net Sun Dec 31 12:38:42 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Sun, 31 Dec 2006 12:38:42 +0000 Subject: [gamelib-cvs] graphics.lisp Message-ID: <20061231123842.C227D28238@common-lisp.net> Update of /project/gamelib/cvsroot/source In directory clnet:/tmp/cvs-serv2849 Modified Files: graphics.lisp Log Message: IM Sliht changes (essentially ripping out some code taht should've been dead already). Index: graphics.lisp =================================================================== RCS file: /project/gamelib/cvsroot/source/graphics.lisp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** graphics.lisp 5 Sep 2006 06:04:32 -0000 1.3 --- graphics.lisp 31 Dec 2006 12:38:40 -0000 1.4 *************** *** 232,235 **** --- 232,238 ---- )) + ;;; The following function has Gatlopp-specific code (namely the calls to + ;;; (keys *player*). IThat's why it's being discarded. + #-(and) (defun update-status-window () (when *player* *************** *** 241,244 **** --- 244,248 ---- *controls* (x *player*) (y *player*))))) + (defmethod draw ((obj xlib:window)) (cond ((xlib:drawable-equal obj *game-window*) From imattsson at common-lisp.net Sun Dec 31 12:39:04 2006 From: imattsson at common-lisp.net (Ingvar Mattsson) Date: Sun, 31 Dec 2006 12:39:04 +0000 Subject: [gamelib-cvs] games-2d.asd Message-ID: <20061231123904.D485B28238@common-lisp.net> Update of /project/gamelib/cvsroot/source In directory clnet:/tmp/cvs-serv2923 Modified Files: games-2d.asd Log Message: IM Noticed taht one needed file wasn't being included. Index: games-2d.asd =================================================================== RCS file: /project/gamelib/cvsroot/source/games-2d.asd,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** games-2d.asd 10 Oct 2006 06:18:24 -0000 1.7 --- games-2d.asd 31 Dec 2006 12:39:02 -0000 1.8 *************** *** 7,12 **** (:file "globals-2d" :depends-on ("packages-2d")) (:file "xpm-lib" :depends-on ("packages-2d")) (:file "generics" :depends-on ("packages-2d")) ! (:file "graphics" :depends-on ("packages-2d" "xpm-lib" "globals-2d" "generics")) (:file "gameplay" :depends-on ("packages-2d" "globals-2d")) --- 7,13 ---- (:file "globals-2d" :depends-on ("packages-2d")) (:file "xpm-lib" :depends-on ("packages-2d")) + (:file "images" :depends-on ("packages-2d")) (:file "generics" :depends-on ("packages-2d")) ! (:file "graphics" :depends-on ("packages-2d" "xpm-lib" "images" "globals-2d" "generics")) (:file "gameplay" :depends-on ("packages-2d" "globals-2d"))