Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reading the Keyboard!

318 views
Skip to first unread message

Acid Software

unread,
Apr 29, 1995, 3:00:00 AM4/29/95
to
Does anyone know a nice (os friendly) way to read the Amiga's keyboard
while multitasking is off (via. Forbid). I'm writting a game, and have
found the location of a rawkey matrix table by disassembling the
keyboard interupt...but have since discovered that it's not in the same
location on all Amigas.

Help!

Mark


Heinz Wrobel

unread,
Apr 30, 1995, 3:00:00 AM4/30/95
to
Acid Software (ac...@status.gen.nz) wrote:
: Does anyone know a nice (os friendly) way to read the Amiga's keyboard

1. Don't use Forbid()
2. Get the 3.1 NDK
3. Read "OS_Game_Techniques"
4. Read the RKM Libraries


--
Heinz Wrobel Private Mail: he...@hwg.muc.de
My private FAX: +49 89 850 51 25, I prefer email

Peter Elzner

unread,
May 1, 1995, 3:00:00 AM5/1/95
to
he...@hwg.muc.de (Heinz Wrobel ) wrote (30.04.95):

> : Does anyone know a nice (os friendly) way to read the Amiga's keyboard
> : while multitasking is off (via. Forbid). I'm writting a game, and have
> : found the location of a rawkey matrix table by disassembling the
> : keyboard interupt...but have since discovered that it's not in the same
> : location on all Amigas.

> 1. Don't use Forbid()
> 2. Get the 3.1 NDK
> 3. Read "OS_Game_Techniques"
> 4. Read the RKM Libraries

5. Read the RKM Devices
6. Use either input.device or keyboard.device

Peter Elzner [Ha...@blanker.ruhr.de]
------------< Origin 12 - cut here and get a free T-shirt >----------------
A candidate is a person who gets money from the rich and votes from the
poor to protect them from each other.

Big Will Riker

unread,
May 3, 1995, 3:00:00 AM5/3/95
to
On 29 Apr 1995, Acid Software wrote:

> Does anyone know a nice (os friendly) way to read the Amiga's keyboard
> while multitasking is off (via. Forbid). I'm writting a game, and have
> found the location of a rawkey matrix table by disassembling the
> keyboard interupt...but have since discovered that it's not in the same
> location on all Amigas.
>

> Help!
>
> Mark

Mark,

Do you mean the keyboard interrupt is not always in the same place
(eg, you STILL look down the execlist and assume keyboard.device is
in the same place) or do you mean the the matrix is in a different
place inside the interrupt? (eg. Gloom demo doesnt work with
lowlevel.library because I assume you do the same as you did in
one of the blitz2 basic libraries to find keyboard.device)

I've sent simon the fix for this problem, but if this is a different
problem then ignore the above.. :)

Steve.
___________________________________________________________________________
/ Amiga Developer | Current Project : BlitzOS Lib \
| sis...@anubis.sis.port.ac.uk | [####::::::::::::::::::::::::::::::] |
\____________________________________|______________________________________/


Oliver Kastl

unread,
May 3, 1995, 3:00:00 AM5/3/95
to
Hello,

>> Does anyone know a nice (os friendly) way to read the Amiga's
keyboard while multitasking is off (via. Forbid).

Yes!

>> I'm writting a game, and have found the location of a rawkey
matrix table by disassembling the keyboard interupt...but have
since discovered that it's not in the same location on all
Amigas. <<

Uaaaah! Don't even THINK of something like this!

You can safely use DoIO READKEYBOARDMATRIX (sp?) from the
keyboard.device. It will not break your Forbid (avoiding the
Forbid() would be better anyway).

--
Oliver Kastl, Elaborate Bytes
Home is where the heart is

Christian Stieber

unread,
May 4, 1995, 3:00:00 AM5/4/95
to
Acid Software (ac...@iconz.co.nz) wrote:

> I open ciaa.resource, find the keyboard interupt/keyboard data pointers,
> and try to find the rawkey matrix through the data pointer...but it's at
> different offset on different Amigas...why the hell doesn't the OS make
> this matrix accessible!?!?!

NAME
KBD_READMATRIX -- Read the current keyboard key matrix.

FUNCTION
This function reads the up/down state of every key in the
key matrix.

However, input.device is the better choice.

Christian


--
// Christian Stieber Sti...@Informatik.TU-Muenchen.de
\// Certified Amiga Developer http://www.leo.org/~stieber/
--------------------------------------------------------------------------
"Life starts at '030, fun starts at '040, impotence starts at '86"
keyboard not connected -- press F1 to continue

Acid Software

unread,
May 4, 1995, 3:00:00 AM5/4/95
to
Big Will Riker (sis...@sis.port.ac.uk) wrote:
: On 29 Apr 1995, Acid Software wrote:
:
: > Does anyone know a nice (os friendly) way to read the Amiga's keyboard
: > while multitasking is off (via. Forbid). I'm writting a game, and have
: > found the location of a rawkey matrix table by disassembling the
: > keyboard interupt...but have since discovered that it's not in the same
: > location on all Amigas.
: >
: > Help!

: >
: > Mark
:
: Mark,
:
: Do you mean the keyboard interrupt is not always in the same place
: (eg, you STILL look down the execlist and assume keyboard.device is
: in the same place) or do you mean the the matrix is in a different
: place inside the interrupt? (eg. Gloom demo doesnt work with
: lowlevel.library because I assume you do the same as you did in
: one of the blitz2 basic libraries to find keyboard.device)
:
: I've sent simon the fix for this problem, but if this is a different
: problem then ignore the above.. :)
:
: Steve.
: ___________________________________________________________________________

I open ciaa.resource, find the keyboard interupt/keyboard data pointers,

and try to find the rawkey matrix through the data pointer...but it's at
different offset on different Amigas...why the hell doesn't the OS make
this matrix accessible!?!?!

I have to forbid to keep the game up to speed, so I can't use input
events etc.

Mark

Dave Kaupp

unread,
May 6, 1995, 3:00:00 AM5/6/95
to
Hello.

I need to wait for a keypress in a console window like KBhit
for the Clones but it needs to be from the application and not
global. I just got RKM manuals if some one can point me to
a function. It doesnt need to process anything just needs to
know if a key has been pressed. Thanks.


// Dave Kaupp ~ da...@astreet.cts.com
\// Sanity check on memory failed.


... Is your aardvark missing? Check my tires.

* Offline Orbit 0.73c *


Simon or Mark

unread,
May 7, 1995, 3:00:00 AM5/7/95
to

On Sat, 6 May 1995, Michael van Elst wrote:

> In comp.sys.amiga.programmer you write:
>
> >I open ciaa.resource, find the keyboard interupt/keyboard data pointers,
> >and try to find the rawkey matrix through the data pointer...but it's at
> >different offset on different Amigas...why the hell doesn't the OS make
> >this matrix accessible!?!?!
>

> It does. You can tell the keyboard.device to give you a copy.

So I hear...However, so far no one's actually filled me in on how. The
only mention of it I've read is 'this feature is not yet implemented'...

>
> >I have to forbid to keep the game up to speed, so I can't use input
> >events etc.
>

> Rubbish.

Bollocks to you too...didn't realise you had a copy of my code to try it
out on. Ever traced an 'Allocmem' or 'Freemem' when the system is
Alloc'ed up to it's eyeballs? Nice feature having the action jerk when
ever a key is hit, or even worse when 'key repeat' kicks into action.

> Regards,
> --
> Michael van Elst

Game developer by any chance?

Mark Sibly,
Black Magic

Mathias Axelsson

unread,
May 8, 1995, 3:00:00 AM5/8/95
to
In a message dated 07 May 95 Dave Kaupp wrote to All:

DK> I need to wait for a keypress in a console window like KBhit for the

You have to set the console to RAW: mode. If you use SAS/C, take a look at
rawcon(). If you want another way to do it, then use the dos.library function
SetMode(fh, mode).

success = SetMode(fh, mode)

Use mode=1 to go from CON->RAW, and mode=0 to go from RAW->CON. fh is a
filehandle.

/Mathias

( UUCP Dialup connection )


Michael van Elst

unread,
May 8, 1995, 3:00:00 AM5/8/95
to
Simon or Mark <ac...@iconz.co.nz> writes:

>So I hear...However, so far no one's actually filled me in on how. The
>only mention of it I've read is 'this feature is not yet implemented'...

Well, you could read the documentation first. Shows you lots of little
secrets.

>> >I have to forbid to keep the game up to speed, so I can't use input
>> >events etc.
>> Rubbish.

>Bollocks to you too...didn't realise you had a copy of my code to try it
>out on. Ever traced an 'Allocmem' or 'Freemem' when the system is
>Alloc'ed up to it's eyeballs? Nice feature having the action jerk when
>ever a key is hit, or even worse when 'key repeat' kicks into action.

And why would a keypress allocate memory ?

Regards,
--
Michael van Elst

Internet: mle...@serpens.rhein.de
"A potential Snark may lurk in every tree."

Simon or Mark

unread,
May 9, 1995, 3:00:00 AM5/9/95
to

On Mon, 8 May 1995, Matthew Waters wrote:

> Hi Mark
>
> The game I'm working on at the moment uses the keyboard device to read the
> keybaord matrix when I need it. If you're still stuck, then let me know and
> I'll send you a lump of source code (assembly) that should help.
> It works on the 1200.
> BTW, my game uses FORBID as well, for speed, but it does leave the
> important interrupts alone.
>
> Matthew Waters
> Mat...@mattwms.demon.co.uk

Allright! Yes please! That would be truly a good thing...

Mark


Juergen Rally Fischer

unread,
May 9, 1995, 3:00:00 AM5/9/95
to

In article <Pine.SUN.3.91.950509...@iconz.co.nz>, Simon or Mark <ac...@iconz.co.nz> writes:
|>
|>
|> On Mon, 8 May 1995, Matthew Waters wrote:
|>
|> > Hi Mark
|> >
|> > The game I'm working on at the moment uses the keyboard device to read the
|> > keybaord matrix when I need it. If you're still stuck, then let me know and
|> > I'll send you a lump of source code (assembly) that should help.
|> > It works on the 1200.
|> > BTW, my game uses FORBID as well, for speed, but it does leave the
|> > important interrupts alone.

I wonder why you kill system but then try to read keyboard from a device...
Maybe this helps:

move.b $bfec01,d0 : ror.b #1,d0 : not.b d0

Bit 7 is 0 if key still pressed and the value should be same like
RAWKEY ones.

BUT: Keyboard INT must still point to a handshake-routine
(pretty sucking method they invented to just read a byte).

No warranties as I had to type the adress from mind.
No warranties that this will run on AAA (IF not, it's not my
fault), Draco or whatever (I suppose your whole game doesn't).

Also non-68k based architecture might have slight problems
with the 2nd instruction. Maybe SID wont work anymore....

|> >
|> > Matthew Waters
|> > Mat...@mattwms.demon.co.uk
|>
|> Allright! Yes please! That would be truly a good thing...
|>
|> Mark
|>

-----------------------------------------------------------------------------
fisc...@Informatik.TU-Muenchen.DE (Juergen "Rally" Fischer)

=:)
-----------------------------------------------------------------------------

Matthew Waters

unread,
May 9, 1995, 3:00:00 AM5/9/95
to
Simon or Mark (ac...@iconz.co.nz) wrote:


: On Mon, 8 May 1995, Matthew Waters wrote:

: > Hi Mark
: >
: > The game I'm working on at the moment uses the keyboard device to read the
: > keybaord matrix when I need it. If you're still stuck, then let me know and
: > I'll send you a lump of source code (assembly) that should help.
: > It works on the 1200.
: > BTW, my game uses FORBID as well, for speed, but it does leave the
: > important interrupts alone.

: >
: > Matthew Waters
: > Mat...@mattwms.demon.co.uk

: Allright! Yes please! That would be truly a good thing...

: Mark

Well, as I'm feeling generous...

OK then, let's see....
I assume you know a bit about using libraries and such stuff.
You obvioulsy need to open the keyboard device, with
something like:

*******************************************
*Open KEYBOARD device:
*first create message port
CALLEXEC CreateMsgPort (v36 and up!)
move.l d0,MyMsgPortPterKBD
beq .kbderror
*now create io request
move.l d0,a0 pter to port
move.l #56,d0 size of IOStdReq
CALLEXEC CreateIORequest
move.l d0,MyIOReqKBD
beq .kbderror
*now open device
move.l #KBDDevName,a0
move.l #0,d0 unit no
move.l MyIOReqKBD,a1
move.l #0,d1
CALLEXEC OpenDevice
tst.l d0
beq .noerrorkbd
*********
.kbderror
*open intuition library and use EasyRequestArgs to display an
*error message, and quit gracefully.....
...or whatever you like....

bra quit_fast_KBDerror
***********************
.noerrorkbd

...success...


and you need these somewhere:

MyMsgPortPterKBD dc.l 0
MyIOReqKBD dc.l 0
KBDMatrixStore dcb.l 20,0
*******

now, if we want to grab the current matrix, just do:

*read in keyboard matrix:
move.l MyIOReqKBD,a2
move.l #KBDMatrixStore,a1
move.l a1,40(a2) io_data
move.w #KBD_READMATRIX,28(a2)
move.l #16,36(a2)
move.l a2,a1
CALLEXEC DoIO

*now look at stuff at KBDMatrixStore
*see whats being pressed down:
move.l #KBDMatrixStore,a1
btst.b #6,9(a1)
bne .arrowright

btst.b #3,1(a1)
bne .minus

and so on......


When your program quits, you should of course close the device, aborting
any pending IOrequests. May want to clear keyboard input buffer as well.

You need the includes for stuff like KBD_READMATRIX....
This is grabbed from source that compiles in devpac 3.
Hope it is of use.
It's all covered pretty well in the 3rd edition Devices RKM.

BTW, are there two threads running here? Did two people post similar
questions under the same title?? Or is it just me (and tin)...

Matthew
Mat...@mattwms.demon.co.u

Lauri Aalto

unread,
May 10, 1995, 3:00:00 AM5/10/95
to
Mere mortals! Listen in awe as Dave Kaupp speaks:

> I need to wait for a keypress in a console window like KBhit

> for the Clones but it needs to be from the application and not
> global. I just got RKM manuals if some one can point me to
> a function. It doesnt need to process anything just needs to
> know if a key has been pressed. Thanks.

kbhit() doesn't wait a key to be pressed. getch() does.

It all depends on the window type you're using - if you have your own
window, wait for IDCMP_VANILLAKEY messages. If you have a stdio (shell)
window, WaitForChar(Input(), 0) represents kbhit().

--
(__) Lauri Aalto <lauri...@fipnet.fi>
w \@@/ Pronssitie 10, FIN-90250 Oulu, Finland
`/v/-e Tel. +358-81-330434
_/ \_ ...Intel inside--idiot outside...

Oliver Kastl

unread,
May 10, 1995, 3:00:00 AM5/10/95
to
>> move.b $bfec01,d0 : ror.b #1,d0 : not.b d0

Bit 7 is 0 if key still pressed and the value should be same like
RAWKEY ones.
<<

Does not work, if more than one key is pressed. Use the
keyboar.device READKEYBOARDMATRIX (sp?) command, it even works
within Forbid & is super-fast. It even works from Interrupts (but
=warning= this is not documented officially!)

Acid Software

unread,
May 11, 1995, 3:00:00 AM5/11/95
to
Matthew Waters (Mat...@mattwms.demon.co.uk) wrote:
:
: Well, as I'm feeling generous...
:

Thanx - that should do the trick. Unfortunately, my only source of docs
for the Amiga are an old set of Abacus books, a hardware reference
manual, and some cd32 stuff...still, it got me through Blitz 2...

Mark

Keurentjes

unread,
May 13, 1995, 3:00:00 AM5/13/95
to

> Bollocks to you too...didn't realise you had a copy of my code to try it
> out on. Ever traced an 'Allocmem' or 'Freemem' when the system is
> Alloc'ed up to it's eyeballs? Nice feature having the action jerk when
> ever a key is hit, or even worse when 'key repeat' kicks into action.


Why the hell would you want to allocate memory when a key is pressed?


My keypressroutine (OS-illegal) is terribly fast and makes no mistakes....
It buffers as many characters as the programmers desires, keeps constant track
which shift, alt, ctrl, caps or amiga keys are pressed!

Interested?


Keurentjes

unread,
May 13, 1995, 3:00:00 AM5/13/95
to
In article <3oo766$c...@hpsystem1.informatik.tu-muenchen.de> fisc...@informatik.tu-muenchen.de (Juergen "Rally" Fischer) writes:
>
> In article <Pine.SUN.3.91.950509...@iconz.co.nz>, Simon or Mark <ac...@iconz.co.nz> writes:
> |>
> |>
> |> On Mon, 8 May 1995, Matthew Waters wrote:
> |>
> |> > Hi Mark
> |> >
> |> > The game I'm working on at the moment uses the keyboard device to read the
> |> > keybaord matrix when I need it. If you're still stuck, then let me know and
> |> > I'll send you a lump of source code (assembly) that should help.
> |> > It works on the 1200.
> |> > BTW, my game uses FORBID as well, for speed, but it does leave the
> |> > important interrupts alone.
>
> I wonder why you kill system but then try to read keyboard from a device...
> Maybe this helps:
>
> move.b $bfec01,d0 : ror.b #1,d0 : not.b d0
>
> Bit 7 is 0 if key still pressed and the value should be same like
> RAWKEY ones.
>
> BUT: Keyboard INT must still point to a handshake-routine
> (pretty sucking method they invented to just read a byte).
>
> No warranties as I had to type the adress from mind.


The adress is correct, but what's the point of these three instructions when
you're also saying he'll need a keyboard interrupt? Give him the INT then!


Niels

thefro...@gmail.com

unread,
Apr 2, 2017, 8:18:04 AM4/2/17
to
Dam right im interested if you still have the code.
Im stuck with the same problem. Also i cant find how to clear the buffer in assembler so i dont get repeat going constantly.
0 new messages