arduino-libraries / Keyboard

GNU Lesser General Public License v3.0
223 stars 157 forks source link

In Italian Layout < and \ are swapped #72

Closed RobertoD91 closed 1 year ago

RobertoD91 commented 1 year ago

Hardware: The Atmega32u4 inside the WHID https://github.com/whid-injector/WHID

Software: Arduino IDE 1.8.19 Keyboard Library 1.0.4

Simple test program:

#include "Keyboard.h"

void setup() {
  Serial.begin(9600);
  Keyboard.begin(KeyboardLayout_it_IT);
}

void loop() {
  if (Serial.available() > 0) {
    char inChar = Serial.read();
    Serial.print("hai inviato: ");
    Serial.println(inChar);
    Keyboard.write(inChar);
  }
}

Issue: the character < is replaced with \ and viceversa also > is replaced with |and viceversa

Fix? edit the file in Documents/Arduino/libraries/Keyboard/src/KeyboardLayout_it_IT.cpp replacing 0x32 with 0x35 and viceversa

I don't have another hardware for testing, i don't know if the problem is in the library or in the WHID.

edgar-bonet commented 1 year ago

I cannot reproduce the issue.

First of all, I must admit that I wrote this layout file without having ever touche an Italian keyboard. That being said, all the sources I found online (e.g. 1, 2, 3, 4, 5) agree on this:

Is that the case with the keyboard you are using?

I tried your test program, after setting my keyboard layout to Italian (as known by my Ubuntu OS). When I type <, >, \ and |, I do get the same characters echoed back by my Micro.

edgar-bonet commented 1 year ago

Here is a minimal test program:

#include <Keyboard.h>

void setup() {
    Keyboard.begin(KeyboardLayout_it_IT);
    delay(5000);
    Keyboard.print("<>\\|");
}

void loop() {}

I tried it on my Micro, while setting my keyboard layout at the OS level to either Italian or English (US). Here is what the Micro typed into my text editor, as a function of the OS keyboard setting:

@RobertoD91: Could you try this on your device?

@everybody: Could some one who does use an Italian keyboard try it?

RobertoD91 commented 1 year ago

@RobertoD91: Could you try this on your device?

Sure, tested with WHID, with unmodified Keyboard library 1.0.4 :

Ita: \|<> Eng (US): §±`~

I found an old Arduino Yun, tested the same code, same issues.

RobertoD91 commented 1 year ago

Sorry, my fault. I had accidentally set the keyboard as ANSI instead of ISO on all my computer (it wasn't a system-wide setting).

The library is ok, tested with WHID and Arduino Yun.

Sorry