-
Notifications
You must be signed in to change notification settings - Fork 0
/
USBto98KbMouseBSKBW120S.ino
59 lines (44 loc) · 1.47 KB
/
USBto98KbMouseBSKBW120S.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <hidboot.h>
#include <usbhub.h>
#include <hiduniversal.h>
#include "BskBw120aMParser.h"
#include "KbdRptParser.h"
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>
USB Usb;
USBHub Hub(&Usb);
HIDBoot < USB_HID_PROTOCOL_KEYBOARD | USB_HID_PROTOCOL_MOUSE > HidComposite(&Usb,false);
KbdRptParser KbdPrs;
BskBw120aMParser MousePrs;
TaskHandle_t thp[1];
void setup()
{
Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
Serial.println("Start");
if (Usb.Init() == -1) Serial.println("OSC did not start.");
delay( 200 );
//マウス・キーボートパーサーの初期化
KbdPrs.setUp98Keyboard();
//キーボート通信処理用タスク(loopだとUSB処理が重く起動時にパケットロスを起こすのでCore0でマルチタスク化)
xTaskCreatePinnedToCore(Core0_KbdTask, "Core0_KbdTask", 4096, NULL, 24, &thp[0], 0);
MousePrs.setUpBusMouse();
//複合デバイスでマウスが動く場合(Buffalo BSKBW120Sシリーズなど)
//キーボードパーサーセット・マウスパーサーセット
HidComposite.SetReportParser(0, &KbdPrs);
HidComposite.SetReportParser(1, &MousePrs);
}
void loop()
{
Usb.Task();
//KbdPrs.task();
}
void Core0_KbdTask(void *args) {
while (1) {
delay(1);
KbdPrs.task();
}
}