USB_Host_Shield_2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
le3dp_rptparser.cpp
Go to the documentation of this file.
1 #include "le3dp_rptparser.h"
2 
4  joyEvents(evt)
5 {}
6 
7 void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
8 {
9  bool match = true;
10 
11  // Checking if there are changes in report since the method was last called
12  for (uint8_t i=0; i<RPT_GAMEPAD_LEN; i++) {
13  if( buf[i] != oldPad[i] ) {
14  match = false;
15  break;
16  }
17  }
18  // Calling Game Pad event handler
19  if (!match && joyEvents) {
20  joyEvents->OnGamePadChanged((const GamePadEventData*)buf);
21 
22  for (uint8_t i=0; i<RPT_GAMEPAD_LEN; i++) oldPad[i] = buf[i];
23  }
24 }
25 
27 {
28  Serial.print("X: ");
29  PrintHex<uint16_t>(evt->x);
30  Serial.print(" Y: ");
31  PrintHex<uint16_t>(evt->y);
32  Serial.print(" Hat Switch: ");
33  PrintHex<uint8_t>(evt->hat);
34  Serial.print(" Twist: ");
35  PrintHex<uint8_t>(evt->twist);
36  Serial.print(" Slider: ");
37  PrintHex<uint8_t>(evt->slider);
38  Serial.print(" Buttons A: ");
39  PrintHex<uint8_t>(evt->buttons_a);
40  Serial.print(" Buttons B: ");
41  PrintHex<uint8_t>(evt->buttons_b);
42  Serial.println("");
43 }