Bug in Mac OS X keyboard code?
Michael Faerber

Hi! I've tested a program of mine on a Mac now, and it seems that Allegro detects keypresses on KEY_MINUS_PAD as KEY_PLUS_PAD keypresses.

Going through the source for Mac OS X, I found this (in keybd.m):

1/* Mac keycode to Allegro scancode conversion table */
2static const int mac_to_scancode[128] = {
3/* 0x00 */ KEY_A, KEY_S, KEY_D, KEY_F,
4/* 0x04 */ KEY_H, KEY_G, KEY_Z, KEY_X,
5/* 0x08 */ KEY_C, KEY_V, 0, KEY_B,
6/* 0x0c */ KEY_Q, KEY_W, KEY_E, KEY_R,
7/* 0x10 */ KEY_Y, KEY_T, KEY_1, KEY_2,
8/* 0x14 */ KEY_3, KEY_4, KEY_6, KEY_5,
9/* 0x18 */ KEY_EQUALS, KEY_9, KEY_7, KEY_MINUS,
10/* 0x1c */ KEY_8, KEY_0, KEY_CLOSEBRACE, KEY_O,
11/* 0x20 */ KEY_U, KEY_OPENBRACE, KEY_I, KEY_P,
12/* 0x24 */ KEY_ENTER, KEY_L, KEY_J, KEY_QUOTE,
13/* 0x28 */ KEY_K, KEY_SEMICOLON, KEY_BACKSLASH, KEY_COMMA,
14/* 0x2c */ KEY_SLASH, KEY_N, KEY_M, KEY_STOP,
15/* 0x30 */ KEY_TAB, KEY_SPACE, KEY_BACKQUOTE, KEY_BACKSPACE,
16/* 0x34 */ KEY_ENTER, KEY_ESC, 0, KEY_COMMAND,
17/* 0x38 */ KEY_LSHIFT, KEY_CAPSLOCK, KEY_ALT, KEY_LEFT,
18/* 0x3c */ KEY_RIGHT, KEY_DOWN, KEY_UP, 0,
19/* 0x40 */ 0, KEY_STOP, 0, KEY_ASTERISK,
20/* 0x44 */ 0, KEY_PLUS_PAD, 0, KEY_NUMLOCK,
21/* 0x48 */ 0, 0, 0, KEY_SLASH_PAD,
22/* 0x4c */ KEY_ENTER_PAD, 0, KEY_PLUS_PAD, 0,
23/* 0x50 */ 0, KEY_EQUALS_PAD, KEY_0_PAD, KEY_1_PAD,
24/* 0x54 */ KEY_2_PAD, KEY_3_PAD, KEY_4_PAD, KEY_5_PAD,
25/* 0x58 */ KEY_6_PAD, KEY_7_PAD, 0, KEY_8_PAD,
26/* 0x5c */ KEY_9_PAD, 0, 0, 0,
27/* 0x60 */ KEY_F5, KEY_F6, KEY_F7, KEY_F3,
28/* 0x64 */ KEY_F8, KEY_F9, 0, KEY_F11,
29/* 0x68 */ 0, KEY_PRTSCR, 0, KEY_SCRLOCK,
30/* 0x6c */ 0, KEY_F10, 0, KEY_F12,
31/* 0x70 */ 0, KEY_PAUSE, KEY_INSERT, KEY_HOME,
32/* 0x74 */ KEY_PGUP, KEY_DEL, KEY_F4, KEY_END,
33/* 0x78 */ KEY_F2, KEY_PGDN, KEY_F1, KEY_LEFT,
34/* 0x7c */ KEY_RIGHT, KEY_DOWN, KEY_UP, 0
35};

I found out that KEY_PLUS_PAD occured twice in the code, while KEY_MINUS_PAD wasn't existant at all.

Could somebody have a look and see if it's fixed already, or could you make a fix yourself?

Evert

Which of the two needs to be changed?

Peter Hull

It's actually rather hard to find an official list on apple.com; I had to resort to the information in this thread.

It's the second one that's wrong, 0x45 is +, 0x4e is -

Diff attached; could you test it?

Pete

Michael Faerber

I can't because I don't have access to a Mac at the moment.

Thread #582398. Printed from Allegro.cc