Keyboard code refactoring.
This commit is contained in:
@@ -79,7 +79,6 @@
|
||||
<ClInclude Include="ikbd.h" />
|
||||
<ClInclude Include="ini_parser.h" />
|
||||
<ClInclude Include="input.h" />
|
||||
<ClInclude Include="keycodes.h" />
|
||||
<ClInclude Include="logo.h" />
|
||||
<ClInclude Include="menu.h" />
|
||||
<ClInclude Include="mist_cfg.h" />
|
||||
|
||||
@@ -124,9 +124,6 @@
|
||||
<ClInclude Include="input.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="keycodes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="logo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
28
input.h
28
input.h
@@ -2,11 +2,33 @@
|
||||
#ifndef EVINPUT_H
|
||||
#define EVINPUT_H
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#define HID_LED_NUM_LOCK 1
|
||||
#define HID_LED_CAPS_LOCK 2
|
||||
#define HID_LED_SCROLL_LOCK 4
|
||||
#define HID_LED_MASK 7
|
||||
|
||||
#define NONE 0xFF
|
||||
#define LCTRL 0x000100
|
||||
#define LSHIFT 0x000200
|
||||
#define LALT 0x000400
|
||||
#define LGUI 0x000800
|
||||
#define RCTRL 0x001000
|
||||
#define RSHIFT 0x002000
|
||||
#define RALT 0x004000
|
||||
#define RGUI 0x008000
|
||||
#define MODMASK 0x00FF00
|
||||
|
||||
#define OSD 0x010000 // to be used by OSD, not the core itself
|
||||
#define OSD_OPEN 0x020000 // OSD key not forwarded to core, but queued in arm controller
|
||||
#define CAPS_TOGGLE 0x040000 // caps lock toggle behaviour
|
||||
#define EXT 0x080000
|
||||
#define EMU_SWITCH_1 0x100000
|
||||
#define EMU_SWITCH_2 0x200000
|
||||
|
||||
#define UPSTROKE 0x400000
|
||||
|
||||
void set_kbdled(int mask, int state);
|
||||
int get_kbdled(int mask);
|
||||
int toggle_kbdled(int mask);
|
||||
@@ -22,4 +44,10 @@ void finish_map_setting(int dismiss);
|
||||
uint16_t get_map_vid();
|
||||
uint16_t get_map_pid();
|
||||
|
||||
uint32_t get_key_mod();
|
||||
uint32_t get_ps2_code(uint16_t key);
|
||||
uint32_t get_amiga_code(uint16_t key);
|
||||
uint32_t get_atari_code(uint16_t key);
|
||||
uint32_t get_archie_code(uint16_t key);
|
||||
|
||||
#endif
|
||||
|
||||
509
keycodes.h
509
keycodes.h
@@ -1,509 +0,0 @@
|
||||
// http://wiki.amigaos.net/index.php/Keymap_Library
|
||||
// http://www.win.tue.nl/~aeb/linux/kbd/scancodes-14.html
|
||||
|
||||
#include "osd.h"
|
||||
|
||||
#ifndef KEYCODES_H
|
||||
#define KEYCODES_H
|
||||
|
||||
#define MISS 0xff
|
||||
#define KEYCODE_MAX (0x6f)
|
||||
|
||||
// The original minimig had the keyboard connected to the FPGA. Thus all key events (even for OSD)
|
||||
// came from the FPGA core. The MIST has the keyboard attached to the arm controller. To be compatible
|
||||
// with the minimig core all keys (incl. OSD!) are forwarded to the FPGA and the OSD keys are returned.
|
||||
// These keys are tagged with the "OSD" flag
|
||||
// The atari/mist core does not forwards keys through the FPGA but queues them inside the arm controller.
|
||||
// Keys flagged with "OSD_OPEN" are used to open the OSD in non-minimig. They can have a keycode which
|
||||
// will be sent into the core
|
||||
|
||||
#define OSD 0x0100 // to be used by OSD, not the core itself
|
||||
#define OSD_OPEN 0x0200 // OSD key not forwarded to core, but queued in arm controller
|
||||
#define CAPS_LOCK_TOGGLE 0x0400 // caps lock toggle behaviour
|
||||
#define NUM_LOCK_TOGGLE 0x0800
|
||||
#define EXT 0x1000 // extended PS/2 keycode
|
||||
|
||||
// amiga unmapped:
|
||||
// 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
|
||||
const unsigned short usb2ami[] = {
|
||||
MISS, // 00: NoEvent
|
||||
MISS, // 01: Overrun Error
|
||||
MISS, // 02: POST fail
|
||||
MISS, // 03: ErrorUndefined
|
||||
0x20, // 04: a
|
||||
0x35, // 05: b
|
||||
0x33, // 06: c
|
||||
0x22, // 07: d
|
||||
0x12, // 08: e
|
||||
0x23, // 09: f
|
||||
0x24, // 0a: g
|
||||
0x25, // 0b: h
|
||||
0x17, // 0c: i
|
||||
0x26, // 0d: j
|
||||
0x27, // 0e: k
|
||||
0x28, // 0f: l
|
||||
0x37, // 10: m
|
||||
0x36, // 11: n
|
||||
0x18, // 12: o
|
||||
0x19, // 13: p
|
||||
0x10, // 14: q
|
||||
0x13, // 15: r
|
||||
0x21, // 16: s
|
||||
0x14, // 17: t
|
||||
0x16, // 18: u
|
||||
0x34, // 19: v
|
||||
0x11, // 1a: w
|
||||
0x32, // 1b: x
|
||||
0x15, // 1c: y
|
||||
0x31, // 1d: z
|
||||
0x01, // 1e: 1
|
||||
0x02, // 1f: 2
|
||||
0x03, // 20: 3
|
||||
0x04, // 21: 4
|
||||
0x05, // 22: 5
|
||||
0x06, // 23: 6
|
||||
0x07, // 24: 7
|
||||
0x08, // 25: 8
|
||||
0x09, // 26: 9
|
||||
0x0a, // 27: 0
|
||||
0x44, // 28: Return
|
||||
0x45, // 29: Escape
|
||||
0x41, // 2a: Backspace
|
||||
0x42, // 2b: Tab
|
||||
0x40, // 2c: Space
|
||||
0x0b, // 2d: -
|
||||
0x0c, // 2e: =
|
||||
0x1a, // 2f: [
|
||||
0x1b, // 30: ]
|
||||
0x0d, // 31: backslash (only on us keyboards)
|
||||
0x2b, // 32: Europe 1 (only on international keyboards)
|
||||
0x29, // 33: ;
|
||||
0x2a, // 34: '
|
||||
0x00, // 35: `
|
||||
0x38, // 36: ,
|
||||
0x39, // 37: .
|
||||
0x3a, // 38: /
|
||||
0x62 | CAPS_LOCK_TOGGLE, // 39: Caps Lock
|
||||
0x50, // 3a: F1
|
||||
0x51, // 3b: F2
|
||||
0x52, // 3c: F3
|
||||
0x53, // 3d: F4
|
||||
0x54, // 3e: F5
|
||||
0x55, // 3f: F6
|
||||
0x56, // 40: F7
|
||||
0x57, // 41: F8
|
||||
0x58, // 42: F9
|
||||
0x59, // 43: F10
|
||||
0x5f, // 44: F11
|
||||
OSD_OPEN, // 45: F12 (OSD)
|
||||
0x6e | OSD, // 46: Print Screen (OSD)
|
||||
NUM_LOCK_TOGGLE, // 47: Scroll Lock (OSD)
|
||||
0x6f | OSD, // 48: Pause
|
||||
0x0d, // 49: backslash to avoid panic in Germany ;)
|
||||
0x6a, // 4a: Home
|
||||
0x6c | OSD, // 4b: Page Up (OSD)
|
||||
0x46, // 4c: Delete
|
||||
MISS, // 4d: End
|
||||
0x6d | OSD, // 4e: Page Down (OSD)
|
||||
0x4e, // 4f: Right Arrow
|
||||
0x4f, // 50: Left Arrow
|
||||
0x4d, // 51: Down Arrow
|
||||
0x4c, // 52: Up Arrow
|
||||
NUM_LOCK_TOGGLE, // 53: Num Lock
|
||||
0x5c, // 54: KP /
|
||||
0x5d, // 55: KP *
|
||||
0x4a, // 56: KP -
|
||||
0x5e, // 57: KP +
|
||||
0x43, // 58: KP Enter
|
||||
0x1d, // 59: KP 1
|
||||
0x1e, // 5a: KP 2
|
||||
0x1f, // 5b: KP 3
|
||||
0x2d, // 5c: KP 4
|
||||
0x2e, // 5d: KP 5
|
||||
0x2f, // 5e: KP 6
|
||||
0x3d, // 5f: KP 7
|
||||
0x3e, // 60: KP 8
|
||||
0x3f, // 61: KP 9
|
||||
0x0f, // 62: KP 0
|
||||
0x3c, // 63: KP .
|
||||
0x30, // 64: Europe 2
|
||||
0x69 | OSD, // 65: App
|
||||
MISS, // 66: Power
|
||||
MISS, // 67: KP =
|
||||
0x5a, // 68: KP (
|
||||
0x5b, // 69: KP )
|
||||
MISS, // 6a: F15
|
||||
0x5f, // 6b: help (for keyrah)
|
||||
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:
|
||||
// 0x63 KP (
|
||||
// 0x64 KP )
|
||||
|
||||
// keycode translation table for atari
|
||||
const unsigned short usb2atari[] = {
|
||||
MISS, // 00: NoEvent
|
||||
MISS, // 01: Overrun Error
|
||||
MISS, // 02: POST fail
|
||||
MISS, // 03: ErrorUndefined
|
||||
0x1e, // 04: a
|
||||
0x30, // 05: b
|
||||
0x2e, // 06: c
|
||||
0x20, // 07: d
|
||||
0x12, // 08: e
|
||||
0x21, // 09: f
|
||||
0x22, // 0a: g
|
||||
0x23, // 0b: h
|
||||
0x17, // 0c: i
|
||||
0x24, // 0d: j
|
||||
0x25, // 0e: k
|
||||
0x26, // 0f: l
|
||||
0x32, // 10: m
|
||||
0x31, // 11: n
|
||||
0x18, // 12: o
|
||||
0x19, // 13: p
|
||||
0x10, // 14: q
|
||||
0x13, // 15: r
|
||||
0x1f, // 16: s
|
||||
0x14, // 17: t
|
||||
0x16, // 18: u
|
||||
0x2f, // 19: v
|
||||
0x11, // 1a: w
|
||||
0x2d, // 1b: x
|
||||
0x15, // 1c: y
|
||||
0x2c, // 1d: z
|
||||
0x02, // 1e: 1
|
||||
0x03, // 1f: 2
|
||||
0x04, // 20: 3
|
||||
0x05, // 21: 4
|
||||
0x06, // 22: 5
|
||||
0x07, // 23: 6
|
||||
0x08, // 24: 7
|
||||
0x09, // 25: 8
|
||||
0x0a, // 26: 9
|
||||
0x0b, // 27: 0
|
||||
0x1c, // 28: Return
|
||||
0x01, // 29: Escape
|
||||
0x0e, // 2a: Backspace
|
||||
0x0f, // 2b: Tab
|
||||
0x39, // 2c: Space
|
||||
0x0c, // 2d: -
|
||||
0x0d, // 2e: =
|
||||
0x1a, // 2f: [
|
||||
0x1b, // 30: ]
|
||||
0x29, // 31: backslash, only on us keyboard
|
||||
0x29, // 32: Europe 1, only on int. keyboard
|
||||
0x27, // 33: ;
|
||||
0x28, // 34: '
|
||||
0x2b, // 35: `
|
||||
0x33, // 36: ,
|
||||
0x34, // 37: .
|
||||
0x35, // 38: /
|
||||
0x3a | CAPS_LOCK_TOGGLE, // 39: Caps Lock
|
||||
0x3b, // 3a: F1
|
||||
0x3c, // 3b: F2
|
||||
0x3d, // 3c: F3
|
||||
0x3e, // 3d: F4
|
||||
0x3f, // 3e: F5
|
||||
0x40, // 3f: F6
|
||||
0x41, // 40: F7
|
||||
0x42, // 41: F8
|
||||
0x43, // 42: F9
|
||||
0x44, // 43: F10
|
||||
MISS, // 44: F11
|
||||
OSD_OPEN, // 45: F12
|
||||
MISS, // 46: Print Screen
|
||||
NUM_LOCK_TOGGLE, // 47: Scroll Lock
|
||||
MISS, // 48: Pause
|
||||
0x52, // 49: Insert
|
||||
0x47, // 4a: Home
|
||||
0x62, // 4b: Page Up
|
||||
0x53, // 4c: Delete
|
||||
MISS, // 4d: End
|
||||
0x61, // 4e: Page Down
|
||||
0x4d, // 4f: Right Arrow
|
||||
0x4b, // 50: Left Arrow
|
||||
0x50, // 51: Down Arrow
|
||||
0x48, // 52: Up Arrow
|
||||
NUM_LOCK_TOGGLE, // 53: Num Lock
|
||||
0x65, // 54: KP /
|
||||
0x66, // 55: KP *
|
||||
0x4a, // 56: KP -
|
||||
0x4e, // 57: KP +
|
||||
0x72, // 58: KP Enter
|
||||
0x6d, // 59: KP 1
|
||||
0x6e, // 5a: KP 2
|
||||
0x6f, // 5b: KP 3
|
||||
0x6a, // 5c: KP 4
|
||||
0x6b, // 5d: KP 5
|
||||
0x6c, // 5e: KP 6
|
||||
0x67, // 5f: KP 7
|
||||
0x68, // 60: KP 8
|
||||
0x69, // 61: KP 9
|
||||
0x70, // 62: KP 0
|
||||
0x71, // 63: KP .
|
||||
0x60, // 64: Europe 2
|
||||
OSD_OPEN, // 65: App
|
||||
MISS, // 66: Power
|
||||
MISS, // 67: KP =
|
||||
MISS, // 68: F13
|
||||
MISS, // 69: F14
|
||||
MISS, // 6a: F15
|
||||
0x52, // 6b: insert (for keyrah)
|
||||
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
|
||||
const unsigned short usb2ps2[] = {
|
||||
MISS, // 00: NoEvent
|
||||
MISS, // 01: Overrun Error
|
||||
MISS, // 02: POST fail
|
||||
MISS, // 03: ErrorUndefined
|
||||
0x1c, // 04: a
|
||||
0x32, // 05: b
|
||||
0x21, // 06: c
|
||||
0x23, // 07: d
|
||||
0x24, // 08: e
|
||||
0x2b, // 09: f
|
||||
0x34, // 0a: g
|
||||
0x33, // 0b: h
|
||||
0x43, // 0c: i
|
||||
0x3b, // 0d: j
|
||||
0x42, // 0e: k
|
||||
0x4b, // 0f: l
|
||||
0x3a, // 10: m
|
||||
0x31, // 11: n
|
||||
0x44, // 12: o
|
||||
0x4d, // 13: p
|
||||
0x15, // 14: q
|
||||
0x2d, // 15: r
|
||||
0x1b, // 16: s
|
||||
0x2c, // 17: t
|
||||
0x3c, // 18: u
|
||||
0x2a, // 19: v
|
||||
0x1d, // 1a: w
|
||||
0x22, // 1b: x
|
||||
0x35, // 1c: y
|
||||
0x1a, // 1d: z
|
||||
0x16, // 1e: 1
|
||||
0x1e, // 1f: 2
|
||||
0x26, // 20: 3
|
||||
0x25, // 21: 4
|
||||
0x2e, // 22: 5
|
||||
0x36, // 23: 6
|
||||
0x3d, // 24: 7
|
||||
0x3e, // 25: 8
|
||||
0x46, // 26: 9
|
||||
0x45, // 27: 0
|
||||
0x5a, // 28: Return
|
||||
0x76, // 29: Escape
|
||||
0x66, // 2a: Backspace
|
||||
0x0d, // 2b: Tab
|
||||
0x29, // 2c: Space
|
||||
0x4e, // 2d: -
|
||||
0x55, // 2e: =
|
||||
0x54, // 2f: [
|
||||
0x5b, // 30: ]
|
||||
0x5d, // 31: backslash
|
||||
0x5d, // 32: Europe 1
|
||||
0x4c, // 33: ;
|
||||
0x52, // 34: '
|
||||
0x0e, // 35: `
|
||||
0x41, // 36: ,
|
||||
0x49, // 37: .
|
||||
0x4a, // 38: /
|
||||
0x58, // 39: Caps Lock
|
||||
0x05, // 3a: F1
|
||||
0x06, // 3b: F2
|
||||
0x04, // 3c: F3
|
||||
0x0c, // 3d: F4
|
||||
0x03, // 3e: F5
|
||||
0x0b, // 3f: F6
|
||||
0x83, // 40: F7
|
||||
0x0a, // 41: F8
|
||||
0x01, // 42: F9
|
||||
0x09, // 43: F10
|
||||
0x78, // 44: F11
|
||||
OSD_OPEN | 0x07, // 45: F12 (OSD)
|
||||
EXT | 0x7c, // 46: Print Screen
|
||||
NUM_LOCK_TOGGLE, // 47: Scroll Lock
|
||||
0x77, // 48: Pause (special key handled inside user_io)
|
||||
EXT | 0x70, // 49: Insert
|
||||
EXT | 0x6c, // 4a: Home
|
||||
EXT | 0x7d, // 4b: Page Up
|
||||
EXT | 0x71, // 4c: Delete
|
||||
EXT | 0x69, // 4d: End
|
||||
EXT | 0x7a, // 4e: Page Down
|
||||
EXT | 0x74, // 4f: Right Arrow
|
||||
EXT | 0x6b, // 50: Left Arrow
|
||||
EXT | 0x72, // 51: Down Arrow
|
||||
EXT | 0x75, // 52: Up Arrow
|
||||
NUM_LOCK_TOGGLE, // 53: Num Lock
|
||||
EXT | 0x4a, // 54: KP /
|
||||
0x7c, // 55: KP *
|
||||
0x7b, // 56: KP -
|
||||
0x79, // 57: KP +
|
||||
EXT | 0x5a, // 58: KP Enter
|
||||
0x69, // 59: KP 1
|
||||
0x72, // 5a: KP 2
|
||||
0x7a, // 5b: KP 3
|
||||
0x6b, // 5c: KP 4
|
||||
0x73, // 5d: KP 5
|
||||
0x74, // 5e: KP 6
|
||||
0x6c, // 5f: KP 7
|
||||
0x75, // 60: KP 8
|
||||
0x7d, // 61: KP 9
|
||||
0x70, // 62: KP 0
|
||||
0x71, // 63: KP .
|
||||
0x61, // 64: Europe 2
|
||||
OSD_OPEN | EXT | 0x2f, // 65: App
|
||||
EXT | 0x37, // 66: Power
|
||||
0x0f, // 67: KP =
|
||||
0x77, // 68: Num Lock
|
||||
0x7e, // 69: Scroll Lock
|
||||
0x18, // 6a: F15
|
||||
EXT | 0x70, // 6b: insert (for keyrah)
|
||||
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
|
||||
// Missing sterling
|
||||
// Missing kp_hash
|
||||
// Missing button_1
|
||||
// Missing button_2
|
||||
// Missing button_3
|
||||
// Missing button_4
|
||||
// Missing button_5
|
||||
|
||||
// keycode translation table
|
||||
const unsigned short usb2archie[] = {
|
||||
MISS, // 00: NoEvent
|
||||
MISS, // 01: Overrun Error
|
||||
MISS, // 02: POST fail
|
||||
MISS, // 03: ErrorUndefined
|
||||
0x3c, // 04: a
|
||||
0x52, // 05: b
|
||||
0x50, // 06: c
|
||||
0x3e, // 07: d
|
||||
0x29, // 08: e
|
||||
0x3f, // 09: f
|
||||
0x40, // 0a: g
|
||||
0x41, // 0b: h
|
||||
0x2e, // 0c: i
|
||||
0x42, // 0d: j
|
||||
0x43, // 0e: k
|
||||
0x44, // 0f: l
|
||||
0x54, // 10: m
|
||||
0x53, // 11: n
|
||||
0x2f, // 12: o
|
||||
0x30, // 13: p
|
||||
0x27, // 14: q
|
||||
0x2a, // 15: r
|
||||
0x3d, // 16: s
|
||||
0x2b, // 17: t
|
||||
0x2d, // 18: u
|
||||
0x51, // 19: v
|
||||
0x28, // 1a: w
|
||||
0x4f, // 1b: x
|
||||
0x2c, // 1c: y
|
||||
0x4e, // 1d: z
|
||||
0x11, // 1e: 1
|
||||
0x12, // 1f: 2
|
||||
0x13, // 20: 3
|
||||
0x14, // 21: 4
|
||||
0x15, // 22: 5
|
||||
0x16, // 23: 6
|
||||
0x17, // 24: 7
|
||||
0x18, // 25: 8
|
||||
0x19, // 26: 9
|
||||
0x1a, // 27: 0
|
||||
0x47, // 28: Return
|
||||
0x00, // 29: Escape
|
||||
0x1e, // 2a: Backspace
|
||||
0x26, // 2b: Tab
|
||||
0x5f, // 2c: Space
|
||||
0x1b, // 2d: -
|
||||
0x1c, // 2e: =
|
||||
0x31, // 2f: [
|
||||
0x32, // 30: ]
|
||||
0x33, // 31: backslash (only on us keyboards)
|
||||
0x33, // 32: Europe 1 (only on international kbds)
|
||||
0x45, // 33: ;
|
||||
0x46, // 34: '
|
||||
0x10, // 35: `
|
||||
0x55, // 36: ,
|
||||
0x56, // 37: .
|
||||
0x57, // 38: /
|
||||
0x5d, // 39: Caps Lock
|
||||
0x01, // 3a: F1
|
||||
0x02, // 3b: F2
|
||||
0x03, // 3c: F3
|
||||
0x04, // 3d: F4
|
||||
0x05, // 3e: F5
|
||||
0x06, // 3f: F6
|
||||
0x07, // 40: F7
|
||||
0x08, // 41: F8
|
||||
0x09, // 42: F9
|
||||
0x0a, // 43: F10
|
||||
0x0b, // 44: F11
|
||||
0x0c, // 45: F12 - Used heavily by the archie... OSD moved to printscreen.
|
||||
// 0x0d, // 46: Print Screen
|
||||
OSD_OPEN, // 46: Print Screen
|
||||
0x0e, // 47: Scroll Lock
|
||||
0x0f, // 48: Pause
|
||||
0x1f, // 49: Insert
|
||||
0x20, // 4a: Home
|
||||
0x21, // 4b: Page Up
|
||||
0x34, // 4c: Delete
|
||||
0x35, // 4d: End
|
||||
0x36, // 4e: Page Down
|
||||
0x64, // 4f: Right Arrow
|
||||
0x62, // 50: Left Arrow
|
||||
0x63, // 51: Down Arrow
|
||||
0x59, // 52: Up Arrow
|
||||
0x22, // 53: Num Lock
|
||||
0x23, // 54: KP /
|
||||
0x24, // 55: KP *
|
||||
0x3a, // 56: KP -
|
||||
0x4b, // 57: KP +
|
||||
0x67, // 58: KP Enter
|
||||
0x5a, // 59: KP 1
|
||||
0x5b, // 5a: KP 2
|
||||
0x5c, // 5b: KP 3
|
||||
0x48, // 5c: KP 4
|
||||
0x49, // 5d: KP 5
|
||||
0x4a, // 5e: KP 6
|
||||
0x37, // 5f: KP 7
|
||||
0x38, // 60: KP 8
|
||||
0x39, // 61: KP 9
|
||||
0x65, // 62: KP 0
|
||||
0x66, // 63: KP decimal
|
||||
MISS, // 64: Europe 2
|
||||
0x72, // 65: App (maps to middle mouse button)
|
||||
MISS, // 66: Power
|
||||
MISS, // 67: KP =
|
||||
MISS, // 68: F13
|
||||
MISS, // 69: F14
|
||||
MISS, // 6a: F15
|
||||
0x1f, // 6b: insert (for keyrah)
|
||||
MISS, // 6c: F17
|
||||
MISS, // 6d: F18
|
||||
MISS, // 6e: F19
|
||||
MISS, // 6f: F20
|
||||
};
|
||||
|
||||
#endif
|
||||
80
menu.c
80
menu.c
@@ -415,52 +415,42 @@ const uint8_t keycode_table[128] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static uint8_t GetASCIIKey(unsigned char keycode)
|
||||
static uint8_t GetASCIIKey(uint32_t keycode)
|
||||
{
|
||||
if (keycode & KEY_AMI_UPSTROKE)
|
||||
if (keycode & UPSTROKE)
|
||||
return 0;
|
||||
|
||||
return keycode_table[keycode & 0x7F];
|
||||
return keycode_table[get_amiga_code(keycode & 0xFFFF) & 0x7F];
|
||||
}
|
||||
|
||||
/* the Atari core handles OSD keys competely inside the core */
|
||||
static unsigned char menu_key = 0;
|
||||
static unsigned char menu_mod = 0;
|
||||
static uint32_t menu_key = 0;
|
||||
|
||||
void menu_key_set(unsigned char c)
|
||||
void menu_key_set(uint32_t c)
|
||||
{
|
||||
//iprintf("OSD enqueue: %x\n", c);
|
||||
//printf("OSD enqueue: %x\n", c);
|
||||
menu_key = c;
|
||||
}
|
||||
|
||||
void menu_mod_set(uint8_t m)
|
||||
{
|
||||
menu_mod = m;
|
||||
}
|
||||
|
||||
// get key status
|
||||
static uint8_t menu_key_get(void)
|
||||
static uint32_t menu_key_get(void)
|
||||
{
|
||||
static unsigned char c2;
|
||||
static uint32_t c2;
|
||||
static unsigned long delay;
|
||||
static unsigned long repeat;
|
||||
static unsigned char repeat2;
|
||||
unsigned char c1, c;
|
||||
uint32_t c1, c;
|
||||
|
||||
c1 = menu_key;
|
||||
|
||||
// OsdKeyGet permanently returns the last key event.
|
||||
|
||||
// generate normal "key-pressed" event
|
||||
c = 0;
|
||||
if (c1 != c2) c = c1;
|
||||
c2 = c1;
|
||||
|
||||
// inject a fake "MENU_KEY" if no menu is visible and the menu key is loaded
|
||||
if (!user_io_osd_is_visible() && is_menu_core()) c = KEY_AMI_MENU;
|
||||
if (!user_io_osd_is_visible() && is_menu_core()) c = KEY_F12;
|
||||
|
||||
// generate repeat "key-pressed" events
|
||||
if ((c1 & KEY_AMI_UPSTROKE) || (!c1))
|
||||
if ((c1 & UPSTROKE) || (!c1))
|
||||
{
|
||||
repeat = GetTimer(REPEATDELAY);
|
||||
}
|
||||
@@ -475,10 +465,9 @@ static uint8_t menu_key_get(void)
|
||||
{
|
||||
static unsigned char last_but = 0;
|
||||
unsigned char but = user_io_menu_button();
|
||||
if (!but && last_but) c = KEY_AMI_MENU;
|
||||
if (!but && last_but) c = KEY_F12;
|
||||
last_but = but;
|
||||
}
|
||||
|
||||
return(c);
|
||||
}
|
||||
|
||||
@@ -486,7 +475,7 @@ void HandleUI(void)
|
||||
{
|
||||
char *p;
|
||||
char s[40];
|
||||
unsigned char i, c, m, up, down, select, menu, right, left, plus, minus;
|
||||
unsigned char i, m, up, down, select, menu, right, left, plus, minus;
|
||||
uint8_t mod;
|
||||
unsigned long len;
|
||||
static hardfileTYPE t_hardfile[2]; // temporary copy of former hardfile configuration
|
||||
@@ -502,7 +491,7 @@ void HandleUI(void)
|
||||
char usb_id[64];
|
||||
|
||||
// get user control codes
|
||||
c = menu_key_get();
|
||||
uint32_t c = menu_key_get();
|
||||
|
||||
// decode and set events
|
||||
menu = false;
|
||||
@@ -516,9 +505,9 @@ void HandleUI(void)
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case KEY_AMI_MENU:
|
||||
case KEY_F12:
|
||||
menu = true;
|
||||
menu_key_set(KEY_AMI_MENU | KEY_AMI_UPSTROKE);
|
||||
menu_key_set(KEY_F12 | UPSTROKE);
|
||||
break;
|
||||
|
||||
// Within the menu the esc key acts as the menu key. problem:
|
||||
@@ -526,35 +515,35 @@ void HandleUI(void)
|
||||
// break code for the ESC key when the key is released will
|
||||
// reach the core which never saw the make code. Simple solution:
|
||||
// react on break code instead of make code
|
||||
case KEY_AMI_ESC | KEY_AMI_UPSTROKE:
|
||||
case KEY_ESC | UPSTROKE:
|
||||
if (menustate != MENU_NONE2)
|
||||
menu = true;
|
||||
break;
|
||||
case KEY_AMI_ENTER:
|
||||
case KEY_AMI_SPACE:
|
||||
case KEY_ENTER:
|
||||
case KEY_SPACE:
|
||||
select = true;
|
||||
break;
|
||||
case KEY_AMI_UP:
|
||||
case KEY_UP:
|
||||
up = true;
|
||||
break;
|
||||
case KEY_AMI_DOWN:
|
||||
case KEY_DOWN:
|
||||
down = true;
|
||||
break;
|
||||
case KEY_AMI_LEFT:
|
||||
case KEY_LEFT:
|
||||
left = true;
|
||||
break;
|
||||
case KEY_AMI_RIGHT:
|
||||
case KEY_RIGHT:
|
||||
right = true;
|
||||
break;
|
||||
case KEY_AMI_KPPLUS:
|
||||
case 0x0c: // =/+
|
||||
case KEY_KPPLUS:
|
||||
case KEY_EQUAL: // =/+
|
||||
plus = true;
|
||||
break;
|
||||
case KEY_AMI_KPMINUS:
|
||||
case 0x0b: // -/_
|
||||
case KEY_KPMINUS:
|
||||
case KEY_MINUS: // -/_
|
||||
minus = true;
|
||||
break;
|
||||
|
||||
/*
|
||||
case 0x01: // 1: 1280x720 mode
|
||||
if (user_io_osd_is_visible) mist_cfg.video_mode = 0;
|
||||
break;
|
||||
@@ -562,6 +551,7 @@ void HandleUI(void)
|
||||
case 0x02: // 2: 1280x1024 mode
|
||||
if (user_io_osd_is_visible) mist_cfg.video_mode = 1;
|
||||
break;
|
||||
*/
|
||||
}
|
||||
|
||||
if (menu || select || up || down || left || right)
|
||||
@@ -633,7 +623,7 @@ void HandleUI(void)
|
||||
case MENU_NONE2:
|
||||
if (menu)
|
||||
{
|
||||
if (menu_mod & 0x44) //Alt+Menu
|
||||
if (get_key_mod() & (LALT|RALT)) //Alt+Menu
|
||||
{
|
||||
OsdSetSize(16);
|
||||
SelectFile("RBF", 0, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_NONE1, 0);
|
||||
@@ -1832,7 +1822,7 @@ void HandleUI(void)
|
||||
else if (menusub == 11)
|
||||
menustate = MENU_NONE1;
|
||||
}
|
||||
else if (c == KEY_AMI_BACK) // eject all floppies
|
||||
else if (c == KEY_BACKSPACE) // eject all floppies
|
||||
{
|
||||
for (i = 0; i <= drives; i++)
|
||||
df[i].status = 0;
|
||||
@@ -1934,25 +1924,25 @@ void HandleUI(void)
|
||||
|
||||
ScrollLongName(); // scrolls file name if longer than display line
|
||||
|
||||
if (c == KEY_AMI_HOME)
|
||||
if (c == KEY_HOME)
|
||||
{
|
||||
ScanDirectory(SelectedPath, SCAN_INIT, fs_pFileExt, fs_Options);
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
}
|
||||
|
||||
if (c == KEY_AMI_BACK)
|
||||
if (c == KEY_BACKSPACE)
|
||||
{
|
||||
changeDir("..");
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
}
|
||||
|
||||
if ((c == KEY_AMI_PGUP) || (c == KEY_AMI_LEFT))
|
||||
if ((c == KEY_PAGEUP) || (c == KEY_LEFT))
|
||||
{
|
||||
ScanDirectory(SelectedPath, SCAN_PREV_PAGE, fs_pFileExt, fs_Options);
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
}
|
||||
|
||||
if ((c == KEY_AMI_PGDN) || (c == KEY_AMI_RIGHT))
|
||||
if ((c == KEY_PAGEDOWN) || (c == KEY_RIGHT))
|
||||
{
|
||||
ScanDirectory(SelectedPath, SCAN_NEXT_PAGE, fs_pFileExt, fs_Options);
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
|
||||
21
menu.h
21
menu.h
@@ -3,23 +3,6 @@
|
||||
|
||||
#include "fdd.h" // for adfTYPE definition
|
||||
|
||||
#define KEY_AMI_UPSTROKE 0x80
|
||||
#define KEY_AMI_MENU 0x69
|
||||
#define KEY_AMI_PGUP 0x6C
|
||||
#define KEY_AMI_PGDN 0x6D
|
||||
#define KEY_AMI_HOME 0x6A
|
||||
#define KEY_AMI_ESC 0x45
|
||||
#define KEY_AMI_KPENTER 0x43
|
||||
#define KEY_AMI_ENTER 0x44
|
||||
#define KEY_AMI_BACK 0x41
|
||||
#define KEY_AMI_SPACE 0x40
|
||||
#define KEY_AMI_UP 0x4C
|
||||
#define KEY_AMI_DOWN 0x4D
|
||||
#define KEY_AMI_LEFT 0x4F
|
||||
#define KEY_AMI_RIGHT 0x4E
|
||||
#define KEY_AMI_KPPLUS 0x5E
|
||||
#define KEY_AMI_KPMINUS 0x4A
|
||||
|
||||
// UI strings, used by boot messages
|
||||
extern const char *config_filter_msg[];
|
||||
extern const char *config_memory_chip_msg[];
|
||||
@@ -40,7 +23,7 @@ void ShowSplash();
|
||||
void HideSplash();
|
||||
void EjectAllFloppies();
|
||||
|
||||
void menu_key_set(unsigned char c);
|
||||
void menu_mod_set(uint8_t m);
|
||||
void menu_key_set(uint32_t c);
|
||||
void menu_mod_set(uint32_t m);
|
||||
|
||||
#endif
|
||||
|
||||
312
user_io.c
312
user_io.c
@@ -10,7 +10,6 @@
|
||||
#include "user_io.h"
|
||||
#include "archie.h"
|
||||
#include "debug.h"
|
||||
#include "keycodes.h"
|
||||
#include "ikbd.h"
|
||||
#include "spi.h"
|
||||
#include "mist_cfg.h"
|
||||
@@ -334,28 +333,6 @@ void user_io_detect_core_type()
|
||||
}
|
||||
}
|
||||
|
||||
unsigned short usb2amiga(unsigned char k)
|
||||
{
|
||||
// replace MENU key by RGUI to allow using Right Amiga on reduced keyboards
|
||||
// (it also disables the use of Menu for OSD)
|
||||
if (mist_cfg.key_menu_as_rgui && k == 0x65)
|
||||
{
|
||||
return 0x67;
|
||||
}
|
||||
return usb2ami[k];
|
||||
}
|
||||
|
||||
unsigned short usb2ps2code(unsigned char k)
|
||||
{
|
||||
// replace MENU key by RGUI e.g. to allow using RGUI on reduced keyboards without physical key
|
||||
// (it also disables the use of Menu for OSD)
|
||||
if (mist_cfg.key_menu_as_rgui && k == 0x65)
|
||||
{
|
||||
return EXT | 0x27;
|
||||
}
|
||||
return usb2ps2[k];
|
||||
}
|
||||
|
||||
void user_io_analog_joystick(unsigned char joystick, char valueX, char valueY)
|
||||
{
|
||||
if (core_type == CORE_TYPE_8BIT)
|
||||
@@ -816,6 +793,8 @@ void kbd_reply(char code)
|
||||
spi_uio_cmd8(UIO_KEYBOARD, code);
|
||||
}
|
||||
|
||||
static uint8_t use_ps2ctl = 0;
|
||||
|
||||
void user_io_poll()
|
||||
{
|
||||
if ((core_type != CORE_TYPE_MINIMIG2) &&
|
||||
@@ -1214,7 +1193,6 @@ void user_io_poll()
|
||||
|
||||
if (core_type == CORE_TYPE_ARCHIE) archie_poll();
|
||||
|
||||
static uint8_t use_ps2ctl = 0;
|
||||
static uint8_t leds = 0;
|
||||
if(use_ps2ctl)
|
||||
{
|
||||
@@ -1316,12 +1294,36 @@ char user_io_user_button()
|
||||
return((!user_io_menu_button() && (fpga_get_buttons() & BUTTON_USR)) ? 1 : 0);
|
||||
}
|
||||
|
||||
static void send_keycode(unsigned short code)
|
||||
static void send_keycode(unsigned short key, int press)
|
||||
{
|
||||
if (core_type == CORE_TYPE_MINIMIG2)
|
||||
{
|
||||
// amiga has "break" marker in msb
|
||||
if (code & BREAK) code = (code & 0xff) | 0x80;
|
||||
if (press > 1) return;
|
||||
|
||||
uint32_t code = get_amiga_code(key);
|
||||
if (code == NONE) return;
|
||||
|
||||
if (code & CAPS_TOGGLE)
|
||||
{
|
||||
if (press = 1)
|
||||
{
|
||||
// send alternating make and break codes for caps lock
|
||||
if(caps_lock_toggle) code |= 0x80;
|
||||
caps_lock_toggle = !caps_lock_toggle;
|
||||
set_kbd_led(HID_LED_CAPS_LOCK, caps_lock_toggle);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// amiga has "break" marker in msb
|
||||
if (!press) code |= 0x80;
|
||||
}
|
||||
|
||||
code &= 0xff;
|
||||
|
||||
// send immediately if possible
|
||||
if (CheckTimer(kbd_timer) && (kbd_fifo_w == kbd_fifo_r))
|
||||
@@ -1332,63 +1334,103 @@ static void send_keycode(unsigned short code)
|
||||
{
|
||||
kbd_fifo_enqueue(code);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_MIST)
|
||||
{
|
||||
if (press > 1) return;
|
||||
|
||||
uint32_t code = get_atari_code(key);
|
||||
if (code == NONE) return;
|
||||
|
||||
// atari has "break" marker in msb
|
||||
if (code & BREAK) code = (code & 0xff) | 0x80;
|
||||
if (!press) code = (code & 0xff) | 0x80;
|
||||
ikbd_keyboard(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_8BIT)
|
||||
{
|
||||
// send ps2 keycodes for those cores that prefer ps2
|
||||
spi_uio_cmd_cont(UIO_KEYBOARD);
|
||||
uint32_t code = get_ps2_code(key);
|
||||
if (code == NONE) return;
|
||||
|
||||
// "pause" has a complex code
|
||||
if ((code & 0xff) == 0x77)
|
||||
//pause
|
||||
if ((code & 0xff) == 0xE1)
|
||||
{
|
||||
// pause does not have a break code
|
||||
if (!(code & BREAK))
|
||||
if (press != 1)
|
||||
{
|
||||
// Pause key sends E11477E1F014E077
|
||||
static const unsigned char c[] = {
|
||||
0xe1, 0x14, 0x77, 0xe1, 0xf0, 0x14, 0xf0, 0x77, 0x00 };
|
||||
static const unsigned char c[] = { 0xe1, 0x14, 0x77, 0xe1, 0xf0, 0x14, 0xf0, 0x77, 0x00 };
|
||||
const unsigned char *p = c;
|
||||
|
||||
iprintf("PS2 KBD ");
|
||||
spi_uio_cmd_cont(UIO_KEYBOARD);
|
||||
|
||||
printf("PS2 PAUSE CODE: ");
|
||||
while (*p)
|
||||
{
|
||||
iprintf("%x ", *p);
|
||||
printf("%x ", *p);
|
||||
spi8(*p++);
|
||||
}
|
||||
iprintf("\n");
|
||||
printf("\n");
|
||||
|
||||
DisableIO();
|
||||
}
|
||||
}
|
||||
// print screen
|
||||
else if ((code & 0xff) == 0xE2)
|
||||
{
|
||||
if (press <= 1)
|
||||
{
|
||||
static const unsigned char c[2][8] = {
|
||||
{ 0xE0, 0xF0, 0x7C, 0xE0, 0xF0, 0x12, 0x00, 0x00 },
|
||||
{ 0xE0, 0x12, 0xE0, 0x7C, 0x00, 0x00, 0x00, 0x00 }
|
||||
};
|
||||
|
||||
const unsigned char *p = c[press];
|
||||
|
||||
spi_uio_cmd_cont(UIO_KEYBOARD);
|
||||
|
||||
printf("PS2 PRINT CODE: ");
|
||||
while (*p)
|
||||
{
|
||||
printf("%x ", *p);
|
||||
spi8(*p++);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
DisableIO();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
iprintf("PS2 KBD ");
|
||||
if (code & EXT) iprintf("e0 ");
|
||||
if (code & BREAK) iprintf("f0 ");
|
||||
iprintf("%x\n", code & 0xff);
|
||||
*/
|
||||
if (press > 1 && !use_ps2ctl) return;
|
||||
|
||||
spi_uio_cmd_cont(UIO_KEYBOARD);
|
||||
|
||||
// prepend extended code flag if required
|
||||
if (code & EXT) spi8(0xe0);
|
||||
|
||||
// prepend break code if required
|
||||
if (code & BREAK) spi8(0xf0);
|
||||
if (!press) spi8(0xf0);
|
||||
|
||||
// send code itself
|
||||
spi8(code & 0xff);
|
||||
}
|
||||
|
||||
DisableIO();
|
||||
DisableIO();
|
||||
}
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_ARCHIE) archie_kbd(code);
|
||||
if (core_type == CORE_TYPE_ARCHIE)
|
||||
{
|
||||
if (press > 1) return;
|
||||
|
||||
uint32_t code = get_archie_code(key);
|
||||
if (code == NONE) return;
|
||||
|
||||
archie_kbd(code);
|
||||
}
|
||||
}
|
||||
|
||||
void user_io_mouse(unsigned char b, int16_t x, int16_t y)
|
||||
@@ -1423,19 +1465,6 @@ LCTRL LSHIFT LALT LGUI RCTRL RSHIFT RALT RGUI
|
||||
#define EMU_BTN3 (2+(keyrah*4)) // left alt
|
||||
#define EMU_BTN4 (3+(keyrah*4)) // left gui (usually windows key)
|
||||
|
||||
unsigned short keycode(unsigned char in)
|
||||
{
|
||||
if (core_type == CORE_TYPE_MINIMIG2) return usb2amiga(in);
|
||||
|
||||
// atari st and the 8 bit core (currently only used for atari 800)
|
||||
// use the same key codes
|
||||
if (core_type == CORE_TYPE_MIST) return usb2atari[in];
|
||||
if (core_type == CORE_TYPE_ARCHIE) return usb2archie[in];
|
||||
if (core_type == CORE_TYPE_8BIT) return usb2ps2code(in);
|
||||
|
||||
return MISS;
|
||||
}
|
||||
|
||||
extern configTYPE config;
|
||||
|
||||
void user_io_check_reset(unsigned short modifiers, char useKeys)
|
||||
@@ -1473,58 +1502,19 @@ void user_io_check_reset(unsigned short modifiers, char useKeys)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned short modifier_keycode(unsigned char index)
|
||||
{
|
||||
/* usb modifer bits:
|
||||
0 1 2 3 4 5 6 7
|
||||
LCTRL LSHIFT LALT LGUI RCTRL RSHIFT RALT RGUI
|
||||
*/
|
||||
|
||||
if (core_type == CORE_TYPE_MINIMIG2)
|
||||
{
|
||||
static const unsigned short amiga_modifier[] = { 0x63, 0x60, 0x64, 0x66, 0x63, 0x61, 0x65, 0x67 };
|
||||
return amiga_modifier[index];
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_MIST)
|
||||
{
|
||||
static const unsigned short atari_modifier[] = { 0x1d, 0x2a, 0x38, MISS, 0x1d, 0x36, 0x38, MISS };
|
||||
return atari_modifier[index];
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_8BIT)
|
||||
{
|
||||
static const unsigned short ps2_modifier[] = { 0x14, 0x12, 0x11, EXT | 0x1f, EXT | 0x14, 0x59, EXT | 0x11, EXT | 0x27 };
|
||||
return ps2_modifier[index];
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_ARCHIE)
|
||||
{
|
||||
static const unsigned short archie_modifier[] = { 0x36, 0x4c, 0x5e, MISS, 0x61, 0x58, 0x60, MISS };
|
||||
return archie_modifier[index];
|
||||
}
|
||||
|
||||
return MISS;
|
||||
}
|
||||
|
||||
void user_io_osd_key_enable(char on)
|
||||
{
|
||||
iprintf("OSD is now %s\n", on ? "visible" : "invisible");
|
||||
osd_is_visible = on;
|
||||
}
|
||||
|
||||
static char key_used_by_osd(unsigned short s)
|
||||
static char key_used_by_osd(uint32_t s)
|
||||
{
|
||||
// this key is only used to open the OSD and has no keycode
|
||||
if ((s & OSD_OPEN) && !(s & 0xff)) return true;
|
||||
if (s & OSD_OPEN) return 1;
|
||||
|
||||
// no keys are suppressed if the OSD is inactive
|
||||
if (!osd_is_visible) return false;
|
||||
|
||||
// in atari mode eat all keys if the OSD is online,
|
||||
// else none as it's up to the core to forward keys
|
||||
// to the OSD
|
||||
return((core_type == CORE_TYPE_MIST) || (core_type == CORE_TYPE_ARCHIE) || (core_type == CORE_TYPE_8BIT));
|
||||
return osd_is_visible;
|
||||
}
|
||||
|
||||
void user_io_kbd(uint16_t key, int press)
|
||||
@@ -1534,105 +1524,37 @@ void user_io_kbd(uint16_t key, int press)
|
||||
(core_type == CORE_TYPE_ARCHIE) ||
|
||||
(core_type == CORE_TYPE_8BIT))
|
||||
{
|
||||
uint8_t m = key >> 8;
|
||||
uint8_t k = key & 0xFF;
|
||||
|
||||
static unsigned char modifier = 0;
|
||||
|
||||
// handle modifier keys
|
||||
if (m != modifier)
|
||||
if (key)
|
||||
{
|
||||
for (int i = 0; i<8; i++)
|
||||
{
|
||||
uint16_t code = modifier_keycode(i);
|
||||
|
||||
// Do we have a downstroke on a modifier key?
|
||||
if ((m & (1 << i)) && !(modifier & (1 << i)))
|
||||
{
|
||||
if (code != MISS)
|
||||
{
|
||||
if (is_menu_core()) printf("keycode(make)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
if(!osd_is_visible) send_keycode(code);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(m & (1 << i)) && (modifier & (1 << i)))
|
||||
{
|
||||
if (code != MISS)
|
||||
{
|
||||
if (is_menu_core()) printf("keycode(break)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
if (!osd_is_visible) send_keycode(BREAK | code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modifier = m;
|
||||
}
|
||||
|
||||
// check if there are keys in the pressed list which aren't
|
||||
// reported anymore
|
||||
if (k)
|
||||
{
|
||||
uint16_t code = keycode(k);
|
||||
uint32_t code = get_ps2_code(key);
|
||||
if (!press)
|
||||
{
|
||||
if (is_menu_core()) printf("keycode(break)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
if (is_menu_core()) printf("PS2 code(break)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
|
||||
if (code != MISS)
|
||||
if (code & OSD_OPEN) menu_key_set(UPSTROKE | KEY_F12);
|
||||
else if (osd_is_visible) menu_key_set(UPSTROKE | key);
|
||||
else
|
||||
{
|
||||
if (code & OSD_OPEN)
|
||||
{
|
||||
menu_key_set(KEY_AMI_UPSTROKE | KEY_AMI_MENU);
|
||||
}
|
||||
else
|
||||
{
|
||||
// special OSD key handled internally
|
||||
if (osd_is_visible) menu_key_set(KEY_AMI_UPSTROKE | usb2amiga(k));
|
||||
}
|
||||
|
||||
if (!key_used_by_osd(code) && !(code & CAPS_LOCK_TOGGLE) && !(code & NUM_LOCK_TOGGLE))
|
||||
{
|
||||
send_keycode(BREAK | code);
|
||||
}
|
||||
send_keycode(key, press);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_menu_core()) printf("keycode(make)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
if (is_menu_core()) printf("PS2 code(make)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
|
||||
if ((k <= KEYCODE_MAX) && code != MISS)
|
||||
if (code & OSD_OPEN)
|
||||
{
|
||||
// If OSD is visible, then all keys are sent into the OSD
|
||||
// using Amiga key codes since the OSD itself uses Amiga key codes
|
||||
// for historical reasons. If the OSD is invisble then only
|
||||
// those keys marked for OSD in the core specific table are
|
||||
// sent for OSD handling.
|
||||
if (code & OSD_OPEN)
|
||||
if (press == 1) menu_key_set(KEY_F12);
|
||||
}
|
||||
else if (osd_is_visible)
|
||||
{
|
||||
if (press == 1) menu_key_set(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((code & EMU_SWITCH_1) || ((code & EMU_SWITCH_2) && !use_ps2ctl))
|
||||
{
|
||||
menu_key_set(KEY_AMI_MENU);
|
||||
}
|
||||
else
|
||||
{
|
||||
// special OSD key handled internally
|
||||
if (osd_is_visible)
|
||||
{
|
||||
menu_key_set(usb2amiga(k));
|
||||
}
|
||||
}
|
||||
|
||||
// no further processing of any key that is currently
|
||||
// redirected to the OSD
|
||||
if (!key_used_by_osd(code))
|
||||
{
|
||||
if (code & CAPS_LOCK_TOGGLE)
|
||||
{
|
||||
// send alternating make and break codes for caps lock
|
||||
send_keycode((code & 0xff) | (caps_lock_toggle ? BREAK : 0));
|
||||
caps_lock_toggle = !caps_lock_toggle;
|
||||
|
||||
set_kbd_led(HID_LED_CAPS_LOCK, caps_lock_toggle);
|
||||
}
|
||||
else if (code & NUM_LOCK_TOGGLE)
|
||||
if (press == 1)
|
||||
{
|
||||
// num lock has four states indicated by leds:
|
||||
// all off: normal
|
||||
@@ -1640,7 +1562,7 @@ void user_io_kbd(uint16_t key, int press)
|
||||
// num lock on, scroll lock off: joy0 emu
|
||||
// num lock off, scroll lock on: joy1 emu
|
||||
|
||||
switch (code ^ NUM_LOCK_TOGGLE)
|
||||
switch (code & 0xff)
|
||||
{
|
||||
case 1:
|
||||
if (!joy_force) emu_mode = EMU_MOUSE;
|
||||
@@ -1670,10 +1592,10 @@ void user_io_kbd(uint16_t key, int press)
|
||||
if (emu_mode == EMU_MOUSE || emu_mode == EMU_JOY1) set_kbd_led(HID_LED_SCROLL_LOCK, true);
|
||||
else set_kbd_led(HID_LED_SCROLL_LOCK, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
send_keycode((press == 2) ? code & ~EXT : code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
send_keycode(key, press);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user