2014-12-26 82 views
0

我正在用arduino leonardo和RN 42 HID模塊創建藍牙HID手柄。RN的HID報告/掃描碼42 HID的遊戲手柄配置文件

我可以實際使用的模塊來遍歷一個鍵盤或鼠標,但我不明白如何

發出正確的掃描碼迭代一個遊戲手柄或操縱桿。

在模塊的用戶指南,他們說,原報告中有這樣的發送:

0xFD,0x06,Buttons 0-7,Buttons 8-15,X1,Y1,X2,Y2 

如何設置報告任何想法?

回答

1

首先,您必須初始化一個SoftwareSerial實例。 然後,你必須輸入命令模式的RN-42模塊的$$$序列,建立HID搖桿模式(SH,0240)和名稱的設備(SN,...) ,設置波特率(SU,...)等 模塊的初始化成功後,就可以發送HID搖桿報告如下:

SoftwareSerial bluetooth(bluetoothRX, bluetoothTX); 
//... 

// Command Mode 
// -------------- 
bluetooth.begin(9600); 
delay(50); 
bluetooth.print("$$$"); 
delay(50); 
bluetooth.print("SN,HIDJoystick\r\n"); 
delay(50); 
bluetooth.print(" SU,57\r\n"); 
delay(50); 
bluetooth.print("S~,6\r\n"); 
delay(600); 
bluetooth.print("SH,0240\r\n"); 
delay(200); 
bluetooth.print("R,1\r\n"); 
delay(400); 

// HID Joystick Report 
// -------------- 
bluetooth.write((byte)0xFD); //Start HID Report 
bluetooth.write((byte)0x6); //Length byte 

// 1. X/Y-Axis 
bluetooth.write(45); //First X coordinate 
bluetooth.write(-33); //First Y coordinate 

// 2. X/Y-Axis 
bluetooth.write(45); //Second X coordinate 
bluetooth.write(-33); //Second Y coordinate 

// Buttons 
bluetooth.write(B10000001); // Second Byte (Buttons 1-8) 
bluetooth.write(B10000000); // Second Byte (Buttons 9-16) 

請注意,按鈕通過受控二進制值。