File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
hardware/arduino/cores/arduino Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -435,7 +435,7 @@ size_t Keyboard_::press(uint8_t k)
435
435
setWriteError ();
436
436
return 0 ;
437
437
}
438
- if (k & 0x80 ) {
438
+ if (k & 0x80 ) { // it's a capital letter or other character reached with shift
439
439
_keyReport.modifiers |= 0x02 ; // the left shift modifier
440
440
k &= 0x7F ;
441
441
}
@@ -478,22 +478,20 @@ size_t Keyboard_::release(uint8_t k)
478
478
if (!k) {
479
479
return 0 ;
480
480
}
481
- if (k & 0x80 ) {
481
+ if (k & 0x80 ) { // it's a capital letter or other character reached with shift
482
482
_keyReport.modifiers &= ~(0x02 ); // the left shift modifier
483
483
k &= 0x7F ;
484
484
}
485
485
}
486
486
487
487
// Test the key report to see if k is present. Clear it if it exists.
488
+ // Check all positions in case the key is present more than once (which it shouldn't be)
488
489
for (i=0 ; i<6 ; i++) {
489
- if (_keyReport.keys [i] == k) {
490
+ if (0 != k && _keyReport.keys [i] == k) {
490
491
_keyReport.keys [i] = 0x00 ;
491
- break ;
492
492
}
493
493
}
494
- if (i == 6 ) {
495
- return 0 ;
496
- }
494
+
497
495
sendReport (&_keyReport);
498
496
return 1 ;
499
497
}
@@ -514,7 +512,7 @@ size_t Keyboard_::write(uint8_t c)
514
512
{
515
513
uint8_t p = press (c); // Keydown
516
514
uint8_t r = release (c); // Keyup
517
- return (p&r);
515
+ return (p); // just return the result of press() since release() almost always returns 1
518
516
}
519
517
520
518
#endif
You can’t perform that action at this time.
0 commit comments