Lisp HUG Maillist Archive

CAPI: global keyboard handler and double buffering

Hi,

I'm writing a little game, you can paste it to your REPL and start it with
(start):

http://www.frank-buss.de/lisp/aqueduct.lisp.txt
http://www.frank-buss.de/lisp/aqueduct.png

But the problem is, when I click the "Play" button, then I have to click
again in the board before I can start playing with the number keys (1-6, you
can use the number pad for better direction matching). How can I register a
global keyboard handler?

Another problem: I want avoid the flickering, so I need double buffering,
because it's easier to just draw all again instead of bookkeeping which
areas needs to be redrawn. Is there are a simple example how I can do it
with CAPI?

Regards,

Frank


Re: CAPI: global keyboard handler and double buffering

Unable to parse email body. Email id is 3511

RE: CAPI: global keyboard handler and double buffering

> Yes. Check out pixmaps and the gp:pixblt function.

Thanks, this works fine. I've added some comments, compiled it for Windows,
added the CAPI:APPLY-IN-PANE-PROCESS in start, some help text etc. The final
version:

http://www.frank-buss.de/lisp/aqueduct.html

There is still a lot to do, like recording of the movements, a nicer GUI and
I want sound and joystick support. When I've some more time, I'll port the
CAPI part to SDL (http://www.libsdl.org/) and post it to comp.lang.lisp.

BTW: would be great, if someone can compile it for Macintosh and Unix and
can send me the executables and screenshots, but please send a copy to this
mailing list without the attachment, to avoid flooding my mailbox :-)

-- 
Frank Buß, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de



Re: CAPI: global keyboard handler and double buffering

Unable to parse email body. Email id is 3521

RE: CAPI: global keyboard handler and double buffering

>  > http://www.frank-buss.de/lisp/aqueduct.html
> 
> Never say final :)

You are right, I've never seen a final software or it was not used any more
:-)

> I suggest you rewrite START to avoid this problem, like this:

Thanks, that looks much better.

> (defmethod on-gesture ((self aqueduct) x y gspec)
>   (on-key-press self x y (cons (sys:gesture-spec-data gspec)
>                                (sys:gesture-spec-modifiers gspec))))

I'm using LispWork 4.3.7 and I don't have sys:gesture-spec*, but an apropos
shows that sys::gesture-spec* is available and with this changes it works on
Windows. I've uploaded the new version on my web page. This fixed another
small problem, but not related to CAPI: When changing to edit mode, and not
selecting a cell type, :empty was used (I changed it later to nil and forgot
the initialization reference), which caused wrong data when saved.

-- 
Frank Buß, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de



RE: CAPI: global keyboard handler and double buffering

--- Frank Buss <fb@frank-buss.de> wrote:

> BTW: would be great, if someone can compile it for Macintosh and Unix and
> can send me the executables and screenshots, but please send a copy to
this
> mailing list without the attachment, to avoid flooding my mailbox :-)

Dave Fox has delivered it to MacOS and Linux (with no warranties), after
fixing another little bug (hitting the cursor keys let the program crash on
MacOS). I've uploaded it to my web page with screenshots. You can use the
program for whatever you want.

-- 
Frank Buß, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de




Re: CAPI: global keyboard handler and double buffering

On Feb 4, 2005, at 4:51 AM, Frank Buss wrote:

> BTW: would be great, if someone can compile it for Macintosh and Unix 
> and
> can send me the executables and screenshots, but please send a copy to 
> this
> mailing list without the attachment, to avoid flooding my mailbox :-)

I can't speak for linux,  but the game doesn't work on Mac OS X - 
keyboard input only causes a beep and the red dot doesn't move. 
Clicking in the CAPI pane first doesn't fix this problem either.

warmest regards,

Ralph

Raffael Cavallaro, Ph.D.
raffaelcavallaro@mac.com

Re: CAPI: global keyboard handler and double buffering

Unable to parse email body. Email id is 3512

RE: CAPI: global keyboard handler and double buffering

> I think you want to make the Play button's callback set the 
> input focus to the output pane.
> 
> (defmethod on-play ((self aqueduct))
>   (with-slots (board-template board) self
>     (setf board (copy-array board-template))
>     (draw-aqueduct self)
>     (CAPI:SET-PANE-FOCUS SELF)))

thanks, that works for the buttons. I've added it to my lambda construct in
the start function, so it is called for every button, because after loading
a map, the game should be in play-mode, too.

But it doesn't work after starting the program. I've added it to the end of
the start function (capi:set-pane-focus aqueduct), but I must click a button
first to change the focus or I must click in the board. Would be better to
have a global keyboard handler, because adding it to all buttons doesn't
help in all cases: I've tried to click between the buttons on the
button-push-panel, and the focus is lost.

-- 
Frank Buß, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de



Re: CAPI: global keyboard handler and double buffering

Unable to parse email body. Email id is 3515

Updated at: 2020-12-10 08:53 UTC