no mouse-wheel event when shift key is down (shift+mouse-wheel events?)
Asked Answered
N

0

4

I'm trying to manage some events in lisp with lispbuilder-sdl.

Thus far I got this.

;; Load package :
(ql:quickload "lispbuilder-sdl")

;; main definition:
(defun main (argv)
  (defparameter *ticks* 0)
  (sdl:with-init ()
    (sdl:window 100 100 :title-caption "test")
    (sdl:with-events ()
      (setf (sdl:frame-rate) 60)
      (:quit-event () (progn (sdl:quit-image) (exit) t))
      (:mouse-button-down-event 
       (:button button :x x :y y)
       (format t "~&LSHIFT: ~a RSHIFT: ~a BUTTON: ~a X: ~d Y: ~d" 
               (sdl:get-key-state :sdl-key-lshift) 
               (sdl:get-key-state :sdl-key-rshift) 
               button x y))
      (:key-down-event 
       (:key key)
       (format t "~& KEY: ~a" key))
      (:idle ()))))



;; Entrypoint :
(sb-int:with-float-traps-masked (:invalid :inexact :overflow) (main *posix-argv*))

If I launch this, a window appear, I can click and roll, I got an output to describe the state of the keys and buttons pressed. Same if I press a key down. Fine.

But something weird occurs when I keep a shift key down.

If I do so, I still have the output when clicking. But not when rolling (mouse wheel events).

So I guess mouse-wheel events simply arent triggered when a shift (right or left) is down. But only shift keys, and I don't even know why.

So I can't for instance handle shift+mouse-wheel events.

Any idea?

NB : The version of SBCL I use on OSX is 1.2.11 but it works with both 1.3.2 and 1.2.11 on Ubuntu.

Necessity answered 23/2, 2016 at 13:32 Comment(13)
I can't reproduce the problem on linux+sbcl, but you should clean that indentation a bit. I suppose emacs doesn't know how to indent the events properly, so you should just manually indent their body 2 spaces (or use something like (emacs lisp) (put 'sdl:with-events 'common-lisp-indent-function '(4 &rest (&whole 2 4 &rest 2))) to tell Emacs how to do it). All those progns seem to be unnecessary as well, and you probably should just use format instead of multiple prints.Approximal
You're right, I'll try to install SLIME to do this then. Perhaps it has something to do with the OS? my project seemed able to handle this on a linux, but right now I'm working on OSX. I'll retry at home after work.Necessity
@Approximal I made a VM to test and compare, and I wasn't able to reproduce it either on ubuntu. I tried both sbcl 1.3.2 and 1.2.11 (I'm using the 1.2.11 on OSX) but it wasn't a version problem either.Necessity
Can you try if it works on some other implementation on OSX to see if the problem is with sbcl or lispbuilder-sdl? I don't have other OSes available to test on myself.Approximal
@Approximal I'm not sure about what you suggested. Did you suggest to me to try with an over sbcl version on OSX?Necessity
@Approximal Though... lispbuilder.sourceforge.net/lispbuilder-sdl.html#compatibilityNecessity
I meant try with some other Common Lisp implementation besides SBCL. That table seems to say that CLISP should work. In case you're not aware, both SBCL and CLISP are implementations of the same Common Lisp standard (as are the others mentioned on that table), so you can switch to another one without any major changes to your code (unless you're using lots of SBCL's non-standard extensions like that sb-int:with-float-traps-masked)Approximal
@Approximal I tried to ql:quickload "lispbuilder-sdl" but I get "- CFFI requires CLISP compiled with dynamic FFI support. with CLISP, I'm trying to find a solution that doesn't require root access.Necessity
Try the answer from this older question. If it doesn't work, I think you need to compile it from source using --with-dynamic-ffi as an argument to configure.Approximal
@Approximal I already tried but I have no root access (hence the need for an answer without a sudo call), I'll try the compilation then.Necessity
@Approximal Hello again! I've finally found the time to try the compilation, but I have the same problem that the post you linked. And the validated solution doesn't work because I have no root access. I've installed libsigsegv and libffi with brew but even with --with-segv-prefix it doesn't work. I've also tried to install it like the error message suggests. If I try to skip and to run make, I got a C compilation error : avcall.h : file not foundNecessity
@Approximal I've made a new post about this compilation problem if it interests you :) : #36850067Necessity
Have you tested SDL directly with other languages on Mac OS X?Hydroid

© 2022 - 2024 — McMap. All rights reserved.