2 Copyright © 2012, The AROS Development Team. All rights reserved.
6 #include <proto/muimaster.h>
7 #include <proto/intuition.h>
8 #include <proto/keymap.h>
9 #include <proto/utility.h>
10 #include <proto/alib.h>
13 #include <aros/debug.h>
15 #include <libraries/mui.h>
16 #include <devices/rawkeycodes.h>
17 #include <zune/customclasses.h>
21 #include "keyboardgroup_class.h"
24 #define KEY(n) Child, keybtn[n]
28 // On classic keyboard in top left corner of num pad
29 #define RAWKEY_KP_LBRACKET 0x5A
30 #define RAWKEY_KP_RBRACKET 0x5B
38 TEXT shift_alt
[KBUFSIZE
];
39 TEXT ctrl_alt
[KBUFSIZE
];
40 TEXT ctrl_shift
[KBUFSIZE
];
44 // copied from rom/keymap/defaultkeymap.c
45 static const BYTE keymapstr_table
[8][8] =
47 {0, 0, 0, 0, 0, 0, 0, 0}, /* KCF_NOQUAL == 0 */
48 {0, 1, 0, 1, 0, 1, 0, 1}, /* KCF_SHIFT == 1 */
49 {0, 0, 1, 1, 0, 0, 1, 1}, /* KCF_ALT == 2 */
50 {0, 1, 2, 3, 0, 1, 2, 3}, /* KCF_SHIFT|KCF_ALT == 3 */
51 {0, 0, 0, 0, 1, 1, 1, 1}, /* KCF_CONTROL == 4 */
52 {0, 1, 0, 1, 2, 3, 2, 3}, /* KCF_SHIFT|KCF_CONTROL == 5 */
53 {0, 0, 1, 1, 2, 2, 3, 3}, /* KCF_ALT|KCF_CONTROL == 6 */
54 {0, 1, 2, 3, 4, 5, 6, 7} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */
57 // TODO: is this order always the same?
58 static const BYTE deadkey_table
[] = " ´`^~\"°";
61 struct KeyboardGroup_DATA
64 Object
*keybutton
[128]; // 64-127 are high keys
65 struct Hook change_qualifier_hook
;
69 static void set_immutable_key(struct Key
*key
, ULONG idx
, CONST_STRPTR content
)
71 strlcpy(key
[idx
].alone
, content
, KBUFSIZE
);
72 key
[idx
].immutable
= TRUE
;
76 static void parse_normal_key(struct Key
*key
, UBYTE type
, IPTR value
)
81 (*key
).alone
[0] = value
& 0xff;
84 (*key
).alone
[0] = value
& 0xff;
85 (*key
).shift
[0] = (value
>> 8) & 0xff;
88 (*key
).alone
[0] = value
& 0xff;
89 (*key
).alt
[0] = (value
>> 8) & 0xff;
92 (*key
).alone
[0] = value
& 0xff;
93 (*key
).ctrl
[0] = (value
>> 8) & 0xff;
95 case KCF_ALT
+ KCF_SHIFT
:
96 (*key
).alone
[0] = value
& 0xff;
97 (*key
).shift
[0] = (value
>> 8) & 0xff;
98 (*key
).alt
[0] = (value
>> 16) & 0xff;
99 (*key
).shift_alt
[0] = (value
>> 24) & 0xff;
101 case KCF_CONTROL
+ KCF_ALT
:
102 (*key
).alone
[0] = value
& 0xff;
103 (*key
).alt
[0] = (value
>> 8) & 0xff;
104 (*key
).ctrl
[0] = (value
>> 16) & 0xff;
105 (*key
).ctrl_alt
[0] = (value
>> 24) & 0xff;
107 case KCF_CONTROL
+ KCF_SHIFT
:
108 (*key
).alone
[0] = value
& 0xff;
109 (*key
).shift
[0] = (value
>> 8) & 0xff;
110 (*key
).ctrl
[0] = (value
>> 16) & 0xff;
111 (*key
).ctrl_shift
[0]= (value
>> 24) & 0xff;
114 (*key
).alone
[0] = value
& 0xff;
115 (*key
).shift
[0] = (value
>> 8) & 0xff;
116 (*key
).alt
[0] = (value
>> 16) & 0xff;
117 (*key
).shift_alt
[0] = (value
>> 24) & 0xff;
118 (*key
).ctrl
[0] = '^';
119 (*key
).ctrl
[1] = value
& 0xff;
125 static UBYTE
set_string_key(UBYTE type
, IPTR value
, BYTE qual
)
127 D(bug("[KeyShow] set_string_key type %u value %u\n", type
, value
));
131 D(bug("[KeyShow] getting idx at [%d][%d]\n", type
, qual
));
132 idx
= keymapstr_table
[type
][qual
];
136 UBYTE
*str_descrs
= (UBYTE
*)value
;
139 /* Since each string descriptor uses two bytes we multiply by 2 */
142 /* Get string info from string descriptor table */
143 len
= str_descrs
[idx
];
144 offset
= str_descrs
[idx
+ 1];
146 D(bug("[KeyShow] len=%d, offset=%d\n", len
, offset
));
148 /* Return char only if len is 1 */
149 if (len
== 1 && str_descrs
[offset
] > 31)
151 D(bug("[KeyShow] retval %d", str_descrs
[offset
]));
152 return str_descrs
[offset
];
154 } /* if (idx != -1) */
160 static void parse_string_key(struct Key
*key
, UBYTE type
, IPTR value
)
162 D(bug("[KeyShow] parse_string_key type %u value %u\n", type
, value
));
167 (*key
).alone
[0] = set_string_key(type
, value
, KC_NOQUAL
);
170 (*key
).alone
[0] = set_string_key(type
, value
, KC_NOQUAL
);
171 (*key
).shift
[0] = set_string_key(type
, value
, KCF_SHIFT
);
174 (*key
).alone
[0] = set_string_key(type
, value
, KC_NOQUAL
);
175 (*key
).alt
[0] = set_string_key(type
, value
, KCF_ALT
);
178 (*key
).alone
[0] = set_string_key(type
, value
, KC_NOQUAL
);
179 (*key
).ctrl
[0] = set_string_key(type
, value
, KCF_CONTROL
);
181 case KCF_ALT
+ KCF_SHIFT
:
182 (*key
).alone
[0] = set_string_key(type
, value
, KC_NOQUAL
);
183 (*key
).shift
[0] = set_string_key(type
, value
, KCF_SHIFT
);
184 (*key
).alt
[0] = set_string_key(type
, value
, KCF_ALT
);
185 (*key
).shift_alt
[0] = set_string_key(type
, value
, KCF_ALT
+ KCF_SHIFT
);
187 case KCF_CONTROL
+ KCF_ALT
:
188 (*key
).alone
[0] = set_string_key(type
, value
, KC_NOQUAL
);
189 (*key
).alt
[0] = set_string_key(type
, value
, KCF_ALT
);
190 (*key
).ctrl
[0] = set_string_key(type
, value
, KCF_CONTROL
);
191 (*key
).ctrl_alt
[0] = set_string_key(type
, value
, KCF_CONTROL
+ KCF_ALT
);
193 case KCF_CONTROL
+ KCF_SHIFT
:
194 (*key
).alone
[0] = set_string_key(type
, value
, KC_NOQUAL
);
195 (*key
).shift
[0] = set_string_key(type
, value
, KCF_SHIFT
);
196 (*key
).ctrl
[0] = set_string_key(type
, value
, KCF_CONTROL
);
197 (*key
).ctrl_shift
[0]= set_string_key(type
, value
, KCF_CONTROL
+ KCF_SHIFT
);
200 (*key
).alone
[0] = set_string_key(type
, value
, KC_NOQUAL
);
201 (*key
).shift
[0] = set_string_key(type
, value
, KCF_SHIFT
);
202 (*key
).alt
[0] = set_string_key(type
, value
, KCF_ALT
);
203 (*key
).shift_alt
[0] = set_string_key(type
, value
, KCF_ALT
+ KCF_SHIFT
);
204 (*key
).ctrl
[0] = set_string_key(type
, value
, KCF_CONTROL
);
205 (*key
).ctrl_alt
[0] = set_string_key(type
, value
, KCF_CONTROL
+ KCF_ALT
);
206 (*key
).ctrl_shift
[0]= set_string_key(type
, value
, KCF_CONTROL
+ KCF_SHIFT
);
212 static void set_dead_key(STRPTR buffer
, UBYTE type
, IPTR value
, BYTE qual
)
214 D(bug("[KeyShow] set_dead_key type %u value %u\n", type
, value
));
219 /* Use keymap_str table to get idx to right key descriptor */
220 idx
= keymapstr_table
[type
& KC_VANILLA
][qual
];
223 UBYTE
*dead_descr
= (UBYTE
*)value
;
225 switch (dead_descr
[idx
* 2])
229 D(bug("[KeyShow] set_dead_key DPF_DEAD\n"));
230 UBYTE deadidx
= dead_descr
[idx
* 2 + 1];
233 result
= deadkey_table
[deadidx
];
236 // render char. with pen number 5
237 snprintf(buffer
, KBUFSIZE
- 1, "\0335%c", result
);
244 D(bug("[KeyShow] set_dead_key DPF_MOD\n"));
245 result
= dead_descr
[dead_descr
[idx
* 2 + 1]];
248 // render char. in bold
249 snprintf(buffer
, KBUFSIZE
- 1, "\033b%c", result
);
254 D(bug("[KeyShow] set_dead_key DPF 0\n"));
255 result
= dead_descr
[idx
* 2 + 1];
267 static void parse_dead_key(struct Key
*key
, UBYTE type
, IPTR value
)
269 D(bug("[KeyShow] parse_dead_key key %p type %u value %u\n", key
, type
, value
));
274 set_dead_key((*key
).alone
, type
, value
, KC_NOQUAL
);
277 set_dead_key((*key
).alone
, type
, value
, KC_NOQUAL
);
278 set_dead_key((*key
).shift
, type
, value
, KCF_SHIFT
);
281 set_dead_key((*key
).alone
, type
, value
, KC_NOQUAL
);
282 set_dead_key((*key
).alt
, type
, value
, KCF_ALT
);
285 set_dead_key((*key
).alone
, type
, value
, KC_NOQUAL
);
286 set_dead_key((*key
).ctrl
, type
, value
, KCF_CONTROL
);
288 case KCF_ALT
+ KCF_SHIFT
:
289 set_dead_key((*key
).alone
, type
, value
, KC_NOQUAL
);
290 set_dead_key((*key
).shift
, type
, value
, KCF_SHIFT
);
291 set_dead_key((*key
).alt
, type
, value
, KCF_ALT
);
292 set_dead_key((*key
).shift_alt
, type
, value
, KCF_ALT
+ KCF_SHIFT
);
294 case KCF_CONTROL
+ KCF_ALT
:
295 set_dead_key((*key
).alone
, type
, value
, KC_NOQUAL
);
296 set_dead_key((*key
).alt
, type
, value
, KCF_ALT
);
297 set_dead_key((*key
).ctrl
, type
, value
, KCF_CONTROL
);
298 set_dead_key((*key
).ctrl_alt
, type
, value
, KCF_CONTROL
+ KCF_ALT
);
300 case KCF_CONTROL
+ KCF_SHIFT
:
301 set_dead_key((*key
).alone
, type
, value
, KC_NOQUAL
);
302 set_dead_key((*key
).shift
, type
, value
, KCF_SHIFT
);
303 set_dead_key((*key
).ctrl
, type
, value
, KCF_CONTROL
);
304 set_dead_key((*key
).ctrl_shift
, type
, value
, KCF_CONTROL
+ KCF_SHIFT
);
307 set_dead_key((*key
).alone
, type
, value
, KC_NOQUAL
);
308 set_dead_key((*key
).shift
, type
, value
, KCF_SHIFT
);
309 set_dead_key((*key
).alt
, type
, value
, KCF_ALT
);
310 set_dead_key((*key
).shift_alt
, type
, value
, KCF_ALT
+ KCF_SHIFT
);
311 set_dead_key((*key
).ctrl
, type
, value
, KCF_CONTROL
);
312 set_dead_key((*key
).ctrl_alt
, type
, value
, KCF_CONTROL
+ KCF_ALT
);
313 set_dead_key((*key
).ctrl_shift
, type
, value
, KCF_CONTROL
+ KCF_SHIFT
);
319 static struct Key
*read_keymap(void)
321 struct Key
*key
= AllocVec(sizeof(struct Key
) * 128, MEMF_CLEAR
);
324 struct KeyMap
*km
= AskKeyMapDefault();
328 for (i
= 0; i
< 128; i
++)
332 type
= km
->km_LoKeyMapTypes
[i
];
333 value
= km
->km_LoKeyMap
[i
];
337 type
= km
->km_HiKeyMapTypes
[i
-64];
338 value
= km
->km_HiKeyMap
[i
-64];
341 if (type
& KCF_STRING
)
343 parse_string_key(&key
[i
], type
& KC_VANILLA
, value
);
345 else if (type
& KCF_DEAD
)
347 parse_dead_key(&key
[i
], type
& KC_VANILLA
, value
);
351 parse_normal_key(&key
[i
], type
, value
);
355 set_immutable_key(key
, RAWKEY_LSHIFT
, _(MSG_KEY_SHIFT
));
356 set_immutable_key(key
, RAWKEY_RSHIFT
, _(MSG_KEY_SHIFT
));
357 set_immutable_key(key
, RAWKEY_LCONTROL
, _(MSG_KEY_CTRL
));
358 set_immutable_key(key
, RAWKEY_LALT
, _(MSG_KEY_ALT
));
359 set_immutable_key(key
, RAWKEY_RALT
, _(MSG_KEY_ALT
));
362 set_immutable_key(key
, RAWKEY_UP
, "\033I[6:11]");
363 set_immutable_key(key
, RAWKEY_DOWN
, "\033I[6:12]");
364 set_immutable_key(key
, RAWKEY_RIGHT
, "\033I[6:14]");
365 set_immutable_key(key
, RAWKEY_LEFT
, "\033I[6:13]");
368 set_immutable_key(key
, RAWKEY_CAPSLOCK
, _(MSG_KEY_LOCK
));
369 set_immutable_key(key
, RAWKEY_BACKSPACE
, _(MSG_KEY_BACKSP
));
370 set_immutable_key(key
, RAWKEY_TAB
, _(MSG_KEY_TAB
));
371 set_immutable_key(key
, RAWKEY_RETURN
, _(MSG_KEY_RETURN
));
372 set_immutable_key(key
, RAWKEY_ESCAPE
, _(MSG_KEY_ESC
));
374 set_immutable_key(key
, RAWKEY_HELP
, _(MSG_KEY_HELP
));
375 set_immutable_key(key
, RAWKEY_F1
, "F1");
376 set_immutable_key(key
, RAWKEY_F2
, "F2");
377 set_immutable_key(key
, RAWKEY_F3
, "F3");
378 set_immutable_key(key
, RAWKEY_F4
, "F4");
379 set_immutable_key(key
, RAWKEY_F5
, "F5");
380 set_immutable_key(key
, RAWKEY_F6
, "F6");
381 set_immutable_key(key
, RAWKEY_F7
, "F7");
382 set_immutable_key(key
, RAWKEY_F8
, "F8");
383 set_immutable_key(key
, RAWKEY_F9
, "F9");
384 set_immutable_key(key
, RAWKEY_F10
, "F10");
385 set_immutable_key(key
, RAWKEY_F11
, "F11");
386 set_immutable_key(key
, RAWKEY_F12
, "F12");
387 set_immutable_key(key
, RAWKEY_LAMIGA
, _(MSG_KEY_A
));
388 set_immutable_key(key
, RAWKEY_RAMIGA
, _(MSG_KEY_A
));
390 set_immutable_key(key
, RAWKEY_INSERT
, _(MSG_KEY_INSERT
));
391 set_immutable_key(key
, RAWKEY_HOME
, _(MSG_KEY_HOME
));
392 set_immutable_key(key
, RAWKEY_PAGEUP
, _(MSG_KEY_PAGEUP
));
393 set_immutable_key(key
, RAWKEY_DELETE
, _(MSG_KEY_DELETE
));
394 set_immutable_key(key
, RAWKEY_END
, _(MSG_KEY_END
));
395 set_immutable_key(key
, RAWKEY_PAGEDOWN
, _(MSG_KEY_PAGEDOWN
));
397 set_immutable_key(key
, RAWKEY_PRTSCREEN
, _(MSG_KEY_PRTSCREEN
));
398 set_immutable_key(key
, RAWKEY_SCRLOCK
, _(MSG_KEY_SCRLOCK
));
399 set_immutable_key(key
, RAWKEY_PAUSE
, _(MSG_KEY_PAUSE
));
401 set_immutable_key(key
, RAWKEY_KP_ENTER
, _(MSG_KEY_NUM_ENTER
));
402 set_immutable_key(key
, 127, _(MSG_KEY_CTRL
)); // Pseudo right Ctrl
407 AROS_UFH3S(void, change_qualifier_func
,
408 AROS_UFHA(struct Hook
*, h
, A0
),
409 AROS_UFHA(Object
*, obj
, A2
),
410 AROS_UFHA(ULONG
*, msg
, A1
))
414 struct KeyboardGroup_DATA
*data
= h
->h_Data
;
417 ULONG selectedkey
= msg
[0];
418 BOOL keydown
= msg
[1];
420 BOOL shift
= XGET(data
->keybutton
[96], MUIA_Selected
) | XGET(data
->keybutton
[97], MUIA_Selected
);
421 BOOL alt
= XGET(data
->keybutton
[100], MUIA_Selected
) | XGET(data
->keybutton
[101], MUIA_Selected
);
422 BOOL ctrl
= XGET(data
->keybutton
[99], MUIA_Selected
) | XGET(data
->keybutton
[127], MUIA_Selected
);
424 D(bug("[keyshow/change_qualifier_func] old: shift %d alt %d ctrl %d key %d trigger %d\n", shift
, alt
, ctrl
, selectedkey
, keydown
));
428 if ((selectedkey
== RAWKEY_LSHIFT
) || (selectedkey
== RAWKEY_RSHIFT
))
430 else if ((selectedkey
== RAWKEY_LALT
) || (selectedkey
== RAWKEY_RALT
))
432 else if ((selectedkey
== RAWKEY_LCONTROL
) || (selectedkey
== 127))
437 if ((selectedkey
== RAWKEY_LSHIFT
) || (selectedkey
== RAWKEY_RSHIFT
))
439 else if ((selectedkey
== RAWKEY_LALT
) || (selectedkey
== RAWKEY_RALT
))
441 else if ((selectedkey
== RAWKEY_LCONTROL
) || (selectedkey
== 127))
445 NNSET(data
->keybutton
[RAWKEY_LSHIFT
], MUIA_Selected
, shift
);
446 NNSET(data
->keybutton
[RAWKEY_RSHIFT
], MUIA_Selected
, shift
);
447 NNSET(data
->keybutton
[RAWKEY_LALT
], MUIA_Selected
, alt
);
448 NNSET(data
->keybutton
[RAWKEY_RALT
], MUIA_Selected
, alt
);
449 NNSET(data
->keybutton
[RAWKEY_LCONTROL
], MUIA_Selected
, ctrl
);
450 NNSET(data
->keybutton
[127], MUIA_Selected
, ctrl
);
452 D(bug("[keyshow/change_qualifier_func] new: shift %d alt %d ctrl %d key %d trigger %d\n", shift
, alt
, ctrl
, selectedkey
, keydown
));
454 if (shift
&& !alt
&& !ctrl
)
456 for (i
= 0; i
< 128; i
++)
458 if (!data
->key
[i
].immutable
)
459 SET(data
->keybutton
[i
], MUIA_Text_Contents
, data
->key
[i
].shift
);
462 else if (!shift
&& alt
&& !ctrl
)
464 for (i
= 0; i
< 128; i
++)
466 if (!data
->key
[i
].immutable
)
467 SET(data
->keybutton
[i
], MUIA_Text_Contents
, data
->key
[i
].alt
);
470 else if (!shift
&& !alt
&& ctrl
)
472 for (i
= 0; i
< 128; i
++)
474 if (!data
->key
[i
].immutable
)
475 SET(data
->keybutton
[i
], MUIA_Text_Contents
, data
->key
[i
].ctrl
);
478 else if (shift
&& alt
&& !ctrl
)
480 for (i
= 0; i
< 128; i
++)
482 if (!data
->key
[i
].immutable
)
483 SET(data
->keybutton
[i
], MUIA_Text_Contents
, data
->key
[i
].shift_alt
);
486 else if (!shift
&& alt
&& ctrl
)
488 for (i
= 0; i
< 128; i
++)
490 if (!data
->key
[i
].immutable
)
491 SET(data
->keybutton
[i
], MUIA_Text_Contents
, data
->key
[i
].ctrl_alt
);
494 else if (shift
&& !alt
&& ctrl
)
496 for (i
= 0; i
< 128; i
++)
498 if (!data
->key
[i
].immutable
)
499 SET(data
->keybutton
[i
], MUIA_Text_Contents
, data
->key
[i
].ctrl_shift
);
504 for (i
= 0; i
< 128; i
++)
506 if (!data
->key
[i
].immutable
)
507 SET(data
->keybutton
[i
], MUIA_Text_Contents
, data
->key
[i
].alone
);
515 Object
*KeyboardGroup__OM_NEW(Class
*CLASS
, Object
*self
, struct opSet
*message
)
519 struct Key
*key
= read_keymap();
520 ULONG kbtype
= MUIV_KeyboardGroup_Type_Amiga
;
522 struct TagItem
*tstate
= message
->ops_AttrList
;
523 struct TagItem
*tag
= NULL
;
525 while ((tag
= NextTagItem(&tstate
)) != NULL
)
529 case MUIA_KeyboardGroup_Type
:
530 kbtype
= tag
->ti_Data
;
535 for (i
= 0; i
< 128; i
++)
537 if ((i
< 96 || i
> 101 || i
== RAWKEY_CAPSLOCK
) && i
!= 127)
539 keybtn
[i
] = MUI_NewObject(MUIC_Text
,
541 MUIA_Font
, MUIV_Font_Tiny
,
542 MUIA_Text_Contents
, key
[i
].alone
,
543 MUIA_Text_PreParse
, "\33c",
549 keybtn
[i
] = MUI_NewObject(MUIC_Text
,
551 MUIA_Font
, MUIV_Font_Tiny
,
552 MUIA_Text_Contents
, key
[i
].alone
,
553 MUIA_Text_PreParse
, "\33c",
554 MUIA_InputMode
, MUIV_InputMode_Toggle
,
555 MUIA_Background
, MUII_ButtonBack
,
560 if (kbtype
== MUIV_KeyboardGroup_Type_PC105
)
562 self
= (Object
*) DoSuperNewTags
565 MUIA_Group_Horiz
, TRUE
,
569 //MUIA_Group_SameSize, TRUE,
570 KEY(RAWKEY_ESCAPE
), KEY(RAWKEY_F1
), KEY(RAWKEY_F2
), KEY(RAWKEY_F3
), KEY(RAWKEY_F4
), KEY(RAWKEY_F5
),
571 KEY(RAWKEY_F6
), KEY(RAWKEY_F7
), KEY(RAWKEY_F8
), KEY(RAWKEY_F9
), KEY(RAWKEY_F10
), KEY(RAWKEY_F11
), KEY(RAWKEY_F12
),
576 MUIA_Group_SameSize
, TRUE
,
577 KEY(0), KEY(1), KEY(2), KEY(3), KEY(4), KEY(5), KEY(6), KEY(7), KEY(8), KEY(9), KEY(10), KEY(11), KEY(12), KEY(13),
579 KEY(RAWKEY_BACKSPACE
),
584 MUIA_Group_SameSize
, TRUE
,
585 KEY(16), KEY(17), KEY(18), KEY(19), KEY(20), KEY(21), KEY(22), KEY(23), KEY(24), KEY(25), KEY(26), KEY(27),
590 KEY(RAWKEY_CAPSLOCK
),
592 MUIA_Group_SameSize
, TRUE
,
593 KEY(32), KEY(33), KEY(34), KEY(35), KEY(36), KEY(37), KEY(38), KEY(39), KEY(40), KEY(41), KEY(42), KEY(43),
600 MUIA_Group_SameSize
, TRUE
,
601 KEY(48), KEY(49), KEY(50), KEY(51), KEY(52), KEY(53), KEY(54), KEY(55), KEY(56), KEY(57), KEY(58),
607 MUIA_Group_SameSize
, TRUE
,
608 KEY(RAWKEY_LCONTROL
), KEY(RAWKEY_LAMIGA
), KEY(RAWKEY_LALT
),
612 MUIA_Group_SameSize
, TRUE
,
613 KEY(RAWKEY_RALT
), KEY(RAWKEY_RAMIGA
), KEY(RAWKEY_HELP
), KEY(127),
620 //MUIA_Group_SameSize, TRUE,
621 KEY(RAWKEY_PRTSCREEN
), KEY(RAWKEY_SCRLOCK
), KEY(RAWKEY_PAUSE
),
625 //MUIA_Group_SameSize, TRUE,
626 KEY(RAWKEY_INSERT
), KEY(RAWKEY_HOME
), KEY(RAWKEY_PAGEUP
),
627 KEY(RAWKEY_DELETE
), KEY(RAWKEY_END
), KEY(RAWKEY_PAGEDOWN
),
632 MUIA_Group_SameSize
, TRUE
,
636 KEY(RAWKEY_LEFT
), KEY(RAWKEY_DOWN
), KEY(RAWKEY_RIGHT
),
643 MUIA_Group_SameSize
, TRUE
,
644 // rawkey codes refer to a matrix position and can
645 // differ from their real meaning
646 KEY(RAWKEY_KP_LBRACKET
), KEY(RAWKEY_KP_RBRACKET
), KEY(RAWKEY_KP_DIVIDE
), KEY(RAWKEY_KP_MULTIPLY
),
647 KEY(RAWKEY_KP_7
), KEY(RAWKEY_KP_8
), KEY(RAWKEY_KP_9
), KEY(RAWKEY_KP_PLUS
),
648 KEY(RAWKEY_KP_4
), KEY(RAWKEY_KP_5
), KEY(RAWKEY_KP_6
), Child
, HVSpace
,
649 KEY(RAWKEY_KP_1
), KEY(RAWKEY_KP_2
), KEY(RAWKEY_KP_3
), KEY(RAWKEY_KP_ENTER
),
650 KEY(RAWKEY_KP_0
), Child
, HVSpace
, KEY(RAWKEY_KP_DECIMAL
), Child
, HVSpace
,
653 TAG_MORE
, (IPTR
)message
->ops_AttrList
656 else if (kbtype
== MUIV_KeyboardGroup_Type_PC104
)
658 self
= (Object
*) DoSuperNewTags
661 MUIA_Group_Horiz
, TRUE
,
665 //MUIA_Group_SameSize, TRUE,
666 KEY(RAWKEY_ESCAPE
), KEY(RAWKEY_F1
), KEY(RAWKEY_F2
), KEY(RAWKEY_F3
), KEY(RAWKEY_F4
), KEY(RAWKEY_F5
),
667 KEY(RAWKEY_F6
), KEY(RAWKEY_F7
), KEY(RAWKEY_F8
), KEY(RAWKEY_F9
), KEY(RAWKEY_F10
), KEY(RAWKEY_F11
), KEY(RAWKEY_F12
),
672 MUIA_Group_SameSize
, TRUE
,
673 KEY(0), KEY(1), KEY(2), KEY(3), KEY(4), KEY(5), KEY(6), KEY(7), KEY(8), KEY(9), KEY(10), KEY(11), KEY(12),
675 KEY(RAWKEY_BACKSPACE
),
680 MUIA_Group_SameSize
, TRUE
,
681 KEY(16), KEY(17), KEY(18), KEY(19), KEY(20), KEY(21), KEY(22), KEY(23), KEY(24), KEY(25), KEY(26), KEY(27),
683 KEY(13), // FIXME: is this correct?
686 KEY(RAWKEY_CAPSLOCK
),
688 MUIA_Group_SameSize
, TRUE
,
689 KEY(32), KEY(33), KEY(34), KEY(35), KEY(36), KEY(37), KEY(38), KEY(39), KEY(40), KEY(41), KEY(42),
696 MUIA_Group_SameSize
, TRUE
,
697 KEY(49), KEY(50), KEY(51), KEY(52), KEY(53), KEY(54), KEY(55), KEY(56), KEY(57), KEY(58),
703 MUIA_Group_SameSize
, TRUE
,
704 KEY(RAWKEY_LCONTROL
), KEY(RAWKEY_LAMIGA
), KEY(RAWKEY_LALT
),
708 MUIA_Group_SameSize
, TRUE
,
709 KEY(RAWKEY_RALT
), KEY(RAWKEY_RAMIGA
), KEY(RAWKEY_HELP
), KEY(127),
716 //MUIA_Group_SameSize, TRUE,
717 KEY(RAWKEY_PRTSCREEN
), KEY(RAWKEY_SCRLOCK
), KEY(RAWKEY_PAUSE
),
721 //MUIA_Group_SameSize, TRUE,
722 KEY(RAWKEY_INSERT
), KEY(RAWKEY_HOME
), KEY(RAWKEY_PAGEUP
),
723 KEY(RAWKEY_DELETE
), KEY(RAWKEY_END
), KEY(RAWKEY_PAGEDOWN
),
728 MUIA_Group_SameSize
, TRUE
,
732 KEY(RAWKEY_LEFT
), KEY(RAWKEY_DOWN
), KEY(RAWKEY_RIGHT
),
739 MUIA_Group_SameSize
, TRUE
,
740 // rawkey codes refer to a matrix position and can
741 // differ from their real meaning
742 KEY(RAWKEY_KP_LBRACKET
), KEY(RAWKEY_KP_RBRACKET
), KEY(RAWKEY_KP_DIVIDE
), KEY(RAWKEY_KP_MULTIPLY
),
743 KEY(RAWKEY_KP_7
), KEY(RAWKEY_KP_8
), KEY(RAWKEY_KP_9
), KEY(RAWKEY_KP_PLUS
),
744 KEY(RAWKEY_KP_4
), KEY(RAWKEY_KP_5
), KEY(RAWKEY_KP_6
), Child
, HVSpace
,
745 KEY(RAWKEY_KP_1
), KEY(RAWKEY_KP_2
), KEY(RAWKEY_KP_3
), KEY(RAWKEY_KP_ENTER
),
746 KEY(RAWKEY_KP_0
), Child
, HVSpace
, KEY(RAWKEY_KP_DECIMAL
), Child
, HVSpace
,
749 TAG_MORE
, (IPTR
)message
->ops_AttrList
754 self
= (Object
*) DoSuperNewTags
757 MUIA_Group_Horiz
, TRUE
,
761 //MUIA_Group_SameSize, TRUE,
762 KEY(RAWKEY_ESCAPE
), KEY(RAWKEY_F1
), KEY(RAWKEY_F2
), KEY(RAWKEY_F3
), KEY(RAWKEY_F4
), KEY(RAWKEY_F5
),
763 KEY(RAWKEY_F6
), KEY(RAWKEY_F7
), KEY(RAWKEY_F8
), KEY(RAWKEY_F9
), KEY(RAWKEY_F10
),
768 MUIA_Group_SameSize
, TRUE
,
769 KEY(0), KEY(1), KEY(2), KEY(3), KEY(4), KEY(5), KEY(6), KEY(7), KEY(8), KEY(9), KEY(10), KEY(11), KEY(12), KEY(13),
771 KEY(RAWKEY_BACKSPACE
),
776 MUIA_Group_SameSize
, TRUE
,
777 KEY(16), KEY(17), KEY(18), KEY(19), KEY(20), KEY(21), KEY(22), KEY(23), KEY(24), KEY(25), KEY(26), KEY(27),
782 KEY(RAWKEY_LCONTROL
),
783 KEY(RAWKEY_CAPSLOCK
),
785 MUIA_Group_SameSize
, TRUE
,
786 KEY(32), KEY(33), KEY(34), KEY(35), KEY(36), KEY(37), KEY(38), KEY(39), KEY(40), KEY(41), KEY(42), KEY(43),
793 MUIA_Group_SameSize
, TRUE
,
794 KEY(48), KEY(49), KEY(50), KEY(51), KEY(52), KEY(53), KEY(54), KEY(55), KEY(56), KEY(57), KEY(58),
800 MUIA_Group_SameSize
, TRUE
,
801 KEY(RAWKEY_LALT
), KEY(RAWKEY_LAMIGA
),
805 MUIA_Group_SameSize
, TRUE
,
806 KEY(RAWKEY_RAMIGA
), KEY(RAWKEY_RALT
),
813 //MUIA_Group_SameSize, TRUE,
814 KEY(RAWKEY_DELETE
), KEY(RAWKEY_HELP
),
819 MUIA_Group_SameSize
, TRUE
,
823 KEY(RAWKEY_LEFT
), KEY(RAWKEY_DOWN
), KEY(RAWKEY_RIGHT
),
830 MUIA_Group_SameSize
, TRUE
,
831 KEY(RAWKEY_KP_LBRACKET
), KEY(RAWKEY_KP_RBRACKET
), KEY(RAWKEY_KP_DIVIDE
), KEY(RAWKEY_KP_MULTIPLY
),
832 KEY(RAWKEY_KP_7
), KEY(RAWKEY_KP_8
), KEY(RAWKEY_KP_9
), KEY(RAWKEY_KP_MINUS
),
833 KEY(RAWKEY_KP_4
), KEY(RAWKEY_KP_5
), KEY(RAWKEY_KP_6
), KEY(RAWKEY_KP_PLUS
),
834 KEY(RAWKEY_KP_1
), KEY(RAWKEY_KP_2
), KEY(RAWKEY_KP_3
), KEY(RAWKEY_KP_ENTER
),
835 KEY(RAWKEY_KP_0
), Child
, HVSpace
, KEY(RAWKEY_KP_DECIMAL
), Child
, HVSpace
,
838 TAG_MORE
, (IPTR
)message
->ops_AttrList
844 struct KeyboardGroup_DATA
*data
= INST_DATA(CLASS
, self
);
847 for (i
= 0; i
< 128; i
++)
849 data
->keybutton
[i
] = keybtn
[i
];
852 data
->change_qualifier_hook
.h_Entry
= (HOOKFUNC
)change_qualifier_func
;
853 data
->change_qualifier_hook
.h_Data
= data
;
855 // add notifications to the qualifier keys
856 for (i
= 96; i
< 104; i
++)
860 data
->keybutton
[i
], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
861 self
, 4, MUIM_CallHook
, &data
->change_qualifier_hook
, i
, MUIV_TriggerValue
866 data
->keybutton
[127], MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
867 self
, 4, MUIM_CallHook
, &data
->change_qualifier_hook
, 127, MUIV_TriggerValue
874 IPTR
KeyboardGroup__OM_DISPOSE(Class
*CLASS
, Object
*self
, Msg message
)
876 struct KeyboardGroup_DATA
*data
= INST_DATA(CLASS
, self
);
880 return DoSuperMethodA(CLASS
, self
, message
);
884 IPTR
KeyboardGroup__MUIM_Setup(Class
*CLASS
, Object
*obj
, struct MUIP_HandleInput
*msg
)
886 if (!DoSuperMethodA(CLASS
, obj
, msg
))
889 MUI_RequestIDCMP(obj
, IDCMP_RAWKEY
);
895 IPTR
KeyboardGroup__MUIM_Cleanup(Class
*CLASS
, Object
*obj
, struct MUIP_HandleInput
*msg
)
897 MUI_RejectIDCMP(obj
,IDCMP_MOUSEBUTTONS
|IDCMP_RAWKEY
);
898 return DoSuperMethodA(CLASS
, obj
, msg
);
902 IPTR
KeyboardGroup__MUIM_HandleInput(Class
*CLASS
, Object
*obj
, struct MUIP_HandleInput
*msg
)
904 struct KeyboardGroup_DATA
*data
= INST_DATA(CLASS
, obj
);
908 switch (msg
->imsg
->Class
)
912 D(bug("[KeyShow/HandleInput] Rawkey %d\n", msg
->imsg
->Code
));
913 if (msg
->imsg
->Code
> 95 && msg
->imsg
->Code
< 102 && msg
->imsg
->Code
!= RAWKEY_CAPSLOCK
) // Qualifier key
915 Object
*btn
= data
->keybutton
[msg
->imsg
->Code
];
918 SET(btn
, MUIA_Selected
, XGET(btn
, MUIA_Selected
) ? FALSE
: TRUE
);
919 //MUI_Redraw(obj, MADF_DRAWUPDATE);
932 KeyboardGroup
, NULL
, MUIC_Group
, NULL
,
933 OM_NEW
, struct opSet
*,
935 MUIM_Setup
, struct MUIP_HandleInput
*,
936 MUIM_Cleanup
, struct MUIP_HandleInput
*,
937 MUIM_HandleInput
, struct MUIP_HandleInput
*