Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Turkish keymap aliases and sendstring LUT #7676

Merged
merged 2 commits into from
Feb 21, 2020

Conversation

fauxpark
Copy link
Member

Description

@Ardakilic here you go, please test this :)

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@fauxpark fauxpark requested a review from a team December 19, 2019 09:27
@Ardakilic
Copy link
Contributor

Ardakilic commented Dec 19, 2019

Hey there, awesome! Thanks @fauxpark

I'll test the keys for keymap_turkish.h this evening, also to test the sendstring_turkish.h, would a macro that types

SEND_STRING("Turkish special chars along with some other strings etc.");

and checking the output suffice? Or are there proper methods which I'm not yet aware of ?

Thanks again for the awesome job!

@ergenekonyigit
Copy link

🤘

@drashna
Copy link
Member

drashna commented Dec 19, 2019

@Ardakilic That would be the best way to test that out, yeah.

@fauxpark
Copy link
Member Author

fauxpark commented Dec 19, 2019

Unfortunately the sendstring LUT, by its nature, only addresses ASCII characters. If you need to type Ğ you have to use tap_code(TR_GBRV). Sorry :(

And of course, this will only work if you have the Turkish input layout set in your OS.

@Ardakilic
Copy link
Contributor

Also pinging @bbaserdem here. Although I don't know him personally, he's the first person I stumbled upon while checking Turkish layout for ortholinear keyboards.

@bbaserdem
Copy link
Contributor

Thanks for pinging me, this is nice feature to add. I would also translate to turkish F layout (Instead of the TR_ prefix, maybe use TQ for turkish q prefix? Then we can include a TF prefix for turkish f?)

From what I understand, the sendkeys function only sends keycodes, not unicode sequences. (which would also increase string type time by 5 which is undesirable.) So as @fauxpark stated, the only way to accomplish would be to detect non-ascii characters in string and send them with their specific modifiers. Sendkeys already does this with capital letters and shift, so it should not be too difficult to do. (I would do it cause I am working on my own keymap right now.)

For the record, my implementation was; I wrote some custom keycodes that detected if shift was pressed, and sent the correct case of the turkish letter unicode sequences. But I abandoned that implementation since the unicode is dependent on the us qwerty layout. Correct me if I am wrong. Currently the only thing I do for turkish layout is include some other keys in my planck layout so if i switch to F on software keymap, I have access to all letters. (But planck is too small for all the turkish letters so I seldom do this)

@Ardakilic
Copy link
Contributor

@fauxpark @drashna All I have to do is compile like I do, and these will be included into the compiled firmware, right? Do I have to add anything else to my keyboard files ?

@bbaserdem These keycodes and maps are useful only when you've set Turkish as your OS's language. Aside from that, I do similar approach (E.g: In my handwired 40%, for Ğ and Ü keys, I use raise button + L and ;/Ş respectively which feels right for me), because I'm still using Turkish as input language, and I possibly would to a similar approach if I ever switched to US layout.

@fauxpark
Copy link
Member Author

@Ardakilic you also have to #include "keymap_turkish.h" at the top of your keymap and use the keycodes defined in there instead, but yes, essentially. And to use the sendstring LUT you'd need to just #include "sendstring_turkish.h" as well.

@bbaserdem I don't think it will be that easy to get Unicode sendstring working, due to the sheer number of characters that then must be mapped - probably it will not fit on a 32U4. But if you have an idea, do share it :)

@bbaserdem
Copy link
Contributor

bbaserdem commented Dec 19, 2019

@fauxpark, unicode sendstring method does not work with non-us layouts, at least not on linux. My usecase is I use xkbmap on linux to set my keyboard layout to us-dvorak, and switch between turkish-f and us-q, and have ibus for unicode and emoji. Since my default layout is dvorak, the unicode methods' send string is converted to different letters by libinput, and the hex code is garbled. I have not found any way to ignore xkb keymap in ibus input so I have abandoned using unicode keys. I find that besides these edge cases, I don't find any use in it.

The only non-ascii letters in a turkish string should be ğĞüÜşŞöÖçÇâÂıİ. It should not be hard to come up with exceptions for these 14. Or a better would be to rewrite a copy of the send_keys function that takes in a utf string array as opposed to a char array, and does the same thing as the send_keys function. I find the declaration line here. I never dealt with utf on C before though.

I just checked and TF is not associated with any other language abbreviation. TF_* keycodes can be used to also do a turkish f keyboard database. I do not know how to add suggestions to your pull request, but I can submit it along with my upcoming update to my userspace code.

@fauxpark
Copy link
Member Author

The issue here is that Unicode characters are multiple bytes, and the sendstring LUTs operate only on single bytes. Here's an example SEND_STRING():
image
And here's what the resulting firmware looks like in a hex editor:
image

The Ğ character is encoded into the bytes C4 9E: https://en.wikipedia.org/wiki/%C4%9E#Character_encoding
You would need to have a function that detects and transforms these bytes into their Unicode codepoints to send off to the Unicode send function - so this would be more suited for the Unicode feature TBH.

Additionally, my earlier statement that the LUT could be extended was wrong. Ç, the next character in the "extended ASCII" table, is encoded into C3 87... because we're dealing with UTF-8 here. The reason these 128 character tables work is because backward compatibility with ASCII is part of the design of UTF-8.

@bbaserdem
Copy link
Contributor

Checking these strings;

All the first bytes in UTF are C3 or C4. They could be treated as edge cases; since they do not correspond to keycodes as far as I see? Correct me if I am wrong but the send_string_with_delay_p function reads multiple characters for the edge cases. And the send-off does not need to be unicode strings, it can just be keypresses with modifiers activated. (Obviously the implementation would be dependent on the F or Q layouts being used.) I can take a stab at trying it out this weekend. (I think if this request follows through, I can bring my master branch up to date with upstream, and then edit the existing code. I don't think I can submit an amendment to this request since I am not a maintainer, I'm still trying to get the hang of using git and github.)

People would have to specifically work with UTF-8 on their respective code editors, but that should not be a problem.

(My programming skills with C is pretty low; if I am saying something really stupid I thank you for your patience.)

@Ardakilic
Copy link
Contributor

I say it's good to merge. Turkish characters such as Ğ ğ etc. on macros don't work, but for the time being, as mentioned, tap_code is a workaround and works.

@fauxpark
Copy link
Member Author

Added the Turkish F keymap and sendstring LUT.

@bbaserdem I did some Googling and it appears to be fairly trivial to extract codepoints from a stream of UTF-8 bytes, so there is possibly a pathway there to have a sendstring-like function that works with UTF-8 string literals (cf. send_unicode_hex_string()). As I mentioned earlier though, it would have to be part of the Unicode feature, leaving the existing sendstring function as a purely ASCII implementation.

@bbaserdem
Copy link
Contributor

bbaserdem commented Dec 22, 2019

Yes, I agree that it is out of scope with the sendstring functions we have currently. I don't know if there is any merit to code for it; as I certainly would not use it.

I looked at your keymaps, and it is different than my f layout that I was planning on submitting after your fork got pulled in.. I found no dead-keys on the alt-gr, and some symbols have different locations. All the dead keys are on altgr + shift. I am using the Xorg implementation (on arch linux, and using setxkbmap)

% setxkbmap -query
rules:      evdev
model:      pc105
layout:     us,tr,us
variant:    dvorak,f,
options:    grp:caps_toggle

@fauxpark
Copy link
Member Author

This is how it is on Windows:
altgr
saltgr
macOS has yet another set of mappings for the AltGr keys. I don't know whether keyboard layouts on Linux are consistent across all distros, if not I think it may not be worth trying to get them all. For now we only "support" Windows and a handful of layouts for macOS (Italian, French, German mainly).

@fauxpark fauxpark requested a review from a team January 20, 2020 07:11
@fauxpark fauxpark merged commit 562482c into qmk:master Feb 21, 2020
@fauxpark fauxpark deleted the turkish-keymap-sendstring branch February 21, 2020 07:21
@Ardakilic
Copy link
Contributor

Awesome, thanks again for all the reviews and the merge 🎉

nesth pushed a commit to nesth/qmk_firmware that referenced this pull request Feb 21, 2020
* upstream/master: (330 commits)
  Add Danish keymap and sendstring LUT (qmk#8218)
  format code according to conventions [skip ci]
  uart.c fix from TMK (qmk#7628)
  S75 Encoder Fixes (qmk#7758)
  Add Turkish keymap aliases and sendstring LUT (qmk#7676)
  Add Arm Teensys to mcu_selection.mk (qmk#8026)
  [New keyboard]silverbullet44 (qmk#7950)
  Allow 30us matrix delay to be keyboard/user overridable  (qmk#8216)
  Merge /prime_l and /prime_l_v2 (qmk#8194)
  [Keymap] Keymap for XD75 with 7U spacebar EN-RU gamers (qmk#8184)
  Add VIA support for kbd8x mk2 (qmk#8168)
  Move Grave/Tilde and some lesser used keys on my ergo boards (qmk#8200)
  [Keyboard] KC60SE cleanup (qmk#8171)
  Made windows driver installation accept y as All to allow CI (qmk#8189)
  Change the image photo of /keyboards/reviung41/readme.md (qmk#8195)
  MxSS RGB Handler Touchup (qmk#8105)
  Centromere Configurator layout support and readme update (qmk#8190)
  dynamic keymap sanity check (qmk#8181)
  [keyboard] Austin (qmk#8176)
  Use pathlib everywhere we can (qmk#7872)
  ...
sowbug pushed a commit to sowbug/qmk_firmware that referenced this pull request Feb 23, 2020
* Add Turkish keymap aliases and sendstring LUT

* Split into F and Q layouts
nesth pushed a commit to nesth/qmk_firmware that referenced this pull request Feb 27, 2020
* 'master' of https://github.com/nesth/qmk_firmware: (331 commits)
  helix like crkbd
  Add Danish keymap and sendstring LUT (qmk#8218)
  format code according to conventions [skip ci]
  uart.c fix from TMK (qmk#7628)
  S75 Encoder Fixes (qmk#7758)
  Add Turkish keymap aliases and sendstring LUT (qmk#7676)
  Add Arm Teensys to mcu_selection.mk (qmk#8026)
  [New keyboard]silverbullet44 (qmk#7950)
  Allow 30us matrix delay to be keyboard/user overridable  (qmk#8216)
  Merge /prime_l and /prime_l_v2 (qmk#8194)
  [Keymap] Keymap for XD75 with 7U spacebar EN-RU gamers (qmk#8184)
  Add VIA support for kbd8x mk2 (qmk#8168)
  Move Grave/Tilde and some lesser used keys on my ergo boards (qmk#8200)
  [Keyboard] KC60SE cleanup (qmk#8171)
  Made windows driver installation accept y as All to allow CI (qmk#8189)
  Change the image photo of /keyboards/reviung41/readme.md (qmk#8195)
  MxSS RGB Handler Touchup (qmk#8105)
  Centromere Configurator layout support and readme update (qmk#8190)
  dynamic keymap sanity check (qmk#8181)
  [keyboard] Austin (qmk#8176)
  ...
HokieGeek pushed a commit to HokieGeek/qmk_firmware that referenced this pull request Mar 5, 2020
* Add Turkish keymap aliases and sendstring LUT

* Split into F and Q layouts
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Mar 19, 2020
* Add Turkish keymap aliases and sendstring LUT

* Split into F and Q layouts
c0psrul3 pushed a commit to c0psrul3/qmk_firmware that referenced this pull request Mar 23, 2020
* Add Turkish keymap aliases and sendstring LUT

* Split into F and Q layouts
fdidron pushed a commit to zsa/qmk_firmware that referenced this pull request Mar 24, 2020
* Add Turkish keymap aliases and sendstring LUT

* Split into F and Q layouts
kylekuj pushed a commit to kylekuj/qmk_firmware that referenced this pull request Apr 21, 2020
* Add Turkish keymap aliases and sendstring LUT

* Split into F and Q layouts
jakeisnt pushed a commit to jakeisnt/qmk_firmware that referenced this pull request Aug 20, 2020
* Add Turkish keymap aliases and sendstring LUT

* Split into F and Q layouts
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
* Add Turkish keymap aliases and sendstring LUT

* Split into F and Q layouts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants