Tony Kemp wrote:
> Hi,
>
> My setup code is as follows:
>
> (sdl:with-init (sdl:SDL-INIT-EVERYTHING)
>      (setup-window 1024 768)
>      (run-trial)
>      (sdl:with-events ()
>        (:quit-event () t)
>        (:key-down-event (:key key)
>         (process-key key))
>        (:joy-button-down-event (:button but)
>         (button-press but))
>        (:idle () (sdl:update-display))
>        (:video-expose-event () (sdl:update-display))))
>
>   
It seems the joystick needs to be initialized prior to use using 
SDL_JoystickOpen. See http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API.

Try the following, it is a straight port from the example in the link above.

(defvar *joystick* nil)

(defun joystick ()
  (sdl:with-init (sdl:SDL-INIT-EVERYTHING)
    (sdl:window 320 240 :title-caption "Joystick" :icon-caption "Joystick")

    (if (> (sdl-cffi::sdl-num-joysticks) 0)
    (progn
      (setf *joystick* (sdl-cffi::sdl-joystick-open 0))
           
      (if (sdl:is-valid-ptr *joystick*)
          (progn
        (format t "Opened Joystick 0.~%")
        (format t "Name: ~A~%" (sdl-cffi::sdl-joystick-name *joystick*))
        (format t "Number of Axes: ~d~%" 
(sdl-cffi::sdl-joystick-num-axes *joystick*))
        (format t "Number of Buttons: ~d~%" 
(sdl-cffi::sdl-joystick-num-buttons *joystick*))
        (format t "Number of Balls:~d~%" 
(sdl-cffi::sdl-joystick-num-balls *joystick*)))
          (format t "Couldn't open Joystick.~%"))

      (when (> (sdl-cffi::sdl-joystick-opened *joystick*) 0)
        (sdl-cffi::sdl-joystick-close *joystick*)))
    (format t "No Joystick found.~%"))))


- Luke
_______________________________________________
application-builder mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/application-builder

Reply via email to