[comp.sys.amiga.tech] input.device stuff

scott@applix.UUCP (Scott Evernden) (08/26/88)

I am trying to feed a stream of ASCII characters into the input.device.
I'm trying to simulate keyboard activity.

The input.device expects (optionally qualified) raw key presses and
releases.  So, to do what I want, for each character, I must determine
a raw key code and appropriate qualifiers which will generate it.  In
other words, I need something like a RawKeyConvert() that runs backwards
(accepts ASCII and produces a raw key event).

The brute force way is to scan thru the entire KeyMap, trying to discover
keycodes and qualifiers which generate each ASCII code, while filling up a
lookup table.  This turns out to be somewhat painful, since I don't
completely understand the use of some KCF_DEAD key types and other such
stuff.  It's also messy enough that I feel there must be an easier way.

What I really want, tho, is a more direct way to fake keyboard input.
There are comments in "devices/inputevent.h" which suggest a IECLASS_ANSI
may have once existed.  Something like this would appear to be exactly
what I need for tagging input events- like

	ie.ie_Code = <ascii code>;
	ie.ie_Class = IECLASS_ANSI (or IECLASS_ASCII even);

How about:  temporarily SetFunction()'ing RawKeyConvert() ??   Along with
being kludgy and possibly dumb, this is probably impossible, since I
think SetFunction() can only handle library, and not device, vectors. (?)

How about:  SetDefaultKeyMap()'ing my own simple KeyMap for the duration
of the input injection period, and restoring afterwards ?  This doesn't
strike me as being too system-friendly.

As you can tell, I'm groping for a solution here.
Are there some tricks, hints, or tips that I have overlooked??

-scott

jimm@amiga.UUCP (Jim Mackraz) (08/29/88)

In article <788@applix.UUCP> scott@applix.UUCP (Scott Evernden) writes:
)I am trying to feed a stream of ASCII characters into the input.device.
)I'm trying to simulate keyboard activity.
)
)The input.device expects (optionally qualified) raw key presses and
)releases.  So, to do what I want, for each character, I must determine
)a raw key code and appropriate qualifiers which will generate it.  In
)other words, I need something like a RawKeyConvert() that runs backwards
)(accepts ASCII and produces a raw key event).

The function InvertKeyMap() in commodities.library (part of Commodities
Exchange) does what you want.  Source has been distributed, but you
can't steal hunks of it wholesale.  Perhaps you will find ikm.c
educational.

One good think about it living in a library (hopefully soon to be
semi-standard) is that it undoubtedly has bugs (none known) which can
be fixed retroactively for client programs by updating the library.

And don't forget dead keys.

	jimm

-- 
	Jim Mackraz, I and I Computing	  
	amiga!jimm	BIX:jmackraz
Opinions are my own.  Comments regarding the Amiga operating system, and
all others, are not to be taken as Commodore official policy.

fullmer@dover.uucp (Glen Fullmer) (09/11/88)

In article <2814@amiga.UUCP> jimm@cloyd.UUCP (Jim Mackraz) writes:

>The function InvertKeyMap() in commodities.library (part of Commodities
>Exchange) does what you want.  Source has been distributed, but you
>can't steal hunks of it wholesale.  Perhaps you will find ikm.c
>educational.
>	Jim Mackraz, I and I Computing	  
>	amiga!jimm	BIX:jmackraz

Ok, I'll bite who/what is Commodities Exchange?


-- 
  _____     _  "First you do it once, then you do it for fun,"
 {____/    //  "next you do it seriously and then you're done." Jerry Rubin
      \   // _  ____   "ARE WE HAVING FUN YET?"                            
 {____/  </_</_/ / <_  {sun!sunburn | cadillac} !dover!fullmer