2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /****************************************************************************************/
11 #include <devices/inputevent.h>
14 #include <aros/debug.h>
16 #include "keymap_intern.h"
18 /****************************************************************************************/
21 extern struct KeymapBase
*DebugKeymapBase
;
23 # define SysBase DebugKeymapBase->SysBase
27 /****************************************************************************************/
29 BOOL
WriteToBuffer(struct BufInfo
*bufinfo
, UBYTE
*string
, LONG numchars
)
31 if (bufinfo
->CharsWritten
+ numchars
> bufinfo
->BufLength
)
34 strncpy(bufinfo
->Buffer
, string
, numchars
);
35 bufinfo
->CharsWritten
+= numchars
;
40 /****************************************************************************************/
42 BOOL
GetKeyInfo(struct KeyInfo
*ki
, UWORD code
, UWORD qual
, struct KeyMap
*km
)
44 BOOL valid
= TRUE
; /* valid code is default */
46 if (code
& IECODE_UP_PREFIX
) /* Key pressed ? */
50 else if (code
>= 128) /* Keymaps at the moment support only 128 keys */
59 ki
->KCFQual
= KC_NOQUAL
; /* == 0 */
61 code
&= ~IECODE_UP_PREFIX
;
63 /* Convert from IEQUAL_xxx into KCF_xx */
64 if (qual
& (IEQUALIFIER_LSHIFT
|IEQUALIFIER_RSHIFT
))
65 ki
->KCFQual
|= KCF_SHIFT
;
67 if (qual
& (IEQUALIFIER_LALT
|IEQUALIFIER_RALT
))
68 ki
->KCFQual
|= KCF_ALT
;
70 if (qual
& IEQUALIFIER_CONTROL
)
71 ki
->KCFQual
|= KCF_CONTROL
;
73 D(bug("mrk: KCF qual: %d\n", ki
->KCFQual
));
75 /* Get the type of the key */
78 /* Get key info from low keymap */
79 ki
->Key_MapType
= km
->km_LoKeyMapTypes
[code
];
80 ki
->Key_Mapping
= km
->km_LoKeyMap
[code
];
82 capsable
= GetBitProperty(km
->km_LoCapsable
, code
);
83 repeatable
= GetBitProperty(km
->km_LoRepeatable
, code
);
87 code
-= 0x40; /* hex 40 is first indexed */
89 /* Get key info from high keymap */
90 ki
->Key_MapType
= km
->km_HiKeyMapTypes
[code
];
91 ki
->Key_Mapping
= km
->km_HiKeyMap
[code
];
92 capsable
= GetBitProperty(km
->km_HiCapsable
, code
);
93 repeatable
= GetBitProperty(km
->km_HiRepeatable
, code
);
96 D(bug("mrk: capsable=%d\n", capsable
));
98 if ((qual
& IEQUALIFIER_CAPSLOCK
) && capsable
)
99 ki
->KCFQual
|= KCF_SHIFT
;
101 if ((qual
& IEQUALIFIER_REPEAT
) && (!repeatable
))
103 valid
= FALSE
; /* Repeating not supported for key, skip keypress */
106 D(bug("mrk:repeat test passed\n"));
108 D(bug("mrk: key mapping: %04x\n", ki
->Key_Mapping
));
114 /****************************************************************************************/
116 WORD
GetDeadKeyIndex(UWORD code
, UWORD qual
, struct KeyMap
*km
)
121 /* Get the key info for the key */
123 if (GetKeyInfo(&ki
, code
, qual
, km
))
125 if (ki
.Key_MapType
& KCF_DEAD
)
129 /* Use keymap_str table to get idx to right key descriptor */
130 idx
= keymapstr_table
[ki
.Key_MapType
& KC_VANILLA
][ki
.KCFQual
];
133 UBYTE
*dead_descr
= (UBYTE
*)ki
.Key_Mapping
;
135 if (dead_descr
[idx
* 2] == DPF_DEAD
)
139 retval
= dead_descr
[idx
* 2 + 1];
141 retval
&= 0x00FF; /* Clear upper byte */
150 /****************************************************************************************/