[SOLVED] V-USB Arduino Library not working on new version of IDE

Hello,
I downloaded the V-USB library for arduino from here that a guy that made this tutorial wrote a few years ago. It’s supposed to work with newer IDEs but the guy has abandoned the project since 2010. I had several errors while compiling a blank project with just loading the library. I managed to fix half of them by replacing all variables on the library .h files with constants (adding a const in fron of the declaration) because for some reason the new compiler needs that. Now it gives me an error that a function that the library code calls is not declared (the actuall function exists… it is called on the file UsbKeyboard.h but is written on the usbdrv.h that IS included on the UsbKeyboard.h one). This is the error I’m getting:

In file included from C:\Users\frank\Documents\Arduino\sketch_may14a\sketch_may14a.ino:5:0:

C:\Program Files (x86)\Arduino\libraries\UsbKeyboard/UsbKeyboard.h: In constructor ‘UsbKeyboardDevice::UsbKeyboardDevice()’:

C:\Program Files (x86)\Arduino\libraries\UsbKeyboard/UsbKeyboard.h:146:55: error: ‘usbSetInterrupt’ was not declared in this scope

usbSetInterrupt(reportBuffer, sizeof(reportBuffer));

^

C:\Program Files (x86)\Arduino\libraries\UsbKeyboard/UsbKeyboard.h: In member function ‘void UsbKeyboardDevice::sendKeyStroke(byte, byte)’:

C:\Program Files (x86)\Arduino\libraries\UsbKeyboard/UsbKeyboard.h:159:33: error: ‘usbInterruptIsReady’ was not declared in this scope

while (!usbInterruptIsReady()) {

^

C:\Program Files (x86)\Arduino\libraries\UsbKeyboard/UsbKeyboard.h:170:55: error: ‘usbSetInterrupt’ was not declared in this scope

usbSetInterrupt(reportBuffer, sizeof(reportBuffer));

^

C:\Program Files (x86)\Arduino\libraries\UsbKeyboard/UsbKeyboard.h:172:33: error: ‘usbInterruptIsReady’ was not declared in this scope

while (!usbInterruptIsReady()) {

^

exit status 1
Error compiling for board Arduino/Genuino Uno.

And this is my code (just inserted the library in a blank project):

#include <oddebug.h>
#include <usbconfig-prototype.h>
#include <usbconfig.h>
#include <usbdrv.h>
#include <UsbKeyboard.h>
#include <usbportability.h>


void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Solution:
The solution was very easy actually. You must not include the library from arduino ide Sketch>Include Library>UsbKeyboard but only write #include <UsbKeyboard.h> at the begining of the sketch. You do actually have to change every variable on the 2 .h files i mentioned to const!

vusb-for-arduino-005 Libraries.zip (347 KB)

If you go through the files mentioned in the errors and change any reference to 'PROGMEM' (without quotes) to 'const PROGMEM' it compiles okay on IDE 1.8.2 but this is no guarantee it will work. :confused:

Riva:
If you go through the files mentioned in the errors and change any reference to 'PROGMEM' (without quotes) to 'const PROGMEM' it compiles okay on IDE 1.8.2 but this is no guarantee it will work. :confused:

Thank you for the answer. I actually changed everything to const as I mentioned on my question. Adding a const in front of every 'PROGMEM' actually gave out duplicate const error. The error I'm getting is that a function is "not declared in this scope". It's weird that I'm getting this and you don't.