So I'm trying to upload this demo sketch to my Arduino Uno R3 to simulate a mouse driver that I found here: http://hunt.net.nz/users/darran/weblog/cca39/Arduino_UNO_Mouse_HID.html
Originally, I was able to upload the sketch just fine, and flashed it to imitate a USB Mouse Driver and the program ran just fine (meaning the mouse cursor was moving in a square pattern). I wanted to slightly tweak the code to possibly make it move in a slightly bigger square pattern so I flashed it back to the original firmware. Now, after updating the code, I'm getting this error called "unexpected token: struct" whenever I attempt to compile it. I have no idea what I did wrong since I'm using the same software as before, and the board runs the blink program just fine when I test the board.
/* Arduino USB Mouse HID demo */
/* Author: Darran Hunt
* Release into the public domain.
*/
struct {
uint8_t buttons;
int8_t x;
int8_t y;
int8_t wheel; /* Not yet implemented */
} mouseReport;
uint8_t nullReport[4] = { 0, 0, 0, 0 };
void setup();
void loop();
void setup()
{
Serial.begin(9600);
delay(200);
}
/* Move the mouse in a clockwise square every 5 seconds */
void loop()
{
int ind;
delay(5000);
mouseReport.buttons = 0;
mouseReport.x = 0;
mouseReport.y = 0;
mouseReport.wheel = 0;
mouseReport.x = -5;
for (ind=0; ind<20; ind++) {
Serial.write((uint8_t *)&mouseReport, 4);
Serial.write((uint8_t *)&nullReport, 4);
}
mouseReport.x = 0;
mouseReport.y = -5;
for (ind=0; ind<20; ind++) {
Serial.write((uint8_t *)&mouseReport, 4);
Serial.write((uint8_t *)&nullReport, 4);
}
mouseReport.x = 5;
mouseReport.y = 0;
for (ind=0; ind<20; ind++) {
Serial.write((uint8_t *)&mouseReport, 4);
Serial.write((uint8_t *)&nullReport, 4);
}
mouseReport.x = 0;
mouseReport.y = 5;
for (ind=0; ind<20; ind++) {
Serial.write((uint8_t *)&mouseReport, 4);
Serial.write((uint8_t *)&nullReport, 4);
}
}
The only error I get when I attempt to compile is "unexpected token: struct" and it highlights the struct function. No other detail is shown.
I read somewhere that the update to the software may have caused an error to old programs, but since I was able to run this just fine at my first attempt without an issues using processing-2.0b6, I don't think it's the software. I assume I probably uploaded the wrong firmware but under device manager, it reads as Arduino Uno R3, so I'm a bit stumped at the moment. Any help and/or guidance would be appriaciated, thanks!