mirror of
https://github.com/fruit-bat/pico-zxspectrum.git
synced 2025-04-19 00:04:01 +03:00
Better cursor key support
This commit is contained in:
parent
0b92fe12fe
commit
3c878cc06f
@ -51,6 +51,9 @@ SN loads the current snapshot, SN- load the previous snapshot and SN+ loads the
|
||||
These are the mappings with the numeric shift on:<br/>
|
||||
<img src="docs/retro_vga_keyboard_num.svg" width="500"/><br/>
|
||||
|
||||
Alt+V sets the arrow keys to behave like a Kempston joystick,
|
||||
Alt+C sets the arrow keys to operate the Spectrum cursor keys.
|
||||
|
||||
### RetroVGA kiosk mode
|
||||
Kiosk mode disables the menu system and quick-save buttons.
|
||||
Kiosk mode is enabled by placing the following file on the SD-card:
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 33 KiB |
@ -66,7 +66,11 @@ ZxSpectrumHidKey KEYS[] = {
|
||||
{ HID_KEY_B, 1, { {7, 4} }},
|
||||
|
||||
{ HID_KEY_BACKSPACE, 2, { {0, 0}, {4, 0} }},
|
||||
|
||||
|
||||
{ HID_KEY_ARROW_LEFT, 2, { {0, 0}, {3, 4} }},
|
||||
{ HID_KEY_ARROW_DOWN, 2, { {0, 0}, {4, 4} }},
|
||||
{ HID_KEY_ARROW_UP, 2, { {0, 0}, {4, 3} }},
|
||||
{ HID_KEY_ARROW_RIGHT, 2, { {0, 0}, {4, 2} }}
|
||||
};
|
||||
|
||||
static bool KEYS_SORTED = false;
|
||||
|
@ -38,8 +38,8 @@ static uint8_t rdb[6]; // Debounced pins
|
||||
static hid_keyboard_report_t hr[2]; // Current and previous hid report
|
||||
static uint8_t hri = 0; // Currenct hid report index
|
||||
static uint8_t kbi = 0;
|
||||
static uint8_t kbits[3][6][6] = {
|
||||
// Normal mappings
|
||||
static uint8_t kbits[5][6][6] = {
|
||||
// Normal mappings + cursor joystick
|
||||
{
|
||||
// Row 0
|
||||
{ HID_KEY_SPACE, HID_KEY_ALT_RIGHT, HID_KEY_M, HID_KEY_N, HID_KEY_B, HID_KEY_ARROW_DOWN },
|
||||
@ -54,7 +54,37 @@ static uint8_t kbits[3][6][6] = {
|
||||
// Row 5
|
||||
{ HID_KEY_Q, HID_KEY_W, HID_KEY_E, HID_KEY_R, HID_KEY_T, /* HID_KEY_ALT_LEFT */ 0}
|
||||
},
|
||||
// Numeric mappings
|
||||
// Normal mappings + kempston joystick
|
||||
{
|
||||
// Row 0
|
||||
{ HID_KEY_SPACE, HID_KEY_ALT_RIGHT, HID_KEY_M, HID_KEY_N, HID_KEY_B, 0 },
|
||||
// Row 1
|
||||
{ HID_KEY_ENTER, HID_KEY_L, HID_KEY_K, HID_KEY_J, HID_KEY_H, 0 },
|
||||
// Row 2
|
||||
{ HID_KEY_P, HID_KEY_O, HID_KEY_I, HID_KEY_U, HID_KEY_Y, 0 },
|
||||
// Row 3
|
||||
{ HID_KEY_BACKSPACE, HID_KEY_Z, HID_KEY_X, HID_KEY_C, HID_KEY_V, 0 },
|
||||
// Row 4
|
||||
{ HID_KEY_A, HID_KEY_S, HID_KEY_D, HID_KEY_F, HID_KEY_G, HID_KEY_ESCAPE },
|
||||
// Row 5
|
||||
{ HID_KEY_Q, HID_KEY_W, HID_KEY_E, HID_KEY_R, HID_KEY_T, /* HID_KEY_ALT_LEFT */ 0}
|
||||
},
|
||||
// Numeric mappings + cursor joystick
|
||||
{
|
||||
// Row 0
|
||||
{ HID_KEY_SPACE, HID_KEY_ALT_RIGHT, HID_KEY_SEMICOLON, HID_KEY_MINUS, HID_KEY_EQUAL, 0 },
|
||||
// Row 1
|
||||
{ HID_KEY_ENTER, HID_KEY_BRACKET_RIGHT, HID_KEY_BRACKET_LEFT, HID_KEY_GRAVE, HID_KEY_BACKSLASH, 0 },
|
||||
// Row 2
|
||||
{ HID_KEY_0, HID_KEY_9, HID_KEY_8, HID_KEY_7, HID_KEY_6, 0 },
|
||||
// Row 3
|
||||
{ HID_KEY_BACKSPACE, HID_KEY_COMMA, HID_KEY_PERIOD, HID_KEY_SLASH, HID_KEY_APOSTROPHE, 0 },
|
||||
// Row 4
|
||||
{ HID_KEY_A, HID_KEY_S, HID_KEY_D, HID_KEY_F, HID_KEY_G, HID_KEY_ESCAPE },
|
||||
// Row 5
|
||||
{ HID_KEY_1, HID_KEY_2, HID_KEY_3, HID_KEY_4, HID_KEY_5, /* HID_KEY_ALT_LEFT */ 0 }
|
||||
},
|
||||
// Numeric mappings + kempston joystick
|
||||
{
|
||||
// Row 0
|
||||
{ HID_KEY_SPACE, HID_KEY_ALT_RIGHT, HID_KEY_SEMICOLON, HID_KEY_MINUS, HID_KEY_EQUAL, HID_KEY_ARROW_DOWN },
|
||||
@ -78,7 +108,7 @@ static uint8_t kbits[3][6][6] = {
|
||||
// Row 2 (Quick save 1-5)
|
||||
{ HID_KEY_F5, HID_KEY_F4, HID_KEY_F3, HID_KEY_F2, HID_KEY_F1, 0 },
|
||||
// Row 3
|
||||
{ 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, /* cursor mode (C) */ 0, /* joystick mode (V) */ 0, 0 },
|
||||
// Row 4
|
||||
{ HID_KEY_F8, HID_KEY_F9, HID_KEY_F10, 0, 0, 0 },
|
||||
// Row 5 (Menu, 0, ZX Symbol)
|
||||
@ -150,13 +180,16 @@ void __not_in_flash_func(pzx_keyscan_row)() {
|
||||
rdb[ri] = (am | rdb[ri]) & om;
|
||||
}
|
||||
|
||||
static uint8_t kempstonJoystick = 0;
|
||||
|
||||
uint8_t __not_in_flash_func(pzx_kempston)() {
|
||||
return
|
||||
return kempstonJoystick ?
|
||||
((rdb[KEY_ESC_ROW] & KEY_ESC_BIT) >> 1) // Kempston fire
|
||||
| ((rdb[KEY_UP_ROW] & KEY_UP_BIT) >> 2) // Kempston up
|
||||
| ((rdb[KEY_DOWN_ROW] & KEY_DOWN_BIT) >> 3) // Kempston down
|
||||
| ((rdb[KEY_LEFT_ROW] & KEY_LEFT_BIT) >> 4) // Kempston left
|
||||
| ((rdb[KEY_RIGHT_ROW] & KEY_RIGHT_BIT) >> 5); // Kempston right
|
||||
| ((rdb[KEY_RIGHT_ROW] & KEY_RIGHT_BIT) >> 5): // Kempston right
|
||||
0;
|
||||
}
|
||||
|
||||
void __not_in_flash_func(pzx_keyscan_get_hid_reports)(hid_keyboard_report_t const **curr, hid_keyboard_report_t const **prev) {
|
||||
@ -177,16 +210,27 @@ void __not_in_flash_func(pzx_keyscan_get_hid_reports)(hid_keyboard_report_t cons
|
||||
}
|
||||
if (rdb[KEY_RIGHT_ROW] & KEY_RIGHT_BIT) {
|
||||
// Numeric keyboard on
|
||||
kbi = 1;
|
||||
kbi = 2 + kempstonJoystick;
|
||||
}
|
||||
else if (rdb[KEY_LEFT_ROW] & KEY_LEFT_BIT) {
|
||||
// Numeric keyboard off
|
||||
kbi = 0;
|
||||
kbi = 0 + kempstonJoystick;
|
||||
}
|
||||
if (rdb[3] & (1<<3)) {
|
||||
// Cursor mode
|
||||
kempstonJoystick = 0;
|
||||
kbi &= ~1;
|
||||
}
|
||||
else if (rdb[3] & (1<<4)) {
|
||||
// Joystick mode
|
||||
kempstonJoystick = 1;
|
||||
kbi |= 1;
|
||||
}
|
||||
rdb[KEY_UP_ROW] &= ~KEY_UP_BIT;
|
||||
rdb[KEY_DOWN_ROW] &= ~KEY_DOWN_BIT;
|
||||
rdb[KEY_RIGHT_ROW] &= ~KEY_RIGHT_BIT;
|
||||
rdb[KEY_LEFT_ROW] &= ~KEY_LEFT_BIT;
|
||||
rdb[3] &= ~((1<<3) | (1<<4));
|
||||
}
|
||||
|
||||
// Build the current hid report
|
||||
@ -206,7 +250,7 @@ void __not_in_flash_func(pzx_keyscan_get_hid_reports)(hid_keyboard_report_t cons
|
||||
while(ki < sizeof(chr->keycode)) chr->keycode[ki++] = 1;
|
||||
break;
|
||||
}
|
||||
uint8_t kc = kbits[alt_down ? 2 : kbi][ri][ci];
|
||||
uint8_t kc = kbits[alt_down ? 4 : kbi][ri][ci];
|
||||
if (kc) chr->keycode[ki++] = kc;
|
||||
}
|
||||
++ci;
|
||||
|
Loading…
x
Reference in New Issue
Block a user