キーボードの長押しに対応。

Dependents:   PS4_FF14_Adapter

Fork of USBDevice by mbed official

Embed: (wiki syntax)

« Back to documentation index

USBKeyboard Class Reference

USBKeyboard Class Reference

USBKeyboard example. More...

#include <USBKeyboard.h>

Inherits USBHID.

Public Member Functions

 USBKeyboard (uint16_t vendor_id=0x1235, uint16_t product_id=0x0050, uint16_t product_release=0x0001)
 コンストラクタ
bool keyCode (uint8_t key, uint8_t modifier=0)
 修飾子(CTRL, SHIFT, ALT)とキーで定義された文字を送信します。
bool keyDown (uint8_t key)
 キーダウン ///
bool keyUp (uint8_t)
 キーアップ ///
virtual int _putc (int c)
 キャラクタを送信します。
bool mediaControl (MEDIA_KEY key)
 メディアキーを制御する
virtual uint8_t * reportDesc ()
 reportDesc
virtual bool EP1_OUT_callback ()
 EP1_OUT_callback.
uint8_t lockStatus ()
 ロックキーの状態を読み取ります。押されたキーに応じてLEDをスイッチオン/オフするのに便利です。 結果の最初の3ビットのみが重要です。

  • 最初のビット: NUM_LOCK
  • 二番目のビット: CAPS_LOCK
  • 三番目のビット: SCROLL_LOCK

bool send (HID_REPORT *report)
 Send a Report.
bool sendNB (HID_REPORT *report)
 Send a Report.
bool read (HID_REPORT *report)
 Read a report: blocking.
bool readNB (HID_REPORT *report)
 Read a report: non blocking.

Protected Member Functions

virtual uint8_t * configurationDesc ()
 Descの設定

Detailed Description

USBKeyboard example.

 #include "mbed.h"
 #include "USBKeyboard.h"

 USBKeyboard key;

 int main(void)
 {
   while (1)
   {
       key.printf("Hello World\r\n");
       wait(1);
   }
 }

Definition at line 92 of file USBKeyboard.h.


Constructor & Destructor Documentation

USBKeyboard ( uint16_t  vendor_id = 0x1235,
uint16_t  product_id = 0x0050,
uint16_t  product_release = 0x0001 
)

コンストラクタ

Parameters:
ledsLeds bus: first: NUM_LOCK, second: CAPS_LOCK, third: SCROLL_LOCK
vendor_idYour vendor_id (default: 0x1235)
product_idYour product_id (default: 0x0050)
product_releaseYour preoduct_release (default: 0x0001)

Definition at line 105 of file USBKeyboard.h.


Member Function Documentation

int _putc ( int  c ) [virtual]

キャラクタを送信します。

文字を送信する

Parameters:
c送信するキャラクタ
Returns:
エラーがない場合はtrueを返し、そうでない場合はfalseを返します。

Definition at line 455 of file USBKeyboard.cpp.

uint8_t * configurationDesc (  ) [protected, virtual]

Descの設定

Reimplemented from USBHID.

Definition at line 591 of file USBKeyboard.cpp.

bool EP1_OUT_callback (  ) [virtual]

EP1_OUT_callback.

Definition at line 429 of file USBKeyboard.cpp.

bool keyCode ( uint8_t  key,
uint8_t  modifier = 0 
)

修飾子(CTRL, SHIFT, ALT)とキーで定義された文字を送信します。

キーコード

 //To send CTRL + s (save)
  keyboard.keyCode('s', KEY_CTRL);
Parameters:
modifierbit 0: KEY_CTRL, bit 1: KEY_SHIFT, bit 2: KEY_ALT (default: 0)
key送信するキャラクタ
Returns:
true if there is no error, false otherwise キーコード

Definition at line 463 of file USBKeyboard.cpp.

bool keyDown ( uint8_t  key )

キーダウン ///

キーダウン

Definition at line 500 of file USBKeyboard.cpp.

bool keyUp ( uint8_t  key )

キーアップ ///

キーアップ

Definition at line 529 of file USBKeyboard.cpp.

uint8_t lockStatus (  )

ロックキーの状態を読み取ります。押されたキーに応じてLEDをスイッチオン/オフするのに便利です。 結果の最初の3ビットのみが重要です。

  • 最初のビット: NUM_LOCK
  • 二番目のビット: CAPS_LOCK
  • 三番目のビット: SCROLL_LOCK

ロックステータスを返す

Returns:
ロックキーのステータス

Definition at line 447 of file USBKeyboard.cpp.

bool mediaControl ( MEDIA_KEY  key )

メディアキーを制御する

メディアコントロール

Parameters:
key押されたメディアキー (KEY_NEXT_TRACK, KEY_PREVIOUS_TRACK, KEY_STOP, KEY_PLAY_PAUSE, KEY_MUTE, KEY_VOLUME_UP, KEY_VOLUME_DOWN)
Returns:
true if there is no error, false otherwise

Definition at line 560 of file USBKeyboard.cpp.

bool read ( HID_REPORT *  report ) [inherited]

Read a report: blocking.

Parameters:
reportpointer to the report to fill
Returns:
true if successful

Definition at line 45 of file USBHID.cpp.

bool readNB ( HID_REPORT *  report ) [inherited]

Read a report: non blocking.

Parameters:
reportpointer to the report to fill
Returns:
true if successful

Definition at line 57 of file USBHID.cpp.

uint8_t * reportDesc (  ) [virtual]

reportDesc

Reimplemented from USBHID.

Definition at line 358 of file USBKeyboard.cpp.

bool send ( HID_REPORT *  report ) [inherited]

Send a Report.

warning: blocking

Parameters:
reportReport which will be sent (a report is defined by all data and the length)
Returns:
true if successful

Definition at line 34 of file USBHID.cpp.

bool sendNB ( HID_REPORT *  report ) [inherited]

Send a Report.

warning: non blocking

Parameters:
reportReport which will be sent (a report is defined by all data and the length)
Returns:
true if successful

Definition at line 39 of file USBHID.cpp.