From fateman at cs.berkeley.edu Thu Dec 22 17:26:38 2005 From: fateman at cs.berkeley.edu (Richard Fateman) Date: Thu, 22 Dec 2005 09:26:38 -0800 Subject: [rdnzl-devel] attaching handler / Tablet PC ink/ stroke/ not working Message-ID: <43AAE1CE.80000@cs.berkeley.edu> Is anyone successfully using microsoft "ink" from Lisp via rdnzl? I sent this note to Edi RJF: Could you look at a (1 page) piece of code and see if there is something obvious that (my student and I) are doing wrong trying to use rdnzl? It is at http://www.cs.berkeley.edu/~fateman/temp/mjnet.lisp Edi: I just did and it looks OK to me. ... Nevertheless it doesn't work on either Allegro (RJF) or Lispworks. (Edi) It opens a window and enables "Ink", but if a handler is set up, it stops inking after the first stroke, and never really calls the handler. Oh, you don't need to have a Tablet PC, but it probably helps to have the microsoft Tablet PC SDK downloaded to your Windows machine. (Our project involves reading and speaking mathematics into a computer for processing by computer algebra programs in Lisp.) Thanks for any hints. RJF From edi at agharta.de Thu Dec 22 17:45:05 2005 From: edi at agharta.de (Edi Weitz) Date: Thu, 22 Dec 2005 18:45:05 +0100 Subject: [rdnzl-devel] attaching handler / Tablet PC ink/ stroke/ not working In-Reply-To: <43AAE1CE.80000@cs.berkeley.edu> (Richard Fateman's message of "Thu, 22 Dec 2005 09:26:38 -0800") References: <43AAE1CE.80000@cs.berkeley.edu> Message-ID: On Thu, 22 Dec 2005 09:26:38 -0800, Richard Fateman wrote: > Oh, you don't need to have a Tablet PC, but it probably helps to > have the microsoft Tablet PC SDK downloaded to your Windows machine. FWIW, I already had this SDK on my machine (which is not a Tablet PC) - most likely because I have Visual Studio. So, if some of you want to give it a try and have a recent version of Visual Studio you should be able to just load and execute the Lisp code. You can use your mouse to simulate the Tablet PC pen. Cheers, Edi. From edi at agharta.de Thu Dec 22 17:47:39 2005 From: edi at agharta.de (Edi Weitz) Date: Thu, 22 Dec 2005 18:47:39 +0100 Subject: [rdnzl-devel] attaching handler / Tablet PC ink/ stroke/ not working In-Reply-To: (Edi Weitz's message of "Thu, 22 Dec 2005 18:45:05 +0100") References: <43AAE1CE.80000@cs.berkeley.edu> Message-ID: I forgot to mention: My guess is that this doesn't work because of threading issues - .NET is trying to call into Lisp from a thread which wasn't created by Lisp. This would explain the failure on LW, see: I'm not familiar enough with AllegroCL but maybe it's similar there. From edi at agharta.de Thu Dec 22 21:28:26 2005 From: edi at agharta.de (Edi Weitz) Date: Thu, 22 Dec 2005 22:28:26 +0100 Subject: [rdnzl-devel] attaching handler / Tablet PC ink/ stroke/ not working In-Reply-To: (Edi Weitz's message of "Thu, 22 Dec 2005 18:47:39 +0100") References: <43AAE1CE.80000@cs.berkeley.edu> Message-ID: On Thu, 22 Dec 2005 18:47:39 +0100, Edi Weitz wrote: > My guess is that this doesn't work because of threading issues - > .NET is trying to call into Lisp from a thread which wasn't created > by Lisp. And I was right. Here's a solution that avoids these problems and works for me. Files are at the end of this message. 1. Build a DLL (they don't have the threading problems I mentioned - see link in my earlier email) using LispWorks as usual, something like (from a console window): "\Program Files\LispWorks\lispworks-4460.exe" -init deliver.lisp 2. Make sure RDNZL.dll can be found - put it into c:\Windows\System32 for example. 3. Start the DLL as a program: rundll32 demo.dll,demo You should now see a window on which you can "draw" using the mouse. After every fifth stroke a message should come up telling you how many strokes the app has counted so far. If you don't have a LispWorks license to deliver executables you can download the DLL to play with from and start with #2 above. I don't know how to do that with AllegroCL but I guess Franz' support will help you. If they come up with a solution it'd be nice if you could post it here. Cheers, Edi. -------------------- deliver.lisp -------------------- (load-all-patches) ;; modify to match the location of RDNZL on your PC (load "/home/lisp/RDNZL/load.lisp") (use-package :rdnzl) (load (compile-file "tablet.lisp")) (shutdown-rdnzl) (deliver 'init "demo" 1 :dll-exports '("demo")) (quit) -------------------- tablet.lisp -------------------- (enable-rdnzl-syntax) (import-types "Microsoft.Ink" "InkOverlay" "InkCollectorStrokeEventHandler") (import-types "System.Windows.Forms" "Form" "Application" "MessageBox") (import-type "System.EventHandler") (use-namespace "Microsoft.Ink") (use-namespace "System.Windows.Forms") (use-namespace "System") (defparameter *stroke-counter* 0) (defun handle-stroke (object event) (declare (ignore object event)) (when (zerop (mod (incf *stroke-counter*) 5)) [MessageBox.Show (format nil "~A strokes so far..." *stroke-counter*)])) (defun demo () (let ((window (new "Form")) (ink-overlay)) (flet ((on-load (object event) (declare (ignore object event)) (setf ink-overlay (new "InkOverlay" [%Handle window]) [%Enabled ink-overlay] t) [+Stroke ink-overlay (new "InkCollectorStrokeEventHandler" #'handle-stroke)])) [+Load window (new "EventHandler" #'on-load)] [Application.Run window]))) (disable-rdnzl-syntax) (fli:define-foreign-callable ("demo" :calling-convention :stdcall) ((hwnd w:hwnd) (hinst w:hinstance) (string :pointer) (cmd-show :int)) (declare (ignore hwnd hinst string cmd-show)) (demo)) (defun init () (init-rdnzl)) From edi at agharta.de Fri Dec 23 11:32:04 2005 From: edi at agharta.de (Edi Weitz) Date: Fri, 23 Dec 2005 12:32:04 +0100 Subject: [rdnzl-devel] attaching handler / Tablet PC ink/ stroke/ not working In-Reply-To: (Edi Weitz's message of "Thu, 22 Dec 2005 22:28:26 +0100") References: <43AAE1CE.80000@cs.berkeley.edu> Message-ID: On Thu, 22 Dec 2005 22:28:26 +0100, Edi Weitz wrote: > On Thu, 22 Dec 2005 18:47:39 +0100, Edi Weitz wrote: > >> My guess is that this doesn't work because of threading issues - >> .NET is trying to call into Lisp from a thread which wasn't created >> by Lisp. > > And I was right. FWIW, I now also tried the example with Corman Lisp and it seems to work fine. Looks like Corman Lisp doesn't have problems with "foreign" threads calling into Lisp. From edi at agharta.de Mon Dec 26 11:38:54 2005 From: edi at agharta.de (Edi Weitz) Date: Mon, 26 Dec 2005 12:38:54 +0100 Subject: [rdnzl-devel] attaching handler / Tablet PC ink/ stroke/ not working In-Reply-To: (Edi Weitz's message of "Fri, 23 Dec 2005 12:32:04 +0100") References: <43AAE1CE.80000@cs.berkeley.edu> Message-ID: On Fri, 23 Dec 2005 12:32:04 +0100, Edi Weitz wrote: > FWIW, I now also tried the example with Corman Lisp and it seems to > work fine. Looks like Corman Lisp doesn't have problems with > "foreign" threads calling into Lisp. Another data point (I realize that I'm talking to myself all of the time... :) - LispWorks version 5.0 (due out Q2 2006) will also be able to cope with this: Cheers, Edi.