HID icon indicating copy to clipboard operation
HID copied to clipboard

HID-Project.h on Pro Micro Leonardo: HID Project can only be used with an USB MCU.

Open codebeat-nl opened this issue 8 years ago • 7 comments

On Pro Micro (Leonardo):

#if !defined(USBCON)
#error HID Project can only be used with an USB MCU.
#endif

Strange error. Will triggered random using HID-Project in/with some other classes. Run the demo's and working fine without this error. So maybe this is not a reliable way to test capability? I removed this check and everything seems to work fine.

codebeat-nl avatar Jul 18 '17 11:07 codebeat-nl

I dont know which classes you use. Can you give me more information about this? Otherwise this seems invalid to me.

NicoHood avatar Jul 18 '17 18:07 NicoHood

If you try to compile (Target: Arduino Leonardo) this code (in zip format, unzip it to project folder):

https://drive.google.com/file/d/0B2l-eQoHefcVRE9LRS1wTHFocG8/view?usp=sharing

You will get the error. Maybe it is because I include the file in a class of mine? I use it as a part of my class. When I test for USBCON myself it is there, but when your code try to detect it, it is not there. Weird. I know the compiler can do sometimes strange things because of the build method that is used, it is not completely error free. I'm using Arduino 1.8.2. Or maybe there is another reason? Please let me know if you get the same error. Thanks for the help.

codebeat-nl avatar Jul 18 '17 20:07 codebeat-nl

I aint got time to try this out. I recommend the arduino irc chat on freenode. They can help you, they usually know my library. They possibly use it more than me. I am really sorry. If you ping me at a later date, I might have time to revisit all those newer issues and try them out myself. Sorry.

As a blind guess:

  • try to include Arduino.h in your file (before the HID.h)
  • Try to include HId.h in the arduino main sketch (if you havent yet)

NicoHood avatar Jul 18 '17 21:07 NicoHood

I got the same issue with the same library and the same board but using platformio to build. Commenting the 3 lines is a functional work around.

Following is the code which triggered it:

#include "HID-Project.h"

void setup() { BootKeyboard.begin(); }

void loop() {
  delay(1000);
  BootKeyboard.write(KEY_ENTER);
}

bricewge avatar Jul 18 '17 21:07 bricewge

I dont know what exactly problem did u have, but it helped,when i commented these lines in main .h file: //#include "SingleReport/RawHID.h" //#include "SingleReport/BootKeyboard.h" //#include "MultiReport/ImprovedKeyboard.h" //#include "SingleReport/SingleNKROKeyboard.h" //#include "MultiReport/NKROKeyboard.h"

JJablon avatar Jul 22 '17 00:07 JJablon

Actually, with platformio, including Arduino.h works for me. I should have thoroughly tested what @NicoHood proposed.

bricewge avatar Aug 04 '17 14:08 bricewge

Also had this issue with the arduino IDE using platformio seems to of fixed it 👍

johnfg2610 avatar Dec 18 '18 08:12 johnfg2610