You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Based on the Java IDE: https://github.com/arduino/Arduino/blob/43b0818f7fa8073301db1b80ac832b7b7596b828/arduino-core/src/cc/arduino/Compiler.java#L528-L578
"'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?"
),
},
"'Keyboard' was not declared in this scope": {
error: nls.localize(
'arduino/cli-error-parser/keyboardError',
"'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?"
),
},
};
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:
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.
Describe the request
Evaluate the often irrelevant supplemental interpretations the Arduino IDE provides on Keyboard and Mouse library-related compilation errors.
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:After the change, it was necessary to add an
#include
directive for the appropriate header file:Attempting to compile the previously valid code results in an error:
These supplemental interpretations are also displayed by the Arduino IDE:
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.
Arduino IDE version
2.0.0-rc8-snapshot-34ef25c
Operating system
Windows
Operating system version
10
Additional context
Related: #1113
Issue checklist
The text was updated successfully, but these errors were encountered: