update adb keycodes with F15-F20, use proper value for F keys, eliminate Mac OS arrow key mapping.

This commit is contained in:
Kelvin Sherlock 2019-02-04 20:43:12 -05:00
parent 82229498b4
commit 35993914f9
2 changed files with 69 additions and 54 deletions

View File

@ -10,6 +10,9 @@
#include "adb.h"
#include "glog.h"
#include "adb_keycodes.h"
int g_fullscreen = 0;
int g_grabmouse = 0;
@ -1655,34 +1658,48 @@ void adb_physical_key_update(int a2code, int is_up) {
/* Now check for special keys (function keys, etc) */
ascii_and_type = a2_key_to_ascii[a2code][1];
special = 0;
if((ascii_and_type & 0xf000) == 0x8000) {
/* special function key */
/* special FKeys? */
if (ascii_and_type & 0x1000) {
special = ascii_and_type & 0xff;
switch(special) {
case 0x01: /* F1 - remap to cmd */
a2code = 0x37;
switch (special) {
case kVK_F1:
/* F1 - remap to cmd */
a2code = kVK_Command;
special = 0;
break;
case 0x02: /* F2 - remap to option */
a2code = 0x3a;
case kVK_F2:
/* F2 - remap to option */
a2code = kVK_Option;
special = 0;
break;
case 0x0c: /* F12 - remap to reset */
a2code = 0x7f;
case kVK_F12:
/* F12 - remap to reset */
a2code = kVK_Reset;
special = 0;
break;
case kVK_F3:
case kVK_F4:
case kVK_F5:
case kVK_F6:
case kVK_F7:
case kVK_F8:
case kVK_F9:
case kVK_F10:
case kVK_F11:
break;
default:
break;
special = 0;
}
}
/* CUA clipboard paste - for those that remember ctrl-insert/shift-insert */
if(is_up == 0 && a2code == 0x72 && SHIFT_DOWN) {
if(is_up == 0 && a2code == kVK_Insert && SHIFT_DOWN) {
clipboard_paste();
}
/* Only process reset requests here */
if(is_up == 0 && a2code == 0x7f && CTRL_DOWN) {
if(is_up == 0 && a2code == kVK_Reset && CTRL_DOWN) {
/* Reset pressed! */
glogf("Reset pressed since CTRL_DOWN: %d", CTRL_DOWN);
do_reset();
@ -1691,10 +1708,10 @@ void adb_physical_key_update(int a2code, int is_up) {
if(special && !is_up) {
switch(special) {
case 0x03: /* F3 - screenshot */
case kVK_F3: /* F3 - screenshot */
g_screenshot_requested = 1;
break;
case 0x04: /* F4 - emulator config panel */
case kVK_F4: /* F4 - emulator config panel */
if (CMD_DOWN) {
glog("Alt-F4 Quit!");
iwm_shut();
@ -1705,7 +1722,7 @@ void adb_physical_key_update(int a2code, int is_up) {
cfg_toggle_config_panel();
}
break;
case 0x05: /* F5 - emulator clipboard paste */
case kVK_F5: /* F5 - emulator clipboard paste */
if (SHIFT_DOWN) {
g_grabmouse = !g_grabmouse;
#ifdef HAVE_SDL
@ -1717,18 +1734,18 @@ void adb_physical_key_update(int a2code, int is_up) {
clipboard_paste();
}
break;
case 0x06: /* F6 - emulator speed */
case kVK_F6: /* F6 - emulator speed */
if(SHIFT_DOWN) {
halt2_printf("Shift-F6 pressed\n");
} else {
adb_increment_speed();
}
break;
case 0x07: /* F7 - fast disk emul */
case kVK_F7: /* F7 - fast disk emul */
g_fast_disk_emul = !g_fast_disk_emul;
glogf("g_fast_disk_emul is now %d", g_fast_disk_emul);
break;
case 0x08: /* F8 - warp pointer */
case kVK_F8: /* F8 - warp pointer */
g_warp_pointer = !g_warp_pointer;
if(g_hide_pointer != g_warp_pointer) {
g_hide_pointer = g_warp_pointer;
@ -1736,7 +1753,7 @@ void adb_physical_key_update(int a2code, int is_up) {
}
glogf("g_warp_pointer is now %d", g_warp_pointer);
break;
case 0x09: /* F9 - swap paddles */
case kVK_F9: /* F9 - swap paddles */
if(SHIFT_DOWN) {
g_swap_paddles = !g_swap_paddles;
glogf("Swap paddles is now: %d", g_swap_paddles);
@ -1745,7 +1762,7 @@ void adb_physical_key_update(int a2code, int is_up) {
glogf("Invert paddles is now: %d", g_invert_paddles);
}
break;
case 0x0a: /* F10 - change a2vid paletter */
case kVK_F10: /* F10 - change a2vid paletter */
if (SHIFT_DOWN) {
#ifdef TOGGLE_STATUS
extern void x_toggle_status_lines();
@ -1758,7 +1775,7 @@ void adb_physical_key_update(int a2code, int is_up) {
change_a2vid_palette((g_a2vid_palette + 1) & 0xf);
}
break;
case 0x0b: /* F11 - full screen */
case kVK_F11: /* F11 - full screen */
g_fullscreen = !g_fullscreen;
x_full_screen(g_fullscreen);
break;
@ -1780,10 +1797,10 @@ void adb_physical_key_update(int a2code, int is_up) {
/* keypress pass on further, except for cmd/opt */
if(ascii == 0x30) {
/* remap '0' to cmd */
a2code = 0x37;
a2code = kVK_Command;
} else if(ascii == 0x2e || ascii == 0x2c) {
/* remap '.' and ',' to option */
a2code = 0x3a;
a2code = kVK_Option;
} else {
/* Just ignore it in this mode */
return;

View File

@ -79,9 +79,9 @@ const int a2_key_to_ascii[][4] = {
{ 0x3c, 0x15, 0x15, -1 }, /* right */
{ 0x3d, 0x0a, 0x0a, -1 }, /* down */
{ 0x3e, 0x0b, 0x0b, -1 }, /* up arrow */
{ 0x3f, -1, -1, -1 },
{ 0x3f, 0x103f, 0x103f, -1 }, /* function key */
{ 0x40, -1, -1, -1 },
{ 0x40, 0x1040, 0x1040, -1 }, /* F17 */
{ 0x41, 0x102e, 0x102e, -1 }, /* keypad . */
{ 0x42, -1, -1, -1 },
{ 0x43, 0x102a, 0x102a, -1 }, /* keypad * */
@ -90,16 +90,16 @@ const int a2_key_to_ascii[][4] = {
{ 0x46, -1, -1, -1 },
{ 0x47, 0x1018, 0x1018, -1 }, /* keypad Clear */
{ 0x48, -1, -1, -1 },
{ 0x49, -1, -1, -1 },
{ 0x4a, -1, -1, -1 },
{ 0x48, 0x1048, 0x1048, -1 }, /* volume up */
{ 0x49, 0x1049, 0x1049, -1 }, /* volume down */
{ 0x4a, 0x104a, 0x104a, -1 }, /* mute */
{ 0x4b, 0x102f, 0x102f, -1 }, /* keypad / */
{ 0x4c, 0x100d, 0x100d, -1 }, /* keypad enter */
{ 0x4d, -1, -1, -1 },
{ 0x4e, 0x102d, 0x102d, -1 }, /* keypad - */
{ 0x4f, -1, -1, -1 },
{ 0x4f, 0x104f, 0x104f, -1 }, /* F18 */
{ 0x50, -1, -1, -1 },
{ 0x50, 0x1050, 0x1050, -1 }, /* F19 */
{ 0x51, 0x103d, 0x103d, -1 }, /* keypad = */
{ 0x52, 0x1030, 0x1030, -1 }, /* keypad 0 */
{ 0x53, 0x1031, 0x1031, -1 }, /* keypad 1 */
@ -110,48 +110,46 @@ const int a2_key_to_ascii[][4] = {
{ 0x58, 0x1036, 0x1036, -1 }, /* keypad 6 */
{ 0x59, 0x1037, 0x1037, -1 }, /* keypad 7 */
{ 0x5a, 'a', 'A', 0x01 }, /* probably not necessary */
{ 0x5a, 0x105a, 0x105a, -1 }, /* F20 */
{ 0x5b, 0x1038, 0x1038, -1 }, /* keypad 8 */
{ 0x5c, 0x1039, 0x1039, -1 }, /* keypad 9 */
{ 0x5d, -1, -1, -1 },
{ 0x5e, -1, -1, -1 },
{ 0x5f, -1, -1, -1 },
{ 0x60, 0x8005, 0x1060, -1 }, /* F5 */
{ 0x61, 0x8006, 0x1061, -1 }, /* F6 */
{ 0x62, 0x8007, 0x1062, -1 }, /* F7 */
{ 0x63, 0x8003, 0x1063, -1 }, /* F3 */
{ 0x64, 0x8008, 0x1064, -1 }, /* F8 */
{ 0x65, 0x8009, 0x1065, -1 }, /* F9 */
{ 0x60, 0x1060, 0x1060, -1 }, /* F5 */
{ 0x61, 0x1061, 0x1061, -1 }, /* F6 */
{ 0x62, 0x1062, 0x1062, -1 }, /* F7 */
{ 0x63, 0x1063, 0x1063, -1 }, /* F3 */
{ 0x64, 0x1064, 0x1064, -1 }, /* F8 */
{ 0x65, 0x1065, 0x1065, -1 }, /* F9 */
{ 0x66, -1, -1, -1 },
{ 0x67, 0x800b, 0x1067, -1 }, /* F11 */
{ 0x67, 0x1067, 0x1067, -1 }, /* F11 */
{ 0x68, -1, -1, -1 },
// { 0x69, 0x800d, 0x1069, -1 }, /* F13 */
// OG remap F13 to reset
{ 0x69, 0x800c, 0x1069, -1 }, /* F13 */
{ 0x6a, -1, -1, -1 },
{ 0x6b, 0x800e, 0x106b, -1 }, /* F14 */
{ 0x69, 0x1069, 0x1069, -1 }, /* F13 */
{ 0x6a, 0x106a, 0x106a, -1 }, /* F16 */
{ 0x6b, 0x106b, 0x106b, -1 }, /* F14 */
{ 0x6c, -1, -1, -1 },
{ 0x6d, 0x800a, 0x106d, -1 }, /* F10 */
{ 0x6e, 0x4000, 0x4000, -1 }, /* windows key alias to option */
{ 0x6f, 0x800c, 0x106f, -1 }, /* F12 */
{ 0x6d, 0x106d, 0x106d, -1 }, /* F10 */
{ 0x6e, -1, -1, -1 },
{ 0x6f, 0x106f, 0x106f, -1 }, /* F12 */
{ 0x70, -1, -1, -1 },
{ 0x71, 0x800f, 0x1071, -1 }, /* F15 */
{ 0x71, 0x1071, 0x1071, -1 }, /* F15 */
{ 0x72, 0x1072, 0x1072, -1 }, /* Help, insert */
{ 0x73, 0x1073, 0x1073, -1 }, /* Home */
{ 0x74, 0x1074, 0x1074, -1 }, /* Page up */
{ 0x75, 0x1075, 0x1075, -1 }, /* keypad delete */
{ 0x76, 0x8004, 0x1076, -1 }, /* F4 */
{ 0x76, 0x1076, 0x1076, -1 }, /* F4 */
{ 0x77, 0x1077, 0x1077, -1 }, /* keypad end */
{ 0x78, 0x8002, 0x1078, -1 }, /* F2 */
{ 0x78, 0x1078, 0x1078, -1 }, /* F2 */
{ 0x79, 0x1079, 0x1079, -1 }, /* keypad page down */
{ 0x7a, 0x8001, 0x107a, -1 }, /* F1 */
{ 0x7b, 0x08, 0x08, -1 }, /* left */ /* remapped to 0x3b */
{ 0x7c, 0x15, 0x15, -1 }, /* right */ /* remapped to 0x3c */
{ 0x7d, 0x0a, 0x0a, -1 }, /* down */ /* remapped to 0x3d */
{ 0x7e, 0x0b, 0x0b, -1 }, /* up arrow */ /* remapped to 0x3e */
{ 0x7a, 0x107a, 0x107a, -1 }, /* F1 */
{ 0x7b, 0x0100, 0x0100, -1 }, /* right shift */
{ 0x7c, 0x4000, 0x4000, -1 }, /* right option */
{ 0x7d, 0x0200, 0x0200, -1 }, /* right control */
{ 0x7e, -1, -1, -1 },
{ 0x7f, -1, -1, -1 }, /* Reset */
};