From ef74c8ff6d3c67c3faaffa03f97d4f8309ffe3d1 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Thu, 12 Jan 2017 01:24:33 +0800 Subject: [PATCH] Keyrah: FN+F3..F6 - mouse/joystick direct emulation selection. (F17..F20 - on other keyboards). --- keycodes.h | 28 ++++++++++++++-------------- user_io.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/keycodes.h b/keycodes.h index fca43ff..4abd676 100644 --- a/keycodes.h +++ b/keycodes.h @@ -21,8 +21,8 @@ #define EXT 0x1000 // extended PS/2 keycode // amiga unmapped: -// 0x5a KP-( -// 0x5b KP-) +// 0x5a KP-( (mapped on Keyrah) +// 0x5b KP-) (mapped on Keyrah) // codes >= 0x69 are for OSD only and are not sent to the amiga itself // keycode translation table @@ -135,10 +135,10 @@ const unsigned short usb2ami[] = { 0x5b, // 69: KP ) MISS, // 6a: F15 MISS, // 6b: F16 - MISS, // 6c: F17 - MISS, // 6d: F18 - MISS, // 6e: F19 - MISS // 6f: F20 + NUM_LOCK_TOGGLE | 1, // 6c: F17 + NUM_LOCK_TOGGLE | 2, // 6d: F18 + NUM_LOCK_TOGGLE | 3, // 6e: F19 + NUM_LOCK_TOGGLE | 4 // 6f: F20 }; // unmapped atari keys: @@ -255,10 +255,10 @@ const unsigned short usb2atari[] = { MISS, // 69: F14 MISS, // 6a: F15 MISS, // 6b: F16 - MISS, // 6c: F17 - MISS, // 6d: F18 - MISS, // 6e: F19 - MISS // 6f: F20 + NUM_LOCK_TOGGLE | 1, // 6c: F17 + NUM_LOCK_TOGGLE | 2, // 6d: F18 + NUM_LOCK_TOGGLE | 3, // 6e: F19 + NUM_LOCK_TOGGLE | 4 // 6f: F20 }; // keycode translation table for ps2 emulation @@ -371,10 +371,10 @@ const unsigned short usb2ps2[] = { 0x7e, // 69: Scroll Lock 0x18, // 6a: F15 0x20, // 6b: F16 - 0x28, // 6c: F17 - 0x30, // 6d: F18 - 0x38, // 6e: F19 - 0x40 // 6f: F20 + NUM_LOCK_TOGGLE | 1, // 6c: F17 + NUM_LOCK_TOGGLE | 2, // 6d: F18 + NUM_LOCK_TOGGLE | 3, // 6e: F19 + NUM_LOCK_TOGGLE | 4 // 6f: F20 }; // Archimedes unmapped keys diff --git a/user_io.c b/user_io.c index b1df05e..baae7bd 100644 --- a/user_io.c +++ b/user_io.c @@ -1549,6 +1549,11 @@ static char kr_fn_table[] = 0x3a, 0x44, // f11 0x3b, 0x45, // f12 + 0x3c, 0x6c, // EMU_MOUSE + 0x3d, 0x6d, // EMU_JOY0 + 0x3e, 0x6e, // EMU_JOY1 + 0x3f, 0x6f, // EMU_NONE + //Emulate keypad for A600 0x1E, 0x59, //KP1 0x1F, 0x5A, //KP2 @@ -1899,7 +1904,29 @@ void user_io_kbd(unsigned char m, unsigned char *k, uint8_t priority, unsigned s if(emu_mode == EMU_MOUSE) emu_timer = GetTimer(EMU_MOUSE_FREQ); - emu_mode = (emu_mode+1)&3; + switch(code ^ NUM_LOCK_TOGGLE) + { + case 1: + emu_mode = EMU_MOUSE; + break; + + case 2: + emu_mode = EMU_JOY0; + break; + + case 3: + emu_mode = EMU_JOY1; + break; + + case 4: + emu_mode = EMU_NONE; + break; + + default: + emu_mode = (emu_mode+1)&3; + break; + } + if(emu_mode == EMU_MOUSE || emu_mode == EMU_JOY0) set_kbd_led(HID_LED_NUM_LOCK, true); else set_kbd_led(HID_LED_NUM_LOCK, false);