Description
Describe the request
Evaluate the often irrelevant supplemental interpretations the Arduino IDE provides on Keyboard and Mouse library-related compilation errors.
- Can false interpretations be reduced?
- Can the interpretation message be adjusted to avoid confusion in the event of false positives?
- Should the interpretations be removed altogether?
Describe the current behavior
The Arduino IDE attempts to provide some additional guidance to users in response to some specific compilation error messages:
arduino-ide/arduino-ide-extension/src/node/cli-error-parser.ts
Lines 134 to 164 in 34ef25c
This is accomplished by matching a subset of the error message produced by the compilation toolchain and then printing an additional message in a notification and to the "Output" panel. That message is intended to make the cause and resolution for the error easier for less advanced users to understand.
Two such interpretations were put in place at the time of a breaking change 7 years ago resulting from moving the popular keyboard and mouse emulation APIs out of the core to standalone libraries: arduino/Arduino#3304
Prior to the change, the APIs could be used without adding an extra #include
directive to the sketch:
void setup() {
Keyboard.begin();
Keyboard.print("hello");
}
void loop() {}
After the change, it was necessary to add an #include
directive for the appropriate header file:
#include <Keyboard.h>
void setup() {
Keyboard.begin();
Keyboard.print("hello");
}
void loop() {}
Attempting to compile the previously valid code results in an error:
C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved2022528-3144-18az9y0.lofa\sketch_jun28a\sketch_jun28a.ino: In function 'void setup()':
C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved2022528-3144-18az9y0.lofa\sketch_jun28a\sketch_jun28a.ino:2:3: error: 'Keyboard' was not declared in this scope
Keyboard.begin();
^~~~~~~~
exit status 1
These supplemental interpretations are also displayed by the Arduino IDE:
'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Arduino and the Arduino community have done a good job of adapting to the change and it is now very rare to find any legacy code without these #include
directives. There is always the chance a user will forget to add an #include
directive in a sketch they write from scratch, but that is just as likely to occur with any arbitrary header file, so does not justify giving these two special treatment.
Meanwhile, another mistake related to keyboard and mouse emulation code is just as prevalent as ever: attempting to use it with a board which does not have native USB support (e.g., Uno, Mega). Unfortunately, doing this produces the same compilation error as omitting the #include
directive, which also triggers the interpretations. In this case the interpretation message is completely irrelevant because the user already has that #include
directive in their sketch and the error is caused by something completely different.
🙁 The interpretation message increases confusion in the cases where it is irrelevant. The cases where it is relevant are increasingly rare as time goes on.
- https://forum.arduino.cc/t/what-is-wrong-here/1080550
- https://forum.arduino.cc/t/issue-on-keyboard-library/1065385
- https://forum.arduino.cc/t/sketch-funktioniert-nicht-keyboard/1099364
- https://forum.arduino.cc/t/missing-keyboard-h/1059440
- https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/679287
- https://forum.arduino.cc/t/keyboard-not-found-does-your-sketch-include-the-line-include-keyboard-h/647842
- https://forum.arduino.cc/t/need-help-in-joystick-wasd-keyboard-keys/877912
- https://forum.arduino.cc/t/trying-to-build-alternative-computer-mouse-but-getting-nothing-but-errors/888471
- https://forum.arduino.cc/t/keyboard-h-header-is-not-working/656172
- https://forum.arduino.cc/t/i-have-the-library-on-the-code-but-it-keeps-asking-me-to-add-it/680602
- https://forum.arduino.cc/t/keyboard-h-not-working/934817
- https://forum.arduino.cc/t/old-lady-needs-a-hand-uno-clone/981702
- https://forum.arduino.cc/t/library-included-but-not-found/690756
- https://forum.arduino.cc/t/fehler-bei-keyboard-h/876342
- https://forum.arduino.cc/t/mouse-begin-not-working/676720/9
- https://forum.arduino.cc/t/another-newb-issue/674351
- https://forum.arduino.cc/t/emulation-dun-clavier-pour-une-arduino-mega-keyboard-emulation-for-an-mega/645375
- https://forum.arduino.cc/t/problem-with-nextion/622119
- https://forum.arduino.cc/t/keyboard-key-codes/287528/4
- https://forum.arduino.cc/t/outputting-keys-to-the-computer/427496
- https://forum.arduino.cc/t/makey-makey-source-code-troubles/422137/2
- https://forum.arduino.cc/t/keyboard-not-found-trying-to-clarify/536713
- https://forum.arduino.cc/t/issues-with-uploading-sketch/528862
- https://forum.arduino.cc/t/file-examples-usb-keyboard-keyboardmessage-not-work-this-example/422238/3
- https://forum.arduino.cc/t/trying-to-make-an-arduino-2-keys-keyboard-but-error-pops-up/499126
- https://forum.arduino.cc/t/library-not-found/503525
- https://forum.arduino.cc/t/library-not-working/491054/3
- https://forum.arduino.cc/t/library-error-keyboard-not-found-when-include-keyboard-h-is-included/629788
- https://forum.arduino.cc/t/problems-including-mouse-h/349502
- https://forum.arduino.cc/t/help-with-keyboard-h/551912
- https://forum.arduino.cc/t/arduino-uno-6-1-exscercise/571440
- https://forum.arduino.cc/t/controlling-a-computer-mouse-with-an-arduino-uno-not-working-mouse-h/588081
- https://forum.arduino.cc/t/key-mapping/402444
- https://forum.arduino.cc/t/arduino-nano-keyboard-h-problem/422820
- https://forum.arduino.cc/t/include-library-problem/469783
- https://forum.arduino.cc/t/cant-seem-to-be-able-use-keyboard-h-library/333667/5
- https://forum.arduino.cc/t/error-with-keyboard-library/421403
- https://forum.arduino.cc/t/compiling-example-programs/557209
- https://forum.arduino.cc/t/need-some-help-sending-commands-through-serial-without-a-keyboard/613920/8
- https://forum.arduino.cc/t/keyboard-library-not-working/362325
- https://forum.arduino.cc/t/new-to-this-using-copied-code-getting-errors/488587/27
- https://forum.arduino.cc/t/help-with-mouse-library/574057
- https://forum.arduino.cc/t/keyboard-library-not-working-correctly/583389
- https://forum.arduino.cc/t/arduino-keyboard-library-problem/546147
- https://forum.arduino.cc/t/keyboard-not-found-using-due/545296
- https://forum.arduino.cc/t/unknown-error-for-compiling-my-code-onto-my-arduino-genuino-uno/509186/2
- https://forum.arduino.cc/t/why-is-keyboard-h-library-not-working-on-arduino-uno/472447
- https://forum.arduino.cc/t/keyboard-not-found-on-usb-hid-capable-arduino-uno/450644
- https://forum.arduino.cc/t/keyboard-h-not-supported/427642
- https://forum.arduino.cc/t/compiling-error-doesnt-think-im-including-libraries-that-i-am/378743
- https://forum.arduino.cc/t/arduino-doesnt-seem-to-notice-that-i-have-already-imported-the-library/1008502
- https://forum.arduino.cc/t/keyboard-library-not-being-included/1043892
- https://forum.arduino.cc/t/keyboard-not-found-have-you-included-keyboard-h-in-your-sketch-arduino-uno/1096544
- https://forum.arduino.cc/t/i-have-the-library-installed-but-it-asks-me-to-use-include/1144083
- https://forum.arduino.cc/t/arduino-nano-is-not-working-with-programing/1153085
- https://forum.arduino.cc/t/no-me-reconoce-la-libreria-keyboar-el-arduino-ide/1168346
- https://forum.arduino.cc/t/mouse-not-found-does-your-sketch-include-the-line-include-mouse-h/1184592
- https://forum.arduino.cc/t/keyboard-h-not-found/1250139
- https://forum.arduino.cc/t/does-your-sketch-include-the-line-include-libname/1264530
- https://forum.arduino.cc/t/problem-whit-using-keyboard-library/1278549
- "Keyboard not found, Does your sketch include the line #include <Keyboard.h>" arduino-libraries/Keyboard#39
- I've loaded the library file for Ridkey.h, but it still gets an error. reference-en#802
Arduino IDE version
2.0.0-rc8-snapshot-34ef25c
Operating system
Windows
Operating system version
10
Additional context
Related: #1113
Issue checklist
- I searched for previous requests in the issue tracker
- I verified the feature was still missing when using the latest nightly build
- My request contains all necessary details