ZHCU602 December 2018
Each keyboard key value is defined in the USB HID Usage Tables, Keyboard/Keypad Page (0x07), available from USB-IF. Typing these same keys or key combinations directly on the Windows keyboard controls the media player the same as the capacitive touch demo.
As shown in USB HID Usage document, each key is represented by an 8-bit value. For example, reporting the F7 key requires an 8-bit value (0x00 to 0xFF). Reporting a key-combination, such as CTRL-P requires two bytes, because two keys are being pressed simultaneously. Table 3 lists each keyboard key’s 8-bit value.
Keyboard Key | Key Value |
---|---|
KEY-B | 0x05 |
KEY-F | 0x09 |
KEY-P | 0x13 |
KEY-F7 | 0x40 |
KEY-F8 | 0x41 |
KEY-F9 | 0x42 |
KEY-MOD-LCTRL | 0xE0 |
The key value is transmitted by the MSP430FR2633 to the MSP430 USB HID device over an I2C interface. When transmitting the key value, the key or key combination is reported as a 16-bit value, in which the lower byte represents the primary key and upper byte represents the key modifier, if applicable. If a key has no modifier, then the upper byte is 0x00. Table 4 lists the final 16-bit key representations that are reported to the MSP430 USB HID device.
Media Player Function | Key Combination | 16-Bit Representation |
---|---|---|
Play or pause | CTRL-P | 0xE013 |
Previous music track | CTRL-B | 0xE005 |
Next music track | CTRL-F | 0xE009 |
Mute | F7 | 0x0040 |
Volume up | F8 | 0x0041 |
Volume down | F9 | 0x0042 |