[Silly Question]Treating keys like buttons . . .

Dean_Swan at Mitel.COM Dean_Swan at Mitel.COM
Thu Jan 6 15:48:14 UTC 2000



From:  Dean Swan at MITEL on 01/06/2000 10:48 AM

Andrew,

     I've discussed this with Andreas and John Maloney, because the same
capability would be useful to use the hardware buttons on WinCE devices as
substitutes for the mouse buttons.  The short answer seems to be that Squeak
doesn't currently support this, and support for this capability would be
platform dependent.  The other thing to note is that not all platforms support
key up events at all.

     Another (obvious, imo) limitation is that since most keyboards are wired as
a row/column matrix, keeping track of multiple keys that are pressed
simultaneously can be problematic or impossible depending on the combination of
keys. There is, of course, an exception to this: ALL MIDI keyboards can report
key on (down) and key off (up) events for every key in any combination, and
Squeak does have pretty good MIDI support (either the standard system, or
Siren), so you *could*, in theory, write a (platform specific) keyboard driver
that echos all key down and key up events from the host OS out a MIDI port,
mapping them to MIDI note numbers (perhaps on some specific channel like 16) and
connect a MIDI cable from that MIDI Out to another MIDI In to get the events
back into Squeak.

     This whole keyboard to MIDI thing may sound a bit convoluted, but it would
*NOT* require platform specific changes to Squeak, which may make it worth
bothering with.

                                   -Dean Swan
                                   dean_swan at mitel.com





"Andrew C. Greenberg" <werdna at gate.net> on 01/05/2000 11:39:44 PM

Please respond to squeak at cs.uiuc.edu

To:   squeak at cs.uiuc.edu
cc:    (bcc: Dean Swan/Ogd/Mitel)

Subject:  [Silly Question]Treating keys like buttons . . .




Please forgive me if there is a simple answer to the following question.

I seem to be unable to find a straightforward way to accomplish in
Squeak a "trick" I commonly used in my old video-game design years:
exploiting the capacity to detect when a key has been released to
treat keyboard keys much in the way we presently treat mouse-buttons.

A common trait of modern computer games (and some real-time systems)
is a perceived capacity to react seamlessly to commands as they are
entered by a user.

Particularly in many "first person" style games, and even old-style
games like Wizardry, keys are used much in the same way as mouse
buttons, to represent an on-off state for a particular feature.

In "my old days," it was fairly common to de-facto or actually
(depending upon the tech) spin off a process that would discern when
certain keys had been pressed or released, and maintain a global
state  accordingly.  For simpler game logic or tight and predictable
main loops, this could also be accomplished synchronously.

The game's main loop would then simply check the global state to
discern whether a "key-button" is in the up-state or down-state.
This approach greatly simplifies game logic in a "sur"real-time
simulation of autonomous and user-controlled entities.

A modern analog is the MacOS keyUp and keyDown event.  I presume this
is true of other modern windowing systems, with which I am somewhat
less familiar.

Squeak seems to model the keyboard as a buffer stream only,
suppressing all key-up commands, so that there is no way, for
example, to realistically discern the period of time during which a
key has been released.

Is there a facility for doing what I want to do inside of Squeak,
either on a machine-specific or -independent fashion, or have we
learned more "modern" ways to do these old-timer computer game
tricks?  Is this something we should be thinking about?











More information about the Squeak-dev mailing list