Mitmgate v0.0.0+dev.3
Man in the Middle Keylogger and Injector
Loading...
Searching...
No Matches
hid_tables.h File Reference

USB HID Usage Tables and ASCII conversion logic. More...

#include "../typedef.h"

Go to the source code of this file.

Macros

#define HIDAPI   static
 Defines scope for table data (defaults to static for header-only usage).
#define HID_USAGE_MAX   (0xFF)
 Maximum supported HID Usage ID for the lookup tables.
#define HID_BITMASK_LEFT_SHIFT   (0x02)
 Bitmask for the Left Shift modifier.
#define HID_BITMASK_RIGHT_SHIFT   (0x20)
 Bitmask for the Right Shift modifier.

Typedefs

typedef enum HID_TABLES_KEY_CODES HidKeyCodes
 Typedef for usage in function signatures.

Enumerations

enum  HID_TABLES_KEY_CODES {
  HID_KEY_NONE = 0x00 , HID_KEY_ERROR_ROLLOVER = 0x01 , HID_KEY_POST_FAIL = 0x02 , HID_KEY_ERROR_UNDEFINED = 0x03 ,
  HID_KEY_A = 0x04 , HID_KEY_B = 0x05 , HID_KEY_C = 0x06 , HID_KEY_D = 0x07 ,
  HID_KEY_E = 0x08 , HID_KEY_F = 0x09 , HID_KEY_G = 0x0A , HID_KEY_H = 0x0B ,
  HID_KEY_I = 0x0C , HID_KEY_J = 0x0D , HID_KEY_K = 0x0E , HID_KEY_L = 0x0F ,
  HID_KEY_M = 0x10 , HID_KEY_N = 0x11 , HID_KEY_O = 0x12 , HID_KEY_P = 0x13 ,
  HID_KEY_Q = 0x14 , HID_KEY_R = 0x15 , HID_KEY_S = 0x16 , HID_KEY_T = 0x17 ,
  HID_KEY_U = 0x18 , HID_KEY_V = 0x19 , HID_KEY_W = 0x1A , HID_KEY_X = 0x1B ,
  HID_KEY_Y = 0x1C , HID_KEY_Z = 0x1D , HID_KEY_1 = 0x1E , HID_KEY_2 = 0x1F ,
  HID_KEY_3 = 0x20 , HID_KEY_4 = 0x21 , HID_KEY_5 = 0x22 , HID_KEY_6 = 0x23 ,
  HID_KEY_7 = 0x24 , HID_KEY_8 = 0x25 , HID_KEY_9 = 0x26 , HID_KEY_0 = 0x27 ,
  HID_KEY_ENTER = 0x28 , HID_KEY_ESCAPE = 0x29 , HID_KEY_BACKSPACE = 0x2A , HID_KEY_TAB = 0x2B ,
  HID_KEY_SPACE = 0x2C , HID_KEY_MINUS = 0x2D , HID_KEY_EQUAL = 0x2E , HID_KEY_BRACKET_LEFT = 0x2F ,
  HID_KEY_BRACKET_RIGHT = 0x30 , HID_KEY_BACKSLASH = 0x31 , HID_KEY_SEMICOLON = 0x33 , HID_KEY_APOSTROPHE = 0x34 ,
  HID_KEY_GRAVE = 0x35 , HID_KEY_COMMA = 0x36 , HID_KEY_PERIOD = 0x37 , HID_KEY_SLASH = 0x38 ,
  HID_KEY_CAPS_LOCK = 0x39 , HID_KEY_F1 = 0x3A , HID_KEY_F2 = 0x3B , HID_KEY_F3 = 0x3C ,
  HID_KEY_F4 = 0x3D , HID_KEY_F5 = 0x3E , HID_KEY_F6 = 0x3F , HID_KEY_F7 = 0x40 ,
  HID_KEY_F8 = 0x41 , HID_KEY_F9 = 0x42 , HID_KEY_F10 = 0x43 , HID_KEY_F11 = 0x44 ,
  HID_KEY_F12 = 0x45 , HID_KEY_PRINT_SCREEN = 0x46 , HID_KEY_SCROLL_LOCK = 0x47 , HID_KEY_PAUSE = 0x48 ,
  HID_KEY_INSERT = 0x49 , HID_KEY_HOME = 0x4A , HID_KEY_PAGE_UP = 0x4B , HID_KEY_DELETE = 0x4C ,
  HID_KEY_END = 0x4D , HID_KEY_PAGE_DOWN = 0x4E , HID_KEY_RIGHT = 0x4F , HID_KEY_LEFT = 0x50 ,
  HID_KEY_DOWN = 0x51 , HID_KEY_UP = 0x52 , HID_KEY_LEFT_CTRL = 0xE0 , HID_KEY_LEFT_SHIFT = 0xE1 ,
  HID_KEY_LEFT_ALT = 0xE2 , HID_KEY_LEFT_GUI = 0xE3 , HID_KEY_RIGHT_CTRL = 0xE4 , HID_KEY_RIGHT_SHIFT = 0xE5 ,
  HID_KEY_RIGHT_ALT = 0xE6 , HID_KEY_RIGHT_GUI = 0xE7
}
 Full HID Usage IDs (Page 0x07 - Keyboard/Keypad). More...

Functions

HIDAPI char hid_parse_key (u8 modifier, u8 usage_id)
 Parses a HID key combination into an ASCII character.

Variables

HIDAPI const char HID_TO_ASCII_LOWER [HID_USAGE_MAX]
 Lookup table for Lowercase characters (No Shift). Maps HID Usage IDs to their ASCII representation.
HIDAPI const char HID_TO_ASCII_UPPER [HID_USAGE_MAX]
 Lookup table for Uppercase characters (Shift Held). Maps HID Usage IDs to their ASCII representation when Shift is active.

Detailed Description

USB HID Usage Tables and ASCII conversion logic.

This header contains the standard USB HID Usage IDs for keyboards (Page 0x07) and lookup tables to convert these Scancodes into ASCII characters based on modifier states (Shift).

Note
This file uses static definitions for tables to allow header-only inclusion.

Enumeration Type Documentation

◆ HID_TABLES_KEY_CODES

Full HID Usage IDs (Page 0x07 - Keyboard/Keypad).

Source: USB HID Usage Tables v1.12

Enumerator
HID_KEY_NONE 

No key pressed

HID_KEY_ERROR_ROLLOVER 

Keyboard Error Roll Over

HID_KEY_POST_FAIL 

Keyboard POST Fail

HID_KEY_ERROR_UNDEFINED 

Keyboard Error Undefined

Function Documentation

◆ hid_parse_key()

HIDAPI char hid_parse_key ( u8 modifier,
u8 usage_id )
inline

Parses a HID key combination into an ASCII character.

Parameters
modifierThe modifier bitmask (e.g., Shift, Ctrl).
usage_idThe HID Usage ID of the key pressed.
Returns
char The ASCII character, or 0 if not mappable.