8 years, 8 months ago.

(Jampanese or Englesh)About mbed USBDevice library. ライブラリー内ソースの一部意図について

すみません、無知すぎて「憶測」以上の判断がむつかしいのでここで質問させていただきます

引用以下部分の後半

(Maybe this is very easy question, but I'm beginer, so please teach me the issue. On below source code ,)

--------

bool USBKeyboard::keyCode(uint8_t key, uint8_t modifier) { Send a simulated keyboard keypress. Returns true if successful. HID_REPORT report;

report.data[0] = REPORT_ID_KEYBOARD; report.data[1] = modifier; report.data[2] = 0; report.data[3] = keymap[key].usage; report.data[4] = 0; report.data[5] = 0; report.data[6] = 0; report.data[7] = 0; report.data[8] = 0;

report.length = 9;

if (!send(&report)) { return false; }

report.data[1] = 0; report.data[3] = 0;

if (!send(&report)) { return false; }

return true;

}-------

report.data[1]と[3]をあえてリセットして、再送しているようなのですが これはUSBの通信上必要なものなのかキーリリースをわざと表現しているだけなのかの諸兄の意見を聞きたく思っています。

(report.data[1] and [3] reset and resend to PC key signal, I want to know the reason. I think this is not USB HID Keyboard protocol rule, this is only "key release" signal. Is it light?)

私の考えとしては、UEBKeybordのPCへの信号については、

①キーのイベントが発生しなければ何も送信しない ②キーのイベントは、「押す」「離す」行為によって発生する ③同時押しは最後から最大6個分を送信する(これは、このライブラリでは表現されておらず、変更の必要あり)

かと思っており、このリセットしたうえで信号送付しているのは、USB規格とは関係なくアプリケーションとして キーを「離した」という信号をPCに送るために送出していると考えています。

この認識は諸兄と同じでしょうか。。。

Be the first to answer this question.