[comp.sys.amiga] Manx/RawKeyConvert-urgent!

c162-fe@zooey.Berkeley.EDU (Jonathan Dubman) (03/08/88)

#define URGENT
#define TIMELY

This is a question for the initiated.  (Bryce?  Matt?  Leo?  Chuck?  CATS?)
Summary of question:  HOW DO YOU CALL RawKeyConvert() from Manx?

I am having major problems calling the RawKeyConvert() function, which takes an
input event of class RAWKEY and returns the ASCII code, using any KeyMap.  It's
gotta be done this way - I already have the RAWKEY and I need to know its
translation.

This is actually a function of the Console Device, so the Console Device has to
be open.  The OpenDevice() call for the console device initializes the
io_Device field of the struct IOStdReq that I pass to it.

HOW DO YOU CALL IT FROM C?  I'd like to avoid writing an assembly language
front end, though I could if I really needed to.

I'm using Manx 3.4b.  I say
	numchars = RawKeyConvert(event, buffer, lengthy, NULL);

Compiles fine, but when I link it, it sings to the tune of
	Undefined _ConsoleDevice
or something.  Now ConsoleDevice() is a function mentioned in the functions.h
file - WHAT IS ConsoleDevice()?  (I'm using a precompiled file that includes
functions.h)

I tried creating a function ConsoleDevice() that returns the address of the
Console Device, but the program guru'ed.

I looked the assembly language output of the compiler.  It puts a bunch of
stuff on the stack and then does a jsr _RawKeyConvert.  Obviously,
_RawKeyConvert is a stub that pulls some stuff off the stack and puts it into
the appropriate registers for calling the real, system RawKeyConvert with a
jsr _LVORawKeyConvert(A6) where A6 is initialized to the address of the
Console Device (really the library node).  WHO SETS A6?  The _RawKeyConvert
stub function?  HOW DOES IT KNOW WHERE THE CONSOLE DEVICE IS?  IS THAT WHAT
ConsoleDevice() is for?

I've got the MANX manual, the RKM, and Mortimer vol. 2, but I just can't figure
this out.  Will somebody PLEASE set me straight?

	*&(Jonathan Dubman)
	upon answer:  :-(  --->  :-)

papa@pollux.usc.edu (Marco Papa) (03/08/88)

In article <1322@pasteur.Berkeley.Edu> c162-fe@zooey.Berkeley.EDU (Jonathan Dubman) writes:
>This is a question for the initiated.  (Bryce?  Matt?  Leo?  Chuck?  CATS?)
>Summary of question:  HOW DO YOU CALL RawKeyConvert() from Manx?
>I am having major problems calling the RawKeyConvert() function, which takes an
>input event of class RAWKEY and returns the ASCII code, using any KeyMap.  It's
>gotta be done this way - I already have the RAWKEY and I need to know its
>translation.
>This is actually a function of the Console Device, so the Console Device has to
>be open.  The OpenDevice() call for the console device initializes the
>io_Device field of the struct IOStdReq that I pass to it.
>HOW DO YOU CALL IT FROM C?  I'd like to avoid writing an assembly language
>front end, though I could if I really needed to.I'm using Manx 3.4b.  I say
>	numchars = RawKeyConvert(event, buffer, lengthy, NULL);
>
>Compiles fine, but when I link it, it sings to the tune of
>	Undefined _ConsoleDevice
>or something.  Now ConsoleDevice() is a function mentioned in the functions.h
>file - WHAT IS ConsoleDevice()?  (I'm using a precompiled file that includes
>functions.h)

The Enhancer Software Manual (included with the Enhancer 1.2 package) has an
example that shows how to get "dead" keys that uses RawKeyConvert. 
The portion you need follows.

This code is Copyright 1986, Commodore-Amiga Inc. All Rights Reserved.

/* must have the ConsoleDevice opened to use RawKeyConvert() */
struct Device *ConsoleDevice; /* external declaration */
struct IOStdReq ioreq;
...
OpenDevice("console.device", -1, &ioreq, 0);
ConsoleDevice = ioreq.io_Device;
...
...

/*
 * DeadKeyConvert()
 *
 * returns:
 * -2 is message is of clas RAWKEY
 * same as RawKeyConvert otherwise:
 * buffer lenght if <= kbsize
 * -1 else
 */

DeadKeyConvert(msg,kbuffer,kbsize,kmap)
struct IntuiMessage *msg;
UBYTE *kbuffer;
int kbsize;
struct Keymap *kmap;
{
	static struct InputEvent = {NULL,IECLASS_RAWKEY, 0,0,0};

	if (msg->Class != RAWKEY) return (-2);

	/* pack input event */
	ievent.ie_Code = msg->Code;
	ievent.ie_Qualifier = msg->Qualifier;

	/* get previous codes from location pointed to by IAddress
	   this pointer is valid until IntuiMessage is replied */
	ievemt.ie_position.ieOSyj3addr = *((APTR *)msg->IAddres);

	return(RawKeyConvert(&ievent,kbuffer,kbsize,kmap));
}

Enjoy.

-- Marco

acs@amdahl.uts.amdahl.com (Tony Sumrall) (03/08/88)

In article <1322@pasteur.Berkeley.Edu> c162-fe@zooey.Berkeley.EDU (Jonathan Dubman) writes:
>This is a question for the initiated.  (Bryce?  Matt?  Leo?  Chuck?  CATS?)
>Summary of question:  HOW DO YOU CALL RawKeyConvert() from Manx?

I posted a little note about this when I gave VT100 R2.8 to the moderators.
In functions.h, Manx declares ConsoleDevice to be a *function*.  It isn't.
What I did for my development of R2.8 was to *remove* the definition of
ConsoleDevice from functions.h and then declare it in vt100.c.  This makes
it work just fine.  I suppose one should really change the definition in
functions.h but I never did.  This problem is also present in 3.60a of
the Manx includes.
-- 
Tony Sumrall acs@uts.amdahl.com <=> amdahl!acs

[ Opinions expressed herein are the author's and should not be construed
  to reflect the views of Amdahl Corp. ]