USBHIDKeyboard Class

USBHIDKeyboard Class

Description
A class used for creating and managing a USB HID Keyboard.

Syntax
class USBHIDKeyboard

Members

Public Constructors 
USBHIDKeyboard::USBHIDKeyboardConstructs a USBHIDKeyboard object.
Public Methods 
USBHIDKeyboard::setReportIDSet HID report ID for the HID Keyboard and HID consumer control.
USBHIDKeyboard::consumerReportSend a HID Consumer report.
USBHIDKeyboard::keyboardReportSend a HID Keyboard report.
USBHIDKeyboard::consumerPressSend a HID Consumer report indicating button pressed.
USBHIDKeyboard::consumerReleaseSend a HID Consumer report indicating button released.
USBHIDKeyboard::keyPressSend a HID Keyboard report indicating keys pressed.
USBHIDKeyboard::keyReleaseSend a HID Keyboard report indicating keys released.
USBHIDKeyboard::keyReleaseAllSend a HID Keyboard report indicating no keys pressed.
USBHIDKeyboard::keyCharPressSend a HID Keyboard report indicating keys pressed to output an ASCII character.
USBHIDKeyboard::keySequenceSend a HID Keyboard report indicating keys pressed to output an ASCII string.

USBHIDKeyboard::USBHIDKeyboard

Description
Constructs a USBHIDKeyboard object.

Syntax
USBHIDKeyboard(void);

Parameters
NA

Returns
NA

Example Code
Example: USBHIDKeyboard
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/USB/examples/USBHIDKeyboard/USBHIDKeyboard.ino)

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::setReportID

Description
Set HID report ID for the HID Keyboard and HID consumer control.

Syntax
void setReportID(uint8_t reportIDKeyboard, uint8_t reportIDConsumer);

Parameters
reportIDKeyboard: The report ID for the HID keyboard device, corresponding to the HID report descriptor.
reportIDConsumer: The report ID for the HID consumer control device, corresponding to the HID report descriptor.

Returns
NA

Example Code
NA

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::consumerReport

Description
Send a HID Consumer report.

Syntax
void consumerReport(uint16_t usage_code);

Parameters
usage_code: HID consumer control usage code for the button pressed.

Returns
NA

Example Code
NA

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::keyboardReport

Description
Send a HID Keyboard report.

Syntax
void keyboardReport(void);
void keyboardReport(uint8_t modifiers, uint8_t keycode[6]);

Parameters
modifiers: bitmap indicating key modifiers pressed (CTRL, ALT, SHIFT).
keycode: byte array indicating keys pressed.

Returns
NA

Example Code
NA

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::consumerPress

Description
Send a HID Consumer report indicating button pressed.

Syntax
void consumerPress(uint16_t usage_code);

Parameters
usage_code: HID consumer control usage code for the button pressed.

Returns
NA

Example Code
Example: USBHIDKeyboard
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/USB/examples/USBHIDKeyboard/USBHIDKeyboard.ino)

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::consumerRelease

Description
Send a HID Consumer report indicating button released.

Syntax
void consumerRelease(void);

Parameters
NA

Returns
NA

Example Code
Example: USBHIDKeyboard
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/USB/examples/USBHIDKeyboard/USBHIDKeyboard.ino)

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::keyPress

Description
Send a HID Keyboard report indicating keys pressed.

Syntax
void keyPress(uint16_t key);

Parameters
key: HID keycode for key pressed, value ranges from 0x00 to 0xE7.

Returns
NA

Example Code
Example: USBHIDKeyboard
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/USB/examples/USBHIDKeyboard/USBHIDKeyboard.ino)

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::keyRelease

Description
Send a HID Keyboard report indicating keys released.

Syntax
void keyRelease(uint16_t key);

Parameters
key: HID keycode for key pressed, value ranges from 0x00 to 0xE7.

Returns
NA

Example Code
NA

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::keyReleaseAll

Description
Send a HID Keyboard report indicating no keys pressed.

Syntax
void keyReleaseAll(void);

Parameters
NA

Returns
NA

Example Code
Example: USBHIDKeyboard
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/USB/examples/USBHIDKeyboard/USBHIDKeyboard.ino)

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::keyCharPress

Description
Send a HID Keyboard report indicating keys pressed to output an ASCII character.

Syntax
void keyCharPress(char ch);

Parameters
ch: ASCII character to output.

Returns
NA

Example Code
NA

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

USBHIDKeyboard::keySequence

Description
Send a HID Keyboard report indicating keys pressed to output an ASCII string.

Syntax
void keySequence(const char* str, uint16_t delayTime);
void keySequence(String str, uint16_t delayTime);

Parameters
str: character string to output, expressed as a char array or a String class object
delayTime: time delay between key press and release, in milliseconds. Default value of 5.

Returns
NA

Example Code
Example: USBHIDKeyboard
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/USB/examples/USBHIDKeyboard/USBHIDKeyboard.ino)

Notes and Warnings
“USBHIDKeyboard.h” must be included to use the class function.

Copyrights ©瑞晟微电子(苏州)有限公司 2021. All rights reserved. 使用條款
請先確認已安裝QQ通訊軟體