Datasheet
Schematic
#include <M5Stack.h>
#include <SPI.h>
#include <Usb.h>
#include <hiduniversal.h>
#include <hidboot.h>
#include <usbhub.h>
#include "M5Mouse.h"
// new objects
USB Usb;
USBHub Hub(&Usb);
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&Usb);
MouseRptParser Prs;
// initialization
M5.begin();
Usb.Init();
HidMouse.SetReportParser(0,(HIDReportParser*)&Prs);
if(Usb.getUsbTaskState() == USB_STATE_RUNNING)
{
Mouse_Pointer(mou_px, mou_py);
mou_px = 0;
mou_py = 0;
/* left button pressed: draw white point */
if (mou_button == 1)
M5.Lcd.drawCircle(StaPotX, StaPotY, 1, WHITE);
/* right button pressed: draw green point */
if (mou_button == 2)
M5.Lcd.drawCircle(StaPotX, StaPotY, 1, GREEN);
/* middle button pressed: clear screen */
if (mou_button == 4)
M5.Lcd.fillScreen(BLACK);
}
M5Stack Docs
// handle event coming from usb device
Usb.Task();