Mouse.h and MouseController.h don't compile together

Edit: I have debugged for a bit longer and realized that I didn't provide enough information in the code. So here is the updated Version. My mistake.

For some reason I can't compile my project when I try to use Mouse.h's methods when MouseController.h is included. Code is relevant, I have tested it, and the error code is still the same.

#include <Mouse.h>
#include <MouseController.h>

void setup()
{
  Serial.begin(115200);
  Mouse.begin();
}

void loop()
{
}
C:\Users\user\Documents\Arduino\sketches\project\project.ino: In function 'void setup()':
C:\Users\user\Documents\Arduino\sketches\project\project.ino:6:3: error: 'Mouse' was not declared in this scope
   Mouse.begin();
   ^

exit status 1

Compilation error: 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?

Also the error message changes if you declare either Mouse.h first or second, here is the alternative

n file included from C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hidboot.h:24:0,
                 from C:\Users\loren\Documents\Arduino\libraries\USBHost\src/MouseController.h:22,
                 from C:\Users\loren\Documents\Arduino\sketches\project\project.ino:2:
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hid.h:156:21: error: 'HID' is not a type
  virtual void Parse(HID *hid, bool is_rpt_id, uint32_t len, uint8_t *buf) = 0;
                     ^
In file included from C:\Users\loren\Documents\Arduino\libraries\USBHost\src/MouseController.h:22:0,
                 from C:\Users\loren\Documents\Arduino\sketches\project\project.ino:2:
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hidboot.h:62:21: error: 'HID' is not a type
  virtual void Parse(HID *hid, bool is_rpt_id, uint32_t len, uint8_t *buf);
                     ^
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hidboot.h:160:21: error: 'HID' is not a type
  virtual void Parse(HID *hid, bool is_rpt_id, uint32_t len, uint8_t *buf);
                     ^
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hidboot.h:163:28: error: 'HID' is not a type
  uint8_t HandleLockingKeys(HID* hid, uint8_t key);
                            ^
In file included from C:\Users\loren\Documents\Arduino\libraries\USBHost\src/MouseController.h:22:0,
                 from C:\Users\loren\Documents\Arduino\sketches\project\project.ino:2:
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual uint32_t HIDBoot<BOOT_PROTOCOL>::Poll()':
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hidboot.h:547:56: error: no matching function for call to 'HIDReportParser::Parse(HID*, int, uint32_t, uint8_t [16])'
    pRptParser->Parse((HID*)this, 0, (uint32_t)read, buf);
                                                        ^
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hidboot.h:547:56: note: candidate is:
In file included from C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hidboot.h:24:0,
                 from C:\Users\loren\Documents\Arduino\libraries\USBHost\src/MouseController.h:22,
                 from C:\Users\loren\Documents\Arduino\sketches\project\project.ino:2:
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hid.h:156:15: note: virtual void HIDReportParser::Parse(int*, bool, uint32_t, uint8_t*)
  virtual void Parse(HID *hid, bool is_rpt_id, uint32_t len, uint8_t *buf) = 0;
               ^
C:\Users\loren\Documents\Arduino\libraries\USBHost\src/hid.h:156:15: note:   no known conversion for argument 1 from 'HID*' to 'int*'

exit status 1

Compilation error: exit status 1

I'm really sorry I made some mistakes when first debugging my project and gave the wrong information, I had everything set up properly but didn't realize two of my libraries were somehow incompatible. Or at least didn't like each other when compiling

Hi @tchinka. Which board do you have selected from the Tools > Board menu in Arduino IDE?

Far outside my comfort zone but I would like to address below; don't feel bad.

I don't seem to be able to find for which board you're trying to compile so that's also missing :wink: MouseController indicates either a host shield or a board that can act like a USB host; can you shine some light on that?

@ptillisch @sterretje yes, I have been using the Arduino Due, in my IDE I have it set to Arduino Due (Programing Port) so as far as I'm concerned it should compile.

I am also using 2.3.2, did you try it with the updated code with the library I forgot to mention?

Here is a more minimal demonstration sketch:

#include <HID.h>  // Platform bundled HID library
#include <MouseController.h>  // USBHost library
void setup() {}
void loop() {}

There is a name collision between this:

and this:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.