Added source code, MZ6500 module still not complete
This commit is contained in:
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/BT.h
|
||||
222
main/include/BT.h
Normal file
222
main/include/BT.h
Normal file
@@ -0,0 +1,222 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: BT.h
|
||||
// Created: Jan 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header file for the Bluetooth Class.
|
||||
//
|
||||
// Credits:
|
||||
// Copyright: (c) 2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BT_H_
|
||||
#define BT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_bt.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_hidh.h"
|
||||
#include "esp_hid_common.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
|
||||
// Bluetooth interface class. Provides Mouse and Keyboard functionality via the Bluetooth wireless interface.
|
||||
class BT {
|
||||
#define SIZEOF_ARRAY(a) (sizeof(a) / sizeof(*a))
|
||||
|
||||
public:
|
||||
typedef void t_pairingHandler(uint32_t code, uint8_t trigger);
|
||||
|
||||
// Structure to contain details of a single device forming a scanned device list.
|
||||
//
|
||||
typedef struct {
|
||||
esp_bd_addr_t bda;
|
||||
std::string name;
|
||||
int8_t rssi;
|
||||
esp_hid_usage_t usage;
|
||||
esp_hid_transport_t transport; //BT, BLE or USB
|
||||
|
||||
union {
|
||||
struct {
|
||||
esp_bt_cod_t cod;
|
||||
esp_bt_uuid_t uuid;
|
||||
} bt;
|
||||
struct {
|
||||
esp_ble_addr_type_t addr_type;
|
||||
uint16_t appearance;
|
||||
} ble;
|
||||
};
|
||||
|
||||
// Display format values.
|
||||
std::string deviceAddr; // MAC address of the Bluetooth device.
|
||||
std::string deviceType; // BT, BLE or USB
|
||||
} t_scanListItem;
|
||||
|
||||
|
||||
// Prototypes.
|
||||
BT(void);
|
||||
virtual ~BT(void);
|
||||
void getDeviceList(std::vector<t_scanListItem> &scanList, int waitTime);
|
||||
bool setup(t_pairingHandler *handler = nullptr);
|
||||
|
||||
inline uint8_t getBatteryLevel() { return btCtrl.batteryLevel; }
|
||||
inline void setBatteryLevel(uint8_t level) { btCtrl.batteryLevel = level; }
|
||||
|
||||
private:
|
||||
static constexpr char const *TAG = "BT";
|
||||
#ifdef CONFIG_CLASSIC_BT_ENABLED
|
||||
const char *gap_bt_prop_type_names[5] = { "", "BDNAME", "COD", "RSSI", "EIR" };
|
||||
const char *bt_gap_evt_names[10] = { "DISC_RES", "DISC_STATE_CHANGED", "RMT_SRVCS", "RMT_SRVC_REC", "AUTH_CMPL", "PIN_REQ", "CFM_REQ", "KEY_NOTIF", "KEY_REQ", "READ_RSSI_DELTA" };
|
||||
#endif
|
||||
const char *ble_gap_evt_names[28] = { "ADV_DATA_SET_COMPLETE", "SCAN_RSP_DATA_SET_COMPLETE", "SCAN_PARAM_SET_COMPLETE", "SCAN_RESULT", "ADV_DATA_RAW_SET_COMPLETE",
|
||||
"SCAN_RSP_DATA_RAW_SET_COMPLETE", "ADV_START_COMPLETE", "SCAN_START_COMPLETE", "AUTH_CMPL", "KEY",
|
||||
"SEC_REQ", "PASSKEY_NOTIF", "PASSKEY_REQ", "OOB_REQ", "LOCAL_IR",
|
||||
"LOCAL_ER", "NC_REQ", "ADV_STOP_COMPLETE", "SCAN_STOP_COMPLETE", "SET_STATIC_RAND_ADDR",
|
||||
"UPDATE_CONN_PARAMS", "SET_PKT_LENGTH_COMPLETE", "SET_LOCAL_PRIVACY_COMPLETE", "REMOVE_BOND_DEV_COMPLETE", "CLEAR_BOND_DEV_COMPLETE",
|
||||
"GET_BOND_DEV_COMPLETE", "READ_RSSI_COMPLETE", "UPDATE_WHITELIST_COMPLETE" };
|
||||
const char *ble_addr_type_names[4] = { "PUBLIC", "RANDOM", "RPA_PUBLIC", "RPA_RANDOM" };
|
||||
|
||||
// Define possible HIDH host modes.
|
||||
static const esp_bt_mode_t HIDH_IDLE_MODE = (esp_bt_mode_t) 0x00;
|
||||
static const esp_bt_mode_t HIDH_BLE_MODE = (esp_bt_mode_t) 0x01;
|
||||
static const esp_bt_mode_t HIDH_BT_MODE = (esp_bt_mode_t) 0x02;
|
||||
static const esp_bt_mode_t HIDH_BTDM_MODE = (esp_bt_mode_t) 0x03;
|
||||
|
||||
// Structure to maintain control variables.
|
||||
typedef struct {
|
||||
#ifdef CONFIG_CLASSIC_BT_ENABLED
|
||||
std::vector<t_scanListItem> btScanList;
|
||||
#endif
|
||||
std::vector<t_scanListItem> bleScanList;
|
||||
|
||||
t_pairingHandler *pairingHandler;
|
||||
esp_hidh_dev_t *hidhDevHdl;
|
||||
|
||||
int8_t batteryLevel;
|
||||
|
||||
#ifdef CONFIG_CLASSIC_BT_ENABLED
|
||||
xSemaphoreHandle bt_hidh_cb_semaphore;
|
||||
#endif
|
||||
xSemaphoreHandle ble_hidh_cb_semaphore;
|
||||
|
||||
BT *pThis;
|
||||
} t_btCtrl;
|
||||
|
||||
// All control variables are stored in a struct for ease of reference.
|
||||
t_btCtrl btCtrl;
|
||||
|
||||
|
||||
// Prototypes.
|
||||
static void processBTGapEvent(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t * param);
|
||||
static void processBLEGapEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t * param);
|
||||
t_scanListItem* findValidScannedDevice(esp_bd_addr_t bda, std::vector<t_scanListItem> &scanList);
|
||||
void processBLEDeviceScanResult(esp_ble_gap_cb_param_t * scan_rst);
|
||||
void addBLEScanDevice(esp_bd_addr_t bda, esp_ble_addr_type_t addr_type, uint16_t appearance, uint8_t *name, uint8_t name_len, int rssi);
|
||||
|
||||
#ifdef CONFIG_CLASSIC_BT_ENABLED
|
||||
void processBTDeviceScanResult(esp_bt_gap_cb_param_t * param);
|
||||
void addBTScanDevice(esp_bd_addr_t bda, esp_bt_cod_t *cod, esp_bt_uuid_t *uuid, uint8_t *name, uint8_t name_len, int rssi);
|
||||
#endif
|
||||
esp_err_t scanForBLEDevices(uint32_t timeout);
|
||||
esp_err_t scanForBTDevices(uint32_t timeout);
|
||||
esp_err_t scanForAllDevices(uint32_t timeout, size_t *noDevices, std::vector<t_scanListItem> &scanList);
|
||||
void printUUID(esp_bt_uuid_t * uuid);
|
||||
|
||||
const char *ble_addr_type_str(esp_ble_addr_type_t ble_addr_type)
|
||||
{
|
||||
if (ble_addr_type > BLE_ADDR_TYPE_RPA_RANDOM)
|
||||
{
|
||||
return "UNKNOWN";
|
||||
}
|
||||
return ble_addr_type_names[ble_addr_type];
|
||||
}
|
||||
|
||||
const char *ble_gap_evt_str(uint8_t event)
|
||||
{
|
||||
if (event >= SIZEOF_ARRAY(ble_gap_evt_names))
|
||||
{
|
||||
return "UNKNOWN";
|
||||
}
|
||||
return ble_gap_evt_names[event];
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CLASSIC_BT_ENABLED
|
||||
const char *bt_gap_evt_str(uint8_t event)
|
||||
{
|
||||
if (event >= SIZEOF_ARRAY(bt_gap_evt_names))
|
||||
{
|
||||
return "UNKNOWN";
|
||||
}
|
||||
return bt_gap_evt_names[event];
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *ble_key_type_str(esp_ble_key_type_t key_type)
|
||||
{
|
||||
const char *key_str = nullptr;
|
||||
switch (key_type)
|
||||
{
|
||||
case ESP_LE_KEY_NONE:
|
||||
key_str = "ESP_LE_KEY_NONE";
|
||||
break;
|
||||
case ESP_LE_KEY_PENC:
|
||||
key_str = "ESP_LE_KEY_PENC";
|
||||
break;
|
||||
case ESP_LE_KEY_PID:
|
||||
key_str = "ESP_LE_KEY_PID";
|
||||
break;
|
||||
case ESP_LE_KEY_PCSRK:
|
||||
key_str = "ESP_LE_KEY_PCSRK";
|
||||
break;
|
||||
case ESP_LE_KEY_PLK:
|
||||
key_str = "ESP_LE_KEY_PLK";
|
||||
break;
|
||||
case ESP_LE_KEY_LLK:
|
||||
key_str = "ESP_LE_KEY_LLK";
|
||||
break;
|
||||
case ESP_LE_KEY_LENC:
|
||||
key_str = "ESP_LE_KEY_LENC";
|
||||
break;
|
||||
case ESP_LE_KEY_LID:
|
||||
key_str = "ESP_LE_KEY_LID";
|
||||
break;
|
||||
case ESP_LE_KEY_LCSRK:
|
||||
key_str = "ESP_LE_KEY_LCSRK";
|
||||
break;
|
||||
default:
|
||||
key_str = "INVALID BLE KEY TYPE";
|
||||
break;
|
||||
}
|
||||
|
||||
return key_str;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BT_H_
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/BTHID.h
|
||||
701
main/include/BTHID.h
Normal file
701
main/include/BTHID.h
Normal file
@@ -0,0 +1,701 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: BTHID.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header file for the Bluetooth Keyboard Class.
|
||||
//
|
||||
// Credits:
|
||||
// Copyright: (c) 2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// Jun 2022 - Updated with latest findings. Now checks the bonded list and opens
|
||||
// connections or scans for new devices if no connections exist.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BT_KEYBOARD_H_
|
||||
#define BT_KEYBOARD_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_bt.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_hidh.h"
|
||||
#include "esp_hid_common.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "PS2KeyAdvanced.h"
|
||||
#include "PS2Mouse.h"
|
||||
#include "BT.h"
|
||||
|
||||
// Keyboard is a sub-class of BT which provides methods to setup BT for use by a keyboard.
|
||||
class BTHID : public BT {
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Global constants
|
||||
#define MAX_KEYBOARD_DATA_BYTES 8
|
||||
#define MAX_CCONTROL_DATA_BYTES 3
|
||||
#define MAX_MOUSE_DATA_BYTES 7
|
||||
#define MAX_BT2PS2_MAP_ENTRIES 179
|
||||
#define MAX_BTMEDIA2PS2_MAP_ENTRIES 8
|
||||
|
||||
// LED's
|
||||
#define BT_LED_NUMLOCK 0x01
|
||||
#define BT_LED_CAPSLOCK 0x02
|
||||
#define BT_LED_SCROLLLOCK 0x04
|
||||
|
||||
// Control keys.
|
||||
#define BT_NONE 0x0000
|
||||
#define BT_CTRL_LEFT 0x0001
|
||||
#define BT_SHIFT_LEFT 0x0002
|
||||
#define BT_ALT_LEFT 0x0004
|
||||
#define BT_GUI_LEFT 0x0008
|
||||
#define BT_CTRL_RIGHT 0x0010
|
||||
#define BT_SHIFT_RIGHT 0x0020
|
||||
#define BT_ALT_RIGHT 0x0040
|
||||
#define BT_GUI_RIGHT 0x0080
|
||||
#define BT_CAPS_LOCK 0x0100
|
||||
#define BT_NUM_LOCK 0x0200
|
||||
#define BT_SCROLL_LOCK 0x0400
|
||||
#define BT_DUPLICATE 0xFFFF // Duplicate BT flags onto PS/2 flags.
|
||||
|
||||
#define BT_PS2_FUNCTION 0x01
|
||||
#define BT_PS2_GUI 0x02
|
||||
#define BT_PS2_ALT_GR 0x04
|
||||
#define BT_PS2_ALT 0x08
|
||||
#define BT_PS2_CAPS 0x10
|
||||
#define BT_PS2_CTRL 0x20
|
||||
#define BT_PS2_SHIFT 0x40
|
||||
#define BT_PS2_BREAK 0x80
|
||||
|
||||
#define BT_KEY_NONE 0x00 // No key pressed
|
||||
#define BT_KEY_ERR_OVF 0x01 // Keyboard Error Roll Over
|
||||
// 0x02 // Keyboard POST Fail
|
||||
// 0x03 // Keyboard Error Undefined
|
||||
#define BT_KEY_A 0x04 // Keyboard a and A
|
||||
#define BT_KEY_B 0x05 // Keyboard b and B
|
||||
#define BT_KEY_C 0x06 // Keyboard c and C
|
||||
#define BT_KEY_D 0x07 // Keyboard d and D
|
||||
#define BT_KEY_E 0x08 // Keyboard e and E
|
||||
#define BT_KEY_F 0x09 // Keyboard f and F
|
||||
#define BT_KEY_G 0x0a // Keyboard g and G
|
||||
#define BT_KEY_H 0x0b // Keyboard h and H
|
||||
#define BT_KEY_I 0x0c // Keyboard i and I
|
||||
#define BT_KEY_J 0x0d // Keyboard j and J
|
||||
#define BT_KEY_K 0x0e // Keyboard k and K
|
||||
#define BT_KEY_L 0x0f // Keyboard l and L
|
||||
#define BT_KEY_M 0x10 // Keyboard m and M
|
||||
#define BT_KEY_N 0x11 // Keyboard n and N
|
||||
#define BT_KEY_O 0x12 // Keyboard o and O
|
||||
#define BT_KEY_P 0x13 // Keyboard p and P
|
||||
#define BT_KEY_Q 0x14 // Keyboard q and Q
|
||||
#define BT_KEY_R 0x15 // Keyboard r and R
|
||||
#define BT_KEY_S 0x16 // Keyboard s and S
|
||||
#define BT_KEY_T 0x17 // Keyboard t and T
|
||||
#define BT_KEY_U 0x18 // Keyboard u and U
|
||||
#define BT_KEY_V 0x19 // Keyboard v and V
|
||||
#define BT_KEY_W 0x1a // Keyboard w and W
|
||||
#define BT_KEY_X 0x1b // Keyboard x and X
|
||||
#define BT_KEY_Y 0x1c // Keyboard y and Y
|
||||
#define BT_KEY_Z 0x1d // Keyboard z and Z
|
||||
|
||||
#define BT_KEY_1 0x1e // Keyboard 1 and !
|
||||
#define BT_KEY_2 0x1f // Keyboard 2 and @
|
||||
#define BT_KEY_3 0x20 // Keyboard 3 and #
|
||||
#define BT_KEY_4 0x21 // Keyboard 4 and $
|
||||
#define BT_KEY_5 0x22 // Keyboard 5 and %
|
||||
#define BT_KEY_6 0x23 // Keyboard 6 and ^
|
||||
#define BT_KEY_7 0x24 // Keyboard 7 and &
|
||||
#define BT_KEY_8 0x25 // Keyboard 8 and *
|
||||
#define BT_KEY_9 0x26 // Keyboard 9 and (
|
||||
#define BT_KEY_0 0x27 // Keyboard 0 and )
|
||||
|
||||
#define BT_KEY_ENTER 0x28 // Keyboard Return (ENTER)
|
||||
#define BT_KEY_ESC 0x29 // Keyboard ESCAPE
|
||||
#define BT_KEY_BACKSPACE 0x2a // Keyboard DELETE (Backspace)
|
||||
#define BT_KEY_TAB 0x2b // Keyboard Tab
|
||||
#define BT_KEY_SPACE 0x2c // Keyboard Spacebar
|
||||
#define BT_KEY_MINUS 0x2d // Keyboard - and _
|
||||
#define BT_KEY_EQUAL 0x2e // Keyboard = and +
|
||||
#define BT_KEY_LEFTBRACE 0x2f // Keyboard [ and {
|
||||
#define BT_KEY_RIGHTBRACE 0x30 // Keyboard ] and }
|
||||
#define BT_KEY_BACKSLASH 0x31 // Keyboard \ and |
|
||||
#define BT_KEY_HASHTILDE 0x32 // Keyboard Non-US # and ~
|
||||
#define BT_KEY_SEMICOLON 0x33 // Keyboard ; and :
|
||||
#define BT_KEY_APOSTROPHE 0x34 // Keyboard ' and "
|
||||
#define BT_KEY_GRAVE 0x35 // Keyboard ` and ~
|
||||
#define BT_KEY_COMMA 0x36 // Keyboard , and <
|
||||
#define BT_KEY_DOT 0x37 // Keyboard . and >
|
||||
#define BT_KEY_SLASH 0x38 // Keyboard / and ?
|
||||
#define BT_KEY_CAPSLOCK 0x39 // Keyboard Caps Lock
|
||||
|
||||
#define BT_KEY_F1 0x3a // Keyboard F1
|
||||
#define BT_KEY_F2 0x3b // Keyboard F2
|
||||
#define BT_KEY_F3 0x3c // Keyboard F3
|
||||
#define BT_KEY_F4 0x3d // Keyboard F4
|
||||
#define BT_KEY_F5 0x3e // Keyboard F5
|
||||
#define BT_KEY_F6 0x3f // Keyboard F6
|
||||
#define BT_KEY_F7 0x40 // Keyboard F7
|
||||
#define BT_KEY_F8 0x41 // Keyboard F8
|
||||
#define BT_KEY_F9 0x42 // Keyboard F9
|
||||
#define BT_KEY_F10 0x43 // Keyboard F10
|
||||
#define BT_KEY_F11 0x44 // Keyboard F11
|
||||
#define BT_KEY_F12 0x45 // Keyboard F12
|
||||
|
||||
#define BT_KEY_SYSRQ 0x46 // Keyboard Print Screen
|
||||
#define BT_KEY_SCROLLLOCK 0x47 // Keyboard Scroll Lock
|
||||
#define BT_KEY_PAUSE 0x48 // Keyboard Pause
|
||||
#define BT_KEY_INSERT 0x49 // Keyboard Insert
|
||||
#define BT_KEY_HOME 0x4a // Keyboard Home
|
||||
#define BT_KEY_PAGEUP 0x4b // Keyboard Page Up
|
||||
#define BT_KEY_DELETE 0x4c // Keyboard Delete Forward
|
||||
#define BT_KEY_END 0x4d // Keyboard End
|
||||
#define BT_KEY_PAGEDOWN 0x4e // Keyboard Page Down
|
||||
#define BT_KEY_RIGHT 0x4f // Keyboard Right Arrow
|
||||
#define BT_KEY_LEFT 0x50 // Keyboard Left Arrow
|
||||
#define BT_KEY_DOWN 0x51 // Keyboard Down Arrow
|
||||
#define BT_KEY_UP 0x52 // Keyboard Up Arrow
|
||||
|
||||
#define BT_KEY_NUMLOCK 0x53 // Keyboard Num Lock and Clear
|
||||
#define BT_KEY_KPSLASH 0x54 // Keypad /
|
||||
#define BT_KEY_KPASTERISK 0x55 // Keypad *
|
||||
#define BT_KEY_KPMINUS 0x56 // Keypad -
|
||||
#define BT_KEY_KPPLUS 0x57 // Keypad +
|
||||
#define BT_KEY_KPENTER 0x58 // Keypad ENTER
|
||||
#define BT_KEY_KP1 0x59 // Keypad 1 and End
|
||||
#define BT_KEY_KP2 0x5a // Keypad 2 and Down Arrow
|
||||
#define BT_KEY_KP3 0x5b // Keypad 3 and PageDn
|
||||
#define BT_KEY_KP4 0x5c // Keypad 4 and Left Arrow
|
||||
#define BT_KEY_KP5 0x5d // Keypad 5
|
||||
#define BT_KEY_KP6 0x5e // Keypad 6 and Right Arrow
|
||||
#define BT_KEY_KP7 0x5f // Keypad 7 and Home
|
||||
#define BT_KEY_KP8 0x60 // Keypad 8 and Up Arrow
|
||||
#define BT_KEY_KP9 0x61 // Keypad 9 and Page Up
|
||||
#define BT_KEY_KP0 0x62 // Keypad 0 and Insert
|
||||
#define BT_KEY_KPDOT 0x63 // Keypad . and Delete
|
||||
|
||||
#define BT_KEY_102ND 0x64 // Keyboard Non-US \ and |
|
||||
#define BT_KEY_COMPOSE 0x65 // Keyboard Application
|
||||
#define BT_KEY_POWER 0x66 // Keyboard Power
|
||||
#define BT_KEY_KPEQUAL 0x67 // Keypad =
|
||||
|
||||
#define BT_KEY_F13 0x68 // Keyboard F13
|
||||
#define BT_KEY_F14 0x69 // Keyboard F14
|
||||
#define BT_KEY_F15 0x6a // Keyboard F15
|
||||
#define BT_KEY_F16 0x6b // Keyboard F16
|
||||
#define BT_KEY_F17 0x6c // Keyboard F17
|
||||
#define BT_KEY_F18 0x6d // Keyboard F18
|
||||
#define BT_KEY_F19 0x6e // Keyboard F19
|
||||
#define BT_KEY_F20 0x6f // Keyboard F20
|
||||
#define BT_KEY_F21 0x70 // Keyboard F21
|
||||
#define BT_KEY_F22 0x71 // Keyboard F22
|
||||
#define BT_KEY_F23 0x72 // Keyboard F23
|
||||
#define BT_KEY_F24 0x73 // Keyboard F24
|
||||
|
||||
#define BT_KEY_OPEN 0x74 // Keyboard Execute
|
||||
#define BT_KEY_HELP 0x75 // Keyboard Help
|
||||
#define BT_KEY_PROPS 0x76 // Keyboard Menu
|
||||
#define BT_KEY_FRONT 0x77 // Keyboard Select
|
||||
#define BT_KEY_STOP 0x78 // Keyboard Stop
|
||||
#define BT_KEY_AGAIN 0x79 // Keyboard Again
|
||||
#define BT_KEY_UNDO 0x7a // Keyboard Undo
|
||||
#define BT_KEY_CUT 0x7b // Keyboard Cut
|
||||
#define BT_KEY_COPY 0x7c // Keyboard Copy
|
||||
#define BT_KEY_PASTE 0x7d // Keyboard Paste
|
||||
#define BT_KEY_FIND 0x7e // Keyboard Find
|
||||
#define BT_KEY_MUTE 0x7f // Keyboard Mute
|
||||
#define BT_KEY_VOLUMEUP 0x80 // Keyboard Volume Up
|
||||
#define BT_KEY_VOLUMEDOWN 0x81 // Keyboard Volume Down
|
||||
// 0x82 Keyboard Locking Caps Lock
|
||||
// 0x83 Keyboard Locking Num Lock
|
||||
// 0x84 Keyboard Locking Scroll Lock
|
||||
#define BT_KEY_KPCOMMA 0x85 // Keypad Comma
|
||||
// 0x86 Keypad Equal Sign
|
||||
#define BT_KEY_RO 0x87 // Keyboard International1
|
||||
#define BT_KEY_KATAKANAHIRAGANA 0x88 // Keyboard International2
|
||||
#define BT_KEY_YEN 0x89 // Keyboard International3
|
||||
#define BT_KEY_HENKAN 0x8a // Keyboard International4
|
||||
#define BT_KEY_MUHENKAN 0x8b // Keyboard International5
|
||||
#define BT_KEY_KPJPCOMMA 0x8c // Keyboard International6
|
||||
// 0x8d Keyboard International7
|
||||
// 0x8e Keyboard International8
|
||||
// 0x8f Keyboard International9
|
||||
#define BT_KEY_HANGEUL 0x90 // Keyboard LANG1
|
||||
#define BT_KEY_HANJA 0x91 // Keyboard LANG2
|
||||
#define BT_KEY_KATAKANA 0x92 // Keyboard LANG3
|
||||
#define BT_KEY_HIRAGANA 0x93 // Keyboard LANG4
|
||||
#define BT_KEY_ZENKAKUHANKAKU 0x94 // Keyboard LANG5
|
||||
// 0x95 Keyboard LANG6
|
||||
// 0x96 Keyboard LANG7
|
||||
// 0x97 Keyboard LANG8
|
||||
// 0x98 Keyboard LANG9
|
||||
// 0x99 Keyboard Alternate Erase
|
||||
// 0x9a Keyboard SysReq/Attention
|
||||
// 0x9b Keyboard Cancel
|
||||
// 0x9c Keyboard Clear
|
||||
// 0x9d Keyboard Prior
|
||||
// 0x9e Keyboard Return
|
||||
// 0x9f Keyboard Separator
|
||||
// 0xa0 Keyboard Out
|
||||
// 0xa1 Keyboard Oper
|
||||
// 0xa2 Keyboard Clear/Again
|
||||
// 0xa3 Keyboard CrSel/Props
|
||||
// 0xa4 Keyboard ExSel
|
||||
|
||||
// 0xb0 Keypad 00
|
||||
// 0xb1 Keypad 000
|
||||
// 0xb2 Thousands Separator
|
||||
// 0xb3 Decimal Separator
|
||||
// 0xb4 Currency Unit
|
||||
// 0xb5 Currency Sub-unit
|
||||
#define BT_KEY_KPLEFTPAREN 0xb6 // Keypad (
|
||||
#define BT_KEY_KPRIGHTPAREN 0xb7 // Keypad )
|
||||
// 0xb8 Keypad {
|
||||
// 0xb9 Keypad }
|
||||
// 0xba Keypad Tab
|
||||
// 0xbb Keypad Backspace
|
||||
// 0xbc Keypad A
|
||||
// 0xbd Keypad B
|
||||
// 0xbe Keypad C
|
||||
// 0xbf Keypad D
|
||||
// 0xc0 Keypad E
|
||||
// 0xc1 Keypad F
|
||||
// 0xc2 Keypad XOR
|
||||
// 0xc3 Keypad ^
|
||||
// 0xc4 Keypad %
|
||||
// 0xc5 Keypad <
|
||||
// 0xc6 Keypad >
|
||||
// 0xc7 Keypad &
|
||||
// 0xc8 Keypad &&
|
||||
// 0xc9 Keypad |
|
||||
// 0xca Keypad ||
|
||||
// 0xcb Keypad :
|
||||
// 0xcc Keypad #
|
||||
// 0xcd Keypad Space
|
||||
// 0xce Keypad @
|
||||
// 0xcf Keypad !
|
||||
// 0xd0 Keypad Memory Store
|
||||
// 0xd1 Keypad Memory Recall
|
||||
// 0xd2 Keypad Memory Clear
|
||||
// 0xd3 Keypad Memory Add
|
||||
// 0xd4 Keypad Memory Subtract
|
||||
// 0xd5 Keypad Memory Multiply
|
||||
// 0xd6 Keypad Memory Divide
|
||||
// 0xd7 Keypad +/-
|
||||
// 0xd8 Keypad Clear
|
||||
// 0xd9 Keypad Clear Entry
|
||||
// 0xda Keypad Binary
|
||||
// 0xdb Keypad Octal
|
||||
// 0xdc Keypad Decimal
|
||||
// 0xdd Keypad Hexadecimal
|
||||
|
||||
#define BT_KEY_LEFTCTRL 0xe0 // Keyboard Left Control
|
||||
#define BT_KEY_LEFTSHIFT 0xe1 // Keyboard Left Shift
|
||||
#define BT_KEY_LEFTALT 0xe2 // Keyboard Left Alt
|
||||
#define BT_KEY_LEFTMETA 0xe3 // Keyboard Left GUI
|
||||
#define BT_KEY_RIGHTCTRL 0xe4 // Keyboard Right Control
|
||||
#define BT_KEY_RIGHTSHIFT 0xe5 // Keyboard Right Shift
|
||||
#define BT_KEY_RIGHTALT 0xe6 // Keyboard Right Alt
|
||||
#define BT_KEY_RIGHTMETA 0xe7 // Keyboard Right GUI
|
||||
|
||||
#define BT_KEY_MEDIA_PLAYPAUSE 0xe8
|
||||
#define BT_KEY_MEDIA_STOPCD 0xe9
|
||||
#define BT_KEY_MEDIA_PREVIOUSSONG 0xea
|
||||
#define BT_KEY_MEDIA_NEXTSONG 0xeb
|
||||
#define BT_KEY_MEDIA_EJECTCD 0xec
|
||||
#define BT_KEY_MEDIA_VOLUMEUP 0xed
|
||||
#define BT_KEY_MEDIA_VOLUMEDOWN 0xee
|
||||
#define BT_KEY_MEDIA_MUTE 0xef
|
||||
#define BT_KEY_MEDIA_WWW 0xf0
|
||||
#define BT_KEY_MEDIA_BACK 0xf1
|
||||
#define BT_KEY_MEDIA_FORWARD 0xf2
|
||||
#define BT_KEY_MEDIA_STOP 0xf3
|
||||
#define BT_KEY_MEDIA_FIND 0xf4
|
||||
#define BT_KEY_MEDIA_SCROLLUP 0xf5
|
||||
#define BT_KEY_MEDIA_SCROLLDOWN 0xf6
|
||||
#define BT_KEY_MEDIA_EDIT 0xf7
|
||||
#define BT_KEY_MEDIA_SLEEP 0xf8
|
||||
#define BT_KEY_MEDIA_COFFEE 0xf9
|
||||
#define BT_KEY_MEDIA_REFRESH 0xfa
|
||||
#define BT_KEY_MEDIA_CALC 0xfb
|
||||
|
||||
// Media key definition. On the ESP module a seperate usage type, CCONTROL is created for media keys and it delivers a 24bit word, each bit signifying a key.
|
||||
#define BT_MEDIA_SEARCH 0x00200000
|
||||
#define BT_MEDIA_HOME 0x00080000
|
||||
#define BT_MEDIA_BRIGHTNESS_UP 0x00004000
|
||||
#define BT_MEDIA_BRIGHTNESS_DOWN 0x00008000
|
||||
#define BT_MEDIA_MUTE 0x00000040
|
||||
#define BT_MEDIA_VOL_DOWN 0x00000020
|
||||
#define BT_MEDIA_VOL_UP 0x00000010
|
||||
#define BT_MEDIA_TRACK_PREV 0x00000001
|
||||
|
||||
// PS2 Flag definitions.
|
||||
#define PS2_FLG_NONE 0x00 // No keys active = 0
|
||||
#define PS2_FLG_SHIFT PS2_SHIFT >> 8 // Shift Key active = 1
|
||||
#define PS2_FLG_CTRL PS2_CTRL >> 8 // Ctrl Key active = 1
|
||||
#define PS2_FLG_CAPS PS2_CAPS >> 8 // CAPS active = 1
|
||||
#define PS2_FLG_ALT PS2_ALT >> 8 // ALT flag used as Right CTRL flag, active = 1
|
||||
#define PS2_FLG_ALTGR PS2_ALT_GR >> 8 // ALTGR active = 1
|
||||
#define PS2_FLG_GUI PS2_GUI >> 8 // GUI Key active = 1
|
||||
#define PS2_FLG_FUNC PS2_FUNCTION >> 8 // Special Function Keys active = 1
|
||||
#define PS2_FLG_BREAK PS2_BREAL >> 8 // BREAK Key active = 1
|
||||
|
||||
|
||||
public:
|
||||
|
||||
struct KeyInfo {
|
||||
uint8_t keys[MAX_KEYBOARD_DATA_BYTES];
|
||||
uint8_t length;
|
||||
bool cControl;
|
||||
esp_hidh_dev_t *hdlDev;
|
||||
};
|
||||
|
||||
// Prototypes.
|
||||
BTHID(void);
|
||||
virtual ~BTHID(void);
|
||||
bool setup(t_pairingHandler *handler);
|
||||
bool openDevice(esp_bd_addr_t bda, esp_hid_transport_t transport, esp_ble_addr_type_t addrType);
|
||||
bool closeDevice(esp_bd_addr_t bda);
|
||||
void checkBTDevices(void);
|
||||
bool setResolution(enum PS2Mouse::PS2_RESOLUTION resolution);
|
||||
bool setScaling(enum PS2Mouse::PS2_SCALING scaling);
|
||||
bool setSampleRate(enum PS2Mouse::PS2_SAMPLING rate);
|
||||
void processBTKeys(void);
|
||||
uint16_t getKey(uint32_t timeout = 0);
|
||||
|
||||
// Method to register an object method for callback with context.
|
||||
template<typename A, typename B>
|
||||
void setMouseDataCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
btHIDCtrl.ms.mouseDataCallback = bind(func_ptr, obj_ptr, 1, std::placeholders::_1);
|
||||
}
|
||||
|
||||
// Template to aid in conversion of an enum to integer.
|
||||
template <typename E> constexpr typename std::underlying_type<E>::type to_underlying(E e) noexcept
|
||||
{
|
||||
return static_cast<typename std::underlying_type<E>::type>(e);
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr char const * TAG = "BTHID";
|
||||
|
||||
// Structure to hold details of an active or post-active connection.
|
||||
typedef struct {
|
||||
esp_bd_addr_t bda;
|
||||
esp_hid_transport_t transport;
|
||||
esp_ble_addr_type_t addrType;
|
||||
esp_hid_usage_t usage;
|
||||
esp_hidh_dev_t *hidhDevHdl;
|
||||
uint32_t nextCheckTime;
|
||||
bool open;
|
||||
} t_activeDev;
|
||||
|
||||
// Structure to encapsulate a single key map from Bluetooth to PS/2.
|
||||
typedef struct {
|
||||
uint8_t btKeyCode;
|
||||
uint16_t btCtrl;
|
||||
uint8_t ps2KeyCode;
|
||||
uint16_t ps2Ctrl;
|
||||
} t_keyMapEntry;
|
||||
|
||||
// Structure to encapsulate the entire static keyboard mapping table.
|
||||
typedef struct {
|
||||
t_keyMapEntry kme[MAX_BT2PS2_MAP_ENTRIES];
|
||||
} t_keyMap;
|
||||
|
||||
// Structure to contain a media key map.
|
||||
typedef struct {
|
||||
uint32_t mediaKey; // 24bit Media key value.
|
||||
uint8_t ps2Key; // Equivalent PS/2 key for media key.
|
||||
uint16_t ps2Ctrl; // PS/2 translated control flags.
|
||||
} t_mediaMapEntry;
|
||||
|
||||
// Structure to encapsulate Media key mappings.
|
||||
typedef struct {
|
||||
t_mediaMapEntry kme[MAX_BTMEDIA2PS2_MAP_ENTRIES];
|
||||
} t_mediaKeyMap;
|
||||
|
||||
// Structure to maintain control variables.
|
||||
typedef struct {
|
||||
// Array of active devices which connect with the SharpKey.
|
||||
std::vector<t_activeDev> devices;
|
||||
|
||||
// Keyboard handling.
|
||||
struct {
|
||||
// Queues for storing data in the 2 processing stages.
|
||||
xQueueHandle rawKeyQueue;
|
||||
xQueueHandle keyQueue;
|
||||
|
||||
uint8_t lastKeys[MAX_KEYBOARD_DATA_BYTES]; // Required to generate a PS/2 break event when a key is released.
|
||||
uint32_t lastMediaKey; // Required to detect changes in the media control keys, ie. release.
|
||||
uint16_t btFlags; // Bluetooth control flags.
|
||||
uint16_t ps2Flags; // PS/2 translated control flags.
|
||||
uint8_t statusLED; // Keyboard LED state.
|
||||
t_keyMapEntry *kme; // Pointer to the mapping array.
|
||||
t_mediaMapEntry *kmeMedia; // Pointer to the media key mapping array.
|
||||
int kmeRows; // Number of entries in the BT to PS/2 mapping table.
|
||||
int kmeMediaRows; // Number of entries in the BT to PS/2 media key mapping table.
|
||||
} kbd;
|
||||
|
||||
// Mouse handling.
|
||||
struct {
|
||||
int resolution; // PS/2 compatible resolution (pixels per mm) setting.
|
||||
int scaling; // PS/2 compatible scaling (1:1 or 2:1).
|
||||
int sampleRate; // PS/2 compatible sample rate (10 .. 200).
|
||||
int xDivisor; // Divisor on the X plane to scale down the 12bit BT resolution.
|
||||
int yDivisor; // Divisor on the Y plane to scale down the 12bit BT resolution.
|
||||
|
||||
// Callback for streaming processed mouse data to HID handler.
|
||||
std::function<void(PS2Mouse::MouseData)> mouseDataCallback;
|
||||
} ms;
|
||||
|
||||
BTHID *pThis;
|
||||
} t_btHIDCtrl;
|
||||
|
||||
// All control variables are stored in a struct for ease of reference.
|
||||
t_btHIDCtrl btHIDCtrl;
|
||||
|
||||
// Prototypes.
|
||||
static void hidh_callback(void * handler_args, esp_event_base_t base, int32_t id, void * event_data);
|
||||
void pushKeyToFIFO(esp_hid_usage_t src, esp_hidh_dev_t *hdlDev, uint8_t *keys, uint8_t size);
|
||||
void setStatusLED(esp_hidh_dev_t *dev, uint8_t led);
|
||||
void clearStatusLED(esp_hidh_dev_t *dev, uint8_t led);
|
||||
uint16_t mapBTMediaToPS2(uint32_t key);
|
||||
uint16_t mapBTtoPS2(uint8_t key);
|
||||
inline uint32_t milliSeconds(void)
|
||||
{
|
||||
return( (uint32_t) (clock() ) );
|
||||
}
|
||||
|
||||
// Mapping for Media keys. ESP module seperates them but not properly, some media keys are sent as normal key scancodes others as control key bit maps.
|
||||
// Hence two mapping tables, one for normal scancodes and one for media codes.
|
||||
t_mediaKeyMap MediaKeyToPS2 = {
|
||||
{
|
||||
{ BT_MEDIA_SEARCH, PS2_KEY_WEB_SEARCH, PS2_FLG_NONE, },
|
||||
{ BT_MEDIA_HOME, PS2_KEY_WEB_HOME, PS2_FLG_NONE, },
|
||||
{ BT_MEDIA_BRIGHTNESS_UP, PS2_KEY_WEB_FORWARD, PS2_FLG_NONE, },
|
||||
{ BT_MEDIA_BRIGHTNESS_DOWN, PS2_KEY_WEB_BACK, PS2_FLG_NONE, },
|
||||
{ BT_MEDIA_MUTE, PS2_KEY_MUTE, PS2_FLG_NONE, },
|
||||
{ BT_MEDIA_VOL_DOWN, PS2_KEY_VOL_DN, PS2_FLG_NONE, },
|
||||
{ BT_MEDIA_VOL_UP, PS2_KEY_VOL_UP, PS2_FLG_NONE, },
|
||||
{ BT_MEDIA_TRACK_PREV, PS2_KEY_PREV_TR, PS2_FLG_NONE, },
|
||||
}};
|
||||
|
||||
// Mapping table between BT Keyboard Scan Codes and PS/2 Keyboard Scan Codes.
|
||||
//
|
||||
t_keyMap BTKeyToPS2 = {
|
||||
{
|
||||
// Bluetooth Key Bluetooth Control, PS/2 Key PS/2 Control,
|
||||
{ BT_KEY_A, BT_NONE, PS2_KEY_A, PS2_FLG_NONE, },
|
||||
{ BT_KEY_B, BT_NONE, PS2_KEY_B, PS2_FLG_NONE, },
|
||||
{ BT_KEY_C, BT_NONE, PS2_KEY_C, PS2_FLG_NONE, },
|
||||
{ BT_KEY_D, BT_NONE, PS2_KEY_D, PS2_FLG_NONE, },
|
||||
{ BT_KEY_E, BT_NONE, PS2_KEY_E, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F, BT_NONE, PS2_KEY_F, PS2_FLG_NONE, },
|
||||
{ BT_KEY_G, BT_NONE, PS2_KEY_G, PS2_FLG_NONE, },
|
||||
{ BT_KEY_H, BT_NONE, PS2_KEY_H, PS2_FLG_NONE, },
|
||||
{ BT_KEY_I, BT_NONE, PS2_KEY_I, PS2_FLG_NONE, },
|
||||
{ BT_KEY_J, BT_NONE, PS2_KEY_J, PS2_FLG_NONE, },
|
||||
{ BT_KEY_K, BT_NONE, PS2_KEY_K, PS2_FLG_NONE, },
|
||||
{ BT_KEY_L, BT_NONE, PS2_KEY_L, PS2_FLG_NONE, },
|
||||
{ BT_KEY_M, BT_NONE, PS2_KEY_M, PS2_FLG_NONE, },
|
||||
{ BT_KEY_N, BT_NONE, PS2_KEY_N, PS2_FLG_NONE, },
|
||||
{ BT_KEY_O, BT_NONE, PS2_KEY_O, PS2_FLG_NONE, },
|
||||
{ BT_KEY_P, BT_NONE, PS2_KEY_P, PS2_FLG_NONE, },
|
||||
{ BT_KEY_Q, BT_NONE, PS2_KEY_Q, PS2_FLG_NONE, },
|
||||
{ BT_KEY_R, BT_NONE, PS2_KEY_R, PS2_FLG_NONE, },
|
||||
{ BT_KEY_S, BT_NONE, PS2_KEY_S, PS2_FLG_NONE, },
|
||||
{ BT_KEY_T, BT_NONE, PS2_KEY_T, PS2_FLG_NONE, },
|
||||
{ BT_KEY_U, BT_NONE, PS2_KEY_U, PS2_FLG_NONE, },
|
||||
{ BT_KEY_V, BT_NONE, PS2_KEY_V, PS2_FLG_NONE, },
|
||||
{ BT_KEY_W, BT_NONE, PS2_KEY_W, PS2_FLG_NONE, },
|
||||
{ BT_KEY_X, BT_NONE, PS2_KEY_X, PS2_FLG_NONE, },
|
||||
{ BT_KEY_Y, BT_NONE, PS2_KEY_Y, PS2_FLG_NONE, },
|
||||
{ BT_KEY_Z, BT_NONE, PS2_KEY_Z, PS2_FLG_NONE, },
|
||||
{ BT_KEY_1, BT_NONE, PS2_KEY_1, PS2_FLG_NONE, },
|
||||
{ BT_KEY_2, BT_NONE, PS2_KEY_2, PS2_FLG_NONE, },
|
||||
{ BT_KEY_3, BT_NONE, PS2_KEY_3, PS2_FLG_NONE, },
|
||||
{ BT_KEY_4, BT_NONE, PS2_KEY_4, PS2_FLG_NONE, },
|
||||
{ BT_KEY_5, BT_NONE, PS2_KEY_5, PS2_FLG_NONE, },
|
||||
{ BT_KEY_6, BT_NONE, PS2_KEY_6, PS2_FLG_NONE, },
|
||||
{ BT_KEY_7, BT_NONE, PS2_KEY_7, PS2_FLG_NONE, },
|
||||
{ BT_KEY_8, BT_NONE, PS2_KEY_8, PS2_FLG_NONE, },
|
||||
{ BT_KEY_9, BT_NONE, PS2_KEY_9, PS2_FLG_NONE, },
|
||||
{ BT_KEY_0, BT_NONE, PS2_KEY_0, PS2_FLG_NONE, },
|
||||
{ BT_KEY_ENTER, BT_NONE, PS2_KEY_ENTER, PS2_FLG_NONE, },
|
||||
{ BT_KEY_ESC, BT_NONE, PS2_KEY_ESC, PS2_FLG_NONE, },
|
||||
{ BT_KEY_BACKSPACE, BT_NONE, PS2_KEY_BS, PS2_FLG_NONE, },
|
||||
{ BT_KEY_TAB, BT_NONE, PS2_KEY_TAB, PS2_FLG_NONE, },
|
||||
{ BT_KEY_SPACE, BT_NONE, PS2_KEY_SPACE, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MINUS, BT_NONE, PS2_KEY_MINUS, PS2_FLG_NONE, },
|
||||
{ BT_KEY_EQUAL, BT_NONE, PS2_KEY_EQUAL, PS2_FLG_NONE, },
|
||||
{ BT_KEY_LEFTBRACE, BT_NONE, PS2_KEY_OPEN_SQ, PS2_FLG_NONE, },
|
||||
{ BT_KEY_RIGHTBRACE, BT_NONE, PS2_KEY_CLOSE_SQ, PS2_FLG_NONE, },
|
||||
{ BT_KEY_BACKSLASH, BT_NONE, PS2_KEY_BACK, PS2_FLG_NONE, },
|
||||
{ BT_KEY_HASHTILDE, BT_NONE, PS2_KEY_HASH, PS2_FLG_NONE, },
|
||||
{ BT_KEY_SEMICOLON, BT_NONE, PS2_KEY_SEMI, PS2_FLG_NONE, },
|
||||
{ BT_KEY_APOSTROPHE, BT_NONE, PS2_KEY_APOS, PS2_FLG_NONE, },
|
||||
{ BT_KEY_GRAVE, BT_NONE, PS2_KEY_BTICK, PS2_FLG_NONE, },
|
||||
{ BT_KEY_COMMA, BT_NONE, PS2_KEY_COMMA, PS2_FLG_NONE, },
|
||||
{ BT_KEY_DOT, BT_NONE, PS2_KEY_DOT, PS2_FLG_NONE, },
|
||||
{ BT_KEY_SLASH, BT_NONE, PS2_KEY_DIV, PS2_FLG_NONE, },
|
||||
{ BT_KEY_CAPSLOCK, BT_NONE, PS2_KEY_CAPS, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F1, BT_NONE, PS2_KEY_F1, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F2, BT_NONE, PS2_KEY_F2, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F3, BT_NONE, PS2_KEY_F3, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F4, BT_NONE, PS2_KEY_F4, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F5, BT_NONE, PS2_KEY_F5, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F6, BT_NONE, PS2_KEY_F6, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F7, BT_NONE, PS2_KEY_F7, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F8, BT_NONE, PS2_KEY_F8, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F9, BT_NONE, PS2_KEY_F9, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F10, BT_NONE, PS2_KEY_F10, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F11, BT_NONE, PS2_KEY_F11, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F12, BT_NONE, PS2_KEY_F12, PS2_FLG_NONE, },
|
||||
{ BT_KEY_SYSRQ, BT_NONE, PS2_KEY_PRTSCR, PS2_FLG_NONE, },
|
||||
{ BT_KEY_SCROLLLOCK, BT_NONE, PS2_KEY_SCROLL, PS2_FLG_NONE, },
|
||||
{ BT_KEY_PAUSE, BT_NONE, PS2_KEY_PAUSE, PS2_FLG_NONE, },
|
||||
{ BT_KEY_INSERT, BT_NONE, PS2_KEY_INSERT, PS2_FLG_NONE, },
|
||||
{ BT_KEY_HOME, BT_NONE, PS2_KEY_HOME, PS2_FLG_NONE, },
|
||||
{ BT_KEY_PAGEUP, BT_NONE, PS2_KEY_PGUP, PS2_FLG_NONE, },
|
||||
{ BT_KEY_DELETE, BT_NONE, PS2_KEY_DELETE, PS2_FLG_NONE, },
|
||||
{ BT_KEY_END, BT_NONE, PS2_KEY_END, PS2_FLG_NONE, },
|
||||
{ BT_KEY_PAGEDOWN, BT_NONE, PS2_KEY_PGDN, PS2_FLG_NONE, },
|
||||
{ BT_KEY_RIGHT, BT_NONE, PS2_KEY_R_ARROW, PS2_FLG_NONE, },
|
||||
{ BT_KEY_LEFT, BT_NONE, PS2_KEY_L_ARROW, PS2_FLG_NONE, },
|
||||
{ BT_KEY_DOWN, BT_NONE, PS2_KEY_DN_ARROW, PS2_FLG_NONE, },
|
||||
{ BT_KEY_UP, BT_NONE, PS2_KEY_UP_ARROW, PS2_FLG_NONE, },
|
||||
{ BT_KEY_NUMLOCK, BT_NONE, PS2_KEY_NUM, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPSLASH, BT_NONE, PS2_KEY_KP_DIV, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPASTERISK, BT_NONE, PS2_KEY_KP_TIMES, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPMINUS, BT_NONE, PS2_KEY_KP_MINUS, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPPLUS, BT_NONE, PS2_KEY_KP_PLUS, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPENTER, BT_NONE, PS2_KEY_KP_ENTER, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP1, BT_NUM_LOCK, PS2_KEY_KP1, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP2, BT_NUM_LOCK, PS2_KEY_KP2, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP3, BT_NUM_LOCK, PS2_KEY_KP3, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP4, BT_NUM_LOCK, PS2_KEY_KP4, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP5, BT_NUM_LOCK, PS2_KEY_KP5, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP6, BT_NUM_LOCK, PS2_KEY_KP6, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP7, BT_NUM_LOCK, PS2_KEY_KP7, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP8, BT_NUM_LOCK, PS2_KEY_KP8, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP9, BT_NUM_LOCK, PS2_KEY_KP9, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP0, BT_NUM_LOCK, PS2_KEY_KP0, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPDOT, BT_NUM_LOCK, PS2_KEY_KP_DOT, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP1, BT_NONE, PS2_KEY_END, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP2, BT_NONE, PS2_KEY_DN_ARROW, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP3, BT_NONE, PS2_KEY_PGDN, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP4, BT_NONE, PS2_KEY_L_ARROW, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP5, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP6, BT_NONE, PS2_KEY_R_ARROW, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP7, BT_NONE, PS2_KEY_HOME, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP8, BT_NONE, PS2_KEY_UP_ARROW, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP9, BT_NONE, PS2_KEY_PGUP, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KP0, BT_NONE, PS2_KEY_INSERT, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPDOT, BT_NONE, PS2_KEY_DELETE, PS2_FLG_NONE, },
|
||||
{ BT_KEY_102ND, BT_NONE, PS2_KEY_BACK, PS2_FLG_NONE, },
|
||||
{ BT_KEY_COMPOSE, BT_NONE, PS2_KEY_MENU, PS2_FLG_NONE, },
|
||||
{ BT_KEY_POWER, BT_NONE, PS2_KEY_POWER, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPEQUAL, BT_NONE, PS2_KEY_KP_EQUAL, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F13, BT_NONE, PS2_KEY_F13, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F14, BT_NONE, PS2_KEY_F14, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F15, BT_NONE, PS2_KEY_F15, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F16, BT_NONE, PS2_KEY_F16, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F17, BT_NONE, PS2_KEY_F17, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F18, BT_NONE, PS2_KEY_F18, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F19, BT_NONE, PS2_KEY_F19, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F20, BT_NONE, PS2_KEY_F20, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F21, BT_NONE, PS2_KEY_F21, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F22, BT_NONE, PS2_KEY_F22, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F23, BT_NONE, PS2_KEY_F23, PS2_FLG_NONE, },
|
||||
{ BT_KEY_F24, BT_NONE, PS2_KEY_F24, PS2_FLG_NONE, },
|
||||
{ BT_KEY_OPEN, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_HELP, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_PROPS, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_FRONT, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_STOP, BT_NONE, PS2_KEY_STOP, PS2_FLG_NONE, },
|
||||
{ BT_KEY_AGAIN, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_UNDO, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_CUT, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_COPY, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_PASTE, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_FIND, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MUTE, BT_NONE, PS2_KEY_MUTE, PS2_FLG_NONE, },
|
||||
{ BT_KEY_VOLUMEUP, BT_NONE, PS2_KEY_VOL_UP, PS2_FLG_NONE, },
|
||||
{ BT_KEY_VOLUMEDOWN, BT_NONE, PS2_KEY_VOL_DN, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPCOMMA, BT_NONE, PS2_KEY_KP_COMMA, PS2_FLG_NONE, },
|
||||
{ BT_KEY_RO, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KATAKANAHIRAGANA, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_YEN, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_HENKAN, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MUHENKAN, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPJPCOMMA, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_HANGEUL, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_HANJA, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KATAKANA, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_HIRAGANA, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_ZENKAKUHANKAKU, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPLEFTPAREN, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_KPRIGHTPAREN, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
// Control keys.
|
||||
{ BT_KEY_LEFTCTRL, BT_NONE, PS2_KEY_L_CTRL, PS2_FLG_FUNC | PS2_FLG_CTRL, },
|
||||
{ BT_KEY_LEFTSHIFT, BT_NONE, PS2_KEY_L_SHIFT, PS2_FLG_FUNC | PS2_FLG_SHIFT, },
|
||||
{ BT_KEY_LEFTALT, BT_NONE, PS2_KEY_L_ALT, PS2_FLG_FUNC | PS2_FLG_ALT, },
|
||||
{ BT_KEY_LEFTMETA, BT_NONE, PS2_KEY_L_GUI, PS2_FLG_FUNC | PS2_FLG_GUI, },
|
||||
{ BT_KEY_RIGHTCTRL, BT_NONE, PS2_KEY_R_CTRL, PS2_FLG_FUNC | PS2_FLG_CTRL, },
|
||||
{ BT_KEY_RIGHTSHIFT, BT_NONE, PS2_KEY_R_SHIFT, PS2_FLG_FUNC | PS2_FLG_SHIFT, },
|
||||
{ BT_KEY_RIGHTALT, BT_NONE, PS2_KEY_R_ALT, PS2_FLG_FUNC | PS2_FLG_ALTGR, },
|
||||
{ BT_KEY_RIGHTMETA, BT_NONE, PS2_KEY_R_GUI, PS2_FLG_FUNC | PS2_FLG_NONE, },
|
||||
// Media keys
|
||||
{ BT_KEY_MEDIA_PLAYPAUSE, BT_NONE, PS2_KEY_PLAY, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_STOPCD, BT_NONE, PS2_KEY_STOP, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_PREVIOUSSONG, BT_NONE, PS2_KEY_PREV_TR, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_NEXTSONG, BT_NONE, PS2_KEY_NEXT_TR, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_EJECTCD, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_VOLUMEUP, BT_NONE, PS2_KEY_VOL_UP, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_VOLUMEDOWN, BT_NONE, PS2_KEY_VOL_DN, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_MUTE, BT_NONE, PS2_KEY_MUTE, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_WWW, BT_NONE, PS2_KEY_WEB_SEARCH, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_BACK, BT_NONE, PS2_KEY_WEB_BACK, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_FORWARD, BT_NONE, PS2_KEY_WEB_FORWARD, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_STOP, BT_NONE, PS2_KEY_WEB_STOP, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_FIND, BT_NONE, PS2_KEY_WEB_SEARCH, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_SCROLLUP, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_SCROLLDOWN, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_EDIT, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_SLEEP, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_COFFEE, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_REFRESH, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
{ BT_KEY_MEDIA_CALC, BT_NONE, 0x00, PS2_FLG_NONE, },
|
||||
}};
|
||||
};
|
||||
|
||||
#endif // BT_KEYBOARD_H_
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/HID.h
|
||||
385
main/include/HID.h
Normal file
385
main/include/HID.h
Normal file
@@ -0,0 +1,385 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: HID.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: A HID Class definition, used to instantiate differing input device classes and
|
||||
// present a standard API.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
// v1.02 Jun 2022 - Updates to support Bluetooth keyboard and mouse. The mouse can be
|
||||
// a primary device or a secondary device for hosts which support
|
||||
// keyboard and mouse over one physical port.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef HID_H
|
||||
#define HID_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "driver/timer.h"
|
||||
#include "PS2KeyAdvanced.h"
|
||||
#include "PS2Mouse.h"
|
||||
#include "BTHID.h"
|
||||
#include "LED.h"
|
||||
#include "SWITCH.h"
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Define a class which acts as the encapsulation object of many base classes which provide input device functionality.
|
||||
class HID {
|
||||
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define HID_VERSION 1.02
|
||||
#define HID_MOUSE_DATA_POLL_DELAY 10
|
||||
#define MAX_MOUSE_INACTIVITY_TIME 500 * HID_MOUSE_DATA_POLL_DELAY
|
||||
|
||||
// Categories of configuration possible with the mouse. These are used primarily with the web based UI for rendering selection choices.
|
||||
#define HID_MOUSE_HOST_SCALING_TYPE "host_scaling"
|
||||
#define HID_MOUSE_SCALING_TYPE "mouse_scaling"
|
||||
#define HID_MOUSE_RESOLUTION_TYPE "mouse_resolution"
|
||||
#define HID_MOUSE_SAMPLING_TYPE "mouse_sampling"
|
||||
|
||||
#define HID_MOUSE_HOST_SCALING_1_1_NAME "1:1"
|
||||
#define HID_MOUSE_HOST_SCALING_1_2_NAME "1:2"
|
||||
#define HID_MOUSE_HOST_SCALING_1_3_NAME "1:3"
|
||||
#define HID_MOUSE_HOST_SCALING_1_4_NAME "1:4"
|
||||
#define HID_MOUSE_HOST_SCALING_1_5_NAME "1:5"
|
||||
|
||||
// Names for the configuration value settings.
|
||||
#define HID_MOUSE_RESOLUTION_1_1_NAME "1 c/mm"
|
||||
#define HID_MOUSE_RESOLUTION_1_2_NAME "2 c/mm"
|
||||
#define HID_MOUSE_RESOLUTION_1_4_NAME "4 c/mm"
|
||||
#define HID_MOUSE_RESOLUTION_1_8_NAME "8 c/mm"
|
||||
#define HID_MOUSE_SCALING_1_1_NAME "1:1"
|
||||
#define HID_MOUSE_SCALING_2_1_NAME "2:1"
|
||||
#define HID_MOUSE_SAMPLE_RATE_10_NAME "10 S/s"
|
||||
#define HID_MOUSE_SAMPLE_RATE_20_NAME "20 S/s"
|
||||
#define HID_MOUSE_SAMPLE_RATE_40_NAME "40 S/s"
|
||||
#define HID_MOUSE_SAMPLE_RATE_60_NAME "60 S/s"
|
||||
#define HID_MOUSE_SAMPLE_RATE_80_NAME "80 S/s"
|
||||
#define HID_MOUSE_SAMPLE_RATE_100_NAME "100 S/s"
|
||||
#define HID_MOUSE_SAMPLE_RATE_200_NAME "200 S/s"
|
||||
|
||||
public:
|
||||
// Types of devices the HID class can support.
|
||||
enum HID_DEVICE_TYPES {
|
||||
HID_DEVICE_TYPE_KEYBOARD = 0x00,
|
||||
HID_DEVICE_TYPE_MOUSE = 0x01,
|
||||
HID_DEVICE_TYPE_BLUETOOTH = 0x02,
|
||||
};
|
||||
|
||||
// HID class can encapsulate many input device objects, only one at a time though. On startup the device is enumerated and then all
|
||||
// functionality serves the device object.
|
||||
enum HID_INPUT_DEVICE {
|
||||
HID_DEVICE_PS2_KEYBOARD = 0x00,
|
||||
HID_DEVICE_PS2_MOUSE = 0x01,
|
||||
HID_DEVICE_BLUETOOTH = 0x02,
|
||||
HID_DEVICE_BT_KEYBOARD = 0x03,
|
||||
HID_DEVICE_BT_MOUSE = 0x04
|
||||
};
|
||||
|
||||
// Scaling - The host receiving mouse data may have a different resolution to that of the mouse, so we use configurable host side scaling to compensate. The mouse data received
|
||||
// is scaled according to the enum setting.
|
||||
enum HID_MOUSE_HOST_SCALING {
|
||||
HID_MOUSE_HOST_SCALING_1_1 = 0x00,
|
||||
HID_MOUSE_HOST_SCALING_1_2 = 0x01,
|
||||
HID_MOUSE_HOST_SCALING_1_3 = 0x02,
|
||||
HID_MOUSE_HOST_SCALING_1_4 = 0x03,
|
||||
HID_MOUSE_HOST_SCALING_1_5 = 0x04,
|
||||
};
|
||||
|
||||
// Resolution - the mouse can digitize movement from 1mm to 1/8mm, the default being 1/4 (ie. 1mm = 4 counts). This allows configuration for a finer or rougher
|
||||
// tracking digitisation.
|
||||
enum HID_MOUSE_RESOLUTION {
|
||||
HID_MOUSE_RESOLUTION_1_1 = PS2Mouse::PS2_MOUSE_RESOLUTION_1_1,
|
||||
HID_MOUSE_RESOLUTION_1_2 = PS2Mouse::PS2_MOUSE_RESOLUTION_1_2,
|
||||
HID_MOUSE_RESOLUTION_1_4 = PS2Mouse::PS2_MOUSE_RESOLUTION_1_4,
|
||||
HID_MOUSE_RESOLUTION_1_8 = PS2Mouse::PS2_MOUSE_RESOLUTION_1_8,
|
||||
};
|
||||
|
||||
// Scaling - the mouse can provide linear (1:1 no scaling) or non liner (2:1 scaling) adaptation of the digitised data. This allows configuration for amplification of movements.
|
||||
enum HID_MOUSE_SCALING {
|
||||
HID_MOUSE_SCALING_1_1 = PS2Mouse::PS2_MOUSE_SCALING_1_1,
|
||||
HID_MOUSE_SCALING_2_1 = PS2Mouse::PS2_MOUSE_SCALING_2_1,
|
||||
};
|
||||
|
||||
// Sampling rate - the mouse, in streaming mode, the mouse sends with movement updates. This allows for finer or rougher digitisation of movements. The default is 100 samples per
|
||||
// second and the X68000 is fixed at 100 samples per second.
|
||||
enum HID_MOUSE_SAMPLING {
|
||||
HID_MOUSE_SAMPLE_RATE_10 = PS2Mouse::PS2_MOUSE_SAMPLE_RATE_10,
|
||||
HID_MOUSE_SAMPLE_RATE_20 = PS2Mouse::PS2_MOUSE_SAMPLE_RATE_20,
|
||||
HID_MOUSE_SAMPLE_RATE_40 = PS2Mouse::PS2_MOUSE_SAMPLE_RATE_40,
|
||||
HID_MOUSE_SAMPLE_RATE_60 = PS2Mouse::PS2_MOUSE_SAMPLE_RATE_60,
|
||||
HID_MOUSE_SAMPLE_RATE_80 = PS2Mouse::PS2_MOUSE_SAMPLE_RATE_80,
|
||||
HID_MOUSE_SAMPLE_RATE_100 = PS2Mouse::PS2_MOUSE_SAMPLE_RATE_100,
|
||||
HID_MOUSE_SAMPLE_RATE_200 = PS2Mouse::PS2_MOUSE_SAMPLE_RATE_200,
|
||||
};
|
||||
|
||||
// Suspend flag. When active, the interface components enter an idle state after completing there latest cycle.
|
||||
bool suspend = false;
|
||||
bool suspended = true;
|
||||
|
||||
// Element to store mouse data in a queue. The data is actual mouse movements, any control data and private data for the actual mouse is stripped.
|
||||
typedef struct {
|
||||
int16_t xPos;
|
||||
int16_t yPos;
|
||||
uint8_t status;
|
||||
uint8_t wheel;
|
||||
} t_mouseMessageElement;
|
||||
|
||||
// Prototypes.
|
||||
HID(enum HID_DEVICE_TYPES, NVS *hdlNVS, LED *hdlLED, SWITCH *hdlSWITCH);
|
||||
HID(NVS *hdlNVS);
|
||||
HID(void);
|
||||
virtual ~HID(void);
|
||||
bool isBluetooth(void);
|
||||
void enableBluetooth(void);
|
||||
void disableBluetooth(void);
|
||||
bool isSuspended(bool waitForSuspend);
|
||||
void suspendInterface(bool suspendIf);
|
||||
bool persistConfig(void);
|
||||
uint16_t read(void);
|
||||
void setMouseResolution(enum HID_MOUSE_RESOLUTION resolution);
|
||||
void setMouseHostScaling(enum HID_MOUSE_HOST_SCALING scaling);
|
||||
void setMouseScaling(enum HID_MOUSE_SCALING scaling);
|
||||
void setMouseSampleRate(enum HID_MOUSE_SAMPLING sampleRate);
|
||||
void btStartPairing(void);
|
||||
void btCancelPairing(void);
|
||||
|
||||
|
||||
// Method to register an object method for callback with context.
|
||||
template<typename A, typename B>
|
||||
void setDataCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
hidCtrl.dataCallback = bind(func_ptr, obj_ptr, std::placeholders::_1);
|
||||
}
|
||||
|
||||
// Method to suspend input device activity, yielding to the OS until suspend is cleared.
|
||||
inline virtual void yield(uint32_t delay)
|
||||
{
|
||||
// If suspended, go into a permanent loop until the suspend flag is reset.
|
||||
if(this->suspend)
|
||||
{
|
||||
// Suspend the keyboard interface.
|
||||
if(hidCtrl.deviceType == HID_DEVICE_TYPE_KEYBOARD) { printf("SUSPEND\n"); ps2Keyboard->suspend(true); }
|
||||
this->suspended = true;
|
||||
|
||||
// Sleep while suspended.
|
||||
while(this->suspend)
|
||||
{
|
||||
vTaskDelay(100);
|
||||
}
|
||||
|
||||
// Release the keyboard interface.
|
||||
if(hidCtrl.deviceType == HID_DEVICE_TYPE_KEYBOARD) ps2Keyboard->suspend(false);
|
||||
this->suspended = false;
|
||||
} else
|
||||
// Otherwise just delay by the required amount for timing and to give other threads a time slice.
|
||||
{
|
||||
vTaskDelay(delay);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Method to see if the interface must enter suspend mode.
|
||||
//
|
||||
inline virtual bool suspendRequested(void)
|
||||
{
|
||||
return(this->suspend);
|
||||
}
|
||||
|
||||
// Helper method to identify the sub class, this is used in non volatile key management.
|
||||
// Warning: This method wont work if optimisation for size is enabled on the compiler.
|
||||
const char *getClassName(const std::string& prettyFunction)
|
||||
{
|
||||
// First find the CLASS :: METHOD seperation.
|
||||
size_t colons = prettyFunction.find("::");
|
||||
|
||||
// None, then this is not a class.
|
||||
if (colons == std::string::npos)
|
||||
return "::";
|
||||
|
||||
// Split out the class name.
|
||||
size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
|
||||
size_t end = colons - begin;
|
||||
|
||||
// Return the name.
|
||||
return(prettyFunction.substr(begin,end).c_str());
|
||||
}
|
||||
|
||||
// Template to aid in conversion of an enum to integer.
|
||||
template <typename E> constexpr typename std::underlying_type<E>::type to_underlying(E e) noexcept
|
||||
{
|
||||
return static_cast<typename std::underlying_type<E>::type>(e);
|
||||
}
|
||||
|
||||
// Method to return the class version number.
|
||||
virtual float version(void)
|
||||
{
|
||||
return(HID_VERSION);
|
||||
}
|
||||
|
||||
// Method to return the name of this class.
|
||||
virtual std::string ifName(void)
|
||||
{
|
||||
return(className);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
void init(const char *className, enum HID_DEVICE_TYPES deviceTypes);
|
||||
bool nvsPersistData(const char *key, void *pData, uint32_t size);
|
||||
bool nvsRetrieveData(const char *key, void *pData, uint32_t size);
|
||||
bool nvsCommitData(void);
|
||||
void checkKeyboard( void );
|
||||
bool checkPS2Keyboard( void );
|
||||
bool checkPS2Mouse( void );
|
||||
void checkMouse( void );
|
||||
void processPS2Mouse( void );
|
||||
void checkBTMouse( void );
|
||||
void mouseReceiveData(uint8_t src, PS2Mouse::MouseData mouseData);
|
||||
IRAM_ATTR static void hidControl( void * pvParameters );
|
||||
static void btPairingHandler(uint32_t pid, uint8_t trigger);
|
||||
inline uint32_t milliSeconds(void)
|
||||
{
|
||||
return( (uint32_t) (clock() ) );
|
||||
}
|
||||
|
||||
|
||||
enum HOST_CONFIG_MODES {
|
||||
HOST_CONFIG_OFF = 0x00,
|
||||
HOST_CONFIG_SCALING = 0x01,
|
||||
HOST_CONFIG_RESOLUTION = 0x02,
|
||||
};
|
||||
|
||||
// Structure to maintain configuration for the HID.
|
||||
//
|
||||
typedef struct {
|
||||
|
||||
struct {
|
||||
// Mouse data Adjustment and filtering options.
|
||||
//
|
||||
enum HID_MOUSE_RESOLUTION resolution;
|
||||
enum HID_MOUSE_SCALING scaling;
|
||||
enum HID_MOUSE_SAMPLING sampleRate;
|
||||
} mouse;
|
||||
|
||||
struct {
|
||||
// Host data for adjustment and configuration.
|
||||
enum HID_MOUSE_HOST_SCALING scaling;
|
||||
} host;
|
||||
|
||||
struct {
|
||||
// Configuration mode time period used to select configuration option. Once the middle key is held, the configuration option starts at 1, after this number of seconds
|
||||
// the configuration option advances to the next configuration item, and so on...
|
||||
uint16_t optionAdvanceDelay;
|
||||
} params;
|
||||
|
||||
} t_hidConfig;
|
||||
|
||||
// Structure to maintain an active settings for HID devices.
|
||||
typedef struct {
|
||||
enum HID_INPUT_DEVICE hidDevice; // Active HID device, only one can be active.
|
||||
enum HID_DEVICE_TYPES deviceType; // Type of device which is active.
|
||||
bool ps2Active; // Flag to indicate PS/2 device is online and active.
|
||||
uint32_t noEchoCount = 0L; // Echo back counter, used for testing if a keyboard is online.
|
||||
TickType_t ps2CheckTimer = 0; // Check timer, used for timing periodic keyboard checks.
|
||||
|
||||
// Mouse control variables.
|
||||
uint32_t noValidMouseMessage = 0;
|
||||
int wheelCnt = 0;
|
||||
uint32_t loopTimer = 0;
|
||||
bool middleKeyPressed = false;
|
||||
PS2Mouse::MouseData mouseData;
|
||||
|
||||
// Flag to indicate the mouse is active and online.
|
||||
bool active;
|
||||
|
||||
// Flag to indicate the configuration data has been updated.
|
||||
bool updated;
|
||||
|
||||
// Configuration mode selected when middle button pressed.
|
||||
enum HOST_CONFIG_MODES configMode;
|
||||
|
||||
// Mutex to block access during maintenance tasks.
|
||||
SemaphoreHandle_t mutexInternal;
|
||||
|
||||
// Callback for streaming input devices with data to be processed.
|
||||
std::function<void(t_mouseMessageElement)> dataCallback;
|
||||
} t_hidControl;
|
||||
|
||||
// Current configuration of the HID.
|
||||
t_hidConfig hidConfig;
|
||||
|
||||
// Variables to control the HID.
|
||||
t_hidControl hidCtrl;
|
||||
|
||||
// Handle to the persistent storage api.
|
||||
nvs_handle_t nvsHandle;
|
||||
|
||||
// Name of this class, used for NVS access.
|
||||
std::string className;
|
||||
|
||||
// NVS persistence object.
|
||||
NVS *nvs;
|
||||
|
||||
// LED activity object handle.
|
||||
LED *led;
|
||||
|
||||
// SWITCH object handle.
|
||||
SWITCH *sw;
|
||||
|
||||
// Keyboard object for PS/2 data retrieval and management.
|
||||
PS2KeyAdvanced *ps2Keyboard;
|
||||
|
||||
// Keyboard object for Bluetooth data retrieval and management.
|
||||
BTHID *btHID;
|
||||
|
||||
// Mouse object for PS/2 data retrieval and management.
|
||||
PS2Mouse *ps2Mouse;
|
||||
|
||||
// Thread handle for the HID control thread.
|
||||
TaskHandle_t TaskHID = NULL;
|
||||
};
|
||||
#endif // HID_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/KeyInterface.h
|
||||
203
main/include/KeyInterface.h
Normal file
203
main/include/KeyInterface.h
Normal file
@@ -0,0 +1,203 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: KeyInterface.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Virtual class definition on which all host interfaces, instantiated as a singleton,
|
||||
// are based.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef KEYINTERFACE_H
|
||||
#define KEYINTERFACE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "driver/timer.h"
|
||||
#include "PS2KeyAdvanced.h"
|
||||
#include "PS2Mouse.h"
|
||||
#include "NVS.h"
|
||||
#include "LED.h"
|
||||
#include "HID.h"
|
||||
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Define a virtual class which acts as the base and specification of all super classes forming host
|
||||
// interface objects.
|
||||
class KeyInterface {
|
||||
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define KEYIF_VERSION 1.01
|
||||
|
||||
public:
|
||||
// Suspend flag. When active, the interface components enter an idle state after completing there latest cycle.
|
||||
bool suspend = false;
|
||||
bool suspended = true;
|
||||
|
||||
// NVS object.
|
||||
NVS *nvs;
|
||||
|
||||
// LED object.
|
||||
LED *led;
|
||||
|
||||
// HID object, used for keyboard input.
|
||||
HID *hid;
|
||||
|
||||
// Prototypes.
|
||||
KeyInterface(void) {};
|
||||
virtual ~KeyInterface(void) {};
|
||||
KeyInterface(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID) { init(getClassName(__PRETTY_FUNCTION__), hdlNVS, hdlLED, hdlHID, ifMode); };
|
||||
KeyInterface(NVS *hdlNVS, HID *hdlHID) { init(getClassName(__PRETTY_FUNCTION__), hdlNVS, hdlHID); };
|
||||
void reconfigADC2Ports(bool setAsOutput);
|
||||
void suspendInterface(bool suspendIf);
|
||||
virtual bool isSuspended(bool waitForSuspend);
|
||||
virtual bool isRunning(bool waitForRelease);
|
||||
virtual void identify(void) { };
|
||||
virtual void init(const char * subClassName, NVS *hdlNVS, LED *hdlLED, HID *hdlHID, uint32_t ifMode);
|
||||
virtual void init(const char * subClassName, NVS *hdlNVS, HID *hdlHID);
|
||||
// Persistence.
|
||||
virtual bool persistConfig(void) { return(true); }
|
||||
|
||||
// Key mapping.
|
||||
virtual IRAM_ATTR uint32_t mapKey(uint16_t scanCode) { return(0); };
|
||||
virtual bool createKeyMapFile(std::fstream &outFile) { return(false); };
|
||||
virtual bool storeDataToKeyMapFile(std::fstream &outFile, char *data, int size) { return(false); };
|
||||
virtual bool storeDataToKeyMapFile(std::fstream & outFile, std::vector<uint32_t>& dataArray) { return(false); }
|
||||
virtual bool closeAndCommitKeyMapFile(std::fstream &outFile, bool cleanupOnly) { return(false); };
|
||||
virtual std::string getKeyMapFileName(void) { return("nokeymap.bin"); };
|
||||
virtual void getKeyMapHeaders(std::vector<std::string>& headerList) { };
|
||||
virtual void getKeyMapTypes(std::vector<std::string>& typeList) { };
|
||||
virtual bool getKeyMapSelectList(std::vector<std::pair<std::string, int>>& selectList, std::string option) { return(true); }
|
||||
virtual bool getKeyMapData(std::vector<uint32_t>& dataArray, int *row, bool start) { return(true); };
|
||||
// Mouse config.
|
||||
virtual void getMouseConfigTypes(std::vector<std::string>& typeList) { };
|
||||
virtual bool getMouseSelectList(std::vector<std::pair<std::string, int>>& selectList, std::string option) { return(true); }
|
||||
virtual bool setMouseConfigValue(std::string paramName, std::string paramValue) { return(true); }
|
||||
|
||||
// Method to suspend an active interface thread by holding in a tight loop, yielding to the OS. This method was chosen rather than the more conventional
|
||||
// vTaskSuspend as it allows multiple threads, without giving a handle, to yield if required for a fixed period or indefinitely until the suspend mode is de-activated.
|
||||
// The method is inline to avoid a call overhead as it is generally used in time sensitive interface timing.
|
||||
inline virtual void yield(uint32_t delay)
|
||||
{
|
||||
// If suspended, go into a permanent loop until the suspend flag is reset.
|
||||
if(this->suspend)
|
||||
{
|
||||
this->suspended = true;
|
||||
while(this->suspend)
|
||||
{
|
||||
vTaskDelay(100);
|
||||
}
|
||||
this->suspended = false;
|
||||
} else
|
||||
// Otherwise just delay by the required amount for timing and to give other threads a time slice.
|
||||
{
|
||||
vTaskDelay(delay);
|
||||
}
|
||||
}
|
||||
|
||||
// Method to see if the interface must enter suspend mode.
|
||||
//
|
||||
inline virtual bool suspendRequested(void)
|
||||
{
|
||||
return(this->suspend);
|
||||
}
|
||||
|
||||
// Helper method to identify the sub class, this is used in non volatile key management.
|
||||
// Warning: This method wont work if optimisation for size is enabled on the compiler.
|
||||
const char *getClassName(const std::string& prettyFunction)
|
||||
{
|
||||
// First find the CLASS :: METHOD seperation.
|
||||
size_t colons = prettyFunction.find("::");
|
||||
|
||||
// None, then this is not a class.
|
||||
if (colons == std::string::npos)
|
||||
return "::";
|
||||
|
||||
// Split out the class name.
|
||||
size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
|
||||
size_t end = colons - begin;
|
||||
|
||||
// Return the name.
|
||||
return(prettyFunction.substr(begin,end).c_str());
|
||||
}
|
||||
|
||||
// Helper method to change a file extension.
|
||||
void replaceExt(std::string& fileName, const std::string& newExt)
|
||||
{
|
||||
// Locals.
|
||||
std::string::size_type extPos = fileName.rfind('.', fileName.length());
|
||||
|
||||
if(extPos != std::string::npos)
|
||||
{
|
||||
fileName.replace(extPos+1, newExt.length(), newExt);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Template to aid in conversion of an enum to integer.
|
||||
template <typename E> constexpr typename std::underlying_type<E>::type to_underlying(E e) noexcept
|
||||
{
|
||||
return static_cast<typename std::underlying_type<E>::type>(e);
|
||||
}
|
||||
|
||||
// Method to return the class version number.
|
||||
virtual float version(void)
|
||||
{
|
||||
return(KEYIF_VERSION);
|
||||
}
|
||||
|
||||
// Method to return the name of the inferface class.
|
||||
virtual std::string ifName(void)
|
||||
{
|
||||
return(subClassName);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
virtual IRAM_ATTR void selectOption(uint8_t optionCode) {};
|
||||
|
||||
// Name of the sub-class for this instantiation.
|
||||
std::string subClassName;
|
||||
|
||||
// Thread handle for the LED control thread.
|
||||
TaskHandle_t TaskLEDIF = NULL;
|
||||
};
|
||||
#endif // KEYINTERFACE_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/LED.h
|
||||
181
main/include/LED.h
Normal file
181
main/include/LED.h
Normal file
@@ -0,0 +1,181 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: LED.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Class definition for the control of a single LED. The LED is used to indicate to a
|
||||
// user a desired status. This class is normally instantiated as a singleton and
|
||||
// manipulated by public methods.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "driver/timer.h"
|
||||
#include "PS2KeyAdvanced.h"
|
||||
#include "PS2Mouse.h"
|
||||
#include "NVS.h"
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Define a class to encapsulate a LED and required control mechanisms,
|
||||
class LED {
|
||||
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define LED_VERSION 1.01
|
||||
|
||||
public:
|
||||
// Interface LED activity modes.
|
||||
enum LED_MODE {
|
||||
LED_MODE_OFF = 0x00,
|
||||
LED_MODE_ON = 0x01,
|
||||
LED_MODE_BLINK_ONESHOT = 0x02,
|
||||
LED_MODE_BLINK = 0x03,
|
||||
};
|
||||
|
||||
// Interface LED duty cycle.
|
||||
enum LED_DUTY_CYCLE {
|
||||
LED_DUTY_CYCLE_OFF = 0x00,
|
||||
LED_DUTY_CYCLE_10 = 0x01,
|
||||
LED_DUTY_CYCLE_20 = 0x02,
|
||||
LED_DUTY_CYCLE_30 = 0x03,
|
||||
LED_DUTY_CYCLE_40 = 0x04,
|
||||
LED_DUTY_CYCLE_50 = 0x05,
|
||||
LED_DUTY_CYCLE_60 = 0x06,
|
||||
LED_DUTY_CYCLE_70 = 0x07,
|
||||
LED_DUTY_CYCLE_80 = 0x08,
|
||||
LED_DUTY_CYCLE_90 = 0x09,
|
||||
};
|
||||
|
||||
// Prototypes.
|
||||
LED(uint32_t hwPin);
|
||||
LED(void);
|
||||
virtual ~LED(void) {};
|
||||
void identify(void) { };
|
||||
|
||||
// LED Control.
|
||||
bool setLEDMode(enum LED_MODE mode, enum LED_DUTY_CYCLE dutyCycle, uint32_t maxBlinks, uint64_t usDutyPeriod, uint64_t msInterPeriod);
|
||||
IRAM_ATTR static void ledInterface(void *pvParameters);
|
||||
void ledInit(uint8_t ledPin);
|
||||
|
||||
// Helper method to identify the sub class, this is used in non volatile key management.
|
||||
// Warning: This method wont work if optimisation for size is enabled on the compiler.
|
||||
const char *getClassName(const std::string& prettyFunction)
|
||||
{
|
||||
// First find the CLASS :: METHOD seperation.
|
||||
size_t colons = prettyFunction.find("::");
|
||||
|
||||
// None, then this is not a class.
|
||||
if (colons == std::string::npos)
|
||||
return "::";
|
||||
|
||||
// Split out the class name.
|
||||
size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
|
||||
size_t end = colons - begin;
|
||||
|
||||
// Return the name.
|
||||
return(prettyFunction.substr(begin,end).c_str());
|
||||
}
|
||||
|
||||
// Template to aid in conversion of an enum to integer.
|
||||
template <typename E> constexpr typename std::underlying_type<E>::type to_underlying(E e) noexcept
|
||||
{
|
||||
return static_cast<typename std::underlying_type<E>::type>(e);
|
||||
}
|
||||
|
||||
// Method to return the class version number.
|
||||
virtual float version(void)
|
||||
{
|
||||
return(LED_VERSION);
|
||||
}
|
||||
|
||||
// Method to return the name of the inferface class.
|
||||
virtual std::string ifName(void)
|
||||
{
|
||||
return(className);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
|
||||
// Structure to maintain configuration for the LED.
|
||||
//
|
||||
typedef struct {
|
||||
bool valid; // The configuration is valid and should be processed.
|
||||
bool updated; // This configuration is an update to override current configuration.
|
||||
|
||||
enum LED_MODE mode; // Mode of LED activity.
|
||||
enum LED_DUTY_CYCLE dutyCycle; // Duty cycle of the BLINK LED period.
|
||||
uint32_t maxBlinks; // Maximum number of blinks before switching to LED off mode.
|
||||
uint64_t dutyPeriod; // Period, is micro-seconds of the full duty cycle.
|
||||
uint64_t interPeriod; // Period, is milli-seconds between LED activity.
|
||||
} t_ledConfig;
|
||||
|
||||
// Structure to maintain an active setting for the LED. The LED control thread uses these values to effect the required lighting of the LED.
|
||||
typedef struct {
|
||||
// Current, ie. working LED config acted upon by the LED thread.
|
||||
t_ledConfig currentConfig;
|
||||
// New config to replace current on next state.
|
||||
t_ledConfig newConfig;
|
||||
|
||||
// Led GPIO pin.
|
||||
uint8_t ledPin;
|
||||
|
||||
// Runtime parameters for state machine and control.
|
||||
uint32_t blinkCnt; // count of blink on periods.
|
||||
|
||||
// Mutex to block access to limit one thread at a time.
|
||||
SemaphoreHandle_t mutexInternal;
|
||||
} t_ledControl;
|
||||
|
||||
// Variables to control the LED.
|
||||
t_ledControl ledCtrl;
|
||||
|
||||
// Name of the class for this instantiation.
|
||||
std::string className;
|
||||
|
||||
// Thread handle for the LED control thread.
|
||||
TaskHandle_t TaskLEDIF = NULL;
|
||||
};
|
||||
#endif // LED_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/MZ2528.h
|
||||
534
main/include/MZ2528.h
Normal file
534
main/include/MZ2528.h
Normal file
@@ -0,0 +1,534 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: MZ2528.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header for the MZ-2500/MZ-2800 PS/2 logic.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
// v1.02 Jun 2022 - Updates to reflect bluetooth.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MZ2528_H
|
||||
#define MZ2528_H
|
||||
|
||||
// Include the specification class.
|
||||
#include "KeyInterface.h"
|
||||
#include "NVS.h"
|
||||
#include "LED.h"
|
||||
#include "HID.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Encapsulate the MZ-2500/MZ-2800 interface.
|
||||
class MZ2528 : public KeyInterface {
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define MZ2528IF_VERSION 1.02
|
||||
#define MZ2528IF_KEYMAP_FILE "MZ2528_KeyMap.BIN"
|
||||
#define PS2TBL_MZ_MAXROWS 165
|
||||
#define PS2TBL_MZ_MAX_MKROW 3
|
||||
#define PS2TBL_MZ_MAX_BRKROW 2
|
||||
|
||||
// PS2 Flag definitions.
|
||||
#define PS2CTRL_NONE 0x00 // No keys active = 0
|
||||
#define PS2CTRL_SHIFT 0x01 // Shfit Key active = 1
|
||||
#define PS2CTRL_CTRL 0x02 // Ctrl Key active = 1
|
||||
#define PS2CTRL_CAPS 0x04 // CAPS active = 1
|
||||
#define PS2CTRL_ALT 0x08 // ALT active = 1
|
||||
#define PS2CTRL_ALTGR 0x10 // ALTGR active = 1
|
||||
#define PS2CTRL_GUI 0x20 // GUI Key active = 1
|
||||
#define PS2CTRL_FUNC 0x40 // Special Function Keys active = 1
|
||||
#define PS2CTRL_BREAK 0x80 // BREAK Key active = 1
|
||||
#define PS2CTRL_EXACT 0x80 // EXACT Match active = 1
|
||||
|
||||
// The MZ-2500 machine can emulate 3 models, the MZ-80B, MZ-2000 and the MZ-2500. The MZ-2800 provides a new mode as well as the MZ-2500 mode and each has slight
|
||||
// keyboard differences. This requires tagging of machine specific mappings. Normally a mapping would be MZ_ALL, ie. applied to all models, but if a machine specific
|
||||
// mapping appears and it matches the current machine mode, this mapping is chosen.
|
||||
#define MZ_ALL 0xFF
|
||||
#define MZ_80B 0x01
|
||||
#define MZ_2000 0x02
|
||||
#define MZ_2500 0x04
|
||||
#define MZ_2800 0x08
|
||||
|
||||
// Keyboard mapping table select list for target machine.
|
||||
#define MZ2528_SEL_ALL "ALL"
|
||||
#define MZ2528_SEL_MZ_80B "MZ80B"
|
||||
#define MZ2528_SEL_MZ_2000 "MZ2000"
|
||||
#define MZ2528_SEL_MZ_2500 "MZ2500"
|
||||
#define MZ2528_SEL_MZ_2800 "MZ2800"
|
||||
|
||||
// The initial mapping is made inside the PS2KeyAdvanced class from Scan Code Set 2 to ASCII
|
||||
// for a selected keyboard. Special functions are detected and combined inside this module
|
||||
// before mapping with the table below to MZ Scan Matrix.
|
||||
// ie. PS/2 Scan Code -> ASCII + Flags -> MZ Scan Matrix
|
||||
|
||||
|
||||
// Keyboard mapping table column names.
|
||||
#define PS2TBL_PS2KEYCODE_NAME "PS/2 KeyCode"
|
||||
#define PS2TBL_PS2CTRL_NAME "PS/2 Control Key"
|
||||
#define PS2TBL_KEYBOARDMODEL_NAME "For Keyboard"
|
||||
#define PS2TBL_MACHINE_NAME "For Host Model"
|
||||
#define PS2TBL_MZ_MK_ROW1_NAME "Make Row 1"
|
||||
#define PS2TBL_MZ_MK_KEY1_NAME "Key 1"
|
||||
#define PS2TBL_MZ_MK_ROW2_NAME "Row 2"
|
||||
#define PS2TBL_MZ_MK_KEY2_NAME "Key 2"
|
||||
#define PS2TBL_MZ_MK_ROW3_NAME "Row 3"
|
||||
#define PS2TBL_MZ_MK_KEY3_NAME "Key 3"
|
||||
#define PS2TBL_MZ_BRK_ROW1_NAME "Break Row 1"
|
||||
#define PS2TBL_MZ_BRK_KEY1_NAME "Key 1"
|
||||
#define PS2TBL_MZ_BRK_ROW2_NAME "Row 2"
|
||||
#define PS2TBL_MZ_BRK_KEY2_NAME "Key 2"
|
||||
|
||||
// Keyboard mapping table column types.
|
||||
#define PS2TBL_PS2KEYCODE_TYPE "hex"
|
||||
#define PS2TBL_PS2CTRL_TYPE "custom_cbp_ps2ctrl"
|
||||
#define PS2TBL_KEYBOARDMODEL_TYPE "custom_cbp_keybmodel"
|
||||
#define PS2TBL_MACHINE_TYPE "custom_cbp_machine"
|
||||
#define PS2TBL_MZ_MK_ROW1_TYPE "custom_rdp_mzrow"
|
||||
#define PS2TBL_MZ_MK_KEY1_TYPE "hex"
|
||||
#define PS2TBL_MZ_MK_ROW2_TYPE "custom_rdp_mzrow"
|
||||
#define PS2TBL_MZ_MK_KEY2_TYPE "hex"
|
||||
#define PS2TBL_MZ_MK_ROW3_TYPE "custom_rdp_mzrow"
|
||||
#define PS2TBL_MZ_MK_KEY3_TYPE "hex"
|
||||
#define PS2TBL_MZ_BRK_ROW1_TYPE "custom_rdp_mzrow"
|
||||
#define PS2TBL_MZ_BRK_KEY1_TYPE "hex"
|
||||
#define PS2TBL_MZ_BRK_ROW2_TYPE "custom_rdp_mzrow"
|
||||
#define PS2TBL_MZ_BRK_KEY2_TYPE "hex"
|
||||
|
||||
// Keyboard mapping table select list for PS2CTRL.
|
||||
#define PS2TBL_PS2CTRL_SEL_NONE "NONE"
|
||||
#define PS2TBL_PS2CTRL_SEL_SHIFT "SHIFT"
|
||||
#define PS2TBL_PS2CTRL_SEL_CTRL "CTRL"
|
||||
#define PS2TBL_PS2CTRL_SEL_CAPS "CAPS"
|
||||
#define PS2TBL_PS2CTRL_SEL_ALT "ALT"
|
||||
#define PS2TBL_PS2CTRL_SEL_ALTGR "ALTGR"
|
||||
#define PS2TBL_PS2CTRL_SEL_GUI "GUI"
|
||||
#define PS2TBL_PS2CTRL_SEL_FUNC "FUNC"
|
||||
#define PS2TBL_PS2CTRL_SEL_EXACT "EXACT"
|
||||
|
||||
// Keyboard mapping table select list for Model of keyboard.
|
||||
#define KEYMAP_SEL_STANDARD "ALL"
|
||||
#define KEYMAP_SEL_UK_WYSE_KB3926 "UK_WYSE_KB3926"
|
||||
#define KEYMAP_SEL_JAPAN_OADG109 "JAPAN_OADG109"
|
||||
#define KEYMAP_SEL_JAPAN_SANWA_SKBL1 "JAPAN_SANWA_SKBL1"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_4 "KEYBOARD_4"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_5 "KEYBOARD_5"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_6 "KEYBOARD_6"
|
||||
#define KEYMAP_SEL_UK_PERIBOARD_810 "UK_PERIBOARD_810"
|
||||
#define KEYMAP_SEL_UK_OMOTON_K8508 "UK_OMOTON_K8508"
|
||||
|
||||
// Keyboard models. The base on which this interface was created was a Wyse KB3926 PS/2 Keyboard and this is deemed STANDARD. Other models need to insert difference maps
|
||||
// prior to the STANDARD entry along with the keyboard model so that it is processed first thus allowing differing keyboards with different maps.
|
||||
#define KEYMAP_STANDARD 0xFF
|
||||
#define KEYMAP_UK_WYSE_KB3926 0x01
|
||||
#define KEYMAP_JAPAN_OADG109 0x02
|
||||
#define KEYMAP_JAPAN_SANWA_SKBL1 0x04
|
||||
#define KEYMAP_NOT_ASSIGNED_4 0x08
|
||||
#define KEYMAP_NOT_ASSIGNED_5 0x10
|
||||
#define KEYMAP_NOT_ASSIGNED_6 0x20
|
||||
#define KEYMAP_UK_PERIBOARD_810 0x40
|
||||
#define KEYMAP_UK_OMOTON_K8508 0x80
|
||||
|
||||
public:
|
||||
// Prototypes.
|
||||
MZ2528(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID, const char *fsPath);
|
||||
MZ2528(NVS *hdlNVS, HID *hdlHID, const char *fsPath);
|
||||
MZ2528(void);
|
||||
~MZ2528(void);
|
||||
bool createKeyMapFile(std::fstream &outFile);
|
||||
bool storeDataToKeyMapFile(std::fstream &outFile, char *data, int size);
|
||||
bool storeDataToKeyMapFile(std::fstream & outFile, std::vector<uint32_t>& dataArray);
|
||||
bool closeAndCommitKeyMapFile(std::fstream &outFile, bool cleanupOnly);
|
||||
std::string getKeyMapFileName(void) { return(MZ2528IF_KEYMAP_FILE); };
|
||||
void getKeyMapHeaders(std::vector<std::string>& headerList);
|
||||
void getKeyMapTypes(std::vector<std::string>& typeList);
|
||||
bool getKeyMapSelectList(std::vector<std::pair<std::string, int>>& selectList, std::string option);
|
||||
bool getKeyMapData(std::vector<uint32_t>& dataArray, int *row, bool start);
|
||||
|
||||
// Overloaded method to see if the interface must enter suspend mode, either triggered by an external event or internal.
|
||||
//
|
||||
inline bool suspendRequested(void)
|
||||
{
|
||||
return(this->suspend);
|
||||
}
|
||||
|
||||
// // Method to overload the suspend mechanism and include the core release mechanism. Core release is needed in order to use ESP32 API's such as NVS.
|
||||
// // The method is inline to avoid a call overhead as it is generally used in time sensitive interface timing.
|
||||
// inline void yield(uint32_t delay)
|
||||
// {
|
||||
// // If suspended, go into a permanent loop until the suspend flag is reset.
|
||||
// if(this->suspend)
|
||||
// {
|
||||
// this->suspended = true;
|
||||
// while(this->suspend)
|
||||
// {
|
||||
// vTaskDelay(100);
|
||||
// }
|
||||
// this->suspended = false;
|
||||
// } else
|
||||
// // Otherwise just delay by the required amount for timing and to give other threads a time slice.
|
||||
// {
|
||||
// vTaskDelay(delay);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Method to return the class version number.
|
||||
float version(void)
|
||||
{
|
||||
return(MZ2528IF_VERSION);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
void updateMirrorMatrix(void);
|
||||
uint32_t mapKey(uint16_t scanCode);
|
||||
IRAM_ATTR static void mz25Interface(void *pvParameters );
|
||||
IRAM_ATTR static void mz28Interface(void *pvParameters );
|
||||
IRAM_ATTR static void hidInterface(void *pvParameters );
|
||||
void selectOption(uint8_t optionCode);
|
||||
bool loadKeyMap();
|
||||
bool saveKeyMap(void);
|
||||
void init(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID);
|
||||
void init(NVS *hdlNVS, HID *hdlHID);
|
||||
|
||||
// Overload the base yield method to include suspension of the PS/2 Keyboard interface. This interface uses interrupts which are not mutex protected and clash with the
|
||||
// WiFi API methods.
|
||||
// inline void yield(uint32_t delay)
|
||||
// {
|
||||
// // If suspended, go into a permanent loop until the suspend flag is reset.
|
||||
// if(this->suspend)
|
||||
// {
|
||||
// // Suspend the keyboard interface.
|
||||
// Keyboard->suspend(true);
|
||||
//
|
||||
// // Use the base method logic.
|
||||
// KeyInterface::yield(delay);
|
||||
//
|
||||
// // Release the keyboard interface.
|
||||
// Keyboard->suspend(false);
|
||||
// } else
|
||||
// // Otherwise just delay by the required amount for timing and to give other threads a time slice.
|
||||
// {
|
||||
// KeyInterface::yield(delay);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Structure to encapsulate a single key map from PS/2 to MZ-2500/MZ-2800.
|
||||
typedef struct {
|
||||
uint8_t ps2KeyCode;
|
||||
uint8_t ps2Ctrl;
|
||||
uint8_t keyboardModel;
|
||||
uint8_t machine;
|
||||
uint8_t mkRow[PS2TBL_MZ_MAX_MKROW];
|
||||
uint8_t mkKey[PS2TBL_MZ_MAX_MKROW];
|
||||
uint8_t brkRow[PS2TBL_MZ_MAX_BRKROW];
|
||||
uint8_t brkKey[PS2TBL_MZ_MAX_BRKROW];
|
||||
} t_keyMapEntry;
|
||||
|
||||
// Structure to encapsulate the entire static keyboard mapping table.
|
||||
typedef struct {
|
||||
t_keyMapEntry kme[PS2TBL_MZ_MAXROWS];
|
||||
} t_keyMap;
|
||||
|
||||
// Structure to maintain the MZ2528 interface configuration data. This data is persisted through powercycles as needed.
|
||||
typedef struct {
|
||||
struct {
|
||||
uint8_t activeKeyboardMap; // Model of keyboard a keymap entry is applicable to.
|
||||
uint8_t activeMachineModel; // Machine model a keymap entry is applicable to.
|
||||
} params;
|
||||
} t_mzConfig;
|
||||
|
||||
// Configuration data.
|
||||
t_mzConfig mzConfig;
|
||||
|
||||
// Structure to manage the translated key matrix. This is updated by the ps2Interface thread and read by the mzInterface thead.
|
||||
typedef struct {
|
||||
uint8_t strobeAll; // Strobe All flag, 16 possible rows have the same column AND'd together to create this 8bit map. It is used to see if any key has been pressed.
|
||||
uint32_t strobeAllAsGPIO; // Strobe All signal but as a GPIO bit map to save time in the interface thread.
|
||||
uint8_t keyMatrix[16]; // Key matrix as a 16x8 matrix.
|
||||
uint32_t keyMatrixAsGPIO[16]; // Key matrix mapped as GPIO bits to save time in the interface thread.
|
||||
bool mode2500;
|
||||
bool optionSelect; // Flag to indicate a user requested keyboard configuration option is being selected.
|
||||
std::string fsPath; // Path on the underlying filesystem where storage is mounted and accessible.
|
||||
t_keyMapEntry *kme; // Pointer to an array in memory to contain PS2 to MZ-2500/MZ-2800 mapping values.
|
||||
int kmeRows; // Number of rows in the kme table.
|
||||
std::string keyMapFileName; // Name of file where extension or replacement key map entries are stored.
|
||||
bool noKeyPressed; // Flag to indicate no key has been pressed.
|
||||
bool persistConfig; // Flag to request saving of the config into NVS storage.
|
||||
} t_mzControl;
|
||||
|
||||
// Thread handles - one per function, ie. HID interface and host target interface.
|
||||
TaskHandle_t TaskHostIF = NULL;
|
||||
TaskHandle_t TaskHIDIF = NULL;
|
||||
|
||||
// Control structure to control interaction and mapping of keys for the host.
|
||||
t_mzControl mzControl;
|
||||
|
||||
// Spin lock mutex to hold a coresied to an uninterruptable method. This only works on dual core ESP32's.
|
||||
portMUX_TYPE mzMutex;
|
||||
|
||||
// Flag to indicate host interface should yield the CPU.
|
||||
volatile bool yieldHostInterface;
|
||||
|
||||
// // Keyboard object for PS/2 data retrieval and management.
|
||||
// PS2KeyAdvanced *Keyboard;
|
||||
|
||||
// HID object, used for keyboard input.
|
||||
// HID *hid;
|
||||
|
||||
// Lookup table to matrix row/column co-ordinates.
|
||||
//
|
||||
// Given that the MZ-2500 can emulate 3 machines and each machine has it's own mapping, differences are tagged by machine name, ie. ALL, MZ80B, MZ2000, MZ2500
|
||||
//
|
||||
// If a PS2 key is matched, then the Matrix is updated using MK_ROW to point into the array with MK_KEY being the column value, equivalent of strobe line and
|
||||
// the required KEY bits to be set. Upto 3 matrix bits can be set (3 key presses on the MZ-2500 keyboard) per PS/2 key. Upto 2 matrix releases can be set per
|
||||
// PS/2 key. A key release is used when a modifier may already have been pressed, ie. SHIFT and it needs to be released to set the required key into the matrix.
|
||||
// A set bit = 1, reset bits = 0 but is inverted in the actual matrix (1 = inactive, 0 = active), this applies for releases two, if bit = 1 then that key will be released.
|
||||
// The table is scanned for a match from top to bottom. The first match is used so order is important. Japanese characters are being added as I gleam more information.
|
||||
|
||||
///////////////////////////
|
||||
// MZ-2500 Keyboard Map. //
|
||||
///////////////////////////
|
||||
//
|
||||
// Row D7 D6 D5 D4 D3 D2 D1 D0
|
||||
//----------------------------------------------------------------------------------
|
||||
// 0 F8 F7 F6 F5 F4 F3 F2 F1
|
||||
// 1 KP - KP + KP . KP , KP 9 KP 8 F1O F9
|
||||
// 2 KP 7 KP 6 KP 5 KP 4 KP 3 KP 2 KP 1 KP 0
|
||||
// 3 BREAK RIGHT LEFT DOWN UP RETURN SPACE TAB
|
||||
// 4 G F E D C B A / ?
|
||||
// 5 O N M L K J I H
|
||||
// 6 W V U T S R Q P
|
||||
// 7 , < . > _ YEN | ^ '¿ Z ¿ Y X ¿
|
||||
// 8 7 ' 6 & 5 % 4 $ 3 # 2 " 1 ! 0
|
||||
// 9 [ { @ ` - = ; + : * 9 ) 8 (
|
||||
// 10 KP / KP * ESC BACKSPACE INST/DEL CLR/HOME COPY ] }
|
||||
// 11 CTRL KANA SHIFT LOCK GRAPH
|
||||
// 12 KJ2 KJ1
|
||||
// 13 HELP ARGO
|
||||
//
|
||||
// Col 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||
// --------------------------------------------------------------------------------------------------------------------------------------
|
||||
// D0 F1 F9 KP 0 TAB / ? H P X 0 8 ( ] } GRAPH KJ1 ARGO
|
||||
// D1 F2 F10 KP 1 SPACE A I Q Y 1 ! 9 ) COPY LOCK KJ2 HELP
|
||||
// D2 F3 KP 8 KP 2 RETURN B J R Z 2 " : * CLR/HOME SHIFT
|
||||
// D3 F4 KP 9 KP 3 UP C K S ^ '¿ 3 # ; + INST/DEL KANA
|
||||
// D4 F5 KP , KP 4 DOWN D L T YEN | 4 $ - = BACKSPACE CTRL
|
||||
// D5 F6 KP . KP 5 LEFT E M U _ 5 % @ ` ESC
|
||||
// D6 F7 KP + KP 6 RIGHT F N V . > 6 & [ { KP *
|
||||
// D7 F8 KP - KP 7 BREAK G O W , < 7 ' KP /
|
||||
//
|
||||
// This initial mapping is for the UK Wyse KB-3926 PS/2 keyboard and his equates to KEYMAP_STANDARD.
|
||||
//
|
||||
t_keyMap PS2toMZ = {
|
||||
{
|
||||
// < Keys to be applied on match > < Keys to be reset on match >
|
||||
// PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MK_ROW1 MK_ROW2 MK_ROW3 MK_KEY1 MK_KEY2 MK_KEY3 BRK_ROW1 BRK_ROW2 BRK_KEY1 BRK_KEY2
|
||||
{ PS2_KEY_F1, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x00, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F1
|
||||
{ PS2_KEY_F2, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x00, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F2
|
||||
{ PS2_KEY_F3, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x00, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F3
|
||||
{ PS2_KEY_F4, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x00, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F4
|
||||
{ PS2_KEY_F5, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x00, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F5
|
||||
{ PS2_KEY_F6, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x00, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F6
|
||||
{ PS2_KEY_F7, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x00, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F7
|
||||
{ PS2_KEY_F8, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x00, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F8
|
||||
{ PS2_KEY_F9, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x01, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F9
|
||||
{ PS2_KEY_F10, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x01, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F10
|
||||
{ PS2_KEY_F11, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0D, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // HELP
|
||||
{ PS2_KEY_F12, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // COPY
|
||||
{ PS2_KEY_TAB, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // TAB
|
||||
{ PS2_KEY_0, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x09, 0x0B, 0xFF, 0x02, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Close Right Bracket )
|
||||
{ PS2_KEY_0, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 0
|
||||
{ PS2_KEY_1, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x08, 0x0B, 0xFF, 0x02, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Exclamation
|
||||
{ PS2_KEY_1, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 1
|
||||
{ PS2_KEY_2, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x08, 0x0B, 0xFF, 0x04, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Double quote.
|
||||
{ PS2_KEY_2, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 2
|
||||
{ PS2_KEY_3, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x08, 0x0B, 0xFF, 0x08, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Pound Sign -> Hash
|
||||
{ PS2_KEY_3, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 3
|
||||
{ PS2_KEY_4, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x08, 0x0B, 0xFF, 0x10, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Dollar
|
||||
{ PS2_KEY_4, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 4
|
||||
{ PS2_KEY_5, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x08, 0x0B, 0xFF, 0x20, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Percent
|
||||
{ PS2_KEY_5, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 5
|
||||
{ PS2_KEY_6, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0x0B, 0xFF, 0x04, 0xFF, }, // Kappa
|
||||
{ PS2_KEY_6, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 6
|
||||
{ PS2_KEY_7, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x08, 0x0B, 0xFF, 0x40, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Ampersand
|
||||
{ PS2_KEY_7, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 7
|
||||
{ PS2_KEY_8, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x09, 0x0B, 0xFF, 0x04, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Star
|
||||
{ PS2_KEY_8, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x09, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 8
|
||||
{ PS2_KEY_9, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x09, 0x0B, 0xFF, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Open Left Bracket (
|
||||
{ PS2_KEY_9, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x09, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // 9
|
||||
{ PS2_KEY_A, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // a
|
||||
{ PS2_KEY_A, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // A
|
||||
{ PS2_KEY_B, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // b
|
||||
{ PS2_KEY_B, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // B
|
||||
{ PS2_KEY_C, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // c
|
||||
{ PS2_KEY_C, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // C
|
||||
{ PS2_KEY_D, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // d
|
||||
{ PS2_KEY_D, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // D
|
||||
{ PS2_KEY_E, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // e
|
||||
{ PS2_KEY_E, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // E
|
||||
{ PS2_KEY_F, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // f
|
||||
{ PS2_KEY_F, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // F
|
||||
{ PS2_KEY_G, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // g
|
||||
{ PS2_KEY_G, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // G
|
||||
{ PS2_KEY_H, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // h
|
||||
{ PS2_KEY_H, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // H
|
||||
{ PS2_KEY_I, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // i
|
||||
{ PS2_KEY_I, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // I
|
||||
{ PS2_KEY_J, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // j
|
||||
{ PS2_KEY_J, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // J
|
||||
{ PS2_KEY_K, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // k
|
||||
{ PS2_KEY_K, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // K
|
||||
{ PS2_KEY_L, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // l
|
||||
{ PS2_KEY_L, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // L
|
||||
{ PS2_KEY_M, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // m
|
||||
{ PS2_KEY_M, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // M
|
||||
{ PS2_KEY_N, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // n
|
||||
{ PS2_KEY_N, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // N
|
||||
{ PS2_KEY_O, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // o
|
||||
{ PS2_KEY_O, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x05, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // O
|
||||
{ PS2_KEY_P, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // p
|
||||
{ PS2_KEY_P, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // P
|
||||
{ PS2_KEY_Q, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // q
|
||||
{ PS2_KEY_Q, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Q
|
||||
{ PS2_KEY_R, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // r
|
||||
{ PS2_KEY_R, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // R
|
||||
{ PS2_KEY_S, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // s
|
||||
{ PS2_KEY_S, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // S
|
||||
{ PS2_KEY_T, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // t
|
||||
{ PS2_KEY_T, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // T
|
||||
{ PS2_KEY_U, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // u
|
||||
{ PS2_KEY_U, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // U
|
||||
{ PS2_KEY_V, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // v
|
||||
{ PS2_KEY_V, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // V
|
||||
{ PS2_KEY_W, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // w
|
||||
{ PS2_KEY_W, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x06, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // W
|
||||
{ PS2_KEY_X, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // x
|
||||
{ PS2_KEY_X, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // X
|
||||
{ PS2_KEY_Y, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // y
|
||||
{ PS2_KEY_Y, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Y
|
||||
{ PS2_KEY_Z, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // z
|
||||
{ PS2_KEY_Z, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Z
|
||||
// PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MK_ROW1 MK_ROW2 MK_ROW3 MK_KEY1 MK_KEY2 MK_KEY3 BRK_ROW1 BRK_ROW2 BRK_KEY1 BRK_KEY2
|
||||
{ PS2_KEY_SPACE, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Space
|
||||
{ PS2_KEY_COMMA, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0x0B, 0xFF, 0x80, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Less Than <
|
||||
{ PS2_KEY_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Comma ,
|
||||
{ PS2_KEY_SEMI, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x09, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0x0B, 0xFF, 0x04, 0xFF, }, // Colon :
|
||||
{ PS2_KEY_SEMI, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x09, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Semi-Colon ;
|
||||
{ PS2_KEY_DOT, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0x0B, 0xFF, 0x40, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Greater Than >
|
||||
{ PS2_KEY_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Full stop .
|
||||
{ PS2_KEY_DIV, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_2000, 0x07, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0x0B, 0xFF, 0x04, 0xFF, }, // Question ?
|
||||
{ PS2_KEY_DIV, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_80B, 0x07, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0x0B, 0xFF, 0x04, 0xFF, }, // Question ?
|
||||
{ PS2_KEY_DIV, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x04, 0x0B, 0xFF, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Question ?
|
||||
{ PS2_KEY_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x04, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Divide /
|
||||
{ PS2_KEY_MINUS, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_2000, 0x08, 0x0B, 0xFF, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Upper bar
|
||||
{ PS2_KEY_MINUS, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_80B, 0x08, 0x0B, 0xFF, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Upper bar
|
||||
{ PS2_KEY_MINUS, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0x0B, 0xFF, 0x04, 0xFF, }, // Underscore
|
||||
{ PS2_KEY_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x09, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, //
|
||||
|
||||
{ PS2_KEY_APOS, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_80B, 0x09, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0x0B, 0xFF, 0x04, 0xFF, }, // At @
|
||||
{ PS2_KEY_APOS, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x09, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0x0B, 0xFF, 0x04, 0xFF, }, // At @
|
||||
{ PS2_KEY_APOS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0x0B, 0xFF, 0x80, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Single quote '
|
||||
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x09, 0x0B, 0xFF, 0x40, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Open Left Brace {
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x09, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Open Left Square Bracket [
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x09, 0x0B, 0xFF, 0x08, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Plus +
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x09, 0x0B, 0xFF, 0x10, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Equal =
|
||||
{ PS2_KEY_CAPS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x0B, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // LOCK
|
||||
{ PS2_KEY_ENTER, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // ENTER/RETURN
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0x0B, 0xFF, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Close Right Brace }
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Close Right Square Bracket ]
|
||||
{ PS2_KEY_BACK, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0x0B, 0xFF, 0x10, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, //
|
||||
{ PS2_KEY_BACK, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x07, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Back slash maps to Yen
|
||||
{ PS2_KEY_BTICK, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0x07, 0x0B, 0xFF, 0x10, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Pipe
|
||||
{ PS2_KEY_BTICK, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x09, 0x0B, 0xFF, 0x20, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Back tick `
|
||||
{ PS2_KEY_HASH, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_2000, 0x07, 0x0B, 0xFF, 0x08, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Tilde
|
||||
{ PS2_KEY_HASH, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_80B, 0x07, 0x0B, 0xFF, 0x08, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Tilde
|
||||
{ PS2_KEY_HASH, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ_ALL, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Tilde has no mapping.
|
||||
{ PS2_KEY_HASH, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x08, 0x0B, 0xFF, 0x08, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Hash
|
||||
{ PS2_KEY_BS, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Backspace
|
||||
{ PS2_KEY_ESC, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // ESCape
|
||||
{ PS2_KEY_SCROLL, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Not assigned.
|
||||
{ PS2_KEY_INSERT, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0x0B, 0xFF, 0x08, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // INSERT
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC | PS2CTRL_SHIFT | PS2CTRL_EXACT, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0x0B, 0xFF, 0x04, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // CLR
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // HOME
|
||||
{ PS2_KEY_PGUP, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Not assigned.
|
||||
{ PS2_KEY_DELETE, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // DELETE
|
||||
{ PS2_KEY_END, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Not assigned.
|
||||
{ PS2_KEY_PGDN, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_80B|MZ_2000|MZ_2500, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Not mapped
|
||||
{ PS2_KEY_PGDN, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_2800, 0x0C, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Japanese Key - Previous
|
||||
{ PS2_KEY_UP_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Up Arrow
|
||||
{ PS2_KEY_L_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Left Arrow
|
||||
{ PS2_KEY_DN_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Down Arrow
|
||||
{ PS2_KEY_R_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Right Arrow
|
||||
{ PS2_KEY_NUM, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Not assigned.
|
||||
|
||||
// Keypad.
|
||||
{ PS2_KEY_KP0, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x02, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 0
|
||||
{ PS2_KEY_KP1, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x02, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 1
|
||||
{ PS2_KEY_KP2, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x02, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 2
|
||||
{ PS2_KEY_KP3, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x02, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 3
|
||||
{ PS2_KEY_KP4, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x02, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 4
|
||||
{ PS2_KEY_KP5, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x02, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 5
|
||||
{ PS2_KEY_KP6, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x02, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 6
|
||||
{ PS2_KEY_KP7, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x02, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 7
|
||||
{ PS2_KEY_KP8, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x01, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 8
|
||||
{ PS2_KEY_KP9, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x01, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad 9
|
||||
{ PS2_KEY_KP_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x01, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad Comma ,
|
||||
{ PS2_KEY_KP_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x01, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad Full stop .
|
||||
{ PS2_KEY_KP_PLUS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x01, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad Plus +
|
||||
{ PS2_KEY_KP_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x01, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad Minus -
|
||||
{ PS2_KEY_KP_TIMES, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad Times *
|
||||
{ PS2_KEY_KP_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x0A, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad Divide /
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Keypad Ebter /
|
||||
|
||||
// PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MK_ROW1 MK_ROW2 MK_ROW3 MK_KEY1 MK_KEY2 MK_KEY3 BRK_ROW1 BRK_ROW2 BRK_KEY1 BRK_KEY2
|
||||
// Special keys.
|
||||
{ PS2_KEY_PRTSCR, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0D, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // ARGO KEY
|
||||
{ PS2_KEY_PAUSE, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x03, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // BREAK KEY
|
||||
{ PS2_KEY_L_GUI, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, MZ_ALL, 0x0B, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // GRAPH KEY
|
||||
{ PS2_KEY_L_ALT, PS2CTRL_FUNC | PS2CTRL_ALT, KEYMAP_STANDARD, MZ_ALL, 0x0C, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // KJ1 Sentence
|
||||
{ PS2_KEY_R_ALT, PS2CTRL_FUNC | PS2CTRL_ALTGR, KEYMAP_STANDARD, MZ_ALL, 0x0C, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // KJ2 Transform
|
||||
{ PS2_KEY_R_GUI, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, MZ_ALL, 0x0B, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // KANA KEY
|
||||
{ PS2_KEY_MENU, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, MZ_ALL, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Not assigned.
|
||||
// Modifiers are last, only being selected if an earlier match isnt made.
|
||||
{ PS2_KEY_L_SHIFT, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0B, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, },
|
||||
{ PS2_KEY_R_SHIFT, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0B, 0xFF, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, },
|
||||
{ PS2_KEY_L_CTRL, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_ALL, 0x0B, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, },
|
||||
{ PS2_KEY_R_CTRL, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_80B|MZ_2000|MZ_2500, 0x0B, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Map to Control
|
||||
{ PS2_KEY_R_CTRL, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ_2800, 0x0C, 0xFF, 0xFF, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }, // Japanese Key - Cancel
|
||||
{ 0, PS2CTRL_NONE, KEYMAP_STANDARD, MZ_ALL, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, },
|
||||
}};
|
||||
};
|
||||
|
||||
#endif // MZ2528_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/MZ5665.h
|
||||
574
main/include/MZ5665.h
Normal file
574
main/include/MZ5665.h
Normal file
@@ -0,0 +1,574 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: MZ5665.h
|
||||
// Created: Apr 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header for the Sharp MZ-6500 to HID (PS/2, Bluetooth) interface logic.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Apr 2022 - Initial write.
|
||||
// v1.01 Jun 2022 - Updates to reflect changes realised in other modules due to addition of
|
||||
// bluetooth and suspend logic due to NVS issues using both cores.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MZ5665_H
|
||||
#define MZ5665_H
|
||||
|
||||
// Include the specification class.
|
||||
#include "KeyInterface.h"
|
||||
#include "NVS.h"
|
||||
#include "LED.h"
|
||||
#include "HID.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Encapsulate the Sharp MZ-6500 interface.
|
||||
class MZ5665 : public KeyInterface {
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define MZ5665IF_VERSION 1.01
|
||||
#define MZ5665IF_KEYMAP_FILE "MZ5665_KeyMap.BIN"
|
||||
#define MAX_MZ5665_XMIT_KEY_BUF 16
|
||||
#define PS2TBL_MZ5665_MAXROWS 349
|
||||
|
||||
// MZ-6500 Key control bit mask.
|
||||
#define MZ5665_CTRL_GRAPH ((unsigned char) (1 << 4))
|
||||
#define MZ5665_CTRL_CAPS ((unsigned char) (1 << 3))
|
||||
#define MZ5665_CTRL_KANA ((unsigned char) (1 << 2))
|
||||
#define MZ5665_CTRL_SHIFT ((unsigned char) (1 << 1))
|
||||
#define MZ5665_CTRL_CTRL ((unsigned char) (1 << 0))
|
||||
|
||||
// Special key definition.
|
||||
#define MZ5665_KEY_UP 0x1E // ↑
|
||||
#define MZ5665_KEY_DOWN 0x1F // ↓
|
||||
#define MZ5665_KEY_LEFT 0x1D // ←
|
||||
#define MZ5665_KEY_RIGHT 0x1C // → →
|
||||
#define MZ5665_KEY_INS 0x12 // INS
|
||||
#define MZ5665_KEY_DEL 0x08 // DEL
|
||||
#define MZ5665_KEY_CLR 0x0C // CLR
|
||||
#define MZ5665_KEY_HOME 0x0B // HOME
|
||||
|
||||
// PS2 Flag definitions.
|
||||
#define PS2CTRL_NONE 0x00 // No keys active = 0
|
||||
#define PS2CTRL_SHIFT 0x01 // Shfit Key active = 1
|
||||
#define PS2CTRL_CTRL 0x02 // Ctrl Key active = 1
|
||||
#define PS2CTRL_CAPS 0x04 // CAPS active = 1
|
||||
#define PS2CTRL_KANA 0x08 // KANA active = 1
|
||||
#define PS2CTRL_GRAPH 0x10 // GRAPH active = 1
|
||||
#define PS2CTRL_GUI 0x20 // GUI Key active = 1
|
||||
#define PS2CTRL_FUNC 0x40 // Special Function Keys active = 1
|
||||
#define PS2CTRL_BREAK 0x80 // BREAK Key active = 1
|
||||
#define PS2CTRL_EXACT 0x80 // EXACT Match active = 1
|
||||
|
||||
// The initial mapping is made inside the PS2KeyAdvanced class from Scan Code Set 2 to ASCII
|
||||
// for a selected keyboard. Special functions are detected and combined inside this module
|
||||
// before mapping with the table below to extract the MZ-6500 key code and control data.
|
||||
// ie. PS/2 Scan Code -> ASCII + Flags -> MZ-6500 Key Code + Ctrl Data
|
||||
|
||||
// Keyboard mapping table column names.
|
||||
#define PS2TBL_PS2KEYCODE_NAME "PS/2 KeyCode"
|
||||
#define PS2TBL_PS2CTRL_NAME "PS/2 Control Key"
|
||||
#define PS2TBL_KEYBOARDMODEL_NAME "For Keyboard"
|
||||
#define PS2TBL_MACHINE_NAME "For Host Model"
|
||||
#define PS2TBL_MZ5665_KEYCODE_NAME "MZ5665 KeyCode"
|
||||
#define PS2TBL_MZ5665__CTRL_NAME "MZ5665 Control Key"
|
||||
|
||||
// Keyboard mapping table column types.
|
||||
#define PS2TBL_PS2KEYCODE_TYPE "hex"
|
||||
#define PS2TBL_PS2CTRL_TYPE "custom_cbp_ps2ctrl"
|
||||
#define PS2TBL_KEYBOARDMODEL_TYPE "custom_cbp_keybmodel"
|
||||
#define PS2TBL_MACHINE_TYPE "custom_cbp_machine"
|
||||
#define PS2TBL_MZ5665_KEYCODE_TYPE "hex"
|
||||
#define PS2TBL_MZ5665_CTRL_TYPE "custom_cbn_x1ctrl"
|
||||
|
||||
// Keyboard mapping table select list for PS2CTRL.
|
||||
#define PS2TBL_PS2CTRL_SEL_NONE "NONE"
|
||||
#define PS2TBL_PS2CTRL_SEL_SHIFT "SHIFT"
|
||||
#define PS2TBL_PS2CTRL_SEL_CTRL "CTRL"
|
||||
#define PS2TBL_PS2CTRL_SEL_CAPS "CAPS"
|
||||
#define PS2TBL_PS2CTRL_SEL_KANA "KANA"
|
||||
#define PS2TBL_PS2CTRL_SEL_GRAPH "GRAPH"
|
||||
#define PS2TBL_PS2CTRL_SEL_GUI "GUI"
|
||||
#define PS2TBL_PS2CTRL_SEL_FUNC "FUNC"
|
||||
#define PS2TBL_PS2CTRL_SEL_EXACT "EXACT"
|
||||
|
||||
// Keyboard mapping table select list for Model of keyboard.
|
||||
#define KEYMAP_SEL_STANDARD "ALL"
|
||||
#define KEYMAP_SEL_UK_WYSE_KB3926 "UK_WYSE_KB3926"
|
||||
#define KEYMAP_SEL_JAPAN_OADG109 "JAPAN_OADG109"
|
||||
#define KEYMAP_SEL_JAPAN_SANWA_SKBL1 "JAPAN_SANWA_SKBL1"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_4 "KEYBOARD_4"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_5 "KEYBOARD_5"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_6 "KEYBOARD_6"
|
||||
#define KEYMAP_SEL_UK_PERIBOARD_810 "UK_PERIBOARD_810"
|
||||
#define KEYMAP_SEL_UK_OMOTON_K8508 "UK_OMOTON_K8508"
|
||||
|
||||
// Keyboard mapping table select list for target machine.
|
||||
#define MZ5665_SEL_ALL "ALL"
|
||||
|
||||
// Keyboard mapping table select list for MZ5665 Control codes.
|
||||
#define MZ5665_CTRL_SEL_GRAPH "GRAPH"
|
||||
#define MZ5665_CTRL_SEL_CAPS "CAPS"
|
||||
#define MZ5665_CTRL_SEL_KANA "KANA"
|
||||
#define MZ5665_CTRL_SEL_SHIFT "SHIFT"
|
||||
#define MZ5665_CTRL_SEL_CTRL "CTRL"
|
||||
|
||||
// The Sharp MZ-6500 Series was released over a number of years and each iteration added changes/updates. In order to cater for differences, it is possible to assign a key mapping
|
||||
// to a specific machine type(s) or all of the series by adding the flags below into the mapping table.
|
||||
#define MZ5665_ALL 0xFF
|
||||
|
||||
// Keyboard models. The base on which this interface was created was a Wyse KB3926 PS/2 Keyboard and this is deemed STANDARD. Other models need to insert difference maps
|
||||
// prior to the STANDARD entry along with the keyboard model so that it is processed first thus allowing differing keyboards with different maps.
|
||||
#define KEYMAP_STANDARD 0xFF
|
||||
#define KEYMAP_UK_WYSE_KB3926 0x01
|
||||
#define KEYMAP_JAPAN_OADG109 0x02
|
||||
#define KEYMAP_JAPAN_SANWA_SKBL1 0x04
|
||||
#define KEYMAP_NOT_ASSIGNED_4 0x08
|
||||
#define KEYMAP_NOT_ASSIGNED_5 0x10
|
||||
#define KEYMAP_NOT_ASSIGNED_6 0x20
|
||||
#define KEYMAP_UK_PERIBOARD_810 0x40
|
||||
#define KEYMAP_UK_OMOTON_K8508 0x80
|
||||
|
||||
public:
|
||||
// Prototypes.
|
||||
MZ5665(void);
|
||||
MZ5665(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID, const char *fsPath);
|
||||
MZ5665(NVS *hdlNVS, HID *hdlHID, const char *fsPath);
|
||||
~MZ5665(void);
|
||||
bool createKeyMapFile(std::fstream &outFile);
|
||||
bool storeDataToKeyMapFile(std::fstream &outFile, char *data, int size);
|
||||
bool storeDataToKeyMapFile(std::fstream & outFile, std::vector<uint32_t>& dataArray);
|
||||
bool closeAndCommitKeyMapFile(std::fstream &outFile, bool cleanupOnly);
|
||||
std::string getKeyMapFileName(void) { return(MZ5665IF_KEYMAP_FILE); };
|
||||
void getKeyMapHeaders(std::vector<std::string>& headerList);
|
||||
void getKeyMapTypes(std::vector<std::string>& typeList);
|
||||
bool getKeyMapSelectList(std::vector<std::pair<std::string, int>>& selectList, std::string option);
|
||||
bool getKeyMapData(std::vector<uint32_t>& dataArray, int *row, bool start);
|
||||
|
||||
// Method to return the class version number.
|
||||
float version(void)
|
||||
{
|
||||
return(MZ5665IF_VERSION);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
void pushKeyToQueue(uint32_t key);
|
||||
IRAM_ATTR static void mzInterface( void * pvParameters );
|
||||
IRAM_ATTR static void hidInterface( void * pvParameters );
|
||||
void selectOption(uint8_t optionCode);
|
||||
uint32_t mapKey(uint16_t scanCode);
|
||||
bool loadKeyMap();
|
||||
bool saveKeyMap(void);
|
||||
void init(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID);
|
||||
void init(NVS *hdlNVS, HID *hdlHID);
|
||||
|
||||
// // Overload the base yield method to include suspension of the PS/2 Keyboard interface. This interface uses interrupts which are not mutex protected and clash with the
|
||||
// // WiFi API methods.
|
||||
// inline void yield(uint32_t delay)
|
||||
// {
|
||||
// // If suspended, go into a permanent loop until the suspend flag is reset.
|
||||
// if(this->suspend)
|
||||
// {
|
||||
// // Suspend the keyboard interface.
|
||||
// Keyboard->suspend(true);
|
||||
//
|
||||
// // Use the base method logic.
|
||||
// KeyInterface::yield(delay);
|
||||
//
|
||||
// // Release the keyboard interface.
|
||||
// Keyboard->suspend(false);
|
||||
// } else
|
||||
// // Otherwise just delay by the required amount for timing and to give other threads a time slice.
|
||||
// {
|
||||
// KeyInterface::yield(delay);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Structure to encapsulate a single key map from PS/2 to MZ-5600/MZ-6500.
|
||||
typedef struct {
|
||||
uint8_t ps2KeyCode;
|
||||
uint8_t ps2Ctrl;
|
||||
uint8_t keyboardModel;
|
||||
uint8_t machine;
|
||||
uint8_t mzKey;
|
||||
uint8_t mzCtrl;
|
||||
} t_keyMapEntry;
|
||||
|
||||
// Structure to encapsulate the entire static keyboard mapping table.
|
||||
typedef struct {
|
||||
t_keyMapEntry kme[PS2TBL_MZ5665_MAXROWS];
|
||||
} t_keyMap;
|
||||
|
||||
// Structure to maintain the MZ-5600/MZ-6500 interface configuration data. This data is persisted through powercycles as needed.
|
||||
typedef struct {
|
||||
struct {
|
||||
uint8_t activeKeyboardMap; // Model of keyboard a keymap entry is applicable to.
|
||||
uint8_t activeMachineModel; // Machine model a keymap entry is applicable to.
|
||||
} params;
|
||||
} t_mzConfig;
|
||||
|
||||
// Configuration data.
|
||||
t_mzConfig mzConfig;
|
||||
|
||||
// Structure to manage the control signals signifying the state of the MZ-6500 keyboard.
|
||||
typedef struct {
|
||||
bool optionSelect; // Flag to indicate a user requested keyboard configuration option is being selected.
|
||||
uint8_t keyCtrl; // Keyboard state flag control.
|
||||
|
||||
std::string fsPath; // Path on the underlying filesystem where storage is mounted and accessible.
|
||||
t_keyMapEntry *kme; // Pointer to an array in memory to contain PS2 to MZ-6500 mapping values.
|
||||
int kmeRows; // Number of rows in the kme table.
|
||||
std::string keyMapFileName; // Name of file where extension or replacement key map entries are stored.
|
||||
} t_mzControl;
|
||||
|
||||
// Transmit buffer queue item.
|
||||
typedef struct {
|
||||
uint32_t keyCode; // 16bit, bits 8:0 represent the key, 9 if CTRL to be sent, 10 if ALT to be sent.
|
||||
} t_xmitQueueMessage;
|
||||
|
||||
// Thread handles - one per function, ie. HID interface and host target interface.
|
||||
TaskHandle_t TaskHostIF = NULL;
|
||||
TaskHandle_t TaskHIDIF = NULL;
|
||||
|
||||
// Control structure to control interaction and mapping of keys for the host.
|
||||
t_mzControl mzCtrl;
|
||||
|
||||
// Spin lock mutex to hold a coresied to an uninterruptable method. This only works on dual core ESP32's.
|
||||
portMUX_TYPE mzMutex;
|
||||
|
||||
//
|
||||
// This mapping is for the UK Wyse KB-3926 PS/2 keyboard
|
||||
//
|
||||
t_keyMap PS2toMZ5665 = {
|
||||
{
|
||||
// HELP
|
||||
// COPY
|
||||
////PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MZ5665 Data MZ5665 Ctrl (Flags to Set).
|
||||
//{ PS2_KEY_F1, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 'v', 0x00, }, // SHIFT+F1
|
||||
//{ PS2_KEY_F2, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 'w', 0x00, }, // SHIFT+F2
|
||||
//{ PS2_KEY_F3, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 'x', 0x00, }, // SHIFT+F3
|
||||
//{ PS2_KEY_F4, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 'y', 0x00, }, // SHIFT+F4
|
||||
//{ PS2_KEY_F5, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 'z', 0x00, }, // SHIFT+F5
|
||||
//{ PS2_KEY_F1, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 'q', 0x00, }, // F1
|
||||
//{ PS2_KEY_F2, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 'r', 0x00, }, // F2
|
||||
//{ PS2_KEY_F3, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 's', 0x00, }, // F3
|
||||
//{ PS2_KEY_F4, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 't', 0x00, }, // F4
|
||||
//{ PS2_KEY_F5, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 'u', 0x00, }, // F5
|
||||
//{ PS2_KEY_F6, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0xEC, 0x00, }, // F6
|
||||
//{ PS2_KEY_F7, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0xEB, 0x00, }, // F7
|
||||
//{ PS2_KEY_F8, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0xE2, 0x00, }, // F8
|
||||
//{ PS2_KEY_F9, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0xE1, 0x00, }, // F9
|
||||
//{ PS2_KEY_F10, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // XFER
|
||||
//{ PS2_KEY_F11, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0xFE, 0x00, }, // HELP
|
||||
//{ PS2_KEY_F12, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // COPY
|
||||
//{ PS2_KEY_TAB, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x09, 0x00, }, // TAB
|
||||
// Numeric keys.
|
||||
{ PS2_KEY_0, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '0', 0x00, }, // 0
|
||||
{ PS2_KEY_1, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '1', 0x00, }, // 1
|
||||
{ PS2_KEY_2, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '2', 0x00, }, // 2
|
||||
{ PS2_KEY_3, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '3', 0x00, }, // 3
|
||||
{ PS2_KEY_4, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '4', 0x00, }, // 4
|
||||
{ PS2_KEY_5, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '5', 0x00, }, // 5
|
||||
{ PS2_KEY_6, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '6', 0x00, }, // 6
|
||||
{ PS2_KEY_7, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '7', 0x00, }, // 7
|
||||
{ PS2_KEY_8, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '8', 0x00, }, // 8
|
||||
{ PS2_KEY_9, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '9', 0x00, }, // 9
|
||||
// Punctuation keys.
|
||||
{ PS2_KEY_0, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, ')', 0x00, }, // Close Right Bracket )
|
||||
{ PS2_KEY_1, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '!', 0x00, }, // Exclamation
|
||||
{ PS2_KEY_2, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '"', 0x00, }, // Double quote.
|
||||
{ PS2_KEY_3, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0x23, 0x00, }, // Pound Sign -> Hash
|
||||
{ PS2_KEY_4, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '$', 0x00, }, // Dollar
|
||||
{ PS2_KEY_5, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '%', 0x00, }, // Percent
|
||||
{ PS2_KEY_6, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '^', 0x00, }, // Kappa
|
||||
{ PS2_KEY_7, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '&', 0x00, }, // Ampersand
|
||||
{ PS2_KEY_8, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '*', 0x00, }, // Star
|
||||
{ PS2_KEY_9, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '(', 0x00, }, // Open Left Bracket (
|
||||
// ALPHA keys, lower and uppercase.
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MZ5665 Data MZ5665 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_A, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'a', 0x00, }, // a
|
||||
{ PS2_KEY_A, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'A', 0x00, }, // A
|
||||
{ PS2_KEY_B, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'b', 0x00, }, // b
|
||||
{ PS2_KEY_B, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'B', 0x00, }, // B
|
||||
{ PS2_KEY_C, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'c', 0x00, }, // c
|
||||
{ PS2_KEY_C, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'C', 0x00, }, // C
|
||||
{ PS2_KEY_D, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'd', 0x00, }, // d
|
||||
{ PS2_KEY_D, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'D', 0x00, }, // D
|
||||
{ PS2_KEY_E, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'e', 0x00, }, // e
|
||||
{ PS2_KEY_E, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'E', 0x00, }, // E
|
||||
{ PS2_KEY_F, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'f', 0x00, }, // f
|
||||
{ PS2_KEY_F, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'F', 0x00, }, // F
|
||||
{ PS2_KEY_G, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'g', 0x00, }, // g
|
||||
{ PS2_KEY_G, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'G', 0x00, }, // G
|
||||
{ PS2_KEY_H, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'h', 0x00, }, // h
|
||||
{ PS2_KEY_H, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'H', 0x00, }, // H
|
||||
{ PS2_KEY_I, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'i', 0x00, }, // i
|
||||
{ PS2_KEY_I, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'I', 0x00, }, // I
|
||||
{ PS2_KEY_J, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'j', 0x00, }, // j
|
||||
{ PS2_KEY_J, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'J', 0x00, }, // J
|
||||
{ PS2_KEY_K, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'k', 0x00, }, // k
|
||||
{ PS2_KEY_K, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'K', 0x00, }, // K
|
||||
{ PS2_KEY_L, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'l', 0x00, }, // l
|
||||
{ PS2_KEY_L, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'L', 0x00, }, // L
|
||||
{ PS2_KEY_M, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'm', 0x00, }, // m
|
||||
{ PS2_KEY_M, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'M', 0x00, }, // M
|
||||
{ PS2_KEY_N, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'n', 0x00, }, // n
|
||||
{ PS2_KEY_N, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'N', 0x00, }, // N
|
||||
{ PS2_KEY_O, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'o', 0x00, }, // o
|
||||
{ PS2_KEY_O, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'O', 0x00, }, // O
|
||||
{ PS2_KEY_P, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'p', 0x00, }, // p
|
||||
{ PS2_KEY_P, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'P', 0x00, }, // P
|
||||
{ PS2_KEY_Q, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'q', 0x00, }, // q
|
||||
{ PS2_KEY_Q, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'Q', 0x00, }, // Q
|
||||
{ PS2_KEY_R, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'r', 0x00, }, // r
|
||||
{ PS2_KEY_R, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'R', 0x00, }, // R
|
||||
{ PS2_KEY_S, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 's', 0x00, }, // s
|
||||
{ PS2_KEY_S, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'S', 0x00, }, // S
|
||||
{ PS2_KEY_T, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 't', 0x00, }, // t
|
||||
{ PS2_KEY_T, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'T', 0x00, }, // T
|
||||
{ PS2_KEY_U, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'u', 0x00, }, // u
|
||||
{ PS2_KEY_U, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'U', 0x00, }, // U
|
||||
{ PS2_KEY_V, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'v', 0x00, }, // v
|
||||
{ PS2_KEY_V, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'V', 0x00, }, // V
|
||||
{ PS2_KEY_W, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'w', 0x00, }, // w
|
||||
{ PS2_KEY_W, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'W', 0x00, }, // W
|
||||
{ PS2_KEY_X, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'x', 0x00, }, // x
|
||||
{ PS2_KEY_X, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'X', 0x00, }, // X
|
||||
{ PS2_KEY_Y, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'y', 0x00, }, // y
|
||||
{ PS2_KEY_Y, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'Y', 0x00, }, // Y
|
||||
{ PS2_KEY_Z, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'z', 0x00, }, // z
|
||||
{ PS2_KEY_Z, PS2CTRL_CAPS, KEYMAP_STANDARD, MZ5665_ALL, 'Z', 0x00, }, // Z
|
||||
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MZ5665 Data MZ5665 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_SPACE, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, ' ', 0x00, }, // Space
|
||||
{ PS2_KEY_COMMA, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '<', 0x00, }, // Less Than <
|
||||
{ PS2_KEY_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, ',', 0x00, }, // Comma ,
|
||||
{ PS2_KEY_SEMI, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, ':', 0x00, }, // Colon :
|
||||
{ PS2_KEY_SEMI, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, ';', 0x00, }, // Semi-Colon ;
|
||||
{ PS2_KEY_DOT, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '>', 0x00, }, // Greater Than >
|
||||
{ PS2_KEY_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '.', 0x00, }, // Full stop .
|
||||
{ PS2_KEY_DIV, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '?', 0x00, }, // Question ?
|
||||
{ PS2_KEY_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '/', 0x00, }, // Divide /
|
||||
{ PS2_KEY_MINUS, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '_', 0x00, }, // Underscore
|
||||
{ PS2_KEY_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '-', 0x00, },
|
||||
{ PS2_KEY_APOS, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '@', 0x00, }, // At @
|
||||
{ PS2_KEY_APOS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '\'', 0x00, }, // Single quote '
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '{', 0x00, }, // Open Left Brace {
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '[', 0x00, }, // Open Left Square Bracket [
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '+', 0x00, }, // Plus +
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '=', 0x00, }, // Equal =
|
||||
{ PS2_KEY_CAPS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, ' ', 0x00, }, // LOCK
|
||||
{ PS2_KEY_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x0D, 0x00, }, // ENTER/RETURN
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '}', 0x00, }, // Close Right Brace }
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, ']', 0x00, }, // Close Right Square Bracket ]
|
||||
{ PS2_KEY_BACK, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '|', 0x00, }, //
|
||||
{ PS2_KEY_BACK, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '\\', 0x00, }, // Back slash maps to Yen
|
||||
{ PS2_KEY_BTICK, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '`', 0x00, }, // Pipe
|
||||
{ PS2_KEY_BTICK, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '|', 0x00, }, // Back tick `
|
||||
{ PS2_KEY_HASH, PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, '~', 0x00, }, // Tilde has no mapping.
|
||||
{ PS2_KEY_HASH, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '#', 0x00, }, // Hash
|
||||
{ PS2_KEY_BS, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x08, 0x00, }, // Backspace
|
||||
{ PS2_KEY_ESC, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x1B, 0x00, }, // ESCape
|
||||
{ PS2_KEY_SCROLL, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, ' ', 0x00, }, // Not assigned.
|
||||
{ PS2_KEY_INSERT, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, MZ5665_KEY_INS, 0x00, }, // INSERT
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, MZ5665_KEY_CLR, 0x00, }, // CLR
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, MZ5665_KEY_HOME, 0x00, }, // HOME
|
||||
{ PS2_KEY_DELETE, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, MZ5665_KEY_DEL, 0x00, }, // DELETE
|
||||
{ PS2_KEY_END, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x11, 0x00, }, // END
|
||||
{ PS2_KEY_PGUP, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x0E, 0x00, }, // Roll Up.
|
||||
{ PS2_KEY_PGDN, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x0F, 0x00, }, // Roll Down
|
||||
{ PS2_KEY_UP_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, MZ5665_KEY_UP, 0x00, }, // Up Arrow
|
||||
{ PS2_KEY_L_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, MZ5665_KEY_LEFT, 0x00, }, // Left Arrow
|
||||
{ PS2_KEY_DN_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, MZ5665_KEY_DOWN, 0x00, }, // Down Arrow
|
||||
{ PS2_KEY_R_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, MZ5665_KEY_RIGHT, 0x00, }, // Right Arrow
|
||||
{ PS2_KEY_NUM, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // Not assigned.
|
||||
// GRPH (Alt Gr)
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MZ5665 Data MZ5665 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_0, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xFA, 0x00, }, // GRPH+0
|
||||
{ PS2_KEY_1, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF1, 0x00, }, // GRPH+1
|
||||
{ PS2_KEY_2, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF2, 0x00, }, // GRPH+2
|
||||
{ PS2_KEY_3, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF3, 0x00, }, // GRPH+3
|
||||
{ PS2_KEY_4, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF4, 0x00, }, // GRPH+4
|
||||
{ PS2_KEY_5, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF5, 0x00, }, // GRPH+5
|
||||
{ PS2_KEY_6, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF6, 0x00, }, // GRPH+6
|
||||
{ PS2_KEY_7, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF7, 0x00, }, // GRPH+7
|
||||
{ PS2_KEY_8, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF8, 0x00, }, // GRPH+8
|
||||
{ PS2_KEY_9, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF9, 0x00, }, // GRPH+9
|
||||
{ PS2_KEY_A, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x7F, 0x00, }, // GRPH+A
|
||||
{ PS2_KEY_B, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x84, 0x00, }, // GRPH+B
|
||||
{ PS2_KEY_C, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x82, 0x00, }, // GRPH+C
|
||||
{ PS2_KEY_D, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xEA, 0x00, }, // GRPH+D
|
||||
{ PS2_KEY_E, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE2, 0x00, }, // GRPH+E
|
||||
{ PS2_KEY_F, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xEB, 0x00, }, // GRPH+F
|
||||
{ PS2_KEY_G, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xEC, 0x00, }, // GRPH+G
|
||||
{ PS2_KEY_H, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xED, 0x00, }, // GRPH+H
|
||||
{ PS2_KEY_I, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE7, 0x00, }, // GRPH+I
|
||||
{ PS2_KEY_J, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xEE, 0x00, }, // GRPH+J
|
||||
{ PS2_KEY_K, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xEF, 0x00, }, // GRPH+K
|
||||
{ PS2_KEY_L, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x8E, 0x00, }, // GRPH+L
|
||||
{ PS2_KEY_M, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x86, 0x00, }, // GRPH+M
|
||||
{ PS2_KEY_N, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x85, 0x00, }, // GRPH+N
|
||||
{ PS2_KEY_O, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xF0, 0x00, }, // GRPH+O
|
||||
{ PS2_KEY_P, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x8D, 0x00, }, // GRPH+P
|
||||
{ PS2_KEY_Q, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE0, 0x00, }, // GRPH+Q
|
||||
{ PS2_KEY_R, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE3, 0x00, }, // GRPH+R
|
||||
{ PS2_KEY_S, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE9, 0x00, }, // GRPH+S
|
||||
{ PS2_KEY_T, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE4, 0x00, }, // GRPH+T
|
||||
{ PS2_KEY_U, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE6, 0x00, }, // GRPH+U
|
||||
{ PS2_KEY_V, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x83, 0x00, }, // GRPH+V
|
||||
{ PS2_KEY_W, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE1, 0x00, }, // GRPH+W
|
||||
{ PS2_KEY_X, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x81, 0x00, }, // GRPH+X
|
||||
{ PS2_KEY_Y, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE5, 0x00, }, // GRPH+Y
|
||||
{ PS2_KEY_Z, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x80, 0x00, }, // GRPH+Z
|
||||
{ PS2_KEY_COMMA, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x87, 0x00, }, // GRPH+,
|
||||
{ PS2_KEY_SEMI, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x89, 0x00, }, // GRPH+;
|
||||
{ PS2_KEY_DOT, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x88, 0x00, }, // GRPH+.
|
||||
{ PS2_KEY_DIV, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xFE, 0x00, }, // GRPH+/
|
||||
{ PS2_KEY_MINUS, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x8C, 0x00, }, // GRPH+-
|
||||
{ PS2_KEY_APOS, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x8A, 0x00, }, // GRPH+'
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xFC, 0x00, }, // GRPH+[
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0xE8, 0x00, }, // GRPH+]
|
||||
{ PS2_KEY_BACK, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x90, 0x00, }, // GRPH+Backslash
|
||||
{ PS2_KEY_KP0, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x8F, 0x00, }, // GRPH+Keypad 0
|
||||
{ PS2_KEY_KP1, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x99, 0x00, }, // GRPH+Keypad 1
|
||||
{ PS2_KEY_KP2, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x92, 0x00, }, // GRPH+Keypad 2
|
||||
{ PS2_KEY_KP3, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x98, 0x00, }, // GRPH+Keypad 3
|
||||
{ PS2_KEY_KP4, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x95, 0x00, }, // GRPH+Keypad 4
|
||||
{ PS2_KEY_KP5, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x96, 0x00, }, // GRPH+Keypad 5
|
||||
{ PS2_KEY_KP6, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x94, 0x00, }, // GRPH+Keypad 6
|
||||
{ PS2_KEY_KP7, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x9A, 0x00, }, // GRPH+Keypad 7
|
||||
{ PS2_KEY_KP8, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x93, 0x00, }, // GRPH+Keypad 8
|
||||
{ PS2_KEY_KP9, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x97, 0x00, }, // GRPH+Keypad 9
|
||||
{ PS2_KEY_KP_DOT, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x91, 0x00, }, // GRPH+Keypad Full stop .
|
||||
{ PS2_KEY_KP_PLUS, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x9D, 0x00, }, // GRPH+Keypad Plus +
|
||||
{ PS2_KEY_KP_MINUS, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x9C, 0x00, }, // GRPH+Keypad Minus -
|
||||
{ PS2_KEY_KP_TIMES, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x9B, 0x00, }, // GRPH+Keypad Times *
|
||||
{ PS2_KEY_KP_DIV, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x9E, 0x00, }, // GRPH+Keypad Divide /
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x90, 0x00, }, // GRPH+Keypad Ebter /
|
||||
// KANA (Alt)
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MZ5665 Data MZ5665 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_0, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA6, 0x00, }, // KANA+SHIFT+0
|
||||
{ PS2_KEY_0, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xDC, 0x00, }, // KANA+0
|
||||
{ PS2_KEY_1, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC7, 0x00, }, // KANA+1
|
||||
{ PS2_KEY_2, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xCC, 0x00, }, // KANA+2
|
||||
{ PS2_KEY_3, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA7, 0x00, }, // KANA+SHIFT+3
|
||||
{ PS2_KEY_3, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xB1, 0x00, }, // KANA+3
|
||||
{ PS2_KEY_4, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA9, 0x00, }, // KANA+SHIFT+4
|
||||
{ PS2_KEY_4, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xB3, 0x00, }, // KANA+4
|
||||
{ PS2_KEY_5, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xAA, 0x00, }, // KANA+SHIFT+5
|
||||
{ PS2_KEY_5, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xB4, 0x00, }, // KANA+5
|
||||
{ PS2_KEY_6, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xAB, 0x00, }, // KANA+SHIFT+6
|
||||
{ PS2_KEY_6, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xB5, 0x00, }, // KANA+6
|
||||
{ PS2_KEY_7, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xAC, 0x00, }, // KANA+SHIFT+7
|
||||
{ PS2_KEY_7, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD4, 0x00, }, // KANA+7
|
||||
{ PS2_KEY_8, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xAD, 0x00, }, // KANA+SHIFT+8
|
||||
{ PS2_KEY_8, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD5, 0x00, }, // KANA+8
|
||||
{ PS2_KEY_9, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xAE, 0x00, }, // KANA+SHIFT+9
|
||||
{ PS2_KEY_9, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD6, 0x00, }, // KANA+9
|
||||
{ PS2_KEY_A, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC1, 0x00, }, // KANA+A
|
||||
{ PS2_KEY_B, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xBA, 0x00, }, // KANA+B
|
||||
{ PS2_KEY_C, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xBF, 0x00, }, // KANA+C
|
||||
{ PS2_KEY_D, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xBC, 0x00, }, // KANA+D
|
||||
{ PS2_KEY_E, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA8, 0x00, }, // KANA+SHIFT+E
|
||||
{ PS2_KEY_E, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xB2, 0x00, }, // KANA+E
|
||||
{ PS2_KEY_F, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xCA, 0x00, }, // KANA+F
|
||||
{ PS2_KEY_G, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xB7, 0x00, }, // KANA+G
|
||||
{ PS2_KEY_H, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xB8, 0x00, }, // KANA+H
|
||||
{ PS2_KEY_I, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC6, 0x00, }, // KANA+I
|
||||
{ PS2_KEY_J, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xCF, 0x00, }, // KANA+J
|
||||
{ PS2_KEY_K, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC9, 0x00, }, // KANA+K
|
||||
{ PS2_KEY_L, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD8, 0x00, }, // KANA+L
|
||||
{ PS2_KEY_M, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD3, 0x00, }, // KANA+M
|
||||
{ PS2_KEY_N, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD0, 0x00, }, // KANA+N
|
||||
{ PS2_KEY_O, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD7, 0x00, }, // KANA+O
|
||||
{ PS2_KEY_P, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xBE, 0x00, }, // KANA+P
|
||||
{ PS2_KEY_Q, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC0, 0x00, }, // KANA+Q
|
||||
{ PS2_KEY_R, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xBD, 0x00, }, // KANA+R
|
||||
{ PS2_KEY_S, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC4, 0x00, }, // KANA+S
|
||||
{ PS2_KEY_T, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xB6, 0x00, }, // KANA+T
|
||||
{ PS2_KEY_U, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC5, 0x00, }, // KANA+U
|
||||
{ PS2_KEY_V, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xCB, 0x00, }, // KANA+V
|
||||
{ PS2_KEY_W, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC3, 0x00, }, // KANA+W
|
||||
{ PS2_KEY_X, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xBB, 0x00, }, // KANA+X
|
||||
{ PS2_KEY_Y, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xDD, 0x00, }, // KANA+Y
|
||||
{ PS2_KEY_Z, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xAF, 0x00, }, // KANA+SHIFT+Z
|
||||
{ PS2_KEY_Z, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC2, 0x00, }, // KANA+Z
|
||||
{ PS2_KEY_COMMA, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA4, 0x00, }, // KANA+SHIFT+,
|
||||
{ PS2_KEY_COMMA, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xC8, 0x00, }, // KANA+,
|
||||
{ PS2_KEY_SEMI, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xDA, 0x00, }, // KANA+;
|
||||
{ PS2_KEY_DOT, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA1, 0x00, }, // KANA+SHIFT+.
|
||||
{ PS2_KEY_DOT, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD9, 0x00, }, // KANA+.
|
||||
{ PS2_KEY_DIV, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA5, 0x00, }, // KANA+SHIFT+/
|
||||
{ PS2_KEY_DIV, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD2, 0x00, }, // KANA+/
|
||||
{ PS2_KEY_MINUS, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xCE, 0x00, }, // KANA+-
|
||||
{ PS2_KEY_APOS, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xDE, 0x00, }, // KANA+'
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA2, 0x00, }, // KANA+SHIFT+[
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xDF, 0x00, }, // KANA+[
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0xA3, 0x00, }, // KANA+SHIFT+]
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xD1, 0x00, }, // KANA+]
|
||||
{ PS2_KEY_BACK, PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0xDB, 0x00, }, // KANA+Backslash
|
||||
{ PS2_KEY_BS, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, MZ5665_ALL, 0x12, 0x00, }, // KANA+SHIFT+Backspace
|
||||
// Keypad.
|
||||
{ PS2_KEY_KP0, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '0', 0x00, }, // Keypad 0
|
||||
{ PS2_KEY_KP1, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '1', 0x00, }, // Keypad 1
|
||||
{ PS2_KEY_KP2, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '2', 0x00, }, // Keypad 2
|
||||
{ PS2_KEY_KP3, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '3', 0x00, }, // Keypad 3
|
||||
{ PS2_KEY_KP4, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '4', 0x00, }, // Keypad 4
|
||||
{ PS2_KEY_KP5, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '5', 0x00, }, // Keypad 5
|
||||
{ PS2_KEY_KP6, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '6', 0x00, }, // Keypad 6
|
||||
{ PS2_KEY_KP7, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '7', 0x00, }, // Keypad 7
|
||||
{ PS2_KEY_KP8, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '8', 0x00, }, // Keypad 8
|
||||
{ PS2_KEY_KP9, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '9', 0x00, }, // Keypad 9
|
||||
{ PS2_KEY_KP_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, ',', 0x00, }, // Keypad Comma ,
|
||||
{ PS2_KEY_KP_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '.', 0x00, }, // Keypad Full stop .
|
||||
{ PS2_KEY_KP_PLUS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '+', 0x00, }, // Keypad Plus +
|
||||
{ PS2_KEY_KP_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '-', 0x00, }, // Keypad Minus -
|
||||
{ PS2_KEY_KP_TIMES, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '*', 0x00, }, // Keypad Times *
|
||||
{ PS2_KEY_KP_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, '/', 0x00, }, // Keypad Divide /
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x0D, 0x00, }, // Keypad Ebter /
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine MZ5665 Data MZ5665 Ctrl (Flags to Set).
|
||||
// Special keys.
|
||||
{ PS2_KEY_PRTSCR, PS2CTRL_FUNC, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // ARGO KEY
|
||||
{ PS2_KEY_PAUSE, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x03, 0x00, }, // BREAK KEY
|
||||
{ PS2_KEY_L_GUI, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // GRAPH KEY
|
||||
//{ PS2_KEY_L_ALT, PS2CTRL_FUNC | PS2CTRL_KANA, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // KJ1 Sentence
|
||||
//{ PS2_KEY_R_ALT, PS2CTRL_FUNC | PS2CTRL_GRAPH, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // KJ2 Transform
|
||||
{ PS2_KEY_R_GUI, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // KANA KEY
|
||||
{ PS2_KEY_MENU, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // Not assigned.
|
||||
// Modifiers are last, only being selected if an earlier match isnt made.
|
||||
{ PS2_KEY_L_SHIFT, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, },
|
||||
{ PS2_KEY_R_SHIFT, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, },
|
||||
{ PS2_KEY_L_CTRL, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, },
|
||||
{ PS2_KEY_R_CTRL, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, }, // Map to Control
|
||||
{ 0, PS2CTRL_NONE, KEYMAP_STANDARD, MZ5665_ALL, 0x00, 0x00, },
|
||||
}};
|
||||
};
|
||||
|
||||
#endif // MZ5665_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/Mouse.h
|
||||
151
main/include/Mouse.h
Normal file
151
main/include/Mouse.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: Mouse.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header for the PS/2 Mouse to Sharp Host interface logic.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
// v1.02 Jun 2022 - Updates to reflect changes realised in other modules due to addition of
|
||||
// bluetooth and suspend logic due to NVS issues using both cores.
|
||||
// Updates to reflect moving functionality into the HID and to support
|
||||
// Bluetooth as a primary mouse or secondary mouse.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MOUSE_H
|
||||
#define MOUSE_H
|
||||
|
||||
// Include the specification class.
|
||||
#include "KeyInterface.h"
|
||||
#include "NVS.h"
|
||||
#include "HID.h"
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Encapsulate the Mouse interface.
|
||||
class Mouse : public KeyInterface {
|
||||
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define MOUSEIF_VERSION 1.02
|
||||
#define MAX_MOUSE_XMIT_KEY_BUF 128
|
||||
#define BITBANG_UART_BIT_TIME 208UL
|
||||
|
||||
public:
|
||||
|
||||
// Prototypes.
|
||||
Mouse(void);
|
||||
Mouse(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID);
|
||||
Mouse(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID, bool secondaryIf);
|
||||
Mouse(NVS *hdlNVShdlHID, HID *hdlHID);
|
||||
~Mouse(void);
|
||||
void getMouseConfigTypes(std::vector<std::string>& typeList);
|
||||
bool getMouseSelectList(std::vector<std::pair<std::string, int>>& selectList, std::string option);
|
||||
bool setMouseConfigValue(std::string paramName, std::string paramValue);
|
||||
void mouseReceiveData(HID::t_mouseMessageElement mouseMessage);
|
||||
bool persistConfig(void);
|
||||
|
||||
// Method to return the class version number.
|
||||
float version(void)
|
||||
{
|
||||
return(MOUSEIF_VERSION);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
IRAM_ATTR static void hostInterface( void * pvParameters );
|
||||
void init(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID);
|
||||
void init(NVS *hdlNVS, HID *hdlHID);
|
||||
|
||||
// Structure to maintain mouse interface configuration data. This data is persisted through powercycles as needed.
|
||||
typedef struct {
|
||||
struct {
|
||||
// PS/2 Mouse data Adjustment and filtering options.
|
||||
//
|
||||
enum HID::HID_MOUSE_RESOLUTION resolution;
|
||||
enum HID::HID_MOUSE_SCALING scaling;
|
||||
enum HID::HID_MOUSE_SAMPLING sampleRate;
|
||||
} mouse;
|
||||
|
||||
struct {
|
||||
// Host data for adjustment and configuration.
|
||||
enum HID::HID_MOUSE_HOST_SCALING scaling;
|
||||
} host;
|
||||
|
||||
struct {
|
||||
} params;
|
||||
} t_mouseConfig;
|
||||
|
||||
// Configuration data.
|
||||
t_mouseConfig mouseConfig;
|
||||
|
||||
// Structure to manage the Mouse control variables signifying the state of the Mouse.
|
||||
typedef struct {
|
||||
} t_msControl;
|
||||
|
||||
// Mouse Control variables.
|
||||
volatile t_msControl msCtrl;
|
||||
|
||||
// Structure to manage the Sharp host control variables which define control and data mapping of the host interface and data sent.
|
||||
//
|
||||
typedef struct {
|
||||
#ifdef CONFIG_HOST_HW_UART
|
||||
int uartNum;
|
||||
int uartBufferSize;
|
||||
int uartQueueSize;
|
||||
#endif
|
||||
bool secondaryIf; // Mouse runs in tandem with a keyboard interface.
|
||||
|
||||
// Data adjustment and processing options applied to the PS/2 data.
|
||||
bool updated;
|
||||
} t_hostControl;
|
||||
|
||||
// Host Control variables.
|
||||
volatile t_hostControl hostControl;
|
||||
|
||||
// PS/2 to HOST serialiser buffer item.
|
||||
typedef struct {
|
||||
uint8_t xPos;
|
||||
uint8_t yPos;
|
||||
uint8_t status;
|
||||
uint8_t wheel;
|
||||
bool valid;
|
||||
} t_xmitMessage;
|
||||
|
||||
// Create an object for storing the data to be sent to the Host. This data has already been converted and adjusted from the incoming PS/2 message.
|
||||
t_xmitMessage xmitMsg;
|
||||
|
||||
// Thread handles - one per function, ie. ps/2 interface, host target interface, wifi interface.
|
||||
TaskHandle_t TaskHostIF = NULL;
|
||||
TaskHandle_t TaskHIDIF = NULL;
|
||||
|
||||
// Spin lock mutex to hold a coresied to an uninterruptable method. This only works on dual core ESP32's.
|
||||
portMUX_TYPE x1Mutex;
|
||||
};
|
||||
|
||||
#endif // MOUSE_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/NVS.h
|
||||
162
main/include/NVS.h
Normal file
162
main/include/NVS.h
Normal file
@@ -0,0 +1,162 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: NVS.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Class definition to encapsulate the Espressif Non Volatile Storage into a thread safe
|
||||
// object, The underlying API is supposed to be thread safe but experience has shown
|
||||
// that two threads, each with there own handle can cause a lockup.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef NVS_H
|
||||
#define NVS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "driver/timer.h"
|
||||
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Define a virtual class which acts as the base and specification of all super classes forming host
|
||||
// interface objects.
|
||||
class NVS {
|
||||
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define NVS_VERSION 1.01
|
||||
|
||||
public:
|
||||
|
||||
// Prototypes.
|
||||
NVS(void);
|
||||
NVS(std::string keyName);
|
||||
virtual ~NVS(void) {};
|
||||
void eraseAll(void);
|
||||
void init(void);
|
||||
bool takeMutex(void);
|
||||
void giveMutex(void);
|
||||
// Persistence.
|
||||
bool open(std::string keyName);
|
||||
bool persistData(const char *key, void *pData, uint32_t size);
|
||||
bool retrieveData(const char *key, void *pData, uint32_t size);
|
||||
bool commitData(void);
|
||||
|
||||
// Helper method to identify the sub class, this is used in non volatile key management.
|
||||
// Warning: This method wont work if optimisation for size is enabled on the compiler.
|
||||
const char *getClassName(const std::string& prettyFunction)
|
||||
{
|
||||
// First find the CLASS :: METHOD seperation.
|
||||
size_t colons = prettyFunction.find("::");
|
||||
|
||||
// None, then this is not a class.
|
||||
if (colons == std::string::npos)
|
||||
return "::";
|
||||
|
||||
// Split out the class name.
|
||||
size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
|
||||
size_t end = colons - begin;
|
||||
|
||||
// Return the name.
|
||||
return(prettyFunction.substr(begin,end).c_str());
|
||||
}
|
||||
|
||||
// Helper method to change a file extension.
|
||||
void replaceExt(std::string& fileName, const std::string& newExt)
|
||||
{
|
||||
// Locals.
|
||||
std::string::size_type extPos = fileName.rfind('.', fileName.length());
|
||||
|
||||
if(extPos != std::string::npos)
|
||||
{
|
||||
fileName.replace(extPos+1, newExt.length(), newExt);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Template to aid in conversion of an enum to integer.
|
||||
template <typename E> constexpr typename std::underlying_type<E>::type to_underlying(E e) noexcept
|
||||
{
|
||||
return static_cast<typename std::underlying_type<E>::type>(e);
|
||||
}
|
||||
|
||||
// Method to return the class version number.
|
||||
virtual float version(void)
|
||||
{
|
||||
return(NVS_VERSION);
|
||||
}
|
||||
|
||||
// Method to return the name of the class.
|
||||
virtual std::string ifName(void)
|
||||
{
|
||||
return(nvsCtrl.nvsClassName);
|
||||
}
|
||||
|
||||
// Method to return the name of the nvs key.
|
||||
virtual std::string keyName(void)
|
||||
{
|
||||
return(nvsCtrl.nvsKeyName);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Structure to maintain an active setting for the LED. The LED control thread uses these values to effect the required lighting of the LED.
|
||||
typedef struct {
|
||||
// Handle to the persistent storage api.
|
||||
nvs_handle_t nvsHandle;
|
||||
|
||||
// Name of the class for this instantiation.
|
||||
std::string nvsClassName;
|
||||
|
||||
// Name of the key under which NVS was opened.
|
||||
std::string nvsKeyName;
|
||||
|
||||
// Mutex to block access to limit one thread at a time.
|
||||
SemaphoreHandle_t mutexInternal;
|
||||
} t_nvsControl;
|
||||
|
||||
// Var to store all NVS control variables.
|
||||
t_nvsControl nvsCtrl;
|
||||
|
||||
};
|
||||
#endif // NVS_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/PC9801.h
|
||||
529
main/include/PC9801.h
Normal file
529
main/include/PC9801.h
Normal file
@@ -0,0 +1,529 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: PC9801.h
|
||||
// Created: Apr 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header for the NEC PC-9801 to HID (PS/2, Bluetooth) interface logic.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Apr 2022 - Initial write.
|
||||
// v1.01 Jun 2022 - Updates to reflect changes realised in other modules due to addition of
|
||||
// bluetooth and suspend logic due to NVS issues using both cores.
|
||||
//
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PC9801_H
|
||||
#define PC9801_H
|
||||
|
||||
// Include the specification class.
|
||||
#include "KeyInterface.h"
|
||||
#include "NVS.h"
|
||||
#include "LED.h"
|
||||
#include "HID.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Encapsulate the NEC PC-9801 interface.
|
||||
class PC9801 : public KeyInterface {
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define PC9801IF_VERSION 1.00
|
||||
#define PC9801IF_KEYMAP_FILE "PC9801_KeyMap.BIN"
|
||||
#define MAX_PC9801_XMIT_KEY_BUF 16
|
||||
#define MAX_PC9801_RCV_KEY_BUF 16
|
||||
|
||||
// NEC PC-9801 Key control bit mask.
|
||||
#define PC9801_CTRL_SHIFT ((unsigned char) (1 << 5))
|
||||
#define PC9801_CTRL_RELEASESHIFT ((unsigned char) (1 << 4))
|
||||
#define PC9801_CTRL_CTRL ((unsigned char) (1 << 3))
|
||||
#define PC9801_CTRL_GRAPH ((unsigned char) (1 << 2))
|
||||
#define PC9801_CTRL_CAPS ((unsigned char) (1 << 1))
|
||||
#define PC9801_CTRL_KANA ((unsigned char) (1 << 0))
|
||||
#define PC9801_CTRL_NONE 0x00
|
||||
|
||||
// Special key definition.
|
||||
// #define PC9801_KEY_UP 0x1E // ↑
|
||||
// #define PC9801_KEY_DOWN 0x1F // ↓
|
||||
// #define PC9801_KEY_LEFT 0x1D // ←
|
||||
// #define PC9801_KEY_RIGHT 0x1C // → →
|
||||
// #define PC9801_KEY_INS 0x12 // INS
|
||||
// #define PC9801_KEY_DEL 0x08 // DEL
|
||||
// #define PC9801_KEY_CLR 0x0C // CLR
|
||||
// #define PC9801_KEY_HOME 0x0B // HOME
|
||||
|
||||
// PS2 Flag definitions.
|
||||
#define PS2CTRL_NONE 0x00 // No keys active = 0
|
||||
#define PS2CTRL_SHIFT 0x01 // Shfit Key active = 1
|
||||
#define PS2CTRL_CTRL 0x02 // Ctrl Key active = 1
|
||||
#define PS2CTRL_CAPS 0x04 // CAPS active = 1
|
||||
#define PS2CTRL_KANA 0x08 // KANA active = 1
|
||||
#define PS2CTRL_GRAPH 0x10 // GRAPH active = 1
|
||||
#define PS2CTRL_GUI 0x20 // GUI Key active = 1
|
||||
#define PS2CTRL_FUNC 0x40 // Special Function Keys active = 1
|
||||
#define PS2CTRL_BREAK 0x80 // BREAK Key active = 1
|
||||
#define PS2CTRL_EXACT 0x80 // EXACT Match active = 1
|
||||
|
||||
// The initial mapping is made inside the PS2KeyAdvanced class from Scan Code Set 2 to ASCII
|
||||
// for a selected keyboard. Special functions are detected and combined inside this module
|
||||
// before mapping with the table below to extract the PC-9801 key code and control data.
|
||||
// ie. PS/2 Scan Code -> ASCII + Flags -> PC-9801 Key Code + Ctrl Data
|
||||
#define PS2TBL_PC9801_MAXCOLS 6
|
||||
#define PS2TBL_PC9801_MAXROWS 131
|
||||
|
||||
// The initial mapping is made inside the PS2KeyAdvanced class from Scan Code Set 2 to ASCII
|
||||
// for a selected keyboard. Special functions are detected and combined inside this module
|
||||
// before mapping with the table below to extract the NEC PC-9801 key code and control data.
|
||||
// ie. PS/2 Scan Code -> ASCII + Flags -> NEC PC-9801 Key Code + Ctrl Data
|
||||
|
||||
// Keyboard mapping table column names.
|
||||
#define PS2TBL_PS2KEYCODE_NAME "PS/2 KeyCode"
|
||||
#define PS2TBL_PS2CTRL_NAME "PS/2 Control Key"
|
||||
#define PS2TBL_KEYBOARDMODEL_NAME "For Keyboard"
|
||||
#define PS2TBL_MACHINE_NAME "For Host Model"
|
||||
#define PS2TBL_PC9801_KEYCODE_NAME "PC9801 KeyCode"
|
||||
#define PS2TBL_PC9801__CTRL_NAME "PC9801 Control Key"
|
||||
|
||||
// Keyboard mapping table column types.
|
||||
#define PS2TBL_PS2KEYCODE_TYPE "hex"
|
||||
#define PS2TBL_PS2CTRL_TYPE "custom_cbp_ps2ctrl"
|
||||
#define PS2TBL_KEYBOARDMODEL_TYPE "custom_cbp_keybmodel"
|
||||
#define PS2TBL_MACHINE_TYPE "custom_cbp_machine"
|
||||
#define PS2TBL_PC9801_KEYCODE_TYPE "hex"
|
||||
#define PS2TBL_PC9801_CTRL_TYPE "custom_cbn_x1ctrl"
|
||||
|
||||
// Keyboard mapping table select list for PS2CTRL.
|
||||
#define PS2TBL_PS2CTRL_SEL_NONE "NONE"
|
||||
#define PS2TBL_PS2CTRL_SEL_SHIFT "SHIFT"
|
||||
#define PS2TBL_PS2CTRL_SEL_CTRL "CTRL"
|
||||
#define PS2TBL_PS2CTRL_SEL_CAPS "CAPS"
|
||||
#define PS2TBL_PS2CTRL_SEL_KANA "KANA"
|
||||
#define PS2TBL_PS2CTRL_SEL_GRAPH "GRAPH"
|
||||
#define PS2TBL_PS2CTRL_SEL_GUI "GUI"
|
||||
#define PS2TBL_PS2CTRL_SEL_FUNC "FUNC"
|
||||
#define PS2TBL_PS2CTRL_SEL_EXACT "EXACT"
|
||||
|
||||
// Keyboard mapping table select list for target machine.
|
||||
#define PC9801_SEL_ALL "ALL"
|
||||
#define PC9801_SEL_ORIG "ORIGINAL"
|
||||
|
||||
// Keyboard mapping table select list for Model of keyboard.
|
||||
#define KEYMAP_SEL_STANDARD "ALL"
|
||||
#define KEYMAP_SEL_UK_WYSE_KB3926 "UK_WYSE_KB3926"
|
||||
#define KEYMAP_SEL_JAPAN_OADG109 "JAPAN_OADG109"
|
||||
#define KEYMAP_SEL_JAPAN_SANWA_SKBL1 "JAPAN_SANWA_SKBL1"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_4 "KEYBOARD_4"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_5 "KEYBOARD_5"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_6 "KEYBOARD_6"
|
||||
#define KEYMAP_SEL_UK_PERIBOARD_810 "UK_PERIBOARD_810"
|
||||
#define KEYMAP_SEL_UK_OMOTON_K8508 "UK_OMOTON_K8508"
|
||||
|
||||
// Keyboard mapping table select list for PC9801 Control codes.
|
||||
#define PC9801_CTRL_SEL_GRAPH "GRAPH"
|
||||
#define PC9801_CTRL_SEL_CAPS "CAPS"
|
||||
#define PC9801_CTRL_SEL_KANA "KANA"
|
||||
#define PC9801_CTRL_SEL_SHIFT "SHIFT"
|
||||
#define PC9801_CTRL_SEL_CTRL "CTRL"
|
||||
|
||||
// The NEC PC-9801 Series was released over a number of years and each iteration added changes/updates. In order to cater for differences, it is possible to assign a key mapping
|
||||
// to a specific machine type(s) or all of the series by adding the flags below into the mapping table.
|
||||
#define PC9801_ALL 0xFF
|
||||
|
||||
// Keyboard models. The base on which this interface was created was a Wyse KB3926 PS/2 Keyboard and this is deemed STANDARD. Other models need to insert difference maps
|
||||
// prior to the STANDARD entry along with the keyboard model so that it is processed first thus allowing differing keyboards with different maps.
|
||||
#define KEYMAP_STANDARD 0xFF
|
||||
#define KEYMAP_UK_WYSE_KB3926 0x01
|
||||
#define KEYMAP_JAPAN_OADG109 0x02
|
||||
#define KEYMAP_JAPAN_SANWA_SKBL1 0x04
|
||||
#define KEYMAP_NOT_ASSIGNED_4 0x08
|
||||
#define KEYMAP_NOT_ASSIGNED_5 0x10
|
||||
#define KEYMAP_NOT_ASSIGNED_6 0x20
|
||||
#define KEYMAP_UK_PERIBOARD_810 0x40
|
||||
#define KEYMAP_UK_OMOTON_K8508 0x80
|
||||
|
||||
// PC-9801 Scan codes - PS2 codes along with function keys (SHIFT, CTRL etc) are mapped to the X68000 scan codes below.
|
||||
#define PC9801_KEY_ESC 0x00
|
||||
#define PC9801_KEY_0 0x0A
|
||||
#define PC9801_KEY_1 0x01
|
||||
#define PC9801_KEY_2 0x02
|
||||
#define PC9801_KEY_3 0x03
|
||||
#define PC9801_KEY_4 0x04
|
||||
#define PC9801_KEY_5 0x05
|
||||
#define PC9801_KEY_6 0x06
|
||||
#define PC9801_KEY_7 0x07
|
||||
#define PC9801_KEY_8 0x08
|
||||
#define PC9801_KEY_9 0x09
|
||||
#define PC9801_KEY_A 0x1D
|
||||
#define PC9801_KEY_B 0x2D
|
||||
#define PC9801_KEY_C 0x2B
|
||||
#define PC9801_KEY_D 0x1F
|
||||
#define PC9801_KEY_E 0x12
|
||||
#define PC9801_KEY_F 0x20
|
||||
#define PC9801_KEY_G 0x21
|
||||
#define PC9801_KEY_H 0x22
|
||||
#define PC9801_KEY_I 0x17
|
||||
#define PC9801_KEY_J 0x23
|
||||
#define PC9801_KEY_K 0x24
|
||||
#define PC9801_KEY_L 0x25
|
||||
#define PC9801_KEY_M 0x2F
|
||||
#define PC9801_KEY_N 0x2E
|
||||
#define PC9801_KEY_O 0x18
|
||||
#define PC9801_KEY_P 0x19
|
||||
#define PC9801_KEY_Q 0x10
|
||||
#define PC9801_KEY_R 0x13
|
||||
#define PC9801_KEY_S 0x1E
|
||||
#define PC9801_KEY_T 0x14
|
||||
#define PC9801_KEY_U 0x16
|
||||
#define PC9801_KEY_V 0x2C
|
||||
#define PC9801_KEY_W 0x11
|
||||
#define PC9801_KEY_X 0x2A
|
||||
#define PC9801_KEY_Y 0x15
|
||||
#define PC9801_KEY_Z 0x29
|
||||
#define PC9801_KEY_AT 0x1A // Requires SHIFT
|
||||
#define PC9801_KEY_MINUS 0x0B
|
||||
#define PC9801_KEY_CIRCUMFLEX 0x0C
|
||||
#define PC9801_KEY_YEN 0x0D
|
||||
#define PC9801_KEY_BS 0x0E
|
||||
#define PC9801_KEY_TAB 0x0F
|
||||
#define PC9801_KEY_OPEN_SQ 0x1A
|
||||
#define PC9801_KEY_CLOSE_SQ 0x1B
|
||||
#define PC9801_KEY_RETURN 0x1C
|
||||
#define PC9801_KEY_SEMI 0x26
|
||||
#define PC9801_KEY_COLON 0x27
|
||||
#define PC9801_KEY_COMMA 0x30
|
||||
#define PC9801_KEY_DOT 0x31
|
||||
#define PC9801_KEY_DIV 0x32
|
||||
#define PC9801_KEY_UNDERLINE 0x0D // Requires SHIFT
|
||||
#define PC9801_KEY_SPACE 0x34
|
||||
#define PC9801_KEY_HOME 0x3E
|
||||
#define PC9801_KEY_ROLLUP 0x36
|
||||
#define PC9801_KEY_ROLLDN 0x37
|
||||
#define PC9801_KEY_UNDO 0x3 // Not known3
|
||||
#define PC9801_KEY_L_ARROW 0x3B
|
||||
#define PC9801_KEY_UP_ARROW 0x3A
|
||||
#define PC9801_KEY_R_ARROW 0x3C
|
||||
#define PC9801_KEY_DN_ARROW 0x3D
|
||||
#define PC9801_KEY_CLR 0x3F // Not known
|
||||
#define PC9801_KEY_KP0 0x4E
|
||||
#define PC9801_KEY_KP1 0x4A
|
||||
#define PC9801_KEY_KP2 0x4B
|
||||
#define PC9801_KEY_KP3 0x4C
|
||||
#define PC9801_KEY_KP4 0x46
|
||||
#define PC9801_KEY_KP5 0x47
|
||||
#define PC9801_KEY_KP6 0x48
|
||||
#define PC9801_KEY_KP7 0x42
|
||||
#define PC9801_KEY_KP8 0x43
|
||||
#define PC9801_KEY_KP9 0x44
|
||||
#define PC9801_KEY_KP_DIV 0x41
|
||||
#define PC9801_KEY_KP_TIMES 0x45
|
||||
#define PC9801_KEY_KP_MINUS 0x4D
|
||||
#define PC9801_KEY_KP_PLUS 0x49
|
||||
#define PC9801_KEY_KP_EQUAL 0x4D
|
||||
#define PC9801_KEY_KP_ENTER 0x1C
|
||||
#define PC9801_KEY_KP_COMMA 0x4F
|
||||
#define PC9801_KEY_KP_DOT 0x50
|
||||
#define PC9801_KEY_SYMBOL 0x52 // Not known
|
||||
#define PC9801_KEY_HELP 0x3F
|
||||
#define PC9801_KEY_CAPS 0x71
|
||||
#define PC9801_KEY_INS 0x38
|
||||
#define PC9801_KEY_DEL 0x39
|
||||
#define PC9801_KEY_BREAK 0x60 // Stop
|
||||
#define PC9801_KEY_COPY 0x61
|
||||
#define PC9801_KEY_SHIFT 0x70
|
||||
#define PC9801_KEY_R_SHIFT 0x7D
|
||||
#define PC9801_KEY_CTRL 0x74
|
||||
#define PC9801_KEY_GRAPH 0x73
|
||||
#define PC9801_KEY_XFER 0x35
|
||||
#define PC9801_KEY_NFER 0x51
|
||||
#define PC9801_KEY_KATAKANA 0x72
|
||||
#define PC9801_KEY_ROMAJI 0x33
|
||||
#define PC9801_KEY_F1 0x62
|
||||
#define PC9801_KEY_F2 0x63
|
||||
#define PC9801_KEY_F3 0x64
|
||||
#define PC9801_KEY_F4 0x65
|
||||
#define PC9801_KEY_F5 0x66
|
||||
#define PC9801_KEY_F6 0x67
|
||||
#define PC9801_KEY_F7 0x68
|
||||
#define PC9801_KEY_F8 0x69
|
||||
#define PC9801_KEY_F9 0x6A
|
||||
#define PC9801_KEY_F10 0x6B
|
||||
#define PC9801_KEY_F11 0x52
|
||||
#define PC9801_KEY_F12 0x53
|
||||
#define PC9801_KEY_F13 0x54
|
||||
#define PC9801_KEY_F14 0x55
|
||||
#define PC9801_KEY_F15 0x56
|
||||
#define PC9801_KEY_NULL 0xFF
|
||||
|
||||
public:
|
||||
// Prototypes.
|
||||
PC9801(void);
|
||||
PC9801(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID, const char *fsPath);
|
||||
PC9801(NVS *hdlNVS, HID *hdlHID, const char *fsPath);
|
||||
~PC9801(void);
|
||||
bool createKeyMapFile(std::fstream &outFile);
|
||||
bool storeDataToKeyMapFile(std::fstream &outFile, char *data, int size);
|
||||
bool storeDataToKeyMapFile(std::fstream & outFile, std::vector<uint32_t>& dataArray);
|
||||
bool closeAndCommitKeyMapFile(std::fstream &outFile, bool cleanupOnly);
|
||||
std::string getKeyMapFileName(void) { return(PC9801IF_KEYMAP_FILE); };
|
||||
void getKeyMapHeaders(std::vector<std::string>& headerList);
|
||||
void getKeyMapTypes(std::vector<std::string>& typeList);
|
||||
bool getKeyMapSelectList(std::vector<std::pair<std::string, int>>& selectList, std::string option);
|
||||
bool getKeyMapData(std::vector<uint32_t>& dataArray, int *row, bool start);
|
||||
|
||||
// Method to return the class version number.
|
||||
float version(void)
|
||||
{
|
||||
return(PC9801IF_VERSION);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
IRAM_ATTR void pushKeyToQueue(uint32_t key);
|
||||
IRAM_ATTR void pushHostCmdToQueue(uint8_t cmd);
|
||||
IRAM_ATTR static void pcInterface( void * pvParameters );
|
||||
IRAM_ATTR static void hidInterface( void * pvParameters );
|
||||
void selectOption(uint8_t optionCode);
|
||||
uint32_t mapKey(uint16_t scanCode);
|
||||
bool loadKeyMap();
|
||||
bool saveKeyMap(void);
|
||||
void init(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID);
|
||||
void init(NVS *hdlNVS, HID *hdlHID);
|
||||
|
||||
// Structure to encapsulate a single key map from PS/2 to NEC PC-9801
|
||||
typedef struct {
|
||||
uint8_t ps2KeyCode;
|
||||
uint8_t ps2Ctrl;
|
||||
uint8_t keyboardModel;
|
||||
uint8_t machine;
|
||||
uint8_t pcKey;
|
||||
uint8_t pcCtrl;
|
||||
} t_keyMapEntry;
|
||||
|
||||
// Structure to encapsulate the entire static keyboard mapping table.
|
||||
typedef struct {
|
||||
t_keyMapEntry kme[PS2TBL_PC9801_MAXROWS];
|
||||
} t_keyMap;
|
||||
|
||||
// Structure to maintain the NEC PC-9801 interface configuration data. This data is persisted through powercycles as needed.
|
||||
typedef struct {
|
||||
struct {
|
||||
uint8_t activeKeyboardMap; // Model of keyboard a keymap entry is applicable to.
|
||||
uint8_t activeMachineModel; // Machine model a keymap entry is applicable to.
|
||||
bool useOnlyPersisted; // Flag to indicate wether the inbuilt keymap array should be combined with persisted values or the inbuilt array is ignored and only persisted values used.
|
||||
} params;
|
||||
} t_pcConfig;
|
||||
|
||||
// Configuration data.
|
||||
t_pcConfig pcConfig;
|
||||
|
||||
// Structure to manage the control signals signifying the state of the NEC PC-9801 keyboard.
|
||||
typedef struct {
|
||||
uint8_t keyCtrl; // Keyboard state flag control.
|
||||
bool optionSelect; // Flag to indicate a user requested keyboard configuration option is being selected.
|
||||
int uartNum;
|
||||
int uartBufferSize;
|
||||
int uartQueueSize;
|
||||
|
||||
std::string fsPath; // Path on the underlying filesystem where storage is mounted and accessible.
|
||||
t_keyMapEntry *kme; // Pointer to an array in memory to contain PS2 to NEC PC-9801 mapping values.
|
||||
int kmeRows; // Number of rows in the kme table.
|
||||
std::string keyMapFileName; // Name of file where extension or replacement key map entries are stored.
|
||||
bool persistConfig; // Flag to request saving of the config into NVS storage.
|
||||
} t_pcControl;
|
||||
|
||||
// Transmit buffer queue item.
|
||||
typedef struct {
|
||||
uint32_t keyCode; // Key data to be sent to PC-9801, 4 bytes to allow for extended sequences..
|
||||
} t_xmitQueueMessage;
|
||||
|
||||
// Receive buffer queue item.
|
||||
typedef struct {
|
||||
uint8_t hostCmd; // Keyboard configuration command received from X68000.
|
||||
} t_rcvQueueMessage;
|
||||
|
||||
// Thread handles - one per function, ie. HID interface and host target interface.
|
||||
TaskHandle_t TaskHostIF = NULL;
|
||||
TaskHandle_t TaskHIDIF = NULL;
|
||||
|
||||
// Control structure to control interaction and mapping of keys for the host.
|
||||
t_pcControl pcCtrl;
|
||||
|
||||
// Spin lock mutex to hold a coresied to an uninterruptable method. This only works on dual core ESP32's.
|
||||
portMUX_TYPE pcMutex;
|
||||
|
||||
//
|
||||
// This mapping is for the UK Wyse KB-3926 PS/2 keyboard
|
||||
//
|
||||
t_keyMap PS2toPC9801 = {
|
||||
{
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine PC-9801 Data PC-9801 Ctrl (Flags to Set).
|
||||
// Function keys
|
||||
// { PS2_KEY_F1, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_HIRAGANA, PC9801_CTRL_NONE, }, // CTRL + F1 = Hiragana
|
||||
// { PS2_KEY_F2, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_FULLWIDTH, PC9801_CTRL_NONE, }, // CTRL + F2 = Full Width
|
||||
// { PS2_KEY_F3, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KATAKANA, PC9801_CTRL_NONE, }, // CTRL + F3 = Katakana
|
||||
// { PS2_KEY_F4, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_ROMAJI, PC9801_CTRL_NONE, }, // CTRL + F4 = Romaji
|
||||
// { PS2_KEY_F5, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_TRANSPOSE, PC9801_CTRL_NONE, }, // CTRL + F5 = Tranpose
|
||||
// { PS2_KEY_F6, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_SYMBOL, PC9801_CTRL_NONE, }, // CTRL + F6 = Symbol
|
||||
// { PS2_KEY_F7, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_REGISTRATION, PC9801_CTRL_NONE, }, // CTRL + F7 = Registration - maybe a poor translation, needs better one!
|
||||
// { PS2_KEY_F9, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_COPY, PC9801_CTRL_NONE, }, // CTRL + F9 = Copy
|
||||
// { PS2_KEY_F10, PS2CTRL_FUNC | PS2CTRL_CTRL, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_HELP, PC9801_CTRL_NONE, }, // CTRL + F10 = Help
|
||||
{ PS2_KEY_F1, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F1, PC9801_CTRL_NONE, }, // F1
|
||||
{ PS2_KEY_F2, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F2, PC9801_CTRL_NONE, }, // F2
|
||||
{ PS2_KEY_F3, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F3, PC9801_CTRL_NONE, }, // F3
|
||||
{ PS2_KEY_F4, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F4, PC9801_CTRL_NONE, }, // F4
|
||||
{ PS2_KEY_F5, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F5, PC9801_CTRL_NONE, }, // F5
|
||||
{ PS2_KEY_F6, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F6, PC9801_CTRL_NONE, }, // F6
|
||||
{ PS2_KEY_F7, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F7, PC9801_CTRL_NONE, }, // F7
|
||||
{ PS2_KEY_F8, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F8, PC9801_CTRL_NONE, }, // F8
|
||||
{ PS2_KEY_F9, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F9, PC9801_CTRL_NONE, }, // F9
|
||||
{ PS2_KEY_F10, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F10, PC9801_CTRL_NONE, }, // F10
|
||||
// { PS2_KEY_F11, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_OPT_1, PC9801_CTRL_NONE, }, // F11 - OPT.1
|
||||
// { PS2_KEY_F12, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_OPT_2, PC9801_CTRL_NONE, }, // F12 - OPT.2
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine PC-9801 Data PC-9801 Ctrl (Flags to Set).
|
||||
// ALPHA keys, case is maaped in the PC-9801 via the SHIFT key event or CAPS key.
|
||||
{ PS2_KEY_A, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_A, PC9801_CTRL_NONE, }, // A
|
||||
{ PS2_KEY_B, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_B, PC9801_CTRL_NONE, }, // B
|
||||
{ PS2_KEY_C, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_C, PC9801_CTRL_NONE, }, // C
|
||||
{ PS2_KEY_D, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_D, PC9801_CTRL_NONE, }, // D
|
||||
{ PS2_KEY_E, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_E, PC9801_CTRL_NONE, }, // E
|
||||
{ PS2_KEY_F, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_F, PC9801_CTRL_NONE, }, // F
|
||||
{ PS2_KEY_G, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_G, PC9801_CTRL_NONE, }, // G
|
||||
{ PS2_KEY_H, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_H, PC9801_CTRL_NONE, }, // H
|
||||
{ PS2_KEY_I, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_I, PC9801_CTRL_NONE, }, // I
|
||||
{ PS2_KEY_J, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_J, PC9801_CTRL_NONE, }, // J
|
||||
{ PS2_KEY_K, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_K, PC9801_CTRL_NONE, }, // K
|
||||
{ PS2_KEY_L, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_L, PC9801_CTRL_NONE, }, // L
|
||||
{ PS2_KEY_M, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_M, PC9801_CTRL_NONE, }, // M
|
||||
{ PS2_KEY_N, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_N, PC9801_CTRL_NONE, }, // N
|
||||
{ PS2_KEY_O, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_O, PC9801_CTRL_NONE, }, // O
|
||||
{ PS2_KEY_P, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_P, PC9801_CTRL_NONE, }, // P
|
||||
{ PS2_KEY_Q, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_Q, PC9801_CTRL_NONE, }, // Q
|
||||
{ PS2_KEY_R, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_R, PC9801_CTRL_NONE, }, // R
|
||||
{ PS2_KEY_S, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_S, PC9801_CTRL_NONE, }, // S
|
||||
{ PS2_KEY_T, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_T, PC9801_CTRL_NONE, }, // T
|
||||
{ PS2_KEY_U, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_U, PC9801_CTRL_NONE, }, // U
|
||||
{ PS2_KEY_V, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_V, PC9801_CTRL_NONE, }, // V
|
||||
{ PS2_KEY_W, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_W, PC9801_CTRL_NONE, }, // W
|
||||
{ PS2_KEY_X, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_X, PC9801_CTRL_NONE, }, // X
|
||||
{ PS2_KEY_Y, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_Y, PC9801_CTRL_NONE, }, // Y
|
||||
{ PS2_KEY_Z, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_Z, PC9801_CTRL_NONE, }, // Z
|
||||
// Numeric keys.
|
||||
{ PS2_KEY_0, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_9, PC9801_CTRL_NONE, }, // Close Bracket )
|
||||
{ PS2_KEY_0, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_0, PC9801_CTRL_NONE, }, // 0
|
||||
{ PS2_KEY_1, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_1, PC9801_CTRL_NONE, }, // 1
|
||||
{ PS2_KEY_2, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_2, PC9801_CTRL_NONE, }, // 2
|
||||
{ PS2_KEY_3, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_3, PC9801_CTRL_NONE, }, // 3
|
||||
{ PS2_KEY_4, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_4, PC9801_CTRL_NONE, }, // 4
|
||||
{ PS2_KEY_5, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_5, PC9801_CTRL_NONE, }, // 5
|
||||
{ PS2_KEY_6, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_CIRCUMFLEX, PC9801_CTRL_RELEASESHIFT, }, // Circumflex ^
|
||||
{ PS2_KEY_6, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_6, PC9801_CTRL_NONE, }, // 6
|
||||
{ PS2_KEY_7, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_6, PC9801_CTRL_NONE, }, // &
|
||||
{ PS2_KEY_7, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_7, PC9801_CTRL_NONE, }, // 7
|
||||
{ PS2_KEY_8, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_COLON, PC9801_CTRL_NONE, }, // Start *
|
||||
{ PS2_KEY_8, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_8, PC9801_CTRL_NONE, }, // 8
|
||||
{ PS2_KEY_9, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_8, PC9801_CTRL_NONE, }, // Open Bracket (
|
||||
{ PS2_KEY_9, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_9, PC9801_CTRL_NONE, }, // 9
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine PC-9801 Data PC-9801 Ctrl (Flags to Set).
|
||||
// Punctuation keys.
|
||||
{ PS2_KEY_SPACE, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_SPACE, PC9801_CTRL_NONE, }, // Space
|
||||
{ PS2_KEY_MINUS, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_CIRCUMFLEX, PC9801_CTRL_NONE, }, // Upper Bar
|
||||
{ PS2_KEY_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_MINUS, PC9801_CTRL_NONE, }, // Minus -
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_SEMI, PC9801_CTRL_SHIFT, }, // Plus +
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_MINUS, PC9801_CTRL_SHIFT, }, // Equal =
|
||||
{ PS2_KEY_DOT, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_DOT, PC9801_CTRL_NONE, }, // Greater Than >
|
||||
{ PS2_KEY_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_DOT, PC9801_CTRL_NONE, }, // Dot
|
||||
{ PS2_KEY_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_DIV, PC9801_CTRL_NONE, }, // Divide /
|
||||
{ PS2_KEY_SEMI, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_COLON, PC9801_CTRL_RELEASESHIFT, }, // Colon :
|
||||
{ PS2_KEY_SEMI, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_SEMI, PC9801_CTRL_NONE, }, // Semi-Colon ;
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_OPEN_SQ, PC9801_CTRL_NONE, }, // [
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_CLOSE_SQ, PC9801_CTRL_NONE, }, // ]
|
||||
{ PS2_KEY_APOS, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_AT, PC9801_CTRL_RELEASESHIFT, }, // @
|
||||
{ PS2_KEY_APOS, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_7, PC9801_CTRL_SHIFT, }, // '
|
||||
{ PS2_KEY_BACK, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_YEN, PC9801_CTRL_NONE, }, // Back slash maps to Yen
|
||||
{ PS2_KEY_BACK, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_YEN, PC9801_CTRL_NONE, }, // Back slash maps to Yen
|
||||
{ PS2_KEY_HASH, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_3, PC9801_CTRL_SHIFT, }, // Hash
|
||||
{ PS2_KEY_COMMA, PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_COMMA, PC9801_CTRL_NONE, }, // Less Than <
|
||||
{ PS2_KEY_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_COMMA, PC9801_CTRL_NONE, }, // Comma ,
|
||||
{ PS2_KEY_BTICK, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_UNDERLINE, PC9801_CTRL_SHIFT, }, // Underline
|
||||
{ PS2_KEY_BTICK, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_AT, PC9801_CTRL_SHIFT, }, // Back Tick `
|
||||
// Control keys.
|
||||
{ PS2_KEY_TAB, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_TAB, PC9801_CTRL_NONE, }, // TAB
|
||||
{ PS2_KEY_BS, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_BS, PC9801_CTRL_NONE, }, // Backspace
|
||||
{ PS2_KEY_ESC, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_ESC, PC9801_CTRL_NONE, }, // ESCape
|
||||
{ PS2_KEY_INSERT, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_INS, PC9801_CTRL_NONE, }, // INSERT
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_CLR, PC9801_CTRL_NONE, }, // CLR
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_HOME, PC9801_CTRL_NONE, }, // HOME
|
||||
{ PS2_KEY_DELETE, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_DEL, PC9801_CTRL_NONE, }, // DELETE
|
||||
{ PS2_KEY_UP_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_UP_ARROW, PC9801_CTRL_NONE, }, // Up Arrow
|
||||
{ PS2_KEY_L_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_L_ARROW, PC9801_CTRL_NONE, }, // Left Arrow
|
||||
{ PS2_KEY_DN_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_DN_ARROW, PC9801_CTRL_NONE, }, // Down Arrow
|
||||
{ PS2_KEY_R_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_R_ARROW, PC9801_CTRL_NONE, }, // Right Arrow
|
||||
{ PS2_KEY_PGUP, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_ROLLUP, PC9801_CTRL_NONE, }, // Roll Up.
|
||||
{ PS2_KEY_PGDN, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_ROLLDN, PC9801_CTRL_NONE, }, // Roll Down
|
||||
{ PS2_KEY_SCROLL, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, ' ', PC9801_CTRL_NONE, }, // Not assigned.
|
||||
{ PS2_KEY_ENTER, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_RETURN, PC9801_CTRL_NONE, }, // Not assigned.
|
||||
{ PS2_KEY_CAPS, PS2CTRL_CAPS, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_CAPS, PC9801_CTRL_NONE, }, // CAPS
|
||||
{ PS2_KEY_END, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_UNDO, PC9801_CTRL_NONE, }, // UNDO
|
||||
// Keypad.
|
||||
{ PS2_KEY_KP0, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP0, PC9801_CTRL_NONE, }, // Keypad 0
|
||||
{ PS2_KEY_KP1, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP1, PC9801_CTRL_NONE, }, // Keypad 1
|
||||
{ PS2_KEY_KP2, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP2, PC9801_CTRL_NONE, }, // Keypad 2
|
||||
{ PS2_KEY_KP3, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP3, PC9801_CTRL_NONE, }, // Keypad 3
|
||||
{ PS2_KEY_KP4, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP4, PC9801_CTRL_NONE, }, // Keypad 4
|
||||
{ PS2_KEY_KP5, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP5, PC9801_CTRL_NONE, }, // Keypad 5
|
||||
{ PS2_KEY_KP6, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP6, PC9801_CTRL_NONE, }, // Keypad 6
|
||||
{ PS2_KEY_KP7, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP7, PC9801_CTRL_NONE, }, // Keypad 7
|
||||
{ PS2_KEY_KP8, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP8, PC9801_CTRL_NONE, }, // Keypad 8
|
||||
{ PS2_KEY_KP9, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP9, PC9801_CTRL_NONE, }, // Keypad 9
|
||||
{ PS2_KEY_KP_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP_COMMA, PC9801_CTRL_NONE, }, // Keypad Comma ,
|
||||
{ PS2_KEY_KP_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP_DOT, PC9801_CTRL_NONE, }, // Keypad Full stop .
|
||||
{ PS2_KEY_KP_PLUS, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP_PLUS, PC9801_CTRL_NONE, }, // Keypad Plus +
|
||||
{ PS2_KEY_KP_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP_MINUS, PC9801_CTRL_NONE, }, // Keypad Minus -
|
||||
{ PS2_KEY_KP_TIMES, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP_TIMES, PC9801_CTRL_NONE, }, // Keypad Times *
|
||||
{ PS2_KEY_KP_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP_DIV, PC9801_CTRL_NONE, }, // Keypad Divide /
|
||||
{ PS2_KEY_KP_EQUAL, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_MINUS, PC9801_CTRL_SHIFT, }, // Keypad Equal =
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP_ENTER, PC9801_CTRL_NONE, }, // Keypad Ebter /
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_KP_EQUAL, PC9801_CTRL_NONE, }, // Keypad Ebter /
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine PC-9801 Data PC-9801 Ctrl (Flags to Set).
|
||||
// Special keys.
|
||||
{ PS2_KEY_PRTSCR, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, 0x00, PC9801_CTRL_NONE, }, //
|
||||
{ PS2_KEY_PAUSE, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_BREAK, PC9801_CTRL_RELEASESHIFT, }, // BREAK KEY
|
||||
// { PS2_KEY_L_GUI, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_XF1, PC9801_CTRL_NONE, }, // XF1
|
||||
// { PS2_KEY_L_ALT, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_XF2, PC9801_CTRL_NONE, }, // XF2
|
||||
// { PS2_KEY_R_ALT, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_XF3, PC9801_CTRL_NONE, }, // XF3
|
||||
// { PS2_KEY_R_GUI, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_XF4, PC9801_CTRL_NONE, }, // XF4
|
||||
// { PS2_KEY_MENU, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_XF5, PC9801_CTRL_NONE, }, // XF5
|
||||
// Modifiers are last, only being selected if an earlier match isnt made.
|
||||
{ PS2_KEY_L_SHIFT, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_SHIFT, PC9801_CTRL_NONE, }, //
|
||||
{ PS2_KEY_R_SHIFT, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_SHIFT, PC9801_CTRL_NONE, }, //
|
||||
{ PS2_KEY_L_CTRL, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_CTRL, PC9801_CTRL_NONE, }, // Map to Control
|
||||
{ PS2_KEY_R_CTRL, PS2CTRL_FUNC, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_CTRL, PC9801_CTRL_NONE, }, // Map to Control
|
||||
{ 0, PS2CTRL_NONE, KEYMAP_STANDARD, PC9801_ALL, PC9801_KEY_NULL, PC9801_CTRL_NONE, }, //
|
||||
}};
|
||||
};
|
||||
|
||||
#endif // PC9801_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/PS2KeyAdvanced.h
|
||||
451
main/include/PS2KeyAdvanced.h
Normal file
451
main/include/PS2KeyAdvanced.h
Normal file
@@ -0,0 +1,451 @@
|
||||
/* Version V1.0.9
|
||||
PS2KeyAdvanced.h - PS2KeyAdvanced library
|
||||
Copyright (c) 2007 Free Software Foundation. All right reserved.
|
||||
Written by Paul Carpenter, PC Services <sales@pcserviceselectronics.co.uk>
|
||||
Created September 2014
|
||||
Updated January 2016 - Paul Carpenter - add tested on Due and tidy ups for V1.5 Library Management
|
||||
January 2020 Fix typos, correct keyboard reset status improve library.properties
|
||||
and additional platform handling and some documentation
|
||||
March 2020 Add SAMD1 as recognised support as has been tested by user
|
||||
Improve different architecture handling
|
||||
November 2020 Add support for STM32 from user Hiabuto-de
|
||||
Tested on STM32Duino-Framework and PlatformIO on STM32F103C8T6 and an IBM Model M
|
||||
July 2021 Add workaround for ESP32 issue with Silicon (hardware) from user submissions
|
||||
|
||||
IMPORTANT WARNING
|
||||
|
||||
If using a DUE or similar board with 3V3 I/O you MUST put a level translator
|
||||
like a Texas Instruments TXS0102 or FET circuit as the signals are
|
||||
Bi-directional (signals transmitted from both ends on same wire).
|
||||
|
||||
Failure to do so may damage your Arduino Due or similar board.
|
||||
|
||||
Test History
|
||||
September 2014 Uno and Mega 2560 September 2014 using Arduino V1.6.0
|
||||
January 2016 Uno, Mega 2560 and Due using Arduino 1.6.7 and Due Board
|
||||
Manager V1.6.6
|
||||
|
||||
ONLY use defines in this file others may disappear on updates.
|
||||
|
||||
This is for a LATIN style keyboard using Scan code set 2. See various
|
||||
websites on what different scan code sets use. Scan Code Set 2 is the
|
||||
default scan code set for PS2 keyboards on power up.
|
||||
|
||||
Will support most keyboards even ones with multimedia keys or even 24 function keys.
|
||||
|
||||
Fully featured PS2 keyboard library to provide
|
||||
All function and movement keys supported even multi-lingual
|
||||
Parity checking of data sent/received on receive request keyboard resend
|
||||
Resends data when needed handles keyboard protocol for RESEND and ECHO
|
||||
Functions for get and set of
|
||||
Scancode set in use READ only
|
||||
LED and LOCK control
|
||||
ReadID
|
||||
Reset keyboard
|
||||
Send ECHO
|
||||
Ignore Break codes for keys
|
||||
Ignore typematic repeat of CTRL, SHIFT, ALT, Num, Scroll, Caps
|
||||
Handles NUM, CAPS and SCROLL lock keys to LEDs
|
||||
Handles NUM/SCROLL internally
|
||||
|
||||
Read function Returns an UNSIGNED INT containing
|
||||
Make/Break status
|
||||
Caps status
|
||||
Shift, CTRL, ALT, ALT GR, GUI keys
|
||||
Flag for function key not a displayable/printable character
|
||||
8 bit key code
|
||||
|
||||
Code Ranges (bottom byte of unsigned int)
|
||||
0 invalid/error
|
||||
1-1F Functions (Caps, Shift, ALT, Enter, DEL... )
|
||||
1A-1F Functions with ASCII control code
|
||||
(DEL, BS, TAB, ESC, ENTER, SPACE)
|
||||
20-61 Printable characters noting
|
||||
0-9 = 0x30 to 0x39 as ASCII
|
||||
A to Z = 0x41 to 0x5A as upper case ASCII type codes
|
||||
8B Extra European key
|
||||
61-A0 Function keys and other special keys (plus F2 and F1)
|
||||
61-78 F1 to F24
|
||||
79-8A Multimedia
|
||||
8B NOT included
|
||||
8C-8E ACPI power
|
||||
91-A0 and F2 and F1 - Special multilingual
|
||||
A8-FF Keyboard communications commands (note F2 and F1 are special
|
||||
codes for special multi-lingual keyboards)
|
||||
|
||||
By using these ranges it is possible to perform detection of any key and do
|
||||
easy translation to ASCII/UTF-8 avoiding keys that do not have a valid code.
|
||||
|
||||
Top Byte is 8 bits denoting as follows with defines for bit code
|
||||
|
||||
Define name bit description
|
||||
PS2_BREAK 15 1 = Break key code
|
||||
(MSB) 0 = Make Key code
|
||||
PS2_SHIFT 14 1 = Shift key pressed as well (either side)
|
||||
0 = NO shift key
|
||||
PS2_CTRL 13 1 = Ctrl key pressed as well (either side)
|
||||
0 = NO Ctrl key
|
||||
PS2_CAPS 12 1 = Caps Lock ON
|
||||
0 = Caps lock OFF
|
||||
PS2_ALT 11 1 = Left Alt key pressed as well
|
||||
0 = NO Left Alt key
|
||||
PS2_ALT_GR 10 1 = Right Alt (Alt GR) key pressed as well
|
||||
0 = NO Right Alt key
|
||||
PS2_GUI 9 1 = GUI key pressed as well (either)
|
||||
0 = NO GUI key
|
||||
PS2_FUNCTION 8 1 = FUNCTION key non-printable character (plus space, tab, enter)
|
||||
0 = standard character key
|
||||
|
||||
Error Codes
|
||||
Most functions return 0 or 0xFFFF as error, other codes to note and
|
||||
handle appropriately
|
||||
0xAA keyboard has reset and passed power up tests
|
||||
will happen if keyboard plugged in after code start
|
||||
0xFC Keyboard General error or power up fail
|
||||
|
||||
It is responsibility of your programme to deal with converting special cases like
|
||||
<CTRL>+<ENTER> sends a special code to something else. If you wish to do that make a
|
||||
NEW library called SOMETHING different NOT a variant or revision of this one, as you
|
||||
are changing base functionality
|
||||
|
||||
See PS2KeyCode.h for codes from the keyboard this library uses to decode.
|
||||
(may disappear in updates do not rely on that file or definitions)
|
||||
|
||||
See this file for returned definitions of Keys
|
||||
|
||||
Note defines starting
|
||||
PS2_KC_* are internal defines for codes from the keyboard
|
||||
PS2_KEY_* are the codes this library returns
|
||||
PS2_* remaining defines for use in higher levels
|
||||
|
||||
To get the key as ASCII/UTF-8 single byte character conversion requires use
|
||||
of PS2KeyMap library AS WELL.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef PS2KeyAdvanced_h
|
||||
#define PS2KeyAdvanced_h
|
||||
|
||||
// Platform specific areas
|
||||
// Harvard architecture settings for PROGMEM
|
||||
// Add separate for EACH architecture as easier to maintain
|
||||
// AVR (includes Teensy 2.0)
|
||||
#if defined( ARDUINO_ARCH_AVR )
|
||||
#define PS2_SUPPORTED 1
|
||||
#define PS2_REQUIRES_PROGMEM 1
|
||||
#define PS2_CLEAR_PENDING_IRQ 1
|
||||
#endif
|
||||
// SAM (Due)
|
||||
#if defined( ARDUINO_ARCH_SAM )
|
||||
#define PS2_SUPPORTED 1
|
||||
#define PS2_CLEAR_PENDING_IRQ 1
|
||||
#endif
|
||||
// SAMD1
|
||||
#if defined( ARDUINO_ARCH_SAMD1 )
|
||||
#define PS2_SUPPORTED 1
|
||||
#define PS2_CLEAR_PENDING_IRQ 1
|
||||
#endif
|
||||
// STM32
|
||||
#if defined( ARDUINO_ARCH_STM32 )
|
||||
#define PS2_SUPPORTED 1
|
||||
#define PS2_CLEAR_PENDING_IRQ 1
|
||||
#endif
|
||||
// ESP32
|
||||
#if defined( ARDUINO_ARCH_ESP32 )
|
||||
#define PS2_SUPPORTED 1
|
||||
#define PS2_ONLY_CHANGE_IRQ 1
|
||||
#endif
|
||||
|
||||
// Invalid architecture
|
||||
#if !( defined( PS2_SUPPORTED ) )
|
||||
#warning Library is NOT supported on this board Use at your OWN risk
|
||||
#endif
|
||||
|
||||
/* Flags/bit masks for status bits in returned unsigned int value */
|
||||
#define PS2_BREAK 0x8000
|
||||
#define PS2_SHIFT 0x4000
|
||||
#define PS2_CTRL 0x2000
|
||||
#define PS2_CAPS 0x1000
|
||||
#define PS2_ALT 0x800
|
||||
#define PS2_ALT_GR 0x400
|
||||
#define PS2_GUI 0x200
|
||||
#define PS2_FUNCTION 0x100
|
||||
|
||||
/* General defines of communications codes */
|
||||
/* Command or response */
|
||||
#define PS2_KEY_RESEND 0xFE
|
||||
#define PS2_KEY_ACK 0xFA
|
||||
#define PS2_KEY_ECHO 0xEE
|
||||
/* Responses */
|
||||
#define PS2_KEY_BAT 0xAA
|
||||
// Actually buffer overrun
|
||||
#define PS2_KEY_OVERRUN 0xFF
|
||||
// Below is general error code
|
||||
#define PS2_KEY_ERROR 0xFC
|
||||
|
||||
/* Command parameters for functions */
|
||||
/* LED codes OR together */
|
||||
#define PS2_LOCK_SCROLL 0x01
|
||||
#define PS2_LOCK_NUM 0x02
|
||||
#define PS2_LOCK_CAPS 0x04
|
||||
/* Only useful for very few keyboards */
|
||||
#define PS2_LOCK_EXTRA 0x08
|
||||
|
||||
/* Returned keycode definitions */
|
||||
/* Do NOT change these codings as you will break base
|
||||
functionality use PS2KeyMap for that and internationalisation */
|
||||
#define PS2_KEY_NUM 0x01
|
||||
#define PS2_KEY_SCROLL 0x02
|
||||
#define PS2_KEY_CAPS 0x03
|
||||
#define PS2_KEY_PRTSCR 0x04
|
||||
#define PS2_KEY_PAUSE 0x05
|
||||
#define PS2_KEY_L_SHIFT 0x06
|
||||
#define PS2_KEY_R_SHIFT 0x07
|
||||
#define PS2_KEY_L_CTRL 0X08
|
||||
#define PS2_KEY_R_CTRL 0X09
|
||||
#define PS2_KEY_L_ALT 0x0A
|
||||
#define PS2_KEY_R_ALT 0x0B
|
||||
/* Sometimes called windows key */
|
||||
#define PS2_KEY_L_GUI 0x0C
|
||||
#define PS2_KEY_R_GUI 0x0D
|
||||
#define PS2_KEY_MENU 0x0E
|
||||
/* Break is CTRL + PAUSE generated inside keyboard */
|
||||
#define PS2_KEY_BREAK 0x0F
|
||||
/* Generated by some keyboards by ALT and PRTSCR */
|
||||
#define PS2_KEY_SYSRQ 0x10
|
||||
#define PS2_KEY_HOME 0x11
|
||||
#define PS2_KEY_END 0x12
|
||||
#define PS2_KEY_PGUP 0x13
|
||||
#define PS2_KEY_PGDN 0x14
|
||||
#define PS2_KEY_L_ARROW 0x15
|
||||
#define PS2_KEY_R_ARROW 0x16
|
||||
#define PS2_KEY_UP_ARROW 0x17
|
||||
#define PS2_KEY_DN_ARROW 0x18
|
||||
#define PS2_KEY_INSERT 0x19
|
||||
#define PS2_KEY_DELETE 0x1A
|
||||
#define PS2_KEY_ESC 0x1B
|
||||
#define PS2_KEY_BS 0x1C
|
||||
#define PS2_KEY_TAB 0x1D
|
||||
#define PS2_KEY_ENTER 0x1E
|
||||
#define PS2_KEY_SPACE 0x1F
|
||||
#define PS2_KEY_KP0 0x20
|
||||
#define PS2_KEY_KP1 0x21
|
||||
#define PS2_KEY_KP2 0x22
|
||||
#define PS2_KEY_KP3 0x23
|
||||
#define PS2_KEY_KP4 0x24
|
||||
#define PS2_KEY_KP5 0x25
|
||||
#define PS2_KEY_KP6 0x26
|
||||
#define PS2_KEY_KP7 0x27
|
||||
#define PS2_KEY_KP8 0x28
|
||||
#define PS2_KEY_KP9 0x29
|
||||
#define PS2_KEY_KP_DOT 0x2A
|
||||
#define PS2_KEY_KP_ENTER 0x2B
|
||||
#define PS2_KEY_KP_PLUS 0x2C
|
||||
#define PS2_KEY_KP_MINUS 0x2D
|
||||
#define PS2_KEY_KP_TIMES 0x2E
|
||||
#define PS2_KEY_KP_DIV 0x2F
|
||||
#define PS2_KEY_0 0X30
|
||||
#define PS2_KEY_1 0X31
|
||||
#define PS2_KEY_2 0X32
|
||||
#define PS2_KEY_3 0X33
|
||||
#define PS2_KEY_4 0X34
|
||||
#define PS2_KEY_5 0X35
|
||||
#define PS2_KEY_6 0X36
|
||||
#define PS2_KEY_7 0X37
|
||||
#define PS2_KEY_8 0X38
|
||||
#define PS2_KEY_9 0X39
|
||||
#define PS2_KEY_APOS 0X3A
|
||||
#define PS2_KEY_COMMA 0X3B
|
||||
#define PS2_KEY_MINUS 0X3C
|
||||
#define PS2_KEY_DOT 0X3D
|
||||
#define PS2_KEY_DIV 0X3E
|
||||
/* Some Numeric keyboards have an '=' on right keypad */
|
||||
#define PS2_KEY_KP_EQUAL 0x3F
|
||||
/* Single quote or back quote */
|
||||
#define PS2_KEY_SINGLE 0X40
|
||||
#define PS2_KEY_A 0X41
|
||||
#define PS2_KEY_B 0X42
|
||||
#define PS2_KEY_C 0X43
|
||||
#define PS2_KEY_D 0X44
|
||||
#define PS2_KEY_E 0X45
|
||||
#define PS2_KEY_F 0X46
|
||||
#define PS2_KEY_G 0X47
|
||||
#define PS2_KEY_H 0X48
|
||||
#define PS2_KEY_I 0X49
|
||||
#define PS2_KEY_J 0X4A
|
||||
#define PS2_KEY_K 0X4B
|
||||
#define PS2_KEY_L 0X4C
|
||||
#define PS2_KEY_M 0X4D
|
||||
#define PS2_KEY_N 0X4E
|
||||
#define PS2_KEY_O 0X4F
|
||||
#define PS2_KEY_P 0X50
|
||||
#define PS2_KEY_Q 0X51
|
||||
#define PS2_KEY_R 0X52
|
||||
#define PS2_KEY_S 0X53
|
||||
#define PS2_KEY_T 0X54
|
||||
#define PS2_KEY_U 0X55
|
||||
#define PS2_KEY_V 0X56
|
||||
#define PS2_KEY_W 0X57
|
||||
#define PS2_KEY_X 0X58
|
||||
#define PS2_KEY_Y 0X59
|
||||
#define PS2_KEY_Z 0X5A
|
||||
#define PS2_KEY_SEMI 0X5B
|
||||
#define PS2_KEY_BACK 0X5C
|
||||
#define PS2_KEY_OPEN_SQ 0X5D
|
||||
#define PS2_KEY_CLOSE_SQ 0X5E
|
||||
#define PS2_KEY_EQUAL 0X5F
|
||||
/* Some Numeric keypads have a comma key */
|
||||
#define PS2_KEY_KP_COMMA 0x60
|
||||
#define PS2_KEY_F1 0X61
|
||||
#define PS2_KEY_F2 0X62
|
||||
#define PS2_KEY_F3 0X63
|
||||
#define PS2_KEY_F4 0X64
|
||||
#define PS2_KEY_F5 0X65
|
||||
#define PS2_KEY_F6 0X66
|
||||
#define PS2_KEY_F7 0X67
|
||||
#define PS2_KEY_F8 0X68
|
||||
#define PS2_KEY_F9 0X69
|
||||
#define PS2_KEY_F10 0X6A
|
||||
#define PS2_KEY_F11 0X6B
|
||||
#define PS2_KEY_F12 0X6C
|
||||
#define PS2_KEY_F13 0X6D
|
||||
#define PS2_KEY_F14 0X6E
|
||||
#define PS2_KEY_F15 0X6F
|
||||
#define PS2_KEY_F16 0X70
|
||||
#define PS2_KEY_F17 0X71
|
||||
#define PS2_KEY_F18 0X72
|
||||
#define PS2_KEY_F19 0X73
|
||||
#define PS2_KEY_F20 0X74
|
||||
#define PS2_KEY_F21 0X75
|
||||
#define PS2_KEY_F22 0X76
|
||||
#define PS2_KEY_F23 0X77
|
||||
#define PS2_KEY_F24 0X78
|
||||
#define PS2_KEY_NEXT_TR 0X79
|
||||
#define PS2_KEY_PREV_TR 0X7A
|
||||
#define PS2_KEY_STOP 0X7B
|
||||
#define PS2_KEY_PLAY 0X7C
|
||||
#define PS2_KEY_MUTE 0X7D
|
||||
#define PS2_KEY_VOL_UP 0X7E
|
||||
#define PS2_KEY_VOL_DN 0X7F
|
||||
#define PS2_KEY_MEDIA 0X80
|
||||
#define PS2_KEY_EMAIL 0X81
|
||||
#define PS2_KEY_CALC 0X82
|
||||
#define PS2_KEY_COMPUTER 0X83
|
||||
#define PS2_KEY_WEB_SEARCH 0X84
|
||||
#define PS2_KEY_WEB_HOME 0X85
|
||||
#define PS2_KEY_WEB_BACK 0X86
|
||||
#define PS2_KEY_WEB_FORWARD 0X87
|
||||
#define PS2_KEY_WEB_STOP 0X88
|
||||
#define PS2_KEY_WEB_REFRESH 0X89
|
||||
#define PS2_KEY_WEB_FAVOR 0X8A
|
||||
#define PS2_KEY_EUROPE2 0X8B
|
||||
#define PS2_KEY_POWER 0X8C
|
||||
#define PS2_KEY_SLEEP 0X8D
|
||||
#define PS2_KEY_WAKE 0X90
|
||||
#define PS2_KEY_INTL1 0X91
|
||||
#define PS2_KEY_INTL2 0X92
|
||||
#define PS2_KEY_INTL3 0X93
|
||||
#define PS2_KEY_INTL4 0X94
|
||||
#define PS2_KEY_INTL5 0X95
|
||||
#define PS2_KEY_LANG1 0X96
|
||||
#define PS2_KEY_LANG2 0X97
|
||||
#define PS2_KEY_LANG3 0X98
|
||||
#define PS2_KEY_LANG4 0X99
|
||||
#define PS2_KEY_LANG5 0xA0
|
||||
#define PS2_KEY_BTICK 0X9A
|
||||
#define PS2_KEY_HASH 0X9B
|
||||
|
||||
/*
|
||||
Purpose: Provides advanced access to PS2 keyboards
|
||||
Public class definitions
|
||||
|
||||
See standard error codes for error code returns
|
||||
*/
|
||||
class PS2KeyAdvanced {
|
||||
public:
|
||||
/* This constructor does basically nothing. Please call the begin(int,int)
|
||||
method before using any other method of this class. */
|
||||
PS2KeyAdvanced( );
|
||||
|
||||
// Destructor - disable and detach interrupts and free up resources.
|
||||
~PS2KeyAdvanced( );
|
||||
|
||||
/* Starts the keyboard "service" by registering the external interrupt.
|
||||
setting the pin modes correctly and driving those needed to high.
|
||||
Sets default LOCK status (LEDs) to passed in value or default of all off
|
||||
The best place to call this method is in the setup routine. */
|
||||
void begin( uint8_t, uint8_t );
|
||||
|
||||
// Additional key available check which doesnt affect the queue.
|
||||
uint8_t keyAvailable(void);
|
||||
|
||||
/* Returns number of codes available or 0 for none */
|
||||
uint8_t available( );
|
||||
|
||||
/* Returns the key last read from the keyboard.
|
||||
If there is no key available, 0 is returned. */
|
||||
uint16_t read( );
|
||||
|
||||
/* Returns the current status of Locks
|
||||
Use Macro to mask out bits from
|
||||
PS2_LOCK_NUM PS2_LOCK_CAPS PS2_LOCK_SCROLL */
|
||||
uint8_t getLock( );
|
||||
|
||||
/* Sets the current status of Locks and LEDs
|
||||
Use macro defines added together from
|
||||
PS2_LOCK_NUM PS2_LOCK_CAPS PS2_LOCK_SCROLL */
|
||||
void setLock( uint8_t );
|
||||
|
||||
/* Set library to not send break key codes
|
||||
1 = no break codes
|
||||
0 = send break codes */
|
||||
void setNoBreak( uint8_t );
|
||||
|
||||
/* Set library to not repeat make codes for CTRL, ALT, GUI, SHIFT
|
||||
1 = no repeat codes
|
||||
0 = send repeat codes */
|
||||
void setNoRepeat( uint8_t );
|
||||
|
||||
/* Resets keyboard when reset has completed
|
||||
keyboard sends AA - Pass or FC for fail
|
||||
Read from keyboard data buffer */
|
||||
void resetKey( );
|
||||
|
||||
/* Get the current Scancode Set used in keyboard
|
||||
returned data in keyboard buffer read as keys */
|
||||
void getScanCodeSet( void );
|
||||
|
||||
/* Get the current Scancode Set used in keyboard
|
||||
returned data in keyboard buffer read as keys */
|
||||
void readID( void );
|
||||
|
||||
/* Send Echo command to keyboard
|
||||
returned data in keyboard buffer read as keys */
|
||||
void echo( void );
|
||||
|
||||
// Method to suspend PS2 activity, primarily by disabling the interrupts.
|
||||
void suspend(bool suspend);
|
||||
|
||||
/* Send Typematic rate/delay command to keyboard
|
||||
First Parameter rate is 0 - 0x1F (31)
|
||||
0 = 30 CPS
|
||||
0x1F = 2 CPS
|
||||
default in keyboard is 0xB (10.9 CPS)
|
||||
Second Parameter delay is 0 - 3 for 0.25s to 1s in 0.25 increments
|
||||
default in keyboard is 1 = 0.5 second delay
|
||||
Returned data in keyboard buffer read as keys */
|
||||
int typematic( uint8_t , uint8_t );
|
||||
};
|
||||
#endif
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/PS2KeyCode.h
|
||||
276
main/include/PS2KeyCode.h
Normal file
276
main/include/PS2KeyCode.h
Normal file
@@ -0,0 +1,276 @@
|
||||
/* Version V1.0.8
|
||||
PS2KeyCode.h - PS2KeyAdvanced library Internal actual PS2 key code sequences
|
||||
Copyright (c) 2007 Free Software Foundation. All right reserved.
|
||||
Written by Paul Carpenter, PC Services <sales@pcserviceselectronics.co.uk>
|
||||
Created September 2014
|
||||
Updated January 2016 - Paul Carpenter - add tested on Due and tidy ups for V1.5 Library Management
|
||||
Updated December 2019 - Paul Carpenter - Fix typo in code for Multimedia STOP
|
||||
|
||||
PRIVATE to library
|
||||
|
||||
Test History
|
||||
September 2014 Uno and Mega 2560 September 2014 using Arduino V1.6.0
|
||||
January 2016 Uno, Mega 2560 and Due using Arduino 1.6.7 and Due Board
|
||||
Manager V1.6.6
|
||||
|
||||
This is for a LATIN style keyboard. Will support most keyboards even ones
|
||||
with multimedia keys or even 24 function keys.
|
||||
|
||||
Definitions used for key codes from a PS2 keyboard, do not use in your
|
||||
code these are to be handled INTERNALLY by the library.
|
||||
(may disappear in updates do not rely on this file or definitions)
|
||||
|
||||
See PS2KeyAdvanced.h for codes returned from library and flag settings
|
||||
|
||||
Defines are in three groups
|
||||
|
||||
Special codes definition of communications bytes
|
||||
|
||||
Single Byte codes returned as key codes
|
||||
|
||||
Two byte Codes preceded by E0 code returned as keycodes
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PS2KeyCode_h
|
||||
#define PS2KeyCode_h
|
||||
|
||||
/* Ignore code for key code translation */
|
||||
#define PS2_KEY_IGNORE 0xBB
|
||||
|
||||
// buffer sizes keyboard RX and TX, then key reading buffer
|
||||
// Minimum size 8 can be larger
|
||||
#define _RX_BUFFER_SIZE 8
|
||||
// Minimum size 6 can be larger
|
||||
#define _TX_BUFFER_SIZE 6
|
||||
// Output Buffer of unsigned int values. Minimum size 4 can be larger
|
||||
#define _KEY_BUFF_SIZE 4
|
||||
|
||||
/* private defines for library files not global */
|
||||
/* _ps2mode status flags */
|
||||
#define _PS2_BUSY 0x80
|
||||
#define _TX_MODE 0x40
|
||||
#define _BREAK_KEY 0x20
|
||||
#define _WAIT_RESPONSE 0x10
|
||||
#define _E0_MODE 0x08
|
||||
#define _E1_MODE 0x04
|
||||
#define _LAST_VALID 0x02
|
||||
|
||||
/* _tx_ready flags */
|
||||
#define _HANDSHAKE 0x80
|
||||
#define _COMMAND 0x01
|
||||
|
||||
/* Key Repeat defines */
|
||||
#define _NO_BREAKS 0x08
|
||||
#define _NO_REPEATS 0x80
|
||||
|
||||
/* PS2_keystatus byte masks (from 16 bit int masks) */
|
||||
#define _BREAK ( PS2_BREAK >> 8 )
|
||||
#define _SHIFT ( PS2_SHIFT >> 8 )
|
||||
#define _CTRL ( PS2_CTRL >> 8 )
|
||||
#define _CAPS ( PS2_CAPS >> 8 )
|
||||
#define _ALT ( PS2_ALT >> 8 )
|
||||
#define _ALT_GR ( PS2_ALT_GR >> 8 )
|
||||
#define _GUI ( PS2_GUI >> 8 )
|
||||
#define _FUNCTION ( PS2_FUNCTION >> 8 )
|
||||
|
||||
/* General defines of comms codes */
|
||||
/* Command or response */
|
||||
#define PS2_KC_RESEND 0xFE
|
||||
#define PS2_KC_ACK 0xFA
|
||||
#define PS2_KC_ECHO 0xEE
|
||||
/* Responses */
|
||||
#define PS2_KC_BAT 0xAA
|
||||
// Actually buffer overrun
|
||||
#define PS2_KC_OVERRUN 0xFF
|
||||
// Below is general error code
|
||||
#define PS2_KC_ERROR 0xFC
|
||||
#define PS2_KC_KEYBREAK 0xF0
|
||||
#define PS2_KC_EXTEND1 0xE1
|
||||
#define PS2_KC_EXTEND 0xE0
|
||||
/* Commands */
|
||||
#define PS2_KC_RESET 0xFF
|
||||
#define PS2_KC_DEFAULTS 0xF6
|
||||
#define PS2_KC_DISABLE 0xF5
|
||||
#define PS2_KC_ENABLE 0xF4
|
||||
#define PS2_KC_RATE 0xF3
|
||||
#define PS2_KC_READID 0xF2
|
||||
#define PS2_KC_SCANCODE 0xF0
|
||||
#define PS2_KC_LOCK 0xED
|
||||
|
||||
/* Single Byte Key Codes */
|
||||
#define PS2_KC_NUM 0x77
|
||||
#define PS2_KC_SCROLL 0x7E
|
||||
#define PS2_KC_CAPS 0x58
|
||||
#define PS2_KC_L_SHIFT 0x12
|
||||
#define PS2_KC_R_SHIFT 0x59
|
||||
/* This is Left CTRL and ALT but Right version is in E0 with same code */
|
||||
#define PS2_KC_CTRL 0X14
|
||||
#define PS2_KC_ALT 0x11
|
||||
/* Generated by some keyboards by ALT and PRTSCR */
|
||||
#define PS2_KC_SYSRQ 0x84
|
||||
#define PS2_KC_ESC 0x76
|
||||
#define PS2_KC_BS 0x66
|
||||
#define PS2_KC_TAB 0x0D
|
||||
#define PS2_KC_ENTER 0x5A
|
||||
#define PS2_KC_SPACE 0x29
|
||||
#define PS2_KC_KP0 0x70
|
||||
#define PS2_KC_KP1 0x69
|
||||
#define PS2_KC_KP2 0x72
|
||||
#define PS2_KC_KP3 0x7A
|
||||
#define PS2_KC_KP4 0x6B
|
||||
#define PS2_KC_KP5 0x73
|
||||
#define PS2_KC_KP6 0x74
|
||||
#define PS2_KC_KP7 0x6C
|
||||
#define PS2_KC_KP8 0x75
|
||||
#define PS2_KC_KP9 0x7D
|
||||
#define PS2_KC_KP_DOT 0x71
|
||||
#define PS2_KC_KP_PLUS 0x79
|
||||
#define PS2_KC_KP_MINUS 0x7B
|
||||
#define PS2_KC_KP_TIMES 0x7C
|
||||
/* Some keyboards have an '=' on right keypad */
|
||||
#define PS2_KC_KP_EQUAL 0x0F
|
||||
#define PS2_KC_0 0X45
|
||||
#define PS2_KC_1 0X16
|
||||
#define PS2_KC_2 0X1E
|
||||
#define PS2_KC_3 0X26
|
||||
#define PS2_KC_4 0X25
|
||||
#define PS2_KC_5 0X2E
|
||||
#define PS2_KC_6 0X36
|
||||
#define PS2_KC_7 0X3D
|
||||
#define PS2_KC_8 0X3E
|
||||
#define PS2_KC_9 0X46
|
||||
#define PS2_KC_APOS 0X52
|
||||
#define PS2_KC_COMMA 0X41
|
||||
#define PS2_KC_MINUS 0X4E
|
||||
#define PS2_KC_DOT 0X49
|
||||
#define PS2_KC_DIV 0X4A
|
||||
/* Single quote or back apostrophe */
|
||||
#define PS2_KC_BTICK 0X0E
|
||||
#define PS2_KC_A 0X1C
|
||||
#define PS2_KC_B 0X32
|
||||
#define PS2_KC_C 0X21
|
||||
#define PS2_KC_D 0X23
|
||||
#define PS2_KC_E 0X24
|
||||
#define PS2_KC_F 0X2B
|
||||
#define PS2_KC_G 0X34
|
||||
#define PS2_KC_H 0X33
|
||||
#define PS2_KC_I 0X43
|
||||
#define PS2_KC_J 0X3B
|
||||
#define PS2_KC_K 0X42
|
||||
#define PS2_KC_L 0X4B
|
||||
#define PS2_KC_M 0X3A
|
||||
#define PS2_KC_N 0X31
|
||||
#define PS2_KC_O 0X44
|
||||
#define PS2_KC_P 0X4D
|
||||
#define PS2_KC_Q 0X15
|
||||
#define PS2_KC_R 0X2D
|
||||
#define PS2_KC_S 0X1B
|
||||
#define PS2_KC_T 0X2C
|
||||
#define PS2_KC_U 0X3C
|
||||
#define PS2_KC_V 0X2A
|
||||
#define PS2_KC_W 0X1D
|
||||
#define PS2_KC_X 0X22
|
||||
#define PS2_KC_Y 0X35
|
||||
#define PS2_KC_Z 0X1A
|
||||
#define PS2_KC_SEMI 0X4C
|
||||
#define PS2_KC_BACK 0X5D
|
||||
// Extra key left of Z on 102 keyboards
|
||||
#define PS2_KC_EUROPE2 0x61
|
||||
#define PS2_KC_OPEN_SQ 0X54
|
||||
#define PS2_KC_CLOSE_SQ 0X5B
|
||||
#define PS2_KC_EQUAL 0X55
|
||||
#define PS2_KC_F1 0X05
|
||||
#define PS2_KC_F2 0X06
|
||||
#define PS2_KC_F3 0X04
|
||||
#define PS2_KC_F4 0X0C
|
||||
#define PS2_KC_F5 0X03
|
||||
#define PS2_KC_F6 0X0B
|
||||
#define PS2_KC_F7 0X83
|
||||
#define PS2_KC_F8 0X0A
|
||||
#define PS2_KC_F9 0X01
|
||||
#define PS2_KC_F10 0X09
|
||||
#define PS2_KC_F11 0X78
|
||||
#define PS2_KC_F12 0X07
|
||||
#define PS2_KC_F13 0X08
|
||||
#define PS2_KC_F14 0X10
|
||||
#define PS2_KC_F15 0X18
|
||||
#define PS2_KC_F16 0X20
|
||||
#define PS2_KC_F17 0X28
|
||||
#define PS2_KC_F18 0X30
|
||||
#define PS2_KC_F19 0X38
|
||||
#define PS2_KC_F20 0X40
|
||||
#define PS2_KC_F21 0X48
|
||||
#define PS2_KC_F22 0X50
|
||||
#define PS2_KC_F23 0X57
|
||||
#define PS2_KC_F24 0X5F
|
||||
#define PS2_KC_KP_COMMA 0X6D
|
||||
#define PS2_KC_INTL1 0X51
|
||||
#define PS2_KC_INTL2 0X13
|
||||
#define PS2_KC_INTL3 0X6A
|
||||
#define PS2_KC_INTL4 0X64
|
||||
#define PS2_KC_INTL5 0X67
|
||||
#define PS2_KC_LANG1 0XF2
|
||||
#define PS2_KC_LANG2 0XF1
|
||||
#define PS2_KC_LANG3 0X63
|
||||
#define PS2_KC_LANG4 0X62
|
||||
#define PS2_KC_LANG5 0X5F
|
||||
|
||||
/* Extended key codes E0 table for two byte codes */
|
||||
/* PS2_CTRL and PS2_ALT Need using in any table for the right keys */
|
||||
/* first is special case for PRTSCR not always used so ignored by decoding */
|
||||
#define PS2_KC_IGNORE 0x12
|
||||
#define PS2_KC_PRTSCR 0x7C
|
||||
/* Sometimes called windows key */
|
||||
#define PS2_KC_L_GUI 0x1F
|
||||
#define PS2_KC_R_GUI 0x27
|
||||
#define PS2_KC_MENU 0x2F
|
||||
/* Break is CTRL + PAUSE generated inside keyboard */
|
||||
#define PS2_KC_BREAK 0x7E
|
||||
#define PS2_KC_HOME 0x6C
|
||||
#define PS2_KC_END 0x69
|
||||
#define PS2_KC_PGUP 0x7D
|
||||
#define PS2_KC_PGDN 0x7A
|
||||
#define PS2_KC_L_ARROW 0x6B
|
||||
#define PS2_KC_R_ARROW 0x74
|
||||
#define PS2_KC_UP_ARROW 0x75
|
||||
#define PS2_KC_DN_ARROW 0x72
|
||||
#define PS2_KC_INSERT 0x70
|
||||
#define PS2_KC_DELETE 0x71
|
||||
#define PS2_KC_KP_ENTER 0x5A
|
||||
#define PS2_KC_KP_DIV 0x4A
|
||||
#define PS2_KC_NEXT_TR 0X4D
|
||||
#define PS2_KC_PREV_TR 0X15
|
||||
#define PS2_KC_STOP 0X3B
|
||||
#define PS2_KC_PLAY 0X34
|
||||
#define PS2_KC_MUTE 0X23
|
||||
#define PS2_KC_VOL_UP 0X32
|
||||
#define PS2_KC_VOL_DN 0X21
|
||||
#define PS2_KC_MEDIA 0X50
|
||||
#define PS2_KC_EMAIL 0X48
|
||||
#define PS2_KC_CALC 0X2B
|
||||
#define PS2_KC_COMPUTER 0X40
|
||||
#define PS2_KC_WEB_SEARCH 0X10
|
||||
#define PS2_KC_WEB_HOME 0X3A
|
||||
#define PS2_KC_WEB_BACK 0X38
|
||||
#define PS2_KC_WEB_FORWARD 0X30
|
||||
#define PS2_KC_WEB_STOP 0X28
|
||||
#define PS2_KC_WEB_REFRESH 0X20
|
||||
#define PS2_KC_WEB_FAVOR 0X18
|
||||
#define PS2_KC_POWER 0X37
|
||||
#define PS2_KC_SLEEP 0X3F
|
||||
#define PS2_KC_WAKE 0X5E
|
||||
#endif
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/PS2KeyTable.h
|
||||
393
main/include/PS2KeyTable.h
Normal file
393
main/include/PS2KeyTable.h
Normal file
@@ -0,0 +1,393 @@
|
||||
/* Version V1.0.8
|
||||
PS2KeyTable.h - PS2KeyAdvanced library keycode values to return values
|
||||
Copyright (c) 2007 Free Software Foundation. All right reserved.
|
||||
Written by Paul Carpenter, PC Services <sales@pcserviceselectronics.co.uk>
|
||||
Created September 2014
|
||||
V1.0.2 Updated January 2016 - Paul Carpenter - add tested on Due and tidy ups for V1.5 Library Management
|
||||
|
||||
PRIVATE to library
|
||||
|
||||
Test History
|
||||
September 2014 Uno and Mega 2560 September 2014 using Arduino V1.6.0
|
||||
January 2016 Uno, Mega 2560 and Due using Arduino 1.6.7 and Due Board
|
||||
Manager V1.6.6
|
||||
|
||||
Internal to library private tables
|
||||
(may disappear in updates do not rely on this file or definitions)
|
||||
|
||||
This is for a LATIN style keyboard. Will support most keyboards even ones
|
||||
with multimedia keys or even 24 function keys.
|
||||
|
||||
Definitions used for key codes from a PS2 keyboard, do not use in your
|
||||
code these are handled by the library.
|
||||
|
||||
See PS2KeyAdvanced.h for codes returned from library and flag settings
|
||||
|
||||
Two sets of tables
|
||||
|
||||
Single Byte codes returned as key codes
|
||||
|
||||
Two byte Codes preceded by E0 code returned as keycodes
|
||||
|
||||
Same tables used for make and break decode
|
||||
|
||||
Special cases are -
|
||||
|
||||
PRTSCR that ignores one of the sequences (E0,12) as this is not always sent
|
||||
especially with modifier keys or some keyboards when typematic repeat comes on.
|
||||
|
||||
PAUSE as this is an 8 byte sequence only one starting E1 so main code gets E1
|
||||
and waits for 7 more valid bytes to make the coding.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef PS2KeyTable_h
|
||||
#define PS2KeyTable_h
|
||||
|
||||
/* Table contents are pairs of numbers
|
||||
first code from keyboard
|
||||
second is either PS2_KEY_IGNOPRE code or key code to return
|
||||
|
||||
Single byte Key table
|
||||
In codes can only be 1 - 0x9F, plus 0xF2 and 0xF1
|
||||
Out Codes in range 1 to 0x9F
|
||||
*/
|
||||
const uint8_t single_key[][ 2 ] = {
|
||||
{ PS2_KC_NUM, PS2_KEY_NUM },
|
||||
{ PS2_KC_SCROLL, PS2_KEY_SCROLL },
|
||||
{ PS2_KC_CAPS, PS2_KEY_CAPS },
|
||||
{ PS2_KC_L_SHIFT, PS2_KEY_L_SHIFT },
|
||||
{ PS2_KC_R_SHIFT, PS2_KEY_R_SHIFT },
|
||||
{ PS2_KC_CTRL, PS2_KEY_L_CTRL },
|
||||
{ PS2_KC_ALT, PS2_KEY_L_ALT },
|
||||
{ PS2_KC_SYSRQ, PS2_KEY_SYSRQ },
|
||||
{ PS2_KC_ESC, PS2_KEY_ESC },
|
||||
{ PS2_KC_BS, PS2_KEY_BS },
|
||||
{ PS2_KC_TAB, PS2_KEY_TAB },
|
||||
{ PS2_KC_ENTER, PS2_KEY_ENTER },
|
||||
{ PS2_KC_SPACE, PS2_KEY_SPACE },
|
||||
{ PS2_KC_KP0, PS2_KEY_KP0 },
|
||||
{ PS2_KC_KP1, PS2_KEY_KP1 },
|
||||
{ PS2_KC_KP2, PS2_KEY_KP2 },
|
||||
{ PS2_KC_KP3, PS2_KEY_KP3 },
|
||||
{ PS2_KC_KP4, PS2_KEY_KP4 },
|
||||
{ PS2_KC_KP5, PS2_KEY_KP5 },
|
||||
{ PS2_KC_KP6, PS2_KEY_KP6 },
|
||||
{ PS2_KC_KP7, PS2_KEY_KP7 },
|
||||
{ PS2_KC_KP8, PS2_KEY_KP8 },
|
||||
{ PS2_KC_KP9, PS2_KEY_KP9 },
|
||||
{ PS2_KC_KP_DOT, PS2_KEY_KP_DOT },
|
||||
{ PS2_KC_KP_PLUS, PS2_KEY_KP_PLUS },
|
||||
{ PS2_KC_KP_MINUS, PS2_KEY_KP_MINUS },
|
||||
{ PS2_KC_KP_TIMES, PS2_KEY_KP_TIMES },
|
||||
{ PS2_KC_KP_EQUAL, PS2_KEY_KP_EQUAL },
|
||||
{ PS2_KC_0, PS2_KEY_0 },
|
||||
{ PS2_KC_1, PS2_KEY_1 },
|
||||
{ PS2_KC_2, PS2_KEY_2 },
|
||||
{ PS2_KC_3, PS2_KEY_3 },
|
||||
{ PS2_KC_4, PS2_KEY_4 },
|
||||
{ PS2_KC_5, PS2_KEY_5 },
|
||||
{ PS2_KC_6, PS2_KEY_6 },
|
||||
{ PS2_KC_7, PS2_KEY_7 },
|
||||
{ PS2_KC_8, PS2_KEY_8 },
|
||||
{ PS2_KC_9, PS2_KEY_9 },
|
||||
{ PS2_KC_APOS, PS2_KEY_APOS },
|
||||
{ PS2_KC_COMMA, PS2_KEY_COMMA },
|
||||
{ PS2_KC_MINUS, PS2_KEY_MINUS },
|
||||
{ PS2_KC_DOT, PS2_KEY_DOT },
|
||||
{ PS2_KC_DIV, PS2_KEY_DIV },
|
||||
{ PS2_KC_BTICK, PS2_KEY_BTICK },
|
||||
{ PS2_KC_A, PS2_KEY_A },
|
||||
{ PS2_KC_B, PS2_KEY_B },
|
||||
{ PS2_KC_C, PS2_KEY_C },
|
||||
{ PS2_KC_D, PS2_KEY_D },
|
||||
{ PS2_KC_E, PS2_KEY_E },
|
||||
{ PS2_KC_F, PS2_KEY_F },
|
||||
{ PS2_KC_G, PS2_KEY_G },
|
||||
{ PS2_KC_H, PS2_KEY_H },
|
||||
{ PS2_KC_I, PS2_KEY_I },
|
||||
{ PS2_KC_J, PS2_KEY_J },
|
||||
{ PS2_KC_K, PS2_KEY_K },
|
||||
{ PS2_KC_L, PS2_KEY_L },
|
||||
{ PS2_KC_M, PS2_KEY_M },
|
||||
{ PS2_KC_N, PS2_KEY_N },
|
||||
{ PS2_KC_O, PS2_KEY_O },
|
||||
{ PS2_KC_P, PS2_KEY_P },
|
||||
{ PS2_KC_Q, PS2_KEY_Q },
|
||||
{ PS2_KC_R, PS2_KEY_R },
|
||||
{ PS2_KC_S, PS2_KEY_S },
|
||||
{ PS2_KC_T, PS2_KEY_T },
|
||||
{ PS2_KC_U, PS2_KEY_U },
|
||||
{ PS2_KC_V, PS2_KEY_V },
|
||||
{ PS2_KC_W, PS2_KEY_W },
|
||||
{ PS2_KC_X, PS2_KEY_X },
|
||||
{ PS2_KC_Y, PS2_KEY_Y },
|
||||
{ PS2_KC_Z, PS2_KEY_Z },
|
||||
{ PS2_KC_SEMI, PS2_KEY_SEMI },
|
||||
{ PS2_KC_BACK, PS2_KEY_HASH },
|
||||
{ PS2_KC_OPEN_SQ, PS2_KEY_OPEN_SQ },
|
||||
{ PS2_KC_CLOSE_SQ, PS2_KEY_CLOSE_SQ },
|
||||
{ PS2_KC_EQUAL, PS2_KEY_EQUAL },
|
||||
{ PS2_KC_EUROPE2, PS2_KEY_BACK },
|
||||
{ PS2_KC_F1, PS2_KEY_F1 },
|
||||
{ PS2_KC_F2, PS2_KEY_F2 },
|
||||
{ PS2_KC_F3, PS2_KEY_F3 },
|
||||
{ PS2_KC_F4, PS2_KEY_F4 },
|
||||
{ PS2_KC_F5, PS2_KEY_F5 },
|
||||
{ PS2_KC_F6, PS2_KEY_F6 },
|
||||
{ PS2_KC_F7, PS2_KEY_F7 },
|
||||
{ PS2_KC_F8, PS2_KEY_F8 },
|
||||
{ PS2_KC_F9, PS2_KEY_F9 },
|
||||
{ PS2_KC_F10, PS2_KEY_F10 },
|
||||
{ PS2_KC_F11, PS2_KEY_F11 },
|
||||
{ PS2_KC_F12, PS2_KEY_F12 },
|
||||
{ PS2_KC_KP_COMMA, PS2_KEY_KP_COMMA },
|
||||
{ PS2_KC_INTL1, PS2_KEY_INTL1 },
|
||||
{ PS2_KC_INTL2, PS2_KEY_INTL2 },
|
||||
{ PS2_KC_INTL3, PS2_KEY_INTL3 },
|
||||
{ PS2_KC_INTL4, PS2_KEY_INTL4 },
|
||||
{ PS2_KC_INTL5, PS2_KEY_INTL5 },
|
||||
{ PS2_KC_LANG1, PS2_KEY_LANG1 },
|
||||
{ PS2_KC_LANG2, PS2_KEY_LANG2 },
|
||||
{ PS2_KC_LANG3, PS2_KEY_LANG3 },
|
||||
{ PS2_KC_LANG4, PS2_KEY_LANG4 },
|
||||
{ PS2_KC_LANG5, PS2_KEY_LANG5 }
|
||||
};
|
||||
|
||||
/* Two byte Key table after an E0 byte received */
|
||||
const uint8_t extended_key[][ 2 ] = {
|
||||
{ PS2_KC_IGNORE, PS2_KEY_IGNORE },
|
||||
{ PS2_KC_PRTSCR, PS2_KEY_PRTSCR },
|
||||
{ PS2_KC_CTRL, PS2_KEY_R_CTRL },
|
||||
{ PS2_KC_ALT, PS2_KEY_R_ALT },
|
||||
{ PS2_KC_L_GUI, PS2_KEY_L_GUI },
|
||||
{ PS2_KC_R_GUI, PS2_KEY_R_GUI },
|
||||
{ PS2_KC_MENU, PS2_KEY_MENU },
|
||||
{ PS2_KC_BREAK, PS2_KEY_BREAK },
|
||||
{ PS2_KC_HOME, PS2_KEY_HOME },
|
||||
{ PS2_KC_END, PS2_KEY_END },
|
||||
{ PS2_KC_PGUP, PS2_KEY_PGUP },
|
||||
{ PS2_KC_PGDN, PS2_KEY_PGDN },
|
||||
{ PS2_KC_L_ARROW, PS2_KEY_L_ARROW },
|
||||
{ PS2_KC_R_ARROW, PS2_KEY_R_ARROW },
|
||||
{ PS2_KC_UP_ARROW, PS2_KEY_UP_ARROW },
|
||||
{ PS2_KC_DN_ARROW, PS2_KEY_DN_ARROW },
|
||||
{ PS2_KC_INSERT, PS2_KEY_INSERT },
|
||||
{ PS2_KC_DELETE, PS2_KEY_DELETE },
|
||||
{ PS2_KC_KP_ENTER, PS2_KEY_KP_ENTER },
|
||||
{ PS2_KC_KP_DIV, PS2_KEY_KP_DIV },
|
||||
{ PS2_KC_NEXT_TR, PS2_KEY_NEXT_TR },
|
||||
{ PS2_KC_PREV_TR, PS2_KEY_PREV_TR },
|
||||
{ PS2_KC_STOP, PS2_KEY_STOP },
|
||||
{ PS2_KC_PLAY, PS2_KEY_PLAY },
|
||||
{ PS2_KC_MUTE, PS2_KEY_MUTE },
|
||||
{ PS2_KC_VOL_UP, PS2_KEY_VOL_UP },
|
||||
{ PS2_KC_VOL_DN, PS2_KEY_VOL_DN },
|
||||
{ PS2_KC_MEDIA, PS2_KEY_MEDIA },
|
||||
{ PS2_KC_EMAIL, PS2_KEY_EMAIL },
|
||||
{ PS2_KC_CALC, PS2_KEY_CALC },
|
||||
{ PS2_KC_COMPUTER, PS2_KEY_COMPUTER },
|
||||
{ PS2_KC_WEB_SEARCH, PS2_KEY_WEB_SEARCH },
|
||||
{ PS2_KC_WEB_HOME, PS2_KEY_WEB_HOME },
|
||||
{ PS2_KC_WEB_BACK, PS2_KEY_WEB_BACK },
|
||||
{ PS2_KC_WEB_FORWARD, PS2_KEY_WEB_FORWARD },
|
||||
{ PS2_KC_WEB_STOP, PS2_KEY_WEB_STOP },
|
||||
{ PS2_KC_WEB_REFRESH, PS2_KEY_WEB_REFRESH },
|
||||
{ PS2_KC_WEB_FAVOR, PS2_KEY_WEB_FAVOR },
|
||||
{ PS2_KC_POWER, PS2_KEY_POWER },
|
||||
{ PS2_KC_SLEEP, PS2_KEY_SLEEP },
|
||||
{ PS2_KC_WAKE, PS2_KEY_WAKE }
|
||||
};
|
||||
|
||||
/* Scroll lock numeric keypad re-mappings for NOT NUMLOCK */
|
||||
/* in translated code order order is important */
|
||||
const uint8_t scroll_remap[] = {
|
||||
PS2_KEY_INSERT, // PS2_KEY_KP0
|
||||
PS2_KEY_END, // PS2_KEY_KP1
|
||||
PS2_KEY_DN_ARROW, // PS2_KEY_KP2
|
||||
PS2_KEY_PGDN, // PS2_KEY_KP3
|
||||
PS2_KEY_L_ARROW, // PS2_KEY_KP4
|
||||
PS2_KEY_IGNORE, // PS2_KEY_KP5
|
||||
PS2_KEY_R_ARROW, // PS2_KEY_KP6
|
||||
PS2_KEY_HOME, // PS2_KEY_KP7
|
||||
PS2_KEY_UP_ARROW, // PS2_KEY_KP8
|
||||
PS2_KEY_PGUP, // PS2_KEY_KP9
|
||||
PS2_KEY_DELETE // PS2_KEY_KP_DOT
|
||||
};
|
||||
|
||||
//const uint8_t single_key[][ 2 ] = {
|
||||
// { PS2_KC_NUM, PS2_KEY_NUM },
|
||||
// { PS2_KC_SCROLL, PS2_KEY_SCROLL },
|
||||
// { PS2_KC_CAPS, PS2_KEY_CAPS },
|
||||
// { PS2_KC_L_SHIFT, PS2_KEY_L_SHIFT },
|
||||
// { PS2_KC_R_SHIFT, PS2_KEY_R_SHIFT },
|
||||
// { PS2_KC_CTRL, PS2_KEY_L_CTRL },
|
||||
// { PS2_KC_ALT, PS2_KEY_L_ALT },
|
||||
// { PS2_KC_SYSRQ, PS2_KEY_SYSRQ },
|
||||
// { PS2_KC_ESC, PS2_KEY_ESC },
|
||||
// { PS2_KC_BS, PS2_KEY_BS },
|
||||
// { PS2_KC_TAB, PS2_KEY_TAB },
|
||||
// { PS2_KC_ENTER, PS2_KEY_ENTER },
|
||||
// { PS2_KC_SPACE, PS2_KEY_SPACE },
|
||||
// { PS2_KC_KP0, PS2_KEY_KP0 },
|
||||
// { PS2_KC_KP1, PS2_KEY_KP1 },
|
||||
// { PS2_KC_KP2, PS2_KEY_KP2 },
|
||||
// { PS2_KC_KP3, PS2_KEY_KP3 },
|
||||
// { PS2_KC_KP4, PS2_KEY_KP4 },
|
||||
// { PS2_KC_KP5, PS2_KEY_KP5 },
|
||||
// { PS2_KC_KP6, PS2_KEY_KP6 },
|
||||
// { PS2_KC_KP7, PS2_KEY_KP7 },
|
||||
// { PS2_KC_KP8, PS2_KEY_KP8 },
|
||||
// { PS2_KC_KP9, PS2_KEY_KP9 },
|
||||
// { PS2_KC_KP_DOT, PS2_KEY_KP_DOT },
|
||||
// { PS2_KC_KP_PLUS, PS2_KEY_KP_PLUS },
|
||||
// { PS2_KC_KP_MINUS, PS2_KEY_KP_MINUS },
|
||||
// { PS2_KC_KP_TIMES, PS2_KEY_KP_TIMES },
|
||||
// { PS2_KC_KP_EQUAL, PS2_KEY_KP_EQUAL },
|
||||
// { PS2_KC_0, PS2_KEY_0 },
|
||||
// { PS2_KC_1, PS2_KEY_1 },
|
||||
// { PS2_KC_2, PS2_KEY_2 },
|
||||
// { PS2_KC_3, PS2_KEY_3 },
|
||||
// { PS2_KC_4, PS2_KEY_4 },
|
||||
// { PS2_KC_5, PS2_KEY_5 },
|
||||
// { PS2_KC_6, PS2_KEY_6 },
|
||||
// { PS2_KC_7, PS2_KEY_7 },
|
||||
// { PS2_KC_8, PS2_KEY_8 },
|
||||
// { PS2_KC_9, PS2_KEY_9 },
|
||||
// { PS2_KC_APOS, PS2_KEY_APOS },
|
||||
// { PS2_KC_COMMA, PS2_KEY_COMMA },
|
||||
// { PS2_KC_MINUS, PS2_KEY_MINUS },
|
||||
// { PS2_KC_DOT, PS2_KEY_DOT },
|
||||
// { PS2_KC_DIV, PS2_KEY_DIV },
|
||||
// { PS2_KC_BTICK, PS2_KEY_BTICK },
|
||||
// { PS2_KC_A, PS2_KEY_A },
|
||||
// { PS2_KC_B, PS2_KEY_B },
|
||||
// { PS2_KC_C, PS2_KEY_C },
|
||||
// { PS2_KC_D, PS2_KEY_D },
|
||||
// { PS2_KC_E, PS2_KEY_E },
|
||||
// { PS2_KC_F, PS2_KEY_F },
|
||||
// { PS2_KC_G, PS2_KEY_G },
|
||||
// { PS2_KC_H, PS2_KEY_H },
|
||||
// { PS2_KC_I, PS2_KEY_I },
|
||||
// { PS2_KC_J, PS2_KEY_J },
|
||||
// { PS2_KC_K, PS2_KEY_K },
|
||||
// { PS2_KC_L, PS2_KEY_L },
|
||||
// { PS2_KC_M, PS2_KEY_M },
|
||||
// { PS2_KC_N, PS2_KEY_N },
|
||||
// { PS2_KC_O, PS2_KEY_O },
|
||||
// { PS2_KC_P, PS2_KEY_P },
|
||||
// { PS2_KC_Q, PS2_KEY_Q },
|
||||
// { PS2_KC_R, PS2_KEY_R },
|
||||
// { PS2_KC_S, PS2_KEY_S },
|
||||
// { PS2_KC_T, PS2_KEY_T },
|
||||
// { PS2_KC_U, PS2_KEY_U },
|
||||
// { PS2_KC_V, PS2_KEY_V },
|
||||
// { PS2_KC_W, PS2_KEY_W },
|
||||
// { PS2_KC_X, PS2_KEY_X },
|
||||
// { PS2_KC_Y, PS2_KEY_Y },
|
||||
// { PS2_KC_Z, PS2_KEY_Z },
|
||||
// { PS2_KC_SEMI, PS2_KEY_SEMI },
|
||||
// { PS2_KC_BACK, PS2_KEY_BACK },
|
||||
// { PS2_KC_OPEN_SQ, PS2_KEY_OPEN_SQ },
|
||||
// { PS2_KC_CLOSE_SQ, PS2_KEY_CLOSE_SQ },
|
||||
// { PS2_KC_EQUAL, PS2_KEY_EQUAL },
|
||||
// { PS2_KC_EUROPE2, PS2_KEY_BACK },
|
||||
// { PS2_KC_F1, PS2_KEY_F1 },
|
||||
// { PS2_KC_F2, PS2_KEY_F2 },
|
||||
// { PS2_KC_F3, PS2_KEY_F3 },
|
||||
// { PS2_KC_F4, PS2_KEY_F4 },
|
||||
// { PS2_KC_F5, PS2_KEY_F5 },
|
||||
// { PS2_KC_F6, PS2_KEY_F6 },
|
||||
// { PS2_KC_F7, PS2_KEY_F7 },
|
||||
// { PS2_KC_F8, PS2_KEY_F8 },
|
||||
// { PS2_KC_F9, PS2_KEY_F9 },
|
||||
// { PS2_KC_F10, PS2_KEY_F10 },
|
||||
// { PS2_KC_F11, PS2_KEY_F11 },
|
||||
// { PS2_KC_F12, PS2_KEY_F12 },
|
||||
// { PS2_KC_KP_COMMA, PS2_KEY_KP_COMMA },
|
||||
// { PS2_KC_INTL1, PS2_KEY_INTL1 },
|
||||
// { PS2_KC_INTL2, PS2_KEY_INTL2 },
|
||||
// { PS2_KC_INTL3, PS2_KEY_INTL3 },
|
||||
// { PS2_KC_INTL4, PS2_KEY_INTL4 },
|
||||
// { PS2_KC_INTL5, PS2_KEY_INTL5 },
|
||||
// { PS2_KC_LANG1, PS2_KEY_LANG1 },
|
||||
// { PS2_KC_LANG2, PS2_KEY_LANG2 },
|
||||
// { PS2_KC_LANG3, PS2_KEY_LANG3 },
|
||||
// { PS2_KC_LANG4, PS2_KEY_LANG4 },
|
||||
// { PS2_KC_LANG5, PS2_KEY_LANG5 }
|
||||
// };
|
||||
//
|
||||
///* Two byte Key table after an E0 byte received */
|
||||
//const uint8_t extended_key[][ 2 ] = {
|
||||
// { PS2_KC_IGNORE, PS2_KEY_IGNORE },
|
||||
// { PS2_KC_PRTSCR, PS2_KEY_PRTSCR },
|
||||
// { PS2_KC_CTRL, PS2_KEY_R_CTRL },
|
||||
// { PS2_KC_ALT, PS2_KEY_R_ALT },
|
||||
// { PS2_KC_L_GUI, PS2_KEY_L_GUI },
|
||||
// { PS2_KC_R_GUI, PS2_KEY_R_GUI },
|
||||
// { PS2_KC_MENU, PS2_KEY_MENU },
|
||||
// { PS2_KC_BREAK, PS2_KEY_BREAK },
|
||||
// { PS2_KC_HOME, PS2_KEY_HOME },
|
||||
// { PS2_KC_END, PS2_KEY_END },
|
||||
// { PS2_KC_PGUP, PS2_KEY_PGUP },
|
||||
// { PS2_KC_PGDN, PS2_KEY_PGDN },
|
||||
// { PS2_KC_L_ARROW, PS2_KEY_L_ARROW },
|
||||
// { PS2_KC_R_ARROW, PS2_KEY_R_ARROW },
|
||||
// { PS2_KC_UP_ARROW, PS2_KEY_UP_ARROW },
|
||||
// { PS2_KC_DN_ARROW, PS2_KEY_DN_ARROW },
|
||||
// { PS2_KC_INSERT, PS2_KEY_INSERT },
|
||||
// { PS2_KC_DELETE, PS2_KEY_DELETE },
|
||||
// { PS2_KC_KP_ENTER, PS2_KEY_KP_ENTER },
|
||||
// { PS2_KC_KP_DIV, PS2_KEY_KP_DIV },
|
||||
// { PS2_KC_NEXT_TR, PS2_KEY_NEXT_TR },
|
||||
// { PS2_KC_PREV_TR, PS2_KEY_PREV_TR },
|
||||
// { PS2_KC_STOP, PS2_KEY_STOP },
|
||||
// { PS2_KC_PLAY, PS2_KEY_PLAY },
|
||||
// { PS2_KC_MUTE, PS2_KEY_MUTE },
|
||||
// { PS2_KC_VOL_UP, PS2_KEY_VOL_UP },
|
||||
// { PS2_KC_VOL_DN, PS2_KEY_VOL_DN },
|
||||
// { PS2_KC_MEDIA, PS2_KEY_MEDIA },
|
||||
// { PS2_KC_EMAIL, PS2_KEY_EMAIL },
|
||||
// { PS2_KC_CALC, PS2_KEY_CALC },
|
||||
// { PS2_KC_COMPUTER, PS2_KEY_COMPUTER },
|
||||
// { PS2_KC_WEB_SEARCH, PS2_KEY_WEB_SEARCH },
|
||||
// { PS2_KC_WEB_HOME, PS2_KEY_WEB_HOME },
|
||||
// { PS2_KC_WEB_BACK, PS2_KEY_WEB_BACK },
|
||||
// { PS2_KC_WEB_FORWARD, PS2_KEY_WEB_FORWARD },
|
||||
// { PS2_KC_WEB_STOP, PS2_KEY_WEB_STOP },
|
||||
// { PS2_KC_WEB_REFRESH, PS2_KEY_WEB_REFRESH },
|
||||
// { PS2_KC_WEB_FAVOR, PS2_KEY_WEB_FAVOR },
|
||||
// { PS2_KC_POWER, PS2_KEY_POWER },
|
||||
// { PS2_KC_SLEEP, PS2_KEY_SLEEP },
|
||||
// { PS2_KC_WAKE, PS2_KEY_WAKE }
|
||||
// };
|
||||
//
|
||||
///* Scroll lock numeric keypad re-mappings for NOT NUMLOCK */
|
||||
///* in translated code order order is important */
|
||||
//const uint8_t scroll_remap[] = {
|
||||
// PS2_KEY_INSERT, // PS2_KEY_KP0
|
||||
// PS2_KEY_END, // PS2_KEY_KP1
|
||||
// PS2_KEY_DN_ARROW, // PS2_KEY_KP2
|
||||
// PS2_KEY_PGDN, // PS2_KEY_KP3
|
||||
// PS2_KEY_L_ARROW, // PS2_KEY_KP4
|
||||
// PS2_KEY_IGNORE, // PS2_KEY_KP5
|
||||
// PS2_KEY_R_ARROW, // PS2_KEY_KP6
|
||||
// PS2_KEY_HOME, // PS2_KEY_KP7
|
||||
// PS2_KEY_UP_ARROW, // PS2_KEY_KP8
|
||||
// PS2_KEY_PGUP, // PS2_KEY_KP9
|
||||
// PS2_KEY_DELETE // PS2_KEY_KP_DOT
|
||||
// };
|
||||
//
|
||||
#endif
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/PS2Mouse.h
|
||||
187
main/include/PS2Mouse.h
Normal file
187
main/include/PS2Mouse.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: PS2Mouse.h
|
||||
// Created: Jan 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header file for the PS/2 Mouse Class.
|
||||
//
|
||||
// Credits:
|
||||
// Copyright: (c) 2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef MOUSE_H_
|
||||
#define MOUSE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <functional>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_log.h"
|
||||
#include "Arduino.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
|
||||
// PS/2 Mouse Class.
|
||||
class PS2Mouse {
|
||||
|
||||
// mode status flags
|
||||
#define _PS2_BUSY 0x04
|
||||
#define _TX_MODE 0x02
|
||||
#define _WAIT_RESPONSE 0x01
|
||||
|
||||
// Constants.
|
||||
#define MAX_PS2_XMIT_KEY_BUF 16
|
||||
#define MAX_PS2_RCV_KEY_BUF 16
|
||||
#define INTELLI_MOUSE 3
|
||||
#define SCALING_1_TO_1 0xE6
|
||||
#define DEFAULT_MOUSE_TIMEOUT 100
|
||||
|
||||
public:
|
||||
// Public structures used for containment of mouse movement and control data. These are used by the insantiating
|
||||
// object to request and process mouse data.
|
||||
// Postional data - X/Y co-ordinates of mouse movement.
|
||||
typedef struct {
|
||||
int x, y;
|
||||
} Position;
|
||||
|
||||
// Mouse data, containing positional data, status, wheel data and validity.
|
||||
typedef struct {
|
||||
bool valid;
|
||||
bool overrun;
|
||||
int status;
|
||||
Position position;
|
||||
int wheel;
|
||||
} MouseData;
|
||||
|
||||
// Enumeration of all processed mouse responses.
|
||||
enum Responses {
|
||||
MOUSE_RESP_ACK = 0xFA,
|
||||
};
|
||||
|
||||
// Enumeration of all processed mouse commands.
|
||||
enum Commands {
|
||||
MOUSE_CMD_SET_SCALING_1_1 = 0xE6,
|
||||
MOUSE_CMD_SET_SCALING_2_1 = 0xE7,
|
||||
MOUSE_CMD_SET_RESOLUTION = 0xE8,
|
||||
MOUSE_CMD_GET_STATUS = 0xE9,
|
||||
MOUSE_CMD_SET_STREAM_MODE = 0xEA,
|
||||
MOUSE_CMD_REQUEST_DATA = 0xEB,
|
||||
MOUSE_CMD_SET_REMOTE_MODE = 0xF0,
|
||||
MOUSE_CMD_GET_DEVICE_ID = 0xF2,
|
||||
MOUSE_CMD_SET_SAMPLE_RATE = 0xF3,
|
||||
MOUSE_CMD_ENABLE_STREAMING = 0xF4,
|
||||
MOUSE_CMD_DISABLE_STREAMING = 0xF5,
|
||||
MOUSE_CMD_RESEND = 0xFE,
|
||||
MOUSE_CMD_RESET = 0xFF,
|
||||
};
|
||||
|
||||
// Resolution - the PS/2 mouse can digitize movement from 1mm to 1/8mm, the default being 1/4 (ie. 1mm = 4 counts). This allows configuration for a finer or rougher
|
||||
// tracking digitisation.
|
||||
enum PS2_RESOLUTION {
|
||||
PS2_MOUSE_RESOLUTION_1_1 = 0x00,
|
||||
PS2_MOUSE_RESOLUTION_1_2 = 0x01,
|
||||
PS2_MOUSE_RESOLUTION_1_4 = 0x02,
|
||||
PS2_MOUSE_RESOLUTION_1_8 = 0x03,
|
||||
};
|
||||
|
||||
// Scaling - the PS/2 mouse can provide linear (1:1 no scaling) or non liner (2:1 scaling) adaptation of the digitised data. This allows configuration for amplification of movements.
|
||||
enum PS2_SCALING {
|
||||
PS2_MOUSE_SCALING_1_1 = 0x00,
|
||||
PS2_MOUSE_SCALING_2_1 = 0x01,
|
||||
};
|
||||
|
||||
// Sampling rate - the PS/2 mouse, in streaming mode, the mouse sends with movement updates. This allows for finer or rougher digitisation of movements. The default is 100 samples per
|
||||
// second and the X68000 is fixed at 100 samples per second. Adjusting the ps/2 sample rate will affect tracking granularity on the X68000.
|
||||
enum PS2_SAMPLING {
|
||||
PS2_MOUSE_SAMPLE_RATE_10 = 10,
|
||||
PS2_MOUSE_SAMPLE_RATE_20 = 20,
|
||||
PS2_MOUSE_SAMPLE_RATE_40 = 40,
|
||||
PS2_MOUSE_SAMPLE_RATE_60 = 60,
|
||||
PS2_MOUSE_SAMPLE_RATE_80 = 80,
|
||||
PS2_MOUSE_SAMPLE_RATE_100 = 100,
|
||||
PS2_MOUSE_SAMPLE_RATE_200 = 200,
|
||||
};
|
||||
|
||||
// Public accessible prototypes.
|
||||
PS2Mouse(int clockPin, int dataPin);
|
||||
~PS2Mouse();
|
||||
void writeByte(uint8_t);
|
||||
bool setResolution(enum PS2_RESOLUTION resolution);
|
||||
bool setStreamMode(void);
|
||||
bool setRemoteMode(void);
|
||||
bool setScaling(enum PS2_SCALING scaling);
|
||||
char getDeviceId(void);
|
||||
bool checkIntelliMouseExtensions(void);
|
||||
bool setSampleRate(enum PS2_SAMPLING rate);
|
||||
bool enableStreaming(void);
|
||||
bool disableStreaming(void);
|
||||
bool getStatus(uint8_t *respBuf);
|
||||
bool reset(void);
|
||||
MouseData readData(void);
|
||||
void initialize(void);
|
||||
|
||||
// Method to register an object method for callback with context.
|
||||
template<typename A, typename B>
|
||||
void setMouseDataCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
ps2Ctrl.mouseDataCallback = bind(func_ptr, obj_ptr, 0, std::placeholders::_1);
|
||||
}
|
||||
|
||||
private:
|
||||
// PS/2 Control structure - maintains all data and variables relevant to forming a connection with a PS/2 mouse, interaction and processing of its data.
|
||||
struct {
|
||||
int clkPin; // Hardware clock pin - bidirectional.
|
||||
int dataPin; // Hardware data pin - bidirectional.
|
||||
volatile uint8_t mode; // mode contains _PS2_BUSY bit 2 = busy until all expected bytes RX/TX
|
||||
// _TX_MODE bit 1 = direction 1 = TX, 0 = RX (default)
|
||||
// _WAIT_RESPONSE bit 0 = expecting data response
|
||||
bool supportsIntelliMouseExtensions; // Intellimouse extensions supported.
|
||||
bool streamingEnabled; // Streaming mode has been enabled.
|
||||
volatile uint8_t bitCount; // Main state variable and bit count for interrupts
|
||||
volatile uint8_t shiftReg; // Incoming/Outgoing data shift register.
|
||||
volatile uint8_t parity; // Parity flag for data being sent/received.
|
||||
uint16_t rxBuf[16]; // RX buffer - assembled bytes are stored in this buffer awaiting processing.
|
||||
int rxPos; // Position in buffer to store next byte.
|
||||
|
||||
// Callback for streaming processed mouse data to HID handler.
|
||||
std::function<void(PS2Mouse::MouseData)> mouseDataCallback;
|
||||
} ps2Ctrl;
|
||||
|
||||
// Structure to store incoming streamed mouse data along with validity flags.
|
||||
struct {
|
||||
MouseData mouseData;
|
||||
bool newData; // An update has occurred since the last query.
|
||||
bool overrun; // A data overrun has occurred since the last query.
|
||||
} streaming;
|
||||
|
||||
// Interrupt handler - needs to be declared static and assigned to internal RAM (within the ESP32) to function correctly.
|
||||
IRAM_ATTR static void ps2interrupt( void );
|
||||
|
||||
// Prototypes.
|
||||
bool requestData(uint8_t expectedBytes, uint8_t *respBuf, uint32_t timeout);
|
||||
bool sendCmd(uint8_t cmd, uint8_t expectedBytes, uint8_t *respBuf, uint32_t timeout);
|
||||
|
||||
};
|
||||
|
||||
#endif // MOUSE_H_
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/SWITCH.h
|
||||
232
main/include/SWITCH.h
Normal file
232
main/include/SWITCH.h
Normal file
@@ -0,0 +1,232 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: SWITCH.h
|
||||
// Created: May 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Class definition to encapsulate the SharpKey WiFi/Config Switch.
|
||||
//
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: May 2022 - Initial write.
|
||||
// v1.00 Jun 2022 - Updates to add additional callbacks for RESET and CLEARNVS
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SWITCH_H
|
||||
#define SWITCH_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "driver/timer.h"
|
||||
#include "LED.h"
|
||||
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Switch class.
|
||||
class SWITCH {
|
||||
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define SWITCH_VERSION 1.00
|
||||
|
||||
public:
|
||||
|
||||
// Prototypes.
|
||||
SWITCH(LED *led);
|
||||
SWITCH(void);
|
||||
virtual ~SWITCH(void);
|
||||
|
||||
// Method to register an object method for callback with context.
|
||||
template<typename A, typename B>
|
||||
void setCancelEventCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
swCtrl.cancelEventCallback = std::bind(func_ptr, obj_ptr);
|
||||
}
|
||||
template<typename A>
|
||||
void setCancelEventCallback(A func_ptr)
|
||||
{
|
||||
swCtrl.cancelEventCallback = std::bind(func_ptr);
|
||||
}
|
||||
// Wifi enable (configured mode).
|
||||
template<typename A, typename B>
|
||||
void setWifiEnEventCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
swCtrl.wifiEnEventCallback = std::bind(func_ptr, obj_ptr);
|
||||
}
|
||||
template<typename A>
|
||||
void setWifiEnEventCallback(A func_ptr)
|
||||
{
|
||||
swCtrl.wifiEnEventCallback = std::bind(func_ptr);
|
||||
}
|
||||
// Wifi default mode enable.
|
||||
template<typename A, typename B>
|
||||
void setWifiDefEventCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
swCtrl.wifiDefEventCallback = std::bind(func_ptr, obj_ptr);
|
||||
}
|
||||
template<typename A>
|
||||
void setWifiDefEventCallback(A func_ptr)
|
||||
{
|
||||
swCtrl.wifiDefEventCallback = std::bind(func_ptr);
|
||||
}
|
||||
// Bluetooth start pairing event.
|
||||
template<typename A, typename B>
|
||||
void setBTPairingEventCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
swCtrl.btPairingEventCallback = std::bind(func_ptr, obj_ptr);
|
||||
}
|
||||
template<typename A>
|
||||
void setBTPairingEventCallback(A func_ptr)
|
||||
{
|
||||
swCtrl.btPairingEventCallback = std::bind(func_ptr);
|
||||
}
|
||||
// RESET event - callback is executed prior to issuing an esp_restart().
|
||||
template<typename A, typename B>
|
||||
void setResetEventCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
swCtrl.resetEventCallback = std::bind(func_ptr, obj_ptr);
|
||||
}
|
||||
template<typename A>
|
||||
void setResetEventCallback(A func_ptr)
|
||||
{
|
||||
swCtrl.resetEventCallback = std::bind(func_ptr);
|
||||
}
|
||||
// CLEARNVS event - callback when user requests all NVS settings are erased.
|
||||
template<typename A, typename B>
|
||||
void setClearNVSEventCallback(A func_ptr, B obj_ptr)
|
||||
{
|
||||
swCtrl.clearNVSEventCallback = std::bind(func_ptr, obj_ptr);
|
||||
}
|
||||
template<typename A>
|
||||
void setClearNVSEventCallback(A func_ptr)
|
||||
{
|
||||
swCtrl.clearNVSEventCallback = std::bind(func_ptr);
|
||||
}
|
||||
|
||||
// Helper method to identify the sub class, this is used in non volatile key management.
|
||||
// Warning: This method wont work if optimisation for size is enabled on the compiler.
|
||||
const char *getClassName(const std::string& prettyFunction)
|
||||
{
|
||||
// First find the CLASS :: METHOD seperation.
|
||||
size_t colons = prettyFunction.find("::");
|
||||
|
||||
// None, then this is not a class.
|
||||
if (colons == std::string::npos)
|
||||
return "::";
|
||||
|
||||
// Split out the class name.
|
||||
size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
|
||||
size_t end = colons - begin;
|
||||
|
||||
// Return the name.
|
||||
return(prettyFunction.substr(begin,end).c_str());
|
||||
}
|
||||
|
||||
// Helper method to change a file extension.
|
||||
void replaceExt(std::string& fileName, const std::string& newExt)
|
||||
{
|
||||
// Locals.
|
||||
std::string::size_type extPos = fileName.rfind('.', fileName.length());
|
||||
|
||||
if(extPos != std::string::npos)
|
||||
{
|
||||
fileName.replace(extPos+1, newExt.length(), newExt);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Template to aid in conversion of an enum to integer.
|
||||
template <typename E> constexpr typename std::underlying_type<E>::type to_underlying(E e) noexcept
|
||||
{
|
||||
return static_cast<typename std::underlying_type<E>::type>(e);
|
||||
}
|
||||
|
||||
// Method to return the class version number.
|
||||
virtual float version(void)
|
||||
{
|
||||
return(SWITCH_VERSION);
|
||||
}
|
||||
|
||||
// Method to return the name of the class.
|
||||
virtual std::string ifName(void)
|
||||
{
|
||||
return(swCtrl.swClassName);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Prototypes.
|
||||
void init(void);
|
||||
IRAM_ATTR static void swInterface( void * pvParameters );
|
||||
inline uint32_t milliSeconds(void)
|
||||
{
|
||||
return( (uint32_t) clock() );
|
||||
}
|
||||
|
||||
// Structure to maintain an active setting for the LED. The LED control thread uses these values to effect the required lighting of the LED.
|
||||
typedef struct {
|
||||
// Name of the class for this instantiation.
|
||||
std::string swClassName;
|
||||
|
||||
// Thread handles - Switch interface.
|
||||
TaskHandle_t TaskSWIF = NULL;
|
||||
|
||||
// Callback for Cancel Event.
|
||||
std::function<void(void)> cancelEventCallback;
|
||||
|
||||
// Callback for WiFi Enable Event.
|
||||
std::function<void(void)> wifiEnEventCallback;
|
||||
|
||||
// Callback for WiFi Default Event.
|
||||
std::function<void(void)> wifiDefEventCallback;
|
||||
|
||||
// Callback for Bluetooth Pairing Event.
|
||||
std::function<void(void)> btPairingEventCallback;
|
||||
|
||||
// Callback is executed prior to issuing an esp_restart().
|
||||
std::function<bool(void)> resetEventCallback;
|
||||
|
||||
// Callback when user requests all NVS settings are erased.
|
||||
std::function<void(void)> clearNVSEventCallback;
|
||||
} t_swControl;
|
||||
|
||||
// Var to store all SWITCH control variables.
|
||||
t_swControl swCtrl;
|
||||
|
||||
// LED activity object handle.
|
||||
LED *led;
|
||||
};
|
||||
#endif // SWITCH_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/WiFi.h
|
||||
400
main/include/WiFi.h
Normal file
400
main/include/WiFi.h
Normal file
@@ -0,0 +1,400 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: WiFi.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header for the WiFi AP/Client logic.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
// v1.02 Jun 2022 - Seperated out the WiFi Enable switch and made the WiFi module active/
|
||||
// via a reboot process. This is necessary now that Bluetooth is inbuilt
|
||||
// as the ESP32 shares an antenna and both operating together electrically
|
||||
// is difficult but also the IDF stack conflicts as well.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef WIFI_H
|
||||
#define WIFI_H
|
||||
|
||||
#if defined(CONFIG_IF_WIFI_ENABLED)
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sys.h"
|
||||
#include <esp_http_server.h>
|
||||
#include "esp_littlefs.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <arpa/inet.h>
|
||||
#include "NVS.h"
|
||||
#include "LED.h"
|
||||
#include "HID.h"
|
||||
|
||||
// Include the specification class.
|
||||
#include "KeyInterface.h"
|
||||
|
||||
// Encapsulate the WiFi functionality.
|
||||
class WiFi {
|
||||
// Constants.
|
||||
#define WIFI_VERSION 1.02
|
||||
#define OBJECT_VERSION_LIST_MAX 18
|
||||
#define FILEPACK_VERSION_FILE "version.txt"
|
||||
#define WIFI_AP_DEFAULT_IP "192.168.4.1"
|
||||
#define WIFI_AP_DEFAULT_GW "192.168.4.1"
|
||||
#define WIFI_AP_DEFAULT_NETMASK "255.255.255.0"
|
||||
|
||||
// The event group allows multiple bits for each event, but we only care about two events:
|
||||
// - we are connected to the AP with an IP
|
||||
// - we failed to connect after the maximum amount of retries
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
#define WIFI_FAIL_BIT BIT1
|
||||
|
||||
// Tag for ESP WiFi logging.
|
||||
#define WIFITAG "WiFi"
|
||||
|
||||
// Menu selection types.
|
||||
enum WIFIMODES {
|
||||
WIFI_OFF = 0x00, // WiFi is disabled.
|
||||
WIFI_ON = 0x01, // WiFi is enabled.
|
||||
WIFI_CONFIG_AP = 0x02, // WiFi is set to enable Access Point to configure WiFi settings.
|
||||
WIFI_CONFIG_CLIENT = 0x03 // WiFi is set to enable Client mode using persisted settings.
|
||||
};
|
||||
|
||||
// Default WiFi parameters.
|
||||
#define MAX_WIFI_SSID_LEN 31
|
||||
#define MAX_WIFI_PWD_LEN 63
|
||||
#define MAX_WIFI_IP_LEN 15
|
||||
#define MAX_WIFI_NETMASK_LEN 15
|
||||
#define MAX_WIFI_GATEWAY_LEN 15
|
||||
|
||||
// Buffer size for sending file data in chunks to the browser.
|
||||
#define MAX_CHUNK_SIZE 4096
|
||||
|
||||
// Max length a file path can have on the embedded storage device.
|
||||
#define FILE_PATH_MAX (15 + CONFIG_LITTLEFS_OBJ_NAME_LEN)
|
||||
|
||||
public:
|
||||
// Types for holding and maintaining a class/object to version number array.
|
||||
typedef struct {
|
||||
std::string object;
|
||||
float version;
|
||||
} t_versionItem;
|
||||
typedef struct {
|
||||
int elements;
|
||||
t_versionItem *item[OBJECT_VERSION_LIST_MAX];
|
||||
} t_versionList;
|
||||
|
||||
// Prototypes.
|
||||
WiFi(KeyInterface *hdlKeyIf, KeyInterface *hdlMouseIf, bool defaultMode, NVS *nvs, LED *led, const char *fsPath, t_versionList *versionList);
|
||||
WiFi(void);
|
||||
~WiFi(void);
|
||||
void run(void);
|
||||
|
||||
// Primary encapsulated interface object handle.
|
||||
KeyInterface *keyIf;
|
||||
|
||||
// Secondary encapsulated interface object handle.
|
||||
KeyInterface *mouseIf;
|
||||
|
||||
// Non Volatile Storage handle.
|
||||
NVS *nvs;
|
||||
|
||||
// LED activity handle.
|
||||
LED *led;
|
||||
|
||||
// Method to return the class version number.
|
||||
float version(void)
|
||||
{
|
||||
return(WIFI_VERSION);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
// Type for key:value pairs.
|
||||
typedef struct {
|
||||
std::string name;
|
||||
std::string value;
|
||||
} t_kvPair;
|
||||
|
||||
// Structure to maintain wifi configuration data. This data is persisted through powercycles as needed.
|
||||
typedef struct {
|
||||
// Client access parameters, these, when valid, are used for binding to a known wifi access point.
|
||||
struct {
|
||||
bool valid;
|
||||
char ssid[MAX_WIFI_SSID_LEN+1];
|
||||
char pwd[MAX_WIFI_PWD_LEN+1];
|
||||
bool useDHCP;
|
||||
char ip[MAX_WIFI_IP_LEN+1];
|
||||
char netmask[MAX_WIFI_NETMASK_LEN+1];
|
||||
char gateway[MAX_WIFI_GATEWAY_LEN+1];
|
||||
} clientParams;
|
||||
|
||||
// Structure to maintain Access Point parameters. These are configurable to allow possibility of changing them.
|
||||
struct {
|
||||
char ssid[MAX_WIFI_SSID_LEN+1];
|
||||
char pwd[MAX_WIFI_PWD_LEN+1];
|
||||
char ip[MAX_WIFI_IP_LEN+1];
|
||||
char netmask[MAX_WIFI_NETMASK_LEN+1];
|
||||
char gateway[MAX_WIFI_GATEWAY_LEN+1];
|
||||
} apParams;
|
||||
|
||||
// General runtime control parameters.
|
||||
struct {
|
||||
// Configured mode of the Wifi: Access Point or Client.
|
||||
enum WIFIMODES wifiMode;
|
||||
} params;
|
||||
} t_wifiConfig;
|
||||
|
||||
// Configuration data.
|
||||
t_wifiConfig wifiConfig;
|
||||
|
||||
// Structure to manage the WiFi control variables, signifying the state of the Client or Access Point, runtime dependent, and
|
||||
// necessary dedicated run variables (as opposed to locals).
|
||||
typedef struct {
|
||||
// Client mode variables, active when in client mode.
|
||||
struct {
|
||||
int clientRetryCnt;
|
||||
bool connected;
|
||||
char ssid[MAX_WIFI_SSID_LEN+1];
|
||||
char pwd[MAX_WIFI_PWD_LEN+1];
|
||||
char ip[MAX_WIFI_IP_LEN+1];
|
||||
char netmask[MAX_WIFI_NETMASK_LEN+1];
|
||||
char gateway[MAX_WIFI_GATEWAY_LEN+1];
|
||||
} client;
|
||||
|
||||
// Access Point mode variabls, active when in AP mode.
|
||||
struct {
|
||||
char ssid[MAX_WIFI_SSID_LEN+1];
|
||||
char pwd[MAX_WIFI_PWD_LEN+1];
|
||||
char ip[MAX_WIFI_IP_LEN+1];
|
||||
char netmask[MAX_WIFI_NETMASK_LEN+1];
|
||||
char gateway[MAX_WIFI_GATEWAY_LEN+1];
|
||||
} ap;
|
||||
|
||||
// HTTP session variables, parsed out of incoming connections. The sessions are synchronous so only maintain
|
||||
// one copy.
|
||||
struct {
|
||||
std::string host;
|
||||
std::string queryStr;
|
||||
std::string fileName;
|
||||
std::string filePath;
|
||||
bool gzip;
|
||||
bool deflate;
|
||||
} session;
|
||||
|
||||
// Runtime variables, used for global control of the WiFi module.
|
||||
//
|
||||
struct {
|
||||
// Default path on the underlying filesystem. This is where the NVS/SD partition is mounted and all files under this directory are accessible.
|
||||
const char * fsPath;
|
||||
|
||||
// Version list of all objects used to build the SharpKey interface along with their version numbers.
|
||||
t_versionList *versionList;
|
||||
|
||||
// Run mode of the Wifi: Off, On or Access Point.
|
||||
enum WIFIMODES wifiMode;
|
||||
|
||||
// Handle to http server.
|
||||
httpd_handle_t server;
|
||||
|
||||
// Class name, used for NVS keys.
|
||||
std::string thisClass;
|
||||
|
||||
// Flag to raise a reboot button on the displayed page.
|
||||
bool rebootButton;
|
||||
|
||||
// Flag to indicate a hard reboot needed.
|
||||
bool reboot;
|
||||
|
||||
// Base path of file storag.
|
||||
char basePath[FILE_PATH_MAX];
|
||||
|
||||
// String to hold any response error message.
|
||||
std::string errorMsg;
|
||||
} run;
|
||||
} t_wifiControl;
|
||||
|
||||
// Control data.
|
||||
t_wifiControl wifiCtrl;
|
||||
|
||||
// Prototypes.
|
||||
bool setupWifiClient(void);
|
||||
bool setupWifiAP(void);
|
||||
bool stopWifi(void);
|
||||
bool startWebserver(void);
|
||||
void stopWebserver(void);
|
||||
float getVersionNumber(std::string name);
|
||||
esp_err_t expandAndSendFile(httpd_req_t *req, const char *basePath, std::string fileName);
|
||||
esp_err_t expandVarsAndSend(httpd_req_t *req, std::string str);
|
||||
esp_err_t sendKeyMapHeaders(httpd_req_t *req);
|
||||
esp_err_t sendKeyMapTypes(httpd_req_t *req);
|
||||
esp_err_t sendKeyMapCustomTypeFields(httpd_req_t *req);
|
||||
esp_err_t sendKeyMapData(httpd_req_t *req);
|
||||
esp_err_t sendKeyMapPopovers(httpd_req_t *req);
|
||||
esp_err_t sendMouseRadioChoice(httpd_req_t *req, const char *option);
|
||||
|
||||
|
||||
|
||||
esp_err_t wifiDataPOSTHandler(httpd_req_t *req, std::vector<t_kvPair> pairs, std::string& resp);
|
||||
esp_err_t mouseDataPOSTHandler(httpd_req_t *req, std::vector<t_kvPair> pairs, std::string& resp);
|
||||
static esp_err_t defaultDataPOSTHandler(httpd_req_t *req);
|
||||
static esp_err_t defaultDataGETHandler(httpd_req_t *req);
|
||||
IRAM_ATTR static esp_err_t otaFirmwareUpdatePOSTHandler(httpd_req_t *req);
|
||||
IRAM_ATTR static esp_err_t otaFilepackUpdatePOSTHandler(httpd_req_t *req);
|
||||
static esp_err_t keymapUploadPOSTHandler(httpd_req_t *req);
|
||||
static esp_err_t keymapTablePOSTHandler(httpd_req_t *req);
|
||||
|
||||
static esp_err_t defaultRebootHandler(httpd_req_t *req);
|
||||
esp_err_t getPOSTData(httpd_req_t *req, std::vector<t_kvPair> *pairs);
|
||||
|
||||
bool isFileExt(std::string fileName, std::string extension);
|
||||
esp_err_t setContentTypeFromFileType(httpd_req_t *req, std::string fileName);
|
||||
esp_err_t getPathFromURI(std::string& destPath, std::string& destFile, const char *basePath, const char *uri);
|
||||
esp_err_t getPathFromURI(std::string& destPath, const char *basePath, const char *uri);
|
||||
static esp_err_t defaultFileHandler(httpd_req_t *req);
|
||||
std::string esp32PartitionType(esp_partition_type_t type);
|
||||
std::string esp32PartitionSubType(esp_partition_subtype_t subtype);
|
||||
|
||||
|
||||
IRAM_ATTR static void pairBluetoothDevice(void *pvParameters);
|
||||
IRAM_ATTR static void wifiAPHandler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
|
||||
IRAM_ATTR static void wifiClientHandler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
|
||||
|
||||
// Method to split a string based on a delimiter and store in a vector.
|
||||
std::vector<std::string> split(std::string s, std::string delimiter)
|
||||
{
|
||||
// Locals.
|
||||
size_t pos_start = 0;
|
||||
size_t pos_end;
|
||||
size_t delim_len = delimiter.length();
|
||||
std::string token;
|
||||
std::vector<std::string> res;
|
||||
|
||||
// Loop through the string locating delimiters and split on each occurrence.
|
||||
while((pos_end = s.find (delimiter, pos_start)) != std::string::npos)
|
||||
{
|
||||
token = s.substr (pos_start, pos_end - pos_start);
|
||||
pos_start = pos_end + delim_len;
|
||||
// Push each occurrence onto Vector.
|
||||
res.push_back (token);
|
||||
}
|
||||
|
||||
// Store last item in vector.
|
||||
res.push_back (s.substr (pos_start));
|
||||
return res;
|
||||
}
|
||||
|
||||
// check if a given string is a numeric string or not
|
||||
bool isNumber(const std::string &str)
|
||||
{
|
||||
// `std::find_first_not_of` searches the string for the first character
|
||||
// that does not match any of the characters specified in its arguments
|
||||
return !str.empty() &&
|
||||
(str.find_first_not_of("[0123456789]") == std::string::npos);
|
||||
}
|
||||
|
||||
// Function to split string `str` using a given delimiter
|
||||
std::vector<std::string> split(const std::string &str, char delim)
|
||||
{
|
||||
auto i = 0;
|
||||
std::vector<std::string> list;
|
||||
|
||||
auto pos = str.find(delim);
|
||||
|
||||
while (pos != std::string::npos)
|
||||
{
|
||||
list.push_back(str.substr(i, pos - i));
|
||||
i = ++pos;
|
||||
pos = str.find(delim, pos);
|
||||
}
|
||||
|
||||
list.push_back(str.substr(i, str.length()));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
// Function to validate an IP address
|
||||
bool validateIP(std::string ip)
|
||||
{
|
||||
// split the string into tokens
|
||||
std::vector<std::string> list = split(ip, '.');
|
||||
|
||||
// if the token size is not equal to four
|
||||
if (list.size() != 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// validate each token
|
||||
for (std::string str: list)
|
||||
{
|
||||
// verify that the string is a number or not, and the numbers
|
||||
// are in the valid range
|
||||
if (!isNumber(str) || std::stoi(str) > 255 || std::stoi(str) < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Method to split an IP4 address into its components, checking each for validity.
|
||||
bool splitIP(std::string ip, int *a, int *b, int *c, int *d)
|
||||
{
|
||||
// Init.
|
||||
*a = *b = *c = *d = 0;
|
||||
|
||||
// split the string into tokens
|
||||
std::vector<std::string> list = split(ip, '.');
|
||||
|
||||
// if the token size is not equal to four
|
||||
if (list.size() != 4) {
|
||||
printf("Size:%d\n", list.size());
|
||||
return false;
|
||||
}
|
||||
// Loop through vector and check each number for validity before assigning.
|
||||
for(int idx=0; idx < 4; idx++)
|
||||
{
|
||||
// verify that the string is a number or not, and the numbers
|
||||
// are in the valid range
|
||||
if (!isNumber(list.at(idx)) || std::stoi(list.at(idx)) > 255 || std::stoi(list.at(idx)) < 0) {
|
||||
printf("Item:%d, %s\n", idx, list.at(idx).c_str());
|
||||
return false;
|
||||
}
|
||||
int frag = std::stoi(list.at(idx));
|
||||
if(idx == 0) *a = frag;
|
||||
if(idx == 1) *b = frag;
|
||||
if(idx == 2) *c = frag;
|
||||
if(idx == 3) *d = frag;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // WIFI_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/X1.h
|
||||
687
main/include/X1.h
Normal file
687
main/include/X1.h
Normal file
@@ -0,0 +1,687 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: X1.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header for the Sharp X1 to PS/2 interface logic.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
// v1.02 Jun 2022 - Updates to reflect changes realised in other modules due to addition of
|
||||
// bluetooth and suspend logic due to NVS issues using both cores.
|
||||
// v1.03 Jun 2022 - Further updates adding in keymaps for UK BT and Japan OADG109.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef X1_H
|
||||
#define X1_H
|
||||
|
||||
// Include the specification class.
|
||||
#include "KeyInterface.h"
|
||||
#include "NVS.h"
|
||||
#include "LED.h"
|
||||
#include "HID.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Encapsulate the Sharp X1 interface.
|
||||
class X1 : public KeyInterface {
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define X1IF_VERSION 1.03
|
||||
#define X1IF_KEYMAP_FILE "X1_KeyMap.BIN"
|
||||
#define MAX_X1_XMIT_KEY_BUF 16
|
||||
#define PS2TBL_X1_MAXROWS 349
|
||||
|
||||
// X1 Key control bit mask.
|
||||
#define X1_CTRL_TENKEY ((unsigned char) (1 << 7))
|
||||
#define X1_CTRL_PRESS ((unsigned char) (1 << 6))
|
||||
#define X1_CTRL_REPEAT ((unsigned char) (1 << 5))
|
||||
#define X1_CTRL_GRAPH ((unsigned char) (1 << 4))
|
||||
#define X1_CTRL_CAPS ((unsigned char) (1 << 3))
|
||||
#define X1_CTRL_KANA ((unsigned char) (1 << 2))
|
||||
#define X1_CTRL_SHIFT ((unsigned char) (1 << 1))
|
||||
#define X1_CTRL_CTRL ((unsigned char) (1 << 0))
|
||||
|
||||
// X1 Special Key definitions.
|
||||
#define X1KEY_UP 0x1E // ↑
|
||||
#define X1KEY_DOWN 0x1F // ↓
|
||||
#define X1KEY_LEFT 0x1D // ←
|
||||
#define X1KEY_RIGHT 0x1C // → →
|
||||
#define X1KEY_INS 0x12 // INS
|
||||
#define X1KEY_DEL 0x08 // DEL
|
||||
#define X1KEY_CLR 0x0C // CLR
|
||||
#define X1KEY_HOME 0x0B // HOME
|
||||
|
||||
// PS2 Flag definitions.
|
||||
#define PS2CTRL_NONE 0x00 // No keys active = 0
|
||||
#define PS2CTRL_SHIFT 0x01 // Shfit Key active = 1
|
||||
#define PS2CTRL_CTRL 0x02 // Ctrl Key active = 1
|
||||
#define PS2CTRL_CAPS 0x04 // CAPS active = 1
|
||||
#define PS2CTRL_KANA 0x08 // KANA active = 1
|
||||
#define PS2CTRL_GRAPH 0x10 // GRAPH active = 1
|
||||
#define PS2CTRL_GUI 0x20 // GUI Key active = 1
|
||||
#define PS2CTRL_FUNC 0x40 // Special Function Keys active = 1
|
||||
#define PS2CTRL_BREAK 0x80 // BREAK Key active = 1
|
||||
#define PS2CTRL_EXACT 0x80 // EXACT Match active = 1
|
||||
|
||||
// The initial mapping is made inside the PS2KeyAdvanced class from Scan Code Set 2 to ASCII
|
||||
// for a selected keyboard. Special functions are detected and combined inside this module
|
||||
// before mapping with the table below to extract the X1 key code and control data.
|
||||
// ie. PS/2 Scan Code -> ASCII + Flags -> X1 Key Code + Ctrl Data
|
||||
|
||||
// Keyboard mapping table column names.
|
||||
#define PS2TBL_PS2KEYCODE_NAME "PS/2 KeyCode"
|
||||
#define PS2TBL_PS2CTRL_NAME "PS/2 Control Key"
|
||||
#define PS2TBL_KEYBOARDMODEL_NAME "For Keyboard"
|
||||
#define PS2TBL_MACHINE_NAME "For Host Model"
|
||||
#define PS2TBL_X1MODE_NAME "X1 Mode"
|
||||
#define PS2TBL_X1KEYCODE_NAME "X1 KeyCode 1"
|
||||
#define PS2TBL_X1KEYCODE_BYTE2_NAME "X1 KeyCode 2"
|
||||
#define PS2TBL_X1_CTRL_NAME "X1 Control Key"
|
||||
|
||||
// Keyboard mapping table column types.
|
||||
#define PS2TBL_PS2KEYCODE_TYPE "hex"
|
||||
#define PS2TBL_PS2CTRL_TYPE "custom_cbp_ps2ctrl"
|
||||
#define PS2TBL_KEYBOARDMODEL_TYPE "custom_cbp_keybmodel"
|
||||
#define PS2TBL_MACHINE_TYPE "custom_cbp_machine"
|
||||
#define PS2TBL_X1MODE_TYPE "custom_cbp_x1mode"
|
||||
#define PS2TBL_X1KEYCODE_TYPE "hex"
|
||||
#define PS2TBL_X1KEYCODE_BYTE2_TYPE "hex"
|
||||
#define PS2TBL_X1CTRL_TYPE "custom_cbn_x1ctrl"
|
||||
|
||||
// Keyboard mapping table select list for PS2CTRL.
|
||||
#define PS2TBL_PS2CTRL_SEL_NONE "NONE"
|
||||
#define PS2TBL_PS2CTRL_SEL_SHIFT "SHIFT"
|
||||
#define PS2TBL_PS2CTRL_SEL_CTRL "CTRL"
|
||||
#define PS2TBL_PS2CTRL_SEL_CAPS "CAPS"
|
||||
#define PS2TBL_PS2CTRL_SEL_KANA "KANA"
|
||||
#define PS2TBL_PS2CTRL_SEL_GRAPH "GRAPH"
|
||||
#define PS2TBL_PS2CTRL_SEL_GUI "GUI"
|
||||
#define PS2TBL_PS2CTRL_SEL_FUNC "FUNC"
|
||||
#define PS2TBL_PS2CTRL_SEL_EXACT "EXACT"
|
||||
|
||||
// Keyboard mapping table select list for Model of keyboard.
|
||||
#define KEYMAP_SEL_STANDARD "ALL"
|
||||
#define KEYMAP_SEL_UK_WYSE_KB3926 "UK_WYSE_KB3926"
|
||||
#define KEYMAP_SEL_JAPAN_OADG109 "JAPAN_OADG109"
|
||||
#define KEYMAP_SEL_JAPAN_SANWA_SKBL1 "JAPAN_SANWA_SKBL1"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_4 "KEYBOARD_4"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_5 "KEYBOARD_5"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_6 "KEYBOARD_6"
|
||||
#define KEYMAP_SEL_UK_PERIBOARD_810 "UK_PERIBOARD_810"
|
||||
#define KEYMAP_SEL_UK_OMOTON_K8508 "UK_OMOTON_K8508"
|
||||
|
||||
// Keyboard mapping table select list for keyboard mode.
|
||||
#define X1_SEL_MODE_A "Mode_A"
|
||||
#define X1_SEL_MODE_B "Mode_B"
|
||||
|
||||
// Keyboard mapping table select list for target machine.
|
||||
#define X1_SEL_ALL "ALL"
|
||||
#define X1_SEL_ORIG "ORIGINAL"
|
||||
#define X1_SEL_TURBO "TURBO"
|
||||
#define X1_SEL_TURBOZ "TURBOZ"
|
||||
|
||||
// Keyboard mapping table select list for X1 Control codes.
|
||||
#define X1_CTRL_SEL_TENKEY "TENKEY"
|
||||
#define X1_CTRL_SEL_PRESS "PRESS"
|
||||
#define X1_CTRL_SEL_REPEAT "REPEAT"
|
||||
#define X1_CTRL_SEL_GRAPH "GRAPH"
|
||||
#define X1_CTRL_SEL_CAPS "CAPS"
|
||||
#define X1_CTRL_SEL_KANA "KANA"
|
||||
#define X1_CTRL_SEL_SHIFT "SHIFT"
|
||||
#define X1_CTRL_SEL_CTRL "CTRL"
|
||||
|
||||
// The Sharp X1 Series was released over a number of years and each iteration added changes/updates. In order to cater for differences, it is possible to assign a key mapping
|
||||
// to a specific machine type(s) or all of the series by adding the flags below into the mapping table.
|
||||
#define X1_ALL 0xFF
|
||||
#define X1_ORIG 0x01
|
||||
#define X1_TURBO 0x02
|
||||
#define X1_TURBOZ 0x04
|
||||
|
||||
// The X1 Turbo onwards had a mode switch on the keyboard, Mode A was normal use, Mode B was for games, speeding up the key press by shortening the timing and setting common game keys pressed in a 24bit bit map.
|
||||
// The mapping table caters for both, OR'ing data in Mode B so that multiple key presses are sent across as a bit map.
|
||||
#define X1_MODE_A 0x01
|
||||
#define X1_MODE_B 0x02
|
||||
|
||||
// Keyboard models. The base on which this interface was created was a Wyse KB3926 PS/2 Keyboard and this is deemed STANDARD. Other models need to insert difference maps
|
||||
// prior to the STANDARD entry along with the keyboard model so that it is processed first thus allowing differing keyboards with different maps.
|
||||
#define KEYMAP_STANDARD 0xFF
|
||||
#define KEYMAP_UK_WYSE_KB3926 0x01
|
||||
#define KEYMAP_JAPAN_OADG109 0x02
|
||||
#define KEYMAP_JAPAN_SANWA_SKBL1 0x04
|
||||
#define KEYMAP_NOT_ASSIGNED_4 0x08
|
||||
#define KEYMAP_NOT_ASSIGNED_5 0x10
|
||||
#define KEYMAP_NOT_ASSIGNED_6 0x20
|
||||
#define KEYMAP_UK_PERIBOARD_810 0x40
|
||||
#define KEYMAP_UK_OMOTON_K8508 0x80
|
||||
|
||||
public:
|
||||
// Prototypes.
|
||||
X1(void);
|
||||
X1(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID, const char *fsPath);
|
||||
X1(NVS *hdlNVS, HID *hdlHID, const char *fsPath);
|
||||
~X1(void);
|
||||
bool createKeyMapFile(std::fstream &outFile);
|
||||
bool storeDataToKeyMapFile(std::fstream &outFile, char *data, int size);
|
||||
bool storeDataToKeyMapFile(std::fstream & outFile, std::vector<uint32_t>& dataArray);
|
||||
bool closeAndCommitKeyMapFile(std::fstream &outFile, bool cleanupOnly);
|
||||
std::string getKeyMapFileName(void) { return(X1IF_KEYMAP_FILE); };
|
||||
void getKeyMapHeaders(std::vector<std::string>& headerList);
|
||||
void getKeyMapTypes(std::vector<std::string>& typeList);
|
||||
bool getKeyMapSelectList(std::vector<std::pair<std::string, int>>& selectList, std::string option);
|
||||
bool getKeyMapData(std::vector<uint32_t>& dataArray, int *row, bool start);
|
||||
|
||||
// Method to return the class version number.
|
||||
float version(void)
|
||||
{
|
||||
return(X1IF_VERSION);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
void pushKeyToQueue(bool keybMode, uint32_t key);
|
||||
IRAM_ATTR static void x1Interface( void * pvParameters );
|
||||
IRAM_ATTR static void hidInterface( void * pvParameters );
|
||||
void selectOption(uint8_t optionCode);
|
||||
uint32_t mapKey(uint16_t scanCode);
|
||||
bool loadKeyMap();
|
||||
bool saveKeyMap(void);
|
||||
void init(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID);
|
||||
void init(NVS *hdlNVS, HID *hdlHID);
|
||||
|
||||
// // Overload the base yield method to include suspension of the PS/2 Keyboard interface. This interface uses interrupts which are not mutex protected and clash with the
|
||||
// // WiFi API methods.
|
||||
// inline void yield(uint32_t delay)
|
||||
// {
|
||||
// // If suspended, go into a permanent loop until the suspend flag is reset.
|
||||
// if(this->suspend)
|
||||
// {
|
||||
// // Suspend the keyboard interface.
|
||||
// Keyboard->suspend(true);
|
||||
//
|
||||
// // Use the base method logic.
|
||||
// KeyInterface::yield(delay);
|
||||
//
|
||||
// // Release the keyboard interface.
|
||||
// Keyboard->suspend(false);
|
||||
// } else
|
||||
// // Otherwise just delay by the required amount for timing and to give other threads a time slice.
|
||||
// {
|
||||
// KeyInterface::yield(delay);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Structure to encapsulate a single key map from PS/2 to X1.
|
||||
typedef struct {
|
||||
uint8_t ps2KeyCode;
|
||||
uint8_t ps2Ctrl;
|
||||
uint8_t keyboardModel;
|
||||
uint8_t machine;
|
||||
uint8_t x1Mode;
|
||||
uint8_t x1Key;
|
||||
uint8_t x1Key2;
|
||||
uint8_t x1Ctrl;
|
||||
} t_keyMapEntry;
|
||||
|
||||
// Structure to encapsulate the entire static keyboard mapping table.
|
||||
typedef struct {
|
||||
t_keyMapEntry kme[PS2TBL_X1_MAXROWS];
|
||||
} t_keyMap;
|
||||
|
||||
// Structure to maintain the X1 interface configuration data. This data is persisted through powercycles as needed.
|
||||
typedef struct {
|
||||
struct {
|
||||
uint8_t activeKeyboardMap; // Model of keyboard a keymap entry is applicable to.
|
||||
uint8_t activeMachineModel; // Machine model a keymap entry is applicable to.
|
||||
} params;
|
||||
} t_x1Config;
|
||||
|
||||
// Configuration data.
|
||||
t_x1Config x1Config;
|
||||
|
||||
// Structure to manage the control signals signifying the state of the X1 keyboard.
|
||||
typedef struct {
|
||||
bool optionSelect; // Flag to indicate a user requested keyboard configuration option is being selected.
|
||||
bool modeB; // Mode B (Game mode) flag. If set, Mode B active, clear, Mode A active (normal keyboard).
|
||||
uint8_t keyCtrl; // Keyboard state flag control.
|
||||
|
||||
std::string fsPath; // Path on the underlying filesystem where storage is mounted and accessible.
|
||||
t_keyMapEntry *kme; // Pointer to an array in memory to contain PS2 to X1 mapping values.
|
||||
int kmeRows; // Number of rows in the kme table.
|
||||
std::string keyMapFileName; // Name of file where extension or replacement key map entries are stored.
|
||||
bool persistConfig; // Flag to request saving of the config into NVS storage.
|
||||
} t_x1Control;
|
||||
|
||||
// Transmit buffer queue item.
|
||||
typedef struct {
|
||||
uint32_t keyCode; // 32bit because normal mode A is 16bit, game mode B is 24bit
|
||||
bool modeB; // True if in game mode B.
|
||||
} t_xmitQueueMessage;
|
||||
|
||||
// Thread handles - one per function, ie. HID interface and host target interface.
|
||||
TaskHandle_t TaskHostIF = NULL;
|
||||
TaskHandle_t TaskHIDIF = NULL;
|
||||
|
||||
// Control structure to control interaction and mapping of keys for the host.
|
||||
t_x1Control x1Control;
|
||||
|
||||
// Spin lock mutex to hold a coresied to an uninterruptable method. This only works on dual core ESP32's.
|
||||
portMUX_TYPE x1Mutex;
|
||||
|
||||
// Lookup table to match PS/2 codes to X1 Key and Control Data.
|
||||
//
|
||||
// Given that the X1 had many variants, with potential differences between them, the mapping table allows for ALL or variant specific entries, the first entry matching is selected.
|
||||
//
|
||||
|
||||
//
|
||||
// This mapping is for the UK Wyse KB-3926 PS/2 keyboard
|
||||
//
|
||||
t_keyMap PS2toX1 = {
|
||||
{
|
||||
// HELP
|
||||
// COPY
|
||||
// ModeB Byte1 ModeB Byte2 ModeB Byte3
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine X1 Keyb Mode X1 Data X1 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_F1, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'v', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // SHIFT+F1
|
||||
{ PS2_KEY_F2, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'w', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // SHIFT+F2
|
||||
{ PS2_KEY_F3, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'x', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // SHIFT+F3
|
||||
{ PS2_KEY_F4, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'y', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // SHIFT+F4
|
||||
{ PS2_KEY_F5, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'z', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // SHIFT+F5
|
||||
{ PS2_KEY_F1, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'q', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F1
|
||||
{ PS2_KEY_F2, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'r', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F2
|
||||
{ PS2_KEY_F3, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 's', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F3
|
||||
{ PS2_KEY_F4, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 't', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F4
|
||||
{ PS2_KEY_F5, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'u', 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F5
|
||||
{ PS2_KEY_F6, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xEC, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F6
|
||||
{ PS2_KEY_F7, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xEB, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F7
|
||||
{ PS2_KEY_F8, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE2, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F8
|
||||
{ PS2_KEY_F9, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE1, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // F9
|
||||
{ PS2_KEY_F10, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // XFER
|
||||
{ PS2_KEY_F11, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xFE, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // HELP
|
||||
{ PS2_KEY_F12, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // COPY
|
||||
{ PS2_KEY_TAB, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x09, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // TAB
|
||||
// Control keys.
|
||||
{ PS2_KEY_APOS, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-@
|
||||
{ PS2_KEY_A, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x01, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-A
|
||||
{ PS2_KEY_B, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x02, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-B
|
||||
{ PS2_KEY_C, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x03, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-C
|
||||
{ PS2_KEY_D, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x04, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-D
|
||||
{ PS2_KEY_E, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x05, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-E
|
||||
{ PS2_KEY_F, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x06, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-F
|
||||
{ PS2_KEY_G, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x07, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-G
|
||||
{ PS2_KEY_H, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x08, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-H
|
||||
{ PS2_KEY_I, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x09, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-I
|
||||
{ PS2_KEY_J, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0A, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-J
|
||||
{ PS2_KEY_K, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0B, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-K
|
||||
{ PS2_KEY_L, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0C, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-L
|
||||
{ PS2_KEY_M, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0D, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-M
|
||||
{ PS2_KEY_N, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0E, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-N
|
||||
{ PS2_KEY_O, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0F, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-O
|
||||
{ PS2_KEY_P, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x10, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-P
|
||||
{ PS2_KEY_Q, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x11, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-Q
|
||||
{ PS2_KEY_R, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x12, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-R
|
||||
{ PS2_KEY_S, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x13, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-S
|
||||
{ PS2_KEY_T, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x14, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-T
|
||||
{ PS2_KEY_U, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x15, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-U
|
||||
{ PS2_KEY_V, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x16, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-V
|
||||
{ PS2_KEY_W, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x17, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-W
|
||||
{ PS2_KEY_X, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x18, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-X
|
||||
{ PS2_KEY_Y, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x19, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-Y
|
||||
{ PS2_KEY_Z, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x1A, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-Z
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x1B, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-[
|
||||
{ PS2_KEY_BACK, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x1C, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-BACKSLASH
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x1D, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-]
|
||||
{ PS2_KEY_6, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x1E, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-^
|
||||
{ PS2_KEY_MINUS, PS2CTRL_CTRL, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x1F, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CTRL-_
|
||||
// Numeric keys.
|
||||
{ PS2_KEY_0, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '0', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 0
|
||||
{ PS2_KEY_1, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '1', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 1
|
||||
{ PS2_KEY_2, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '2', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 2
|
||||
{ PS2_KEY_3, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '3', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 3
|
||||
{ PS2_KEY_4, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '4', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 4
|
||||
{ PS2_KEY_5, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '5', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 5
|
||||
{ PS2_KEY_6, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '6', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 6
|
||||
{ PS2_KEY_7, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '7', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 7
|
||||
{ PS2_KEY_8, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '8', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 8
|
||||
{ PS2_KEY_9, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '9', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // 9
|
||||
// Punctuation keys.
|
||||
{ PS2_KEY_0, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ')', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Close Right Bracket )
|
||||
{ PS2_KEY_1, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '!', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Exclamation
|
||||
{ PS2_KEY_2, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '"', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Double quote.
|
||||
{ PS2_KEY_3, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x23, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Pound Sign -> Hash
|
||||
{ PS2_KEY_4, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '$', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Dollar
|
||||
{ PS2_KEY_5, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '%', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Percent
|
||||
{ PS2_KEY_6, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '^', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Kappa
|
||||
{ PS2_KEY_7, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '&', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Ampersand
|
||||
{ PS2_KEY_8, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '*', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Star
|
||||
{ PS2_KEY_9, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '(', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Open Left Bracket (
|
||||
// ALPHA keys, lower and uppercase.
|
||||
// ModeB Byte1 ModeB Byte2 ModeB Byte3
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine X1 Keyb Mode X1 Data X1 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_A, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'a', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // a
|
||||
{ PS2_KEY_A, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'A', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // A
|
||||
{ PS2_KEY_B, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'b', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // b
|
||||
{ PS2_KEY_B, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'B', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // B
|
||||
{ PS2_KEY_C, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'c', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // c
|
||||
{ PS2_KEY_C, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'C', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // C
|
||||
{ PS2_KEY_D, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'd', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // d
|
||||
{ PS2_KEY_D, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'D', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // D
|
||||
{ PS2_KEY_E, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'e', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // e
|
||||
{ PS2_KEY_E, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'E', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // E
|
||||
{ PS2_KEY_F, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'f', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // f
|
||||
{ PS2_KEY_F, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'F', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // F
|
||||
{ PS2_KEY_G, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'g', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // g
|
||||
{ PS2_KEY_G, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'G', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // G
|
||||
{ PS2_KEY_H, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'h', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // h
|
||||
{ PS2_KEY_H, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'H', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // H
|
||||
{ PS2_KEY_I, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'i', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // i
|
||||
{ PS2_KEY_I, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'I', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // I
|
||||
{ PS2_KEY_J, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'j', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // j
|
||||
{ PS2_KEY_J, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'J', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // J
|
||||
{ PS2_KEY_K, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'k', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // k
|
||||
{ PS2_KEY_K, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'K', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // K
|
||||
{ PS2_KEY_L, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'l', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // l
|
||||
{ PS2_KEY_L, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'L', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // L
|
||||
{ PS2_KEY_M, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'm', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // m
|
||||
{ PS2_KEY_M, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'M', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // M
|
||||
{ PS2_KEY_N, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'n', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // n
|
||||
{ PS2_KEY_N, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'N', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // N
|
||||
{ PS2_KEY_O, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'o', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // o
|
||||
{ PS2_KEY_O, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'O', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // O
|
||||
{ PS2_KEY_P, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'p', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // p
|
||||
{ PS2_KEY_P, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'P', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // P
|
||||
{ PS2_KEY_Q, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'q', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // q
|
||||
{ PS2_KEY_Q, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'Q', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Q
|
||||
{ PS2_KEY_R, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'r', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // r
|
||||
{ PS2_KEY_R, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'R', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // R
|
||||
{ PS2_KEY_S, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 's', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // s
|
||||
{ PS2_KEY_S, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'S', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // S
|
||||
{ PS2_KEY_T, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 't', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // t
|
||||
{ PS2_KEY_T, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'T', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // T
|
||||
{ PS2_KEY_U, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'u', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // u
|
||||
{ PS2_KEY_U, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'U', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // U
|
||||
{ PS2_KEY_V, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'v', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // v
|
||||
{ PS2_KEY_V, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'V', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // V
|
||||
{ PS2_KEY_W, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'w', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // w
|
||||
{ PS2_KEY_W, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'W', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // W
|
||||
{ PS2_KEY_X, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'x', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // x
|
||||
{ PS2_KEY_X, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'X', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // X
|
||||
{ PS2_KEY_Y, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'y', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // y
|
||||
{ PS2_KEY_Y, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'Y', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Y
|
||||
{ PS2_KEY_Z, PS2CTRL_SHIFT | PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'z', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // z
|
||||
{ PS2_KEY_Z, PS2CTRL_CAPS, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 'Z', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Z
|
||||
// Mode B Mappings.
|
||||
{ PS2_KEY_Q, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b10000000, 0b00000000, 0b00000000, }, // MODE B - Q
|
||||
{ PS2_KEY_W, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b01000000, 0b00000000, 0b00000000, }, // MODE B - W
|
||||
{ PS2_KEY_E, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00100000, 0b00000000, 0b00000000, }, // MODE B - E
|
||||
{ PS2_KEY_A, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00010000, 0b00000000, 0b00000000, }, // MODE B - A
|
||||
{ PS2_KEY_D, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00001000, 0b00000000, 0b00000000, }, // MODE B - D
|
||||
{ PS2_KEY_Z, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000100, 0b00000000, 0b00000000, }, // MODE B - Z
|
||||
{ PS2_KEY_X, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000010, 0b00000000, 0b00000000, }, // MODE B - X
|
||||
{ PS2_KEY_C, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000001, 0b00000000, 0b00000000, }, // MODE B - C
|
||||
{ PS2_KEY_I, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b01000000, }, // MODE B - I - this is not 100%, the specs arent clear.
|
||||
{ PS2_KEY_1, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00100000, 0b00000000, }, // MODE B - 1
|
||||
{ PS2_KEY_2, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00001000, 0b00000000, }, // MODE B - 2
|
||||
{ PS2_KEY_3, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000001, 0b00000000, }, // MODE B - 3
|
||||
{ PS2_KEY_4, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b01000000, 0b00000000, }, // MODE B - 4
|
||||
{ PS2_KEY_6, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000010, 0b00000000, }, // MODE B - 6
|
||||
{ PS2_KEY_7, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b10000000, 0b00000000, }, // MODE B - 7
|
||||
{ PS2_KEY_8, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00010000, 0b00000000, }, // MODE B - 8
|
||||
{ PS2_KEY_9, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000100, 0b00000000, }, // MODE B - 9
|
||||
{ PS2_KEY_ESC, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b10000000, }, // MODE B - ESC
|
||||
{ PS2_KEY_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00100000, }, // MODE B - MINUS
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00010000, }, // MODE B - PLUS
|
||||
{ PS2_KEY_8, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00001000, }, // MODE B - TIMES
|
||||
{ PS2_KEY_TAB, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00000100, }, // MODE B - TAB
|
||||
{ PS2_KEY_SPACE, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00000010, }, // MODE B - SPACE
|
||||
{ PS2_KEY_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00000001, }, // MODE B - RET
|
||||
{ PS2_KEY_KP1, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00100000, 0b00000000, }, // MODE B - KeyPad 1
|
||||
{ PS2_KEY_KP2, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00001000, 0b00000000, }, // MODE B - KeyPad 2
|
||||
{ PS2_KEY_KP3, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000001, 0b00000000, }, // MODE B - KeyPad 3
|
||||
{ PS2_KEY_KP4, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b01000000, 0b00000000, }, // MODE B - KeyPad 4
|
||||
{ PS2_KEY_KP6, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000010, 0b00000000, }, // MODE B - KeyPad 6
|
||||
{ PS2_KEY_KP7, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b10000000, 0b00000000, }, // MODE B - KeyPad 7
|
||||
{ PS2_KEY_KP8, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00010000, 0b00000000, }, // MODE B - KeyPad 8
|
||||
{ PS2_KEY_KP9, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000100, 0b00000000, }, // MODE B - KeyPad 9
|
||||
{ PS2_KEY_KP_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00100000, }, // MODE B - KeyPad MINUS
|
||||
{ PS2_KEY_KP_PLUS, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00010000, }, // MODE B - KeyPad PLUS
|
||||
{ PS2_KEY_KP_TIMES, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_B, 0b00000000, 0b00000000, 0b00001000, }, // MODE B - KeyPad TIMES
|
||||
|
||||
// ModeB Byte1 ModeB Byte2 ModeB Byte3
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine X1 Keyb Mode X1 Data X1 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_SPACE, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ' ', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Space
|
||||
{ PS2_KEY_COMMA, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '<', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Less Than <
|
||||
{ PS2_KEY_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ',', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Comma ,
|
||||
{ PS2_KEY_SEMI, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ':', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Colon :
|
||||
{ PS2_KEY_SEMI, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ';', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Semi-Colon ;
|
||||
{ PS2_KEY_DOT, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '>', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Greater Than >
|
||||
{ PS2_KEY_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '.', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Full stop .
|
||||
{ PS2_KEY_DIV, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '?', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Question ?
|
||||
{ PS2_KEY_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '/', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Divide /
|
||||
{ PS2_KEY_MINUS, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '_', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Underscore
|
||||
{ PS2_KEY_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '-', 0x00, 0xFF & ~(X1_CTRL_PRESS), },
|
||||
{ PS2_KEY_APOS, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '@', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // At @
|
||||
{ PS2_KEY_APOS, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '\'', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Single quote '
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '{', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Open Left Brace {
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '[', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Open Left Square Bracket [
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '+', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Plus +
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '=', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Equal =
|
||||
{ PS2_KEY_CAPS, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ' ', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // LOCK
|
||||
{ PS2_KEY_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0D, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // ENTER/RETURN
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '}', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Close Right Brace }
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ']', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Close Right Square Bracket ]
|
||||
{ PS2_KEY_BACK, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '|', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, //
|
||||
{ PS2_KEY_BACK, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '\\', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Back slash maps to Yen
|
||||
{ PS2_KEY_BTICK, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '`', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Pipe
|
||||
{ PS2_KEY_BTICK, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '|', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Back tick `
|
||||
{ PS2_KEY_HASH, PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '~', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Tilde has no mapping.
|
||||
{ PS2_KEY_HASH, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '#', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Hash
|
||||
{ PS2_KEY_BS, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x08, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Backspace
|
||||
{ PS2_KEY_ESC, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x1B, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // ESCape
|
||||
{ PS2_KEY_SCROLL, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ' ', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Not assigned.
|
||||
{ PS2_KEY_INSERT, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, X1KEY_INS, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // INSERT
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, X1KEY_CLR, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // CLR
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, X1KEY_HOME, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // HOME
|
||||
{ PS2_KEY_DELETE, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, X1KEY_DEL, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // DELETE
|
||||
{ PS2_KEY_END, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x11, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // END
|
||||
{ PS2_KEY_PGUP, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0E, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // Roll Up.
|
||||
{ PS2_KEY_PGDN, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0F, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // Roll Down
|
||||
{ PS2_KEY_UP_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, X1KEY_UP, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Up Arrow
|
||||
{ PS2_KEY_L_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, X1KEY_LEFT, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Left Arrow
|
||||
{ PS2_KEY_DN_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, X1KEY_DOWN, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Down Arrow
|
||||
{ PS2_KEY_R_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, X1KEY_RIGHT, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Right Arrow
|
||||
{ PS2_KEY_NUM, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Not assigned.
|
||||
// GRPH (Alt Gr)
|
||||
// ModeB Byte1 ModeB Byte2 ModeB Byte3
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine X1 Keyb Mode X1 Data X1 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_0, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xFA, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+0
|
||||
{ PS2_KEY_1, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF1, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+1
|
||||
{ PS2_KEY_2, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF2, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+2
|
||||
{ PS2_KEY_3, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF3, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+3
|
||||
{ PS2_KEY_4, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF4, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+4
|
||||
{ PS2_KEY_5, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF5, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+5
|
||||
{ PS2_KEY_6, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF6, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+6
|
||||
{ PS2_KEY_7, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF7, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+7
|
||||
{ PS2_KEY_8, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF8, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+8
|
||||
{ PS2_KEY_9, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF9, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+9
|
||||
{ PS2_KEY_A, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x7F, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+A
|
||||
{ PS2_KEY_B, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x84, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+B
|
||||
{ PS2_KEY_C, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x82, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+C
|
||||
{ PS2_KEY_D, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xEA, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+D
|
||||
{ PS2_KEY_E, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE2, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+E
|
||||
{ PS2_KEY_F, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xEB, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+F
|
||||
{ PS2_KEY_G, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xEC, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+G
|
||||
{ PS2_KEY_H, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xED, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+H
|
||||
{ PS2_KEY_I, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE7, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+I
|
||||
{ PS2_KEY_J, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xEE, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+J
|
||||
{ PS2_KEY_K, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xEF, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+K
|
||||
{ PS2_KEY_L, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x8E, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+L
|
||||
{ PS2_KEY_M, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x86, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+M
|
||||
{ PS2_KEY_N, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x85, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+N
|
||||
{ PS2_KEY_O, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xF0, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+O
|
||||
{ PS2_KEY_P, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x8D, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+P
|
||||
{ PS2_KEY_Q, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE0, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+Q
|
||||
{ PS2_KEY_R, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE3, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+R
|
||||
{ PS2_KEY_S, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE9, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+S
|
||||
{ PS2_KEY_T, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE4, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+T
|
||||
{ PS2_KEY_U, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE6, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+U
|
||||
{ PS2_KEY_V, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x83, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+V
|
||||
{ PS2_KEY_W, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE1, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+W
|
||||
{ PS2_KEY_X, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x81, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+X
|
||||
{ PS2_KEY_Y, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE5, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+Y
|
||||
{ PS2_KEY_Z, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x80, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+Z
|
||||
{ PS2_KEY_COMMA, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x87, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+,
|
||||
{ PS2_KEY_SEMI, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x89, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+;
|
||||
{ PS2_KEY_DOT, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x88, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+.
|
||||
{ PS2_KEY_DIV, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xFE, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+/
|
||||
{ PS2_KEY_MINUS, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x8C, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+-
|
||||
{ PS2_KEY_APOS, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x8A, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+'
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xFC, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+[
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xE8, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+]
|
||||
{ PS2_KEY_BACK, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x90, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRPH+Backslash
|
||||
{ PS2_KEY_KP0, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x8F, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 0
|
||||
{ PS2_KEY_KP1, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x99, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 1
|
||||
{ PS2_KEY_KP2, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x92, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 2
|
||||
{ PS2_KEY_KP3, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x98, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 3
|
||||
{ PS2_KEY_KP4, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x95, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 4
|
||||
{ PS2_KEY_KP5, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x96, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 5
|
||||
{ PS2_KEY_KP6, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x94, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 6
|
||||
{ PS2_KEY_KP7, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x9A, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 7
|
||||
{ PS2_KEY_KP8, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x93, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 8
|
||||
{ PS2_KEY_KP9, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x97, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad 9
|
||||
{ PS2_KEY_KP_DOT, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x91, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad Full stop .
|
||||
{ PS2_KEY_KP_PLUS, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x9D, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad Plus +
|
||||
{ PS2_KEY_KP_MINUS, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x9C, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad Minus -
|
||||
{ PS2_KEY_KP_TIMES, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x9B, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad Times *
|
||||
{ PS2_KEY_KP_DIV, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x9E, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad Divide /
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x90, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // GRPH+Keypad Enter /
|
||||
// KANA (Alt)
|
||||
// ModeB Byte1 ModeB Byte2 ModeB Byte3
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine X1 Keyb Mode X1 Data X1 Ctrl (Flags to Set).
|
||||
{ PS2_KEY_0, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA6, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+0
|
||||
{ PS2_KEY_0, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xDC, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+0
|
||||
{ PS2_KEY_1, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC7, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+1
|
||||
{ PS2_KEY_2, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xCC, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+2
|
||||
{ PS2_KEY_3, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA7, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+3
|
||||
{ PS2_KEY_3, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xB1, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+3
|
||||
{ PS2_KEY_4, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA9, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+4
|
||||
{ PS2_KEY_4, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xB3, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+4
|
||||
{ PS2_KEY_5, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xAA, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+5
|
||||
{ PS2_KEY_5, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xB4, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+5
|
||||
{ PS2_KEY_6, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xAB, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+6
|
||||
{ PS2_KEY_6, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xB5, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+6
|
||||
{ PS2_KEY_7, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xAC, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+7
|
||||
{ PS2_KEY_7, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD4, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+7
|
||||
{ PS2_KEY_8, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xAD, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+8
|
||||
{ PS2_KEY_8, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD5, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+8
|
||||
{ PS2_KEY_9, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xAE, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+9
|
||||
{ PS2_KEY_9, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD6, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+9
|
||||
{ PS2_KEY_A, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC1, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+A
|
||||
{ PS2_KEY_B, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xBA, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+B
|
||||
{ PS2_KEY_C, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xBF, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+C
|
||||
{ PS2_KEY_D, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xBC, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+D
|
||||
{ PS2_KEY_E, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA8, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+E
|
||||
{ PS2_KEY_E, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xB2, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+E
|
||||
{ PS2_KEY_F, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xCA, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+F
|
||||
{ PS2_KEY_G, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xB7, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+G
|
||||
{ PS2_KEY_H, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xB8, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+H
|
||||
{ PS2_KEY_I, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC6, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+I
|
||||
{ PS2_KEY_J, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xCF, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+J
|
||||
{ PS2_KEY_K, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC9, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+K
|
||||
{ PS2_KEY_L, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD8, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+L
|
||||
{ PS2_KEY_M, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD3, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+M
|
||||
{ PS2_KEY_N, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD0, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+N
|
||||
{ PS2_KEY_O, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD7, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+O
|
||||
{ PS2_KEY_P, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xBE, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+P
|
||||
{ PS2_KEY_Q, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC0, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+Q
|
||||
{ PS2_KEY_R, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xBD, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+R
|
||||
{ PS2_KEY_S, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC4, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+S
|
||||
{ PS2_KEY_T, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xB6, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+T
|
||||
{ PS2_KEY_U, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC5, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+U
|
||||
{ PS2_KEY_V, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xCB, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+V
|
||||
{ PS2_KEY_W, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC3, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+W
|
||||
{ PS2_KEY_X, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xBB, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+X
|
||||
{ PS2_KEY_Y, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xDD, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+Y
|
||||
{ PS2_KEY_Z, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xAF, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+Z
|
||||
{ PS2_KEY_Z, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC2, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+Z
|
||||
{ PS2_KEY_COMMA, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA4, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+,
|
||||
{ PS2_KEY_COMMA, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xC8, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+,
|
||||
{ PS2_KEY_SEMI, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xDA, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+;
|
||||
{ PS2_KEY_DOT, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA1, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+.
|
||||
{ PS2_KEY_DOT, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD9, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+.
|
||||
{ PS2_KEY_DIV, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA5, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+/
|
||||
{ PS2_KEY_DIV, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD2, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+/
|
||||
{ PS2_KEY_MINUS, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xCE, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+-
|
||||
{ PS2_KEY_APOS, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xDE, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+'
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA2, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+[
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xDF, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+[
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xA3, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+]
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xD1, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+]
|
||||
{ PS2_KEY_BACK, PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0xDB, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+Backslash
|
||||
{ PS2_KEY_BS, PS2CTRL_KANA | PS2CTRL_SHIFT, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x12, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA+SHIFT+Backspace
|
||||
// Keypad.
|
||||
{ PS2_KEY_KP0, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '0', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 0
|
||||
{ PS2_KEY_KP1, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '1', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 1
|
||||
{ PS2_KEY_KP2, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '2', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 2
|
||||
{ PS2_KEY_KP3, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '3', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 3
|
||||
{ PS2_KEY_KP4, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '4', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 4
|
||||
{ PS2_KEY_KP5, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '5', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 5
|
||||
{ PS2_KEY_KP6, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '6', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 6
|
||||
{ PS2_KEY_KP7, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '7', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 7
|
||||
{ PS2_KEY_KP8, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '8', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 8
|
||||
{ PS2_KEY_KP9, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '9', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad 9
|
||||
{ PS2_KEY_KP_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, ',', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad Comma ,
|
||||
{ PS2_KEY_KP_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '.', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad Full stop .
|
||||
{ PS2_KEY_KP_PLUS, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '+', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad Plus +
|
||||
{ PS2_KEY_KP_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '-', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad Minus -
|
||||
{ PS2_KEY_KP_TIMES, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '*', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad Times *
|
||||
{ PS2_KEY_KP_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '/', 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad Divide /
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x0D, 0x00, 0xFF & ~(X1_CTRL_TENKEY | X1_CTRL_PRESS), }, // Keypad Enter /
|
||||
{ PS2_KEY_KP_EQUAL, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, '=', 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Keypad Equal =
|
||||
// ModeB Byte1 ModeB Byte2 ModeB Byte3
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine X1 Keyb Mode X1 Data X1 Ctrl (Flags to Set).
|
||||
// Special keys.
|
||||
{ PS2_KEY_PRTSCR, PS2CTRL_FUNC, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // ARGO KEY
|
||||
{ PS2_KEY_PAUSE, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x03, 0x00, 0xFF & ~(X1_CTRL_PRESS | X1_CTRL_TENKEY), }, // BREAK KEY
|
||||
{ PS2_KEY_L_GUI, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // GRAPH KEY
|
||||
//{ PS2_KEY_L_ALT, PS2CTRL_FUNC | PS2CTRL_KANA, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KJ1 Sentence
|
||||
//{ PS2_KEY_R_ALT, PS2CTRL_FUNC | PS2CTRL_GRAPH, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KJ2 Transform
|
||||
{ PS2_KEY_R_GUI, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // KANA KEY
|
||||
{ PS2_KEY_MENU, PS2CTRL_FUNC | PS2CTRL_GUI, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Not assigned.
|
||||
// Modifiers are last, only being selected if an earlier match isnt made.
|
||||
{ PS2_KEY_L_SHIFT, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), },
|
||||
{ PS2_KEY_R_SHIFT, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), },
|
||||
{ PS2_KEY_L_CTRL, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), },
|
||||
{ PS2_KEY_R_CTRL, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), }, // Map to Control
|
||||
{ 0, PS2CTRL_NONE, KEYMAP_STANDARD, X1_ALL, X1_MODE_A, 0x00, 0x00, 0xFF & ~(X1_CTRL_PRESS), },
|
||||
}};
|
||||
};
|
||||
|
||||
#endif // X1_H
|
||||
@@ -1 +0,0 @@
|
||||
../../../sharpkey/main/include/X68K.h
|
||||
533
main/include/X68K.h
Normal file
533
main/include/X68K.h
Normal file
@@ -0,0 +1,533 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: X68K.h
|
||||
// Created: Mar 2022
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: Header for the Sharp X68000 to PS/2 interface logic class.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2022 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: Mar 2022 - Initial write.
|
||||
// v1.01 May 2022 - Initial release version.
|
||||
// v1.02 Jun 2022 - Updates to reflect changes realised in other modules due to addition of
|
||||
// bluetooth and suspend logic due to NVS issues using both cores.
|
||||
// v1.03 Jun 2022 - Further updates adding in keymaps for UK BT and Japan OADG109.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef X68K_H
|
||||
#define X68K_H
|
||||
|
||||
// Include the specification class.
|
||||
#include "KeyInterface.h"
|
||||
#include "NVS.h"
|
||||
#include "LED.h"
|
||||
#include "HID.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
// NB: Macros definitions put inside class for clarity, they are still global scope.
|
||||
|
||||
// Encapsulate the Sharp X68K interface.
|
||||
class X68K : public KeyInterface {
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
#define X68KIF_VERSION 1.03
|
||||
#define X68KIF_KEYMAP_FILE "X68K_KeyMap.BIN"
|
||||
#define MAX_X68K_XMIT_KEY_BUF 16
|
||||
#define MAX_X68K_RCV_KEY_BUF 16
|
||||
|
||||
// PS2 Flag definitions.
|
||||
#define PS2CTRL_NONE 0x00 // No keys active = 0
|
||||
#define PS2CTRL_SHIFT 0x01 // Shfit Key active = 1
|
||||
#define PS2CTRL_CTRL 0x02 // Ctrl Key active = 1
|
||||
#define PS2CTRL_CAPS 0x04 // CAPS active = 1
|
||||
#define PS2CTRL_R_CTRL 0x08 // ALT flag used as Right CTRL flag, active = 1
|
||||
#define PS2CTRL_ALTGR 0x10 // ALTGR active = 1
|
||||
#define PS2CTRL_GUI 0x20 // GUI Key active = 1
|
||||
#define PS2CTRL_FUNC 0x40 // Special Function Keys active = 1
|
||||
#define PS2CTRL_BREAK 0x80 // BREAK Key active = 1
|
||||
#define PS2CTRL_EXACT 0x80 // EXACT Match active = 1
|
||||
|
||||
// The initial mapping is made inside the PS2KeyAdvanced class from Scan Code Set 2 to ASCII
|
||||
// for a selected keyboard. Special functions are detected and combined inside this module
|
||||
// before mapping with the table below to extract the X68K key code and control data.
|
||||
// ie. PS/2 Scan Code -> ASCII + Flags -> X68K Key Code + Ctrl Data
|
||||
#define PS2TBL_X68K_MAXCOLS 6
|
||||
#define PS2TBL_X68K_MAXROWS 131
|
||||
|
||||
// Keyboard mapping table column names.
|
||||
#define PS2TBL_PS2KEYCODE_NAME "PS/2 KeyCode"
|
||||
#define PS2TBL_PS2CTRL_NAME "PS/2 Control Key"
|
||||
#define PS2TBL_KEYBOARDMODEL_NAME "For Keyboard"
|
||||
#define PS2TBL_MACHINE_NAME "For Host Model"
|
||||
#define PS2TBL_X68KKEYCODE_NAME "X68K KeyCode"
|
||||
#define PS2TBL_X68KCTRL_NAME "X68K Control Key"
|
||||
|
||||
// Keyboard mapping table column types.
|
||||
#define PS2TBL_PS2KEYCODE_TYPE "hex"
|
||||
#define PS2TBL_PS2CTRL_TYPE "custom_cbp_ps2ctrl"
|
||||
#define PS2TBL_KEYBOARDMODEL_TYPE "custom_cbp_keybmodel"
|
||||
#define PS2TBL_MACHINE_TYPE "custom_cbp_machine"
|
||||
#define PS2TBL_X68KKEYCODE_TYPE "hex"
|
||||
#define PS2TBL_X68KCTRL_TYPE "custom_cbp_x68kctrl"
|
||||
|
||||
// Keyboard mapping table select list for PS2CTRL.
|
||||
#define PS2TBL_PS2CTRL_SEL_NONE "NONE"
|
||||
#define PS2TBL_PS2CTRL_SEL_SHIFT "SHIFT"
|
||||
#define PS2TBL_PS2CTRL_SEL_CTRL "CTRL"
|
||||
#define PS2TBL_PS2CTRL_SEL_CAPS "CAPS"
|
||||
#define PS2TBL_PS2CTRL_SEL_R_CTRL "RCTRL"
|
||||
#define PS2TBL_PS2CTRL_SEL_ALTGR "ALTGR"
|
||||
#define PS2TBL_PS2CTRL_SEL_GUI "GUI"
|
||||
#define PS2TBL_PS2CTRL_SEL_FUNC "FUNC"
|
||||
#define PS2TBL_PS2CTRL_SEL_EXACT "EXACT"
|
||||
|
||||
// Keyboard mapping table select list for target machine.
|
||||
#define X68K_SEL_ALL "ALL"
|
||||
#define X68K_SEL_ORIG "ORIGINAL"
|
||||
#define X68K_SEL_ACE "ACE"
|
||||
#define X68K_SEL_EXPERT "EXPERT"
|
||||
#define X68K_SEL_PRO "PRO"
|
||||
#define X68K_SEL_SUPER "SUPER"
|
||||
#define X68K_SEL_XVI "XVI"
|
||||
#define X68K_SEL_COMPACT "COMPACT"
|
||||
#define X68K_SEL_X68030 "68030"
|
||||
|
||||
// Keyboard mapping table select list for Model of keyboard.
|
||||
#define KEYMAP_SEL_STANDARD "ALL"
|
||||
#define KEYMAP_SEL_UK_WYSE_KB3926 "UK_WYSE_KB3926"
|
||||
#define KEYMAP_SEL_JAPAN_OADG109 "JAPAN_OADG109"
|
||||
#define KEYMAP_SEL_JAPAN_SANWA_SKBL1 "JAPAN_SANWA_SKBL1"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_4 "KEYBOARD_4"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_5 "KEYBOARD_5"
|
||||
#define KEYMAP_SEL_NOT_ASSIGNED_6 "KEYBOARD_6"
|
||||
#define KEYMAP_SEL_UK_PERIBOARD_810 "UK_PERIBOARD_810"
|
||||
#define KEYMAP_SEL_UK_OMOTON_K8508 "UK_OMOTON_K8508"
|
||||
|
||||
// Keyboard mapping table select list for X68K Control codes.
|
||||
#define X68K_CTRL_SEL_NONE "NONE"
|
||||
#define X68K_CTRL_SEL_SHIFT "SHIFT"
|
||||
#define X68K_CTRL_SEL_RELEASESHIFT "RELEASESHIFT"
|
||||
#define X68K_CTRL_SEL_R_CTRL "RCTRL"
|
||||
|
||||
// X68K Key control bit mask.
|
||||
#define X68K_CTRL_SHIFT ((unsigned char) (1 << 7))
|
||||
#define X68K_CTRL_RELEASESHIFT ((unsigned char) (1 << 6))
|
||||
#define X68K_CTRL_R_CTRL ((unsigned char) (1 << 0))
|
||||
#define X68K_CTRL_NONE 0x00
|
||||
|
||||
// The Sharp X68000 Series was released over a number of years with several iterations containing changes/updates. Generally Sharp kept the X68000 compatible through the range but just in case
|
||||
// differences are found, it is possible to assign a key mapping to a specific machine type(s) or all of the series by adding the flags below into the mapping table.
|
||||
#define X68K_ALL 0xFF
|
||||
#define X68K_ORIG 0x01
|
||||
#define X68K_ACE 0x02
|
||||
#define X68K_EXPERT 0x04
|
||||
#define X68K_PRO 0x08
|
||||
#define X68K_SUPER 0x10
|
||||
#define X68K_XVI 0x20
|
||||
#define X68K_COMPACT 0x40
|
||||
#define X68K_X68030 0x80
|
||||
|
||||
// Keyboard models. The base on which this interface was created was a Wyse KB3926 PS/2 Keyboard and this is deemed STANDARD. Other models need to insert difference maps
|
||||
// prior to the STANDARD entry along with the keyboard model so that it is processed first thus allowing differing keyboards with different maps.
|
||||
#define KEYMAP_STANDARD 0xFF
|
||||
#define KEYMAP_UK_WYSE_KB3926 0x01
|
||||
#define KEYMAP_JAPAN_OADG109 0x02
|
||||
#define KEYMAP_JAPAN_SANWA_SKBL1 0x04
|
||||
#define KEYMAP_NOT_ASSIGNED_4 0x08
|
||||
#define KEYMAP_NOT_ASSIGNED_5 0x10
|
||||
#define KEYMAP_NOT_ASSIGNED_6 0x20
|
||||
#define KEYMAP_UK_PERIBOARD_810 0x40
|
||||
#define KEYMAP_UK_OMOTON_K8508 0x80
|
||||
|
||||
// X68000 Scan codes - PS2 codes along with function keys (SHIFT, CTRL etc) are mapped to the X68000 scan codes below.
|
||||
#define X68K_KEY_NULL 0x00
|
||||
#define X68K_KEY_ESC 0x01
|
||||
#define X68K_KEY_0 0x0B
|
||||
#define X68K_KEY_1 0x02
|
||||
#define X68K_KEY_2 0x03
|
||||
#define X68K_KEY_3 0x04
|
||||
#define X68K_KEY_4 0x05
|
||||
#define X68K_KEY_5 0x06
|
||||
#define X68K_KEY_6 0x07
|
||||
#define X68K_KEY_7 0x08
|
||||
#define X68K_KEY_8 0x09
|
||||
#define X68K_KEY_9 0x0A
|
||||
#define X68K_KEY_A 0x1E
|
||||
#define X68K_KEY_B 0x2E
|
||||
#define X68K_KEY_C 0x2C
|
||||
#define X68K_KEY_D 0x20
|
||||
#define X68K_KEY_E 0x13
|
||||
#define X68K_KEY_F 0x21
|
||||
#define X68K_KEY_G 0x22
|
||||
#define X68K_KEY_H 0x23
|
||||
#define X68K_KEY_I 0x18
|
||||
#define X68K_KEY_J 0x24
|
||||
#define X68K_KEY_K 0x25
|
||||
#define X68K_KEY_L 0x26
|
||||
#define X68K_KEY_M 0x30
|
||||
#define X68K_KEY_N 0x2F
|
||||
#define X68K_KEY_O 0x19
|
||||
#define X68K_KEY_P 0x1A
|
||||
#define X68K_KEY_Q 0x11
|
||||
#define X68K_KEY_R 0x14
|
||||
#define X68K_KEY_S 0x1F
|
||||
#define X68K_KEY_T 0x15
|
||||
#define X68K_KEY_U 0x17
|
||||
#define X68K_KEY_V 0x2D
|
||||
#define X68K_KEY_W 0x12
|
||||
#define X68K_KEY_X 0x2B
|
||||
#define X68K_KEY_Y 0x16
|
||||
#define X68K_KEY_Z 0x2A
|
||||
#define X68K_KEY_AT 0x1B
|
||||
#define X68K_KEY_MINUS 0x0C
|
||||
#define X68K_KEY_CIRCUMFLEX 0x0D
|
||||
#define X68K_KEY_YEN 0x0E
|
||||
#define X68K_KEY_BS 0x0F
|
||||
#define X68K_KEY_TAB 0x10
|
||||
#define X68K_KEY_OPEN_SQ 0x1C
|
||||
#define X68K_KEY_CLOSE_SQ 0x29
|
||||
#define X68K_KEY_RETURN 0x1D
|
||||
#define X68K_KEY_SEMI 0x27
|
||||
#define X68K_KEY_COLON 0x28
|
||||
#define X68K_KEY_COMMA 0x31
|
||||
#define X68K_KEY_DOT 0x32
|
||||
#define X68K_KEY_DIV 0x33
|
||||
#define X68K_KEY_UNDERLINE 0x34
|
||||
#define X68K_KEY_SPACE 0x35
|
||||
#define X68K_KEY_HOME 0x36
|
||||
#define X68K_KEY_ROLLUP 0x38
|
||||
#define X68K_KEY_ROLLDN 0x39
|
||||
#define X68K_KEY_UNDO 0x3A
|
||||
#define X68K_KEY_L_ARROW 0x3B
|
||||
#define X68K_KEY_UP_ARROW 0x3C
|
||||
#define X68K_KEY_R_ARROW 0x3D
|
||||
#define X68K_KEY_DN_ARROW 0x3E
|
||||
#define X68K_KEY_CLR 0x3F
|
||||
#define X68K_KEY_KP0 0x4F
|
||||
#define X68K_KEY_KP1 0x4B
|
||||
#define X68K_KEY_KP2 0x4C
|
||||
#define X68K_KEY_KP3 0x4D
|
||||
#define X68K_KEY_KP4 0x47
|
||||
#define X68K_KEY_KP5 0x48
|
||||
#define X68K_KEY_KP6 0x49
|
||||
#define X68K_KEY_KP7 0x43
|
||||
#define X68K_KEY_KP8 0x44
|
||||
#define X68K_KEY_KP9 0x45
|
||||
#define X68K_KEY_KP_DIV 0x40
|
||||
#define X68K_KEY_KP_TIMES 0x41
|
||||
#define X68K_KEY_KP_MINUS 0x42
|
||||
#define X68K_KEY_KP_PLUS 0x46
|
||||
#define X68K_KEY_KP_EQUAL 0x4A
|
||||
#define X68K_KEY_KP_ENTER 0x4E
|
||||
#define X68K_KEY_KP_COMMA 0x50
|
||||
#define X68K_KEY_KP_DOT 0x51
|
||||
#define X68K_KEY_SYMBOL 0x52
|
||||
#define X68K_KEY_HELP 0x54
|
||||
#define X68K_KEY_CAPS 0x5D
|
||||
#define X68K_KEY_INS 0x5E
|
||||
#define X68K_KEY_DEL 0x37
|
||||
#define X68K_KEY_BREAK 0x61
|
||||
#define X68K_KEY_COPY 0x62
|
||||
#define X68K_KEY_SHIFT 0x70
|
||||
#define X68K_KEY_CTRL 0x71
|
||||
#define X68K_KEY_XF1 0x55
|
||||
#define X68K_KEY_XF2 0x56
|
||||
#define X68K_KEY_XF3 0x57
|
||||
#define X68K_KEY_XF4 0x58
|
||||
#define X68K_KEY_XF5 0x59
|
||||
#define X68K_KEY_REGISTRATION 0x53
|
||||
#define X68K_KEY_KATAKANA 0x5A
|
||||
#define X68K_KEY_ROMAJI 0x5B
|
||||
#define X68K_KEY_TRANSPOSE 0x5C
|
||||
#define X68K_KEY_HIRAGANA 0x5F
|
||||
#define X68K_KEY_FULLWIDTH 0x60
|
||||
#define X68K_KEY_F1 0x63
|
||||
#define X68K_KEY_F2 0x64
|
||||
#define X68K_KEY_F3 0x65
|
||||
#define X68K_KEY_F4 0x66
|
||||
#define X68K_KEY_F5 0x67
|
||||
#define X68K_KEY_F6 0x68
|
||||
#define X68K_KEY_F7 0x69
|
||||
#define X68K_KEY_F8 0x6A
|
||||
#define X68K_KEY_F9 0x6B
|
||||
#define X68K_KEY_F10 0x6C
|
||||
#define X68K_KEY_OPT_1 0x72
|
||||
#define X68K_KEY_OPT_2 0x73
|
||||
|
||||
public:
|
||||
// Prototypes.
|
||||
X68K(void);
|
||||
X68K(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID, const char *fsPath);
|
||||
X68K(NVS *hdlNVS, HID *hdlHID, const char *fsPath);
|
||||
~X68K(void);
|
||||
bool createKeyMapFile(std::fstream &outFile);
|
||||
bool storeDataToKeyMapFile(std::fstream &outFile, char *data, int size);
|
||||
bool storeDataToKeyMapFile(std::fstream & outFile, std::vector<uint32_t>& dataArray);
|
||||
bool closeAndCommitKeyMapFile(std::fstream &outFile, bool cleanupOnly);
|
||||
std::string getKeyMapFileName(void) { return(X68KIF_KEYMAP_FILE); };
|
||||
void getKeyMapHeaders(std::vector<std::string>& headerList);
|
||||
void getKeyMapTypes(std::vector<std::string>& typeList);
|
||||
bool getKeyMapSelectList(std::vector<std::pair<std::string, int>>& selectList, std::string option);
|
||||
bool getKeyMapData(std::vector<uint32_t>& dataArray, int *row, bool start);
|
||||
|
||||
// Method to return the class version number.
|
||||
float version(void)
|
||||
{
|
||||
return(X68KIF_VERSION);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Prototypes.
|
||||
IRAM_ATTR void pushKeyToQueue(uint32_t key);
|
||||
IRAM_ATTR void pushHostCmdToQueue(uint8_t cmd);
|
||||
IRAM_ATTR static void x68kInterface( void * pvParameters );
|
||||
IRAM_ATTR static void hidInterface( void * pvParameters );
|
||||
void selectOption(uint8_t optionCode);
|
||||
uint32_t mapKey(uint16_t scanCode);
|
||||
bool loadKeyMap();
|
||||
bool saveKeyMap(void);
|
||||
void init(uint32_t ifMode, NVS *hdlNVS, LED *hdlLED, HID *hdlHID);
|
||||
void init(NVS *hdlNVS, HID *hdlHID);
|
||||
|
||||
// Structure to encapsulate a single key map from PS/2 to X68K.
|
||||
typedef struct {
|
||||
uint8_t ps2KeyCode;
|
||||
uint8_t ps2Ctrl;
|
||||
uint8_t keyboardModel;
|
||||
uint8_t machine;
|
||||
uint8_t x68kKey;
|
||||
uint8_t x68kCtrl;
|
||||
} t_keyMapEntry;
|
||||
|
||||
// Structure to encapsulate the entire static keyboard mapping table.
|
||||
typedef struct {
|
||||
t_keyMapEntry kme[PS2TBL_X68K_MAXROWS];
|
||||
} t_keyMap;
|
||||
|
||||
// Structure to maintain the X68000 interface configuration data. This data is persisted through powercycles as needed.
|
||||
typedef struct {
|
||||
struct {
|
||||
uint8_t activeKeyboardMap; // Model of keyboard a keymap entry is applicable to.
|
||||
uint8_t activeMachineModel; // Machine model a keymap entry is applicable to.
|
||||
bool useOnlyPersisted; // Flag to indicate wether the inbuilt keymap array should be combined with persisted values or the inbuilt array is ignored and only persisted values used.
|
||||
} params;
|
||||
} t_x68kConfig;
|
||||
|
||||
// Configuration data.
|
||||
t_x68kConfig x68kConfig;
|
||||
|
||||
// Structure to manage the control signals signifying the state of the X68K keyboard.
|
||||
typedef struct {
|
||||
uint8_t keyCtrl; // Keyboard state flag control.
|
||||
bool optionSelect; // Flag to indicate a user requested keyboard configuration option is being selected.
|
||||
int uartNum;
|
||||
int uartBufferSize;
|
||||
int uartQueueSize;
|
||||
|
||||
std::string fsPath; // Path on the underlying filesystem where storage is mounted and accessible.
|
||||
t_keyMapEntry *kme; // Pointer to an array in memory to contain PS2 to X68K mapping values.
|
||||
int kmeRows; // Number of rows in the kme table.
|
||||
std::string keyMapFileName; // Name of file where extension or replacement key map entries are stored.
|
||||
bool persistConfig; // Flag to request saving of the config into NVS storage.
|
||||
} t_x68kControl;
|
||||
|
||||
// Transmit buffer queue item.
|
||||
typedef struct {
|
||||
uint32_t keyCode; // Key data to be sent to X68000.
|
||||
} t_xmitQueueMessage;
|
||||
|
||||
// Receive buffer queue item.
|
||||
typedef struct {
|
||||
uint8_t hostCmd; // Keyboard configuration command received from X68000.
|
||||
} t_rcvQueueMessage;
|
||||
|
||||
// Thread handles - one per function, ie. HID interface and host target interface.
|
||||
TaskHandle_t TaskHostIF = NULL;
|
||||
TaskHandle_t TaskHIDIF = NULL;
|
||||
|
||||
// Control structure to control interaction and mapping of keys for the host.
|
||||
t_x68kControl x68kControl;
|
||||
|
||||
// Spin lock mutex to hold a coresied to an uninterruptable method. This only works on dual core ESP32's.
|
||||
portMUX_TYPE x68kMutex;
|
||||
|
||||
// Lookup table to match PS/2 codes to X68K Key and Control Data.
|
||||
//
|
||||
// Given that the X68K had many variants, with potential differences between them, the mapping table allows for ALL or variant specific entries, the first entry matching is selected.
|
||||
//
|
||||
// This mapping is for the UK Wyse KB-3926 PS/2 keyboard which is deemed the KEYMAP_STANDARD and all other variants need to add additional mappings below, position sensitive, ie. add non-standard entries before standard entry.
|
||||
//
|
||||
//const unsigned char PS2toX68K[PS2TBL_X68K_MAXROWS][PS2TBL_X68K_MAXCOLS] =
|
||||
//t_keyMapEntry PS2toX68K[PS2TBL_X68K_MAXROWS] =
|
||||
t_keyMap PS2toX68K = {
|
||||
{
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Keyboard Model Machine X68K Data X68K Ctrl (Flags to Set).
|
||||
// Function keys
|
||||
{ PS2_KEY_F1, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_HIRAGANA, X68K_CTRL_NONE, }, // R_CTRL + F1 = Hiragana
|
||||
{ PS2_KEY_F2, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_FULLWIDTH, X68K_CTRL_NONE, }, // R_CTRL + F2 = Full Width
|
||||
{ PS2_KEY_F3, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KATAKANA, X68K_CTRL_NONE, }, // R_CTRL + F3 = Katakana
|
||||
{ PS2_KEY_F4, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_ROMAJI, X68K_CTRL_NONE, }, // R_CTRL + F4 = Romaji
|
||||
{ PS2_KEY_F5, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_TRANSPOSE, X68K_CTRL_NONE, }, // R_CTRL + F5 = Tranpose
|
||||
{ PS2_KEY_F6, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_SYMBOL, X68K_CTRL_NONE, }, // R_CTRL + F6 = Symbol
|
||||
{ PS2_KEY_F7, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_REGISTRATION, X68K_CTRL_NONE, }, // R_CTRL + F7 = Registration - maybe a poor translation, needs better one!
|
||||
{ PS2_KEY_F9, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_COPY, X68K_CTRL_NONE, }, // R_CTRL + F9 = Copy
|
||||
{ PS2_KEY_F10, PS2CTRL_FUNC | PS2CTRL_CTRL | PS2CTRL_R_CTRL, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_HELP, X68K_CTRL_NONE, }, // R_CTRL + F10 = Help
|
||||
{ PS2_KEY_F1, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F1, X68K_CTRL_NONE, }, // F1
|
||||
{ PS2_KEY_F2, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F2, X68K_CTRL_NONE, }, // F2
|
||||
{ PS2_KEY_F3, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F3, X68K_CTRL_NONE, }, // F3
|
||||
{ PS2_KEY_F4, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F4, X68K_CTRL_NONE, }, // F4
|
||||
{ PS2_KEY_F5, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F5, X68K_CTRL_NONE, }, // F5
|
||||
{ PS2_KEY_F6, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F6, X68K_CTRL_NONE, }, // F6
|
||||
{ PS2_KEY_F7, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F7, X68K_CTRL_NONE, }, // F7
|
||||
{ PS2_KEY_F8, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F8, X68K_CTRL_NONE, }, // F8
|
||||
{ PS2_KEY_F9, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F9, X68K_CTRL_NONE, }, // F9
|
||||
{ PS2_KEY_F10, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F10, X68K_CTRL_NONE, }, // F10
|
||||
{ PS2_KEY_F11, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_OPT_1, X68K_CTRL_NONE, }, // F11 - OPT.1
|
||||
{ PS2_KEY_F12, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_OPT_2, X68K_CTRL_NONE, }, // F12 - OPT.2
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine X68K Data X68K Ctrl (Flags to Set).
|
||||
// ALPHA keys, case is maaped in the X68000 via the SHIFT key event or CAPS key.
|
||||
{ PS2_KEY_A, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_A, X68K_CTRL_NONE, }, // A
|
||||
{ PS2_KEY_B, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_B, X68K_CTRL_NONE, }, // B
|
||||
{ PS2_KEY_C, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_C, X68K_CTRL_NONE, }, // C
|
||||
{ PS2_KEY_D, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_D, X68K_CTRL_NONE, }, // D
|
||||
{ PS2_KEY_E, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_E, X68K_CTRL_NONE, }, // E
|
||||
{ PS2_KEY_F, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_F, X68K_CTRL_NONE, }, // F
|
||||
{ PS2_KEY_G, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_G, X68K_CTRL_NONE, }, // G
|
||||
{ PS2_KEY_H, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_H, X68K_CTRL_NONE, }, // H
|
||||
{ PS2_KEY_I, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_I, X68K_CTRL_NONE, }, // I
|
||||
{ PS2_KEY_J, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_J, X68K_CTRL_NONE, }, // J
|
||||
{ PS2_KEY_K, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_K, X68K_CTRL_NONE, }, // K
|
||||
{ PS2_KEY_L, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_L, X68K_CTRL_NONE, }, // L
|
||||
{ PS2_KEY_M, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_M, X68K_CTRL_NONE, }, // M
|
||||
{ PS2_KEY_N, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_N, X68K_CTRL_NONE, }, // N
|
||||
{ PS2_KEY_O, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_O, X68K_CTRL_NONE, }, // O
|
||||
{ PS2_KEY_P, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_P, X68K_CTRL_NONE, }, // P
|
||||
{ PS2_KEY_Q, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_Q, X68K_CTRL_NONE, }, // Q
|
||||
{ PS2_KEY_R, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_R, X68K_CTRL_NONE, }, // R
|
||||
{ PS2_KEY_S, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_S, X68K_CTRL_NONE, }, // S
|
||||
{ PS2_KEY_T, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_T, X68K_CTRL_NONE, }, // T
|
||||
{ PS2_KEY_U, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_U, X68K_CTRL_NONE, }, // U
|
||||
{ PS2_KEY_V, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_V, X68K_CTRL_NONE, }, // V
|
||||
{ PS2_KEY_W, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_W, X68K_CTRL_NONE, }, // W
|
||||
{ PS2_KEY_X, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_X, X68K_CTRL_NONE, }, // X
|
||||
{ PS2_KEY_Y, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_Y, X68K_CTRL_NONE, }, // Y
|
||||
{ PS2_KEY_Z, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_Z, X68K_CTRL_NONE, }, // Z
|
||||
// Numeric keys.
|
||||
{ PS2_KEY_0, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_9, X68K_CTRL_NONE, }, // Close Bracket )
|
||||
{ PS2_KEY_0, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_0, X68K_CTRL_NONE, }, // 0
|
||||
{ PS2_KEY_1, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_1, X68K_CTRL_NONE, }, // 1
|
||||
{ PS2_KEY_2, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_2, X68K_CTRL_NONE, }, // 2
|
||||
{ PS2_KEY_3, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_3, X68K_CTRL_NONE, }, // 3
|
||||
{ PS2_KEY_4, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_4, X68K_CTRL_NONE, }, // 4
|
||||
{ PS2_KEY_5, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_5, X68K_CTRL_NONE, }, // 5
|
||||
{ PS2_KEY_6, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_CIRCUMFLEX, X68K_CTRL_RELEASESHIFT, }, // Circumflex ^
|
||||
{ PS2_KEY_6, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_6, X68K_CTRL_NONE, }, // 6
|
||||
{ PS2_KEY_7, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_6, X68K_CTRL_NONE, }, // &
|
||||
{ PS2_KEY_7, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_7, X68K_CTRL_NONE, }, // 7
|
||||
{ PS2_KEY_8, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_COLON, X68K_CTRL_NONE, }, // Start *
|
||||
{ PS2_KEY_8, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_8, X68K_CTRL_NONE, }, // 8
|
||||
{ PS2_KEY_9, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_8, X68K_CTRL_NONE, }, // Open Bracket (
|
||||
{ PS2_KEY_9, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_9, X68K_CTRL_NONE, }, // 9
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine X68K Data X68K Ctrl (Flags to Set).
|
||||
// Punctuation keys.
|
||||
{ PS2_KEY_SPACE, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_SPACE, X68K_CTRL_NONE, }, // Space
|
||||
{ PS2_KEY_MINUS, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_CIRCUMFLEX, X68K_CTRL_NONE, }, // Upper Bar
|
||||
{ PS2_KEY_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_MINUS, X68K_CTRL_NONE, }, // Minus -
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_SEMI, X68K_CTRL_SHIFT, }, // Plus +
|
||||
{ PS2_KEY_EQUAL, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_MINUS, X68K_CTRL_SHIFT, }, // Equal =
|
||||
{ PS2_KEY_DOT, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_DOT, X68K_CTRL_NONE, }, // Greater Than >
|
||||
{ PS2_KEY_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_DOT, X68K_CTRL_NONE, }, // Dot
|
||||
{ PS2_KEY_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_DIV, X68K_CTRL_NONE, }, // Divide /
|
||||
{ PS2_KEY_SEMI, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_COLON, X68K_CTRL_RELEASESHIFT, }, // Colon :
|
||||
{ PS2_KEY_SEMI, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_SEMI, X68K_CTRL_NONE, }, // Semi-Colon ;
|
||||
{ PS2_KEY_OPEN_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_OPEN_SQ, X68K_CTRL_NONE, }, // [
|
||||
{ PS2_KEY_CLOSE_SQ, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_CLOSE_SQ, X68K_CTRL_NONE, }, // ]
|
||||
{ PS2_KEY_APOS, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_AT, X68K_CTRL_RELEASESHIFT, }, // @
|
||||
{ PS2_KEY_APOS, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_7, X68K_CTRL_SHIFT, }, // '
|
||||
{ PS2_KEY_BACK, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_YEN, X68K_CTRL_NONE, }, // Back slash maps to Yen
|
||||
{ PS2_KEY_BACK, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_YEN, X68K_CTRL_NONE, }, // Back slash maps to Yen
|
||||
{ PS2_KEY_HASH, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_3, X68K_CTRL_SHIFT, }, // Hash
|
||||
{ PS2_KEY_COMMA, PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_COMMA, X68K_CTRL_NONE, }, // Less Than <
|
||||
{ PS2_KEY_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_COMMA, X68K_CTRL_NONE, }, // Comma ,
|
||||
{ PS2_KEY_BTICK, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_UNDERLINE, X68K_CTRL_SHIFT, }, // Underline
|
||||
{ PS2_KEY_BTICK, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_AT, X68K_CTRL_SHIFT, }, // Back Tick `
|
||||
// Control keys.
|
||||
{ PS2_KEY_TAB, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_TAB, X68K_CTRL_NONE, }, // TAB
|
||||
{ PS2_KEY_BS, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_BS, X68K_CTRL_NONE, }, // Backspace
|
||||
{ PS2_KEY_ESC, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_ESC, X68K_CTRL_NONE, }, // ESCape
|
||||
{ PS2_KEY_INSERT, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_INS, X68K_CTRL_NONE, }, // INSERT
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_CLR, X68K_CTRL_NONE, }, // CLR
|
||||
{ PS2_KEY_HOME, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_HOME, X68K_CTRL_NONE, }, // HOME
|
||||
{ PS2_KEY_DELETE, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_DEL, X68K_CTRL_NONE, }, // DELETE
|
||||
{ PS2_KEY_UP_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_UP_ARROW, X68K_CTRL_NONE, }, // Up Arrow
|
||||
{ PS2_KEY_L_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_L_ARROW, X68K_CTRL_NONE, }, // Left Arrow
|
||||
{ PS2_KEY_DN_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_DN_ARROW, X68K_CTRL_NONE, }, // Down Arrow
|
||||
{ PS2_KEY_R_ARROW, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_R_ARROW, X68K_CTRL_NONE, }, // Right Arrow
|
||||
{ PS2_KEY_PGUP, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_ROLLUP, X68K_CTRL_NONE, }, // Roll Up.
|
||||
{ PS2_KEY_PGDN, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_ROLLDN, X68K_CTRL_NONE, }, // Roll Down
|
||||
{ PS2_KEY_SCROLL, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, ' ', X68K_CTRL_NONE, }, // Not assigned.
|
||||
{ PS2_KEY_ENTER, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_RETURN, X68K_CTRL_NONE, }, // Not assigned.
|
||||
{ PS2_KEY_CAPS, PS2CTRL_CAPS, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_CAPS, X68K_CTRL_NONE, }, // CAPS
|
||||
{ PS2_KEY_END, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_UNDO, X68K_CTRL_NONE, }, // UNDO
|
||||
// Keypad.
|
||||
{ PS2_KEY_KP0, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP0, X68K_CTRL_NONE, }, // Keypad 0
|
||||
{ PS2_KEY_KP1, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP1, X68K_CTRL_NONE, }, // Keypad 1
|
||||
{ PS2_KEY_KP2, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP2, X68K_CTRL_NONE, }, // Keypad 2
|
||||
{ PS2_KEY_KP3, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP3, X68K_CTRL_NONE, }, // Keypad 3
|
||||
{ PS2_KEY_KP4, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP4, X68K_CTRL_NONE, }, // Keypad 4
|
||||
{ PS2_KEY_KP5, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP5, X68K_CTRL_NONE, }, // Keypad 5
|
||||
{ PS2_KEY_KP6, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP6, X68K_CTRL_NONE, }, // Keypad 6
|
||||
{ PS2_KEY_KP7, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP7, X68K_CTRL_NONE, }, // Keypad 7
|
||||
{ PS2_KEY_KP8, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP8, X68K_CTRL_NONE, }, // Keypad 8
|
||||
{ PS2_KEY_KP9, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP9, X68K_CTRL_NONE, }, // Keypad 9
|
||||
{ PS2_KEY_KP_COMMA, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP_COMMA, X68K_CTRL_NONE, }, // Keypad Comma ,
|
||||
{ PS2_KEY_KP_DOT, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP_DOT, X68K_CTRL_NONE, }, // Keypad Full stop .
|
||||
{ PS2_KEY_KP_PLUS, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP_PLUS, X68K_CTRL_NONE, }, // Keypad Plus +
|
||||
{ PS2_KEY_KP_MINUS, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP_MINUS, X68K_CTRL_NONE, }, // Keypad Minus -
|
||||
{ PS2_KEY_KP_TIMES, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP_TIMES, X68K_CTRL_NONE, }, // Keypad Times *
|
||||
{ PS2_KEY_KP_DIV, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP_DIV, X68K_CTRL_NONE, }, // Keypad Divide /
|
||||
{ PS2_KEY_KP_EQUAL, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_MINUS, X68K_CTRL_SHIFT, }, // Keypad Equal =
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP_ENTER, X68K_CTRL_NONE, }, // Keypad Ebter /
|
||||
{ PS2_KEY_KP_ENTER, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_KP_EQUAL, X68K_CTRL_NONE, }, // Keypad Ebter /
|
||||
//PS2 Code PS2 Ctrl (Flags to Match) Machine X68K Data X68K Ctrl (Flags to Set).
|
||||
// Special keys.
|
||||
{ PS2_KEY_PRTSCR, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, 0x00, X68K_CTRL_NONE, }, //
|
||||
{ PS2_KEY_PAUSE, PS2CTRL_FUNC | PS2CTRL_SHIFT, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_BREAK, X68K_CTRL_RELEASESHIFT, }, // BREAK KEY
|
||||
{ PS2_KEY_L_GUI, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_XF1, X68K_CTRL_NONE, }, // XF1
|
||||
{ PS2_KEY_L_ALT, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_XF2, X68K_CTRL_NONE, }, // XF2
|
||||
{ PS2_KEY_R_ALT, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_XF3, X68K_CTRL_NONE, }, // XF3
|
||||
{ PS2_KEY_R_GUI, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_XF4, X68K_CTRL_NONE, }, // XF4
|
||||
{ PS2_KEY_MENU, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_XF5, X68K_CTRL_NONE, }, // XF5
|
||||
// Modifiers are last, only being selected if an earlier match isnt made.
|
||||
{ PS2_KEY_L_SHIFT, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_SHIFT, X68K_CTRL_NONE, }, //
|
||||
{ PS2_KEY_R_SHIFT, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_SHIFT, X68K_CTRL_NONE, }, //
|
||||
{ PS2_KEY_L_CTRL, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_CTRL, X68K_CTRL_NONE, }, // Map to Control
|
||||
{ PS2_KEY_R_CTRL, PS2CTRL_FUNC, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_CTRL, X68K_CTRL_NONE, }, // Map to Control
|
||||
{ 0, PS2CTRL_NONE, KEYMAP_STANDARD, X68K_ALL, X68K_KEY_NULL, X68K_CTRL_NONE, }, //
|
||||
}};
|
||||
};
|
||||
|
||||
#endif // X68K_H
|
||||
Reference in New Issue
Block a user