c2000ware-core-sdk/libraries/communications/usb/f2837xd/source/usbkeyboardmap.c
2023-12-13 16:46:16 +05:30

171 lines
8.3 KiB
C

//#############################################################################
// FILE: usbkeyboardmap.c
// TITLE: This file holds the table to enable USB keyboard usage
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_types.h"
#include "include/usblib.h"
#include "include/usbhid.h"
//*****************************************************************************
//
// This is the array that hold the unshifted and shifted ASCII character for
// each usage ID.
//
//*****************************************************************************
const uint8_t g_pui8KeyBoardMap[USBH_HID_MAX_USAGE][2] =
{
//
// Usage ID to character mapping Usage ID CAPS Lock
//
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 0 - 3 0
{'a', 'A'}, {'b', 'B'}, {'c', 'C'}, {'d', 'D'}, // 4 - 7 f
{'e', 'E'}, {'f', 'F'}, {'g', 'G'}, {'h', 'H'}, // 8 - 11 f
{'i', 'I'}, {'j', 'J'}, {'k', 'K'}, {'l', 'L'}, // 12 - 15 f
{'m', 'M'}, {'n', 'N'}, {'o', 'O'}, {'p', 'P'}, // 16 - 19 f
{'q', 'Q'}, {'r', 'R'}, {'s', 'S'}, {'t', 'T'}, // 20 - 23 f
{'u', 'U'}, {'v', 'V'}, {'w', 'W'}, {'x', 'X'}, // 24 - 27 f
{'y', 'Y'}, {'z', 'Z'}, {'1', '!'}, {'2', '@'}, // 28 - 31 3
{'3', '#'}, {'4', '$'}, {'5', '%'}, {'6', '^'}, // 32 - 35 0
{'7', '&'}, {'8', '*'}, {'9', '('}, {'0', ')'}, // 36 - 39 0
{'\n', '\n'}, {0, 0}, {0, 0}, {'\t', '\t'}, // 40 - 43 0
{' ', ' '}, {'-', '_'}, {'=', '+'}, {'[', '{'}, // 44 - 47 0
{']', '}'}, {'\\', '|'},{'`', '~'}, {';', ':'}, // 48 - 51 0
{'\'', '"'}, {'`', '~'}, {',', '<'}, {'.', '>'},// 52 - 55 0
{'/', '?'}, {0, 0}, {0, 0}, {0, 0}, // 56 - 59 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 60 - 63 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 64 - 67 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 68 - 71 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 72 - 75 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 76 - 79 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 80 - 83 0
{'/', '/'}, {'*', '*'}, {'-', '-'}, {'+', '+'}, // 84 - 87 0
{'\n', '\n'}, {'1', 0}, {'2', 0}, {'3', 0}, // 88 - 91 0
{'4', 0}, {'5', 0}, {'6', 0}, {'7', 0}, // 92 - 95 0
{'8', 0}, {'9', 0}, {'0', 0}, {'.', 0}, // 96 - 99 0
{'\\', '|'},{0, 0}, {0, 0}, {'=', '+'}, // 100 - 103 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 104 - 107 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 108 - 111 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 112 - 115 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 116 - 119 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 120 - 123 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 124 - 127 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 128 - 131 0
{0, 0}, {',', ','}, {'=', '='}, {0, 0}, // 132 - 135 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 136 - 139 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 140 - 143 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 144 - 147 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 148 - 151 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 152 - 155 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 156 - 159 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 160 - 163 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 164 - 167 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 168 - 171 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 172 - 175 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 174 - 179 0
{0, 0}, {0, 0}, {'(', '('}, {')', ')'}, // 180 - 183 0
{'{', '{'}, {'}', '}'}, {'\t', '\t'}, {0, 0}, // 184 - 187 0
{'A', 'A'}, {'B', 'B'}, {'C', 'C'}, {'D', 'D'}, // 188 - 191 0
{'E', 'E'}, {'F', 'F'}, {0, 0}, {'^', '^'}, // 192 - 195 0
{'%', '%'}, {'<', '<'}, {'>', '>'}, {'&', '&'}, // 196 - 199 0
{'&', '&'}, {'|', '|'}, {'|', '|'}, {':', ':'}, // 200 - 203 0
{'#', '#'}, {' ', ' '}, {'@', '@'}, {'!', '!'}, // 204 - 207 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 208 - 211 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 212 - 215 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 216 - 219 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 220 - 223 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 224 - 227 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 228 - 231 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 232 - 235 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 236 - 239 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 240 - 243 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 244 - 247 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 248 - 251 0
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 252 - 255 0
};
//*****************************************************************************
//
// This is the structure that defines the mapping of USB usage IDs to ASCII
// values for printing.
//
//*****************************************************************************
const tHIDKeyboardUsageTable g_sUSKeyboardMap =
{
//
// One byte per character.
//
1,
//
// Packed bit array of usages codes that are effected by Caps Lock state.
//
{
0x3ffffff0, // Alpha characters are only one affected by CAPS LOCK
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
},
//
// The large table of the direct mapping of usage id's to ascii characters.
//
(void *)g_pui8KeyBoardMap
};