Hello,
I'm working on optical sensor from a mouse. I plugged my mouse into USB shield. I want to have in my serial port shown dX, X , dy , Y. dx and dy is latest displacement and X and Y sum of it. I have the problem with the protected class. I cannot get this information from this class. I know that in C# I should use set and get contractors, but I don't know how to do it now. Bew is my code
#include <hidboot.h>
#include <usbhub.h>
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>
class MouseRptParser : public MouseReportParser
{
protected:
void OnMouseMove (MOUSEINFO *mi);
};
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
{
Serial.print("dx=");
Serial.print(mi ->dX, DEC);
Serial.print("X=");
Serial.print(" dy=");
Serial.println(mi ->dY, DEC);
Serial.print("Y=");
};
USB Usb;
USBHub Hub(&Usb);
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&Usb);
MouseRptParser Prs;
void setup()
{
global X,Y = 0;
Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial);
#endif
Serial.println("Start");
if (Usb.Init() == -1)
Serial.println("OSC did not start.");
delay( 200 );
HidMouse.SetReportParser(0, &Prs);
}
void loop()
{
Usb.Task();
}