RawHID - 5 buttons mouse

Hi, I’m a beginner in Arduino and playing with Arduino Leonardo and USB Host Shield.

I have this code working with 3 buttons mouse.

 * USB Mouse pass through. Works at HID report level. HID report is not decoded.
 * Tested on Leonardo with Arduino USB host shield, IDE 1.8.5, and Logitech Marble
 * trackball/mouse. This is a proof of concept so is not guaranteed to work with 
 * all USB mice/trackballs.
// USB host mouse from USB Host Shield Library. Install using Library Manager
#include <hidboot.h>

// USB device mouse library included with Arduino IDE 1.8.5
#include <Mouse.h>

// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>

class MouseRptParser : public MouseReportParser
    void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);

void MouseRptParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
  // Show USB HID mouse report
  for (uint8_t i = 0; i < len ; i++) {
    Serial.print(' '); Serial.print(buf[i], HEX);

  // On error - return
  if (buf[2] == 1)

  if (len > 2) {
    uint8_t mouseRpt[4];
    mouseRpt[0] = buf[0];
    mouseRpt[1] = buf[1];
    mouseRpt[2] = buf[2];
    mouseRpt[3] = 0;

USB     Usb;

MouseRptParser Prs;

void setup()
  Serial.begin( 115200 );
#if !defined(__MIPSEL__)
  while (!Serial) delay(1); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection

  if (Usb.Init() == -1) {
    Serial.println("USB host shield did not start.");
  delay( 200 );

  HidMouse.SetReportParser(0, &Prs);


void loop()

How can I adapt to work with 5 buttons mouse, back and forward, and also the scroll?