home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
192.lha
/
Snip_v1.3
/
kbio.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-04-28
|
3KB
|
211 lines
char UnShifted[] = /* printable char for each key */
{
'`',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0',
'-',
'=',
'\\', /* 13 */
'\0',
'0', /* NK0 */
'q',
'w',
'e',
'r',
't',
'y',
'u',
'i',
'o',
'p',
'[',
']', /* 27 */
'\0',
'1', /* NK1 */
'2',
'3',
'a',
's',
'd',
'f',
'g',
'h',
'j',
'k',
'l',
';',
'\'', /* 42 */
'\0',
'\0',
'4', /* NK4 */
'5',
'6',
'\0',
'z',
'x',
'c',
'v',
'b',
'n',
'm',
',',
'.',
'/', /* 58 */
'\0',
'.', /* NK. */
'7', /* NK7 */
'8',
'9', /* 63 */
' '
};
char Shifted[] = /* definitions of shifted keys */
{
'~',
'!',
'@',
'#',
'$',
'%',
'^',
'&',
'*',
'(',
')',
'_',
'+',
'|',
'\0',
'0',
'Q',
'W',
'E',
'R',
'T',
'Y',
'U',
'I',
'O',
'P',
'{',
'}',
'\0',
'1',
'2',
'3',
'A',
'S',
'D',
'F',
'G',
'H',
'J',
'K',
'L',
':',
'"',
'\0',
'\0',
'4',
'5',
'6',
'\0',
'Z',
'X',
'C',
'V',
'B',
'N',
'M',
'<',
'>',
'?',
'\0',
'.',
'7',
'8',
'9',
' '
};
#include <devices/input.h>
#include "devices/inputevent.h"
struct MsgPort *ioPort, *CreatePort();
struct IOStdReq *ioReq, *CreateStdIO();
struct InputEvent fake;
initstuff()
{
register struct IOStdReq *Req;
if ( ! (ioPort = CreatePort("Snip I/O",NULL)) )
return(0);
if ( ! (ioReq = CreateStdIO(ioPort)) )
return(0);
if ( OpenDevice("input.device",0,ioReq,0) )
return(0);
Req = ioReq;
Req->io_Command = IND_WRITEEVENT;
Req->io_Flags = 0;
Req->io_Length = sizeof(struct InputEvent);
Req->io_Data = (APTR) &fake;
fake.ie_NextEvent = NULL;
fake.ie_Class = IECLASS_RAWKEY;
fake.ie_TimeStamp.tv_secs = 0;
fake.ie_TimeStamp.tv_micro = 0;
return(1);
}
sendline(message,returnp)
register char *message;
BOOL returnp;
{
register short x,y,pos;
register short len = (short)strlen(message);
for (pos = 0; pos < len; pos++)
{
for (x = 0; x < 65; x++)
{
if (UnShifted[x] == message[pos])
{
fake.ie_Code = x;
fake.ie_Qualifier = 0;
DoIO(ioReq);
goto out;
}
if (Shifted[x] == message[pos])
{
fake.ie_Code = x;
fake.ie_Qualifier = IEQUALIFIER_LSHIFT;
DoIO(ioReq);
goto out;
}
}
out: ;
}
fake.ie_Code = returnp ? 68 : 64; /* EOL is return if returnp is true, otherwise space */
fake.ie_Qualifier = 0;
DoIO(ioReq);
}