Getting the mouse position on multiple LW platforms
We are working on a multi-platform project but we do not have in hand all possible machine/OS/LispWorks combinations. Our initial focus is mainly on Intel Macs, Windows, and Linux, all with 32 or 64 bit architectures. I was wondering if a few people on this list would like to fill up some missing pieces. The current code is listed below and only covers the configurations we have tested: - LispWorks (32-bit) for Windows - LispWorks (32-bit) for Macintosh (running on Intel), and - LispWorks (64-bit) for Macintosh (running on Intel)). If you kindly want to give it a try, you will have to play with the feature names and edit the code. You do not need to fixed it up for your platform. Only letting us know that it works or does not work for you would be great. Thanks! Bruno ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; the code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Mouse-location tests #| Fourteen current LispWorks implementations !! http://www.lispworks.com/documentation/lw60/LW/html/lw-600.htm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TESTED #+(and :mswindows :lispworks-32bit) "LispWorks (32-bit) for Windows" #+(and :darwin :x86) "LispWorks (32-bit) for Macintosh (running on Intel)" #+(and :darwin :x86-64 :lispworks-64bit) "LispWorks (64-bit) for Macintosh (running on Intel)" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NOT TESTED #+(and :mswindows :lispworks-64bit) "LispWorks (64-bit) for Windows" #+(and :linux :lispworks-32bit) "LispWorks (32-bit) for Linux" #+(and :linux :lispworks-64bit) "LispWorks (64-bit) for Linux" #+freebsd "LispWorks for FreeBSD" #+(and :darwin :powerpc :lispworks-32bit) "LispWorks (32-bit) for Macintosh (running on PowerPC)" #+(and :darwin :powerpc :lispworks-64bit) "LispWorks (64-bit) for Macintosh (running on PowerPC)" #+(and :solaris2 :x86) "LispWorks (32-bit) for Intel/Solaris" #+(and :solaris2 :x86-64) "LispWorks (64-bit) for Intel/Solaris" #+(and :sparc :lispworks-32bit) "LispWorks (32-bit) for Solaris" #+(and :sparc :lispworks-64bit) "LispWorks (64-bit) for Solaris" #+:hppa "LispWorks for HP PA" |# #+(and :darwin :x86) (progn (fli:define-c-struct (point (:foreign-name "Point")) (y :short) (x :short)) (fli:define-c-typedef (point (:foreign-name "Point")) (:struct point)) (fli:define-foreign-function (getglobalmouse "GetGlobalMouse" :source) ((p (:pointer point))) :result-type :void :language :c)) #+(and :mswindows :lispworks-32bit) (progn (fli:define-c-typedef bool (:boolean :int)) (fli:define-c-typedef long :long) (fli:define-c-struct tagpoint (x long) (y long)) (fli:define-c-typedef point (:struct tagpoint)) (fli:define-c-typedef lppoint (:pointer point)) (fli:define-foreign-function (get-cursor-position "GetCursorPos") ((lp-point lppoint)) :result-type bool)) (defun get-mouse-position () #+:lispworks-32bit (fli:with-dynamic-foreign-objects () (let ((point (fli:allocate-foreign-object :type 'point))) #+(and :darwin :x86) (getglobalmouse point) #+:mswindows (get-cursor-position point) (list (fli:foreign-slot-value point 'x) (fli:foreign-slot-value point 'y)))) #+(and :darwin :x86-64 :lispworks-64bit) (objc:with-autorelease-pool () (let ((mouse-loc (objc:invoke "NSEvent" "mouseLocation"))) (list (aref mouse-loc 0) (aref mouse-loc 1))))) (get-mouse-position)