rust-embedded-community / pc-keyboard

PS/2 Keyboard Decoder in Rust
Apache License 2.0
99 stars 28 forks source link

Add JIS(109-key) layout support and fix usage code in README.md #5

Closed mopisec closed 5 years ago

mopisec commented 5 years ago

Supporting JIS keyboard layout. Sorry, this is first time of sending pull request for me. And also my English is bad. :( Many developers (mostly students) are learning about OS and Rust based on "Writing an OS in Rust" project which uses this crate in my country Japan. And lots of them were confused about difference in keyboard layout. So I tried to implement JIS keyboard layout which is commonly used in our country. (If there is problem, please let me know!! I will try to fix it!!!)

mopisec commented 5 years ago

I knew that there was also wrong code in README.md, so I want to also pull request this commit. Wrong ) HandleControlPlusLetter Correct ) HandleControl Wrong ) HandleControlPlusLetter::MapToUnicode Correct ) HandleControl::MapLettersToUnicode

mopisec commented 5 years ago

I've just fixed few keys that wasn't on the right positions. (Now it's all good.)

thejpster commented 5 years ago

Hi! Thank you so much for this. I don't think I've ever even seen a JIS layout keyboard, so I'll have to take your word for it if you say it's correct!

With three layouts the file was starting to get a bit large, so if you see the jis_support branch I've just created, I've moved each layout into its own module. What would be really helpful for me is if you could determine how similar the JIS layout is to the US104 layout and if over half the keys are the same, perhaps you could do something like I've done for the UK layout where the 'different' keys are handled first, and for anything else it just defaults to the US layout. This will help keep the code size down and avoid duplication. It would also make it easier for you to support the handle_ctrl argument (which makes it so that pressing Control + C generates an ASCII 0x03, and likewise for Control + A all the way to Control + Z) because I think the JIS layout is just QWERTY for the roman letter keys, and therefore matches the US and UK layouts.

As an aside, would you expect a JIS keyboard driver to support hiragana input, or is that something best left to an application?

mopisec commented 5 years ago

Thank you so much for your reply!! I have just shortened layout.rs, and applied changes in jis_support branch. (There was small mistake in uk105.rs, so I've just fixed that one too.) I would expect that we can left hiragana input to application. Because most people aren't using hiragana input on JIS keyboards these days, and it will make code size very large.

thejpster commented 5 years ago

Nice