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 Keygroups functions #669

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add Keygroups functions #669

wants to merge 3 commits into from

Conversation

jdlien
Copy link

@jdlien jdlien commented Jul 20, 2019

I have added a series of functions in keygroups.h that are useful for determining which of several logical groupings a particular key might be in. This was integral to the way FunctionalColors works, and I think it might be useful to other plugin developers. I tried to be quite exhausive in coming up with these groups to include as many keys as I could find defined in Kaleidoscope, but perhaps there are other international keys I missed or something.

The functions I have come up with are the following:
keygroups. I have pored over the key definitions in Kaleidoscope, and models of various keyboards to be comprehensive in coming up with groups that make sense. (It turns out that there are a lot of media keys, but I only added the fairly common ones.)

Keygroups is integral to the way FunctionalColors works, as my intended use was to color keys of various types/groups differently, but not typically each individual key.

The functions I have come up with are the following

  • isAlpha
  • isNumber
  • isPunctuation
  • isFunction
  • isNavigation
  • isArrow
  • isKeypad
  • isSystem
  • isMedia
  • isLang
  • isModifier
  • isShift
  • isControl
  • isGui
  • isAlt
  • isMouseMove
  • isMouseWheel
  • isMouseButton
  • isMouseWarp
  • isMouse
  • isMouseMove

Note that I have not created a separate namespace for these functions, so that may be a desirable change depending on how it fits with the current firmware design.

algernon and others added 3 commits July 9, 2019 12:28
The various keyboard plugins implemented a way to jump to the bootloader on
their own. However, this is a bootloader-specific functionality, and as such, it
makes sense to have a common implementation.

This patch does just that.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Keygroups.h has been added to offer functions that allow determining if a given key is in a certain group.

Signed-off-by: JD Lien <jd@jdlien.com>
Signed-off-by: JD Lien <jd@jdlien.com>
@jdlien
Copy link
Author

jdlien commented Jul 20, 2019

I'm not sure why I'm getting Travis build errors - probably some kind of scope or namespace issue.

Kaleidoscope/src/kaleidoscope/key_events.h:75:42: error: 'KeyAddr' has not been declared"

and so on.

@obra
Copy link
Member

obra commented Jul 25, 2019

Have you given thought to how this interacts with non-US-ANSI key layouts? You're going to run into situations where a key that's an alphanumeric key in a US-ANSI layout is punctuation in a non-US layout and vice-versa.

@jdlien
Copy link
Author

jdlien commented Jul 25, 2019

Yes, I have considered this somewhat, although I have limited exposure to such layouts. For example I am taking the Brazilian forward slash/question mark key and the language keys used in Japanese keyboards. Mostly these come from references to such keys in Kaleidoscope itself. I tried to be thorough.

I’d love more input from international users who use very different layouts.

@jdlien
Copy link
Author

jdlien commented Jul 25, 2019

Do you have specific examples of where a key gets remapped to a different kind of key? (Or can you point to a reference for these cases?) If there are cases where, for instance, letter keys get mapped to punctuation symbols or something, I suppose there could be an optional argument to specify a translation mode or something.

@obra
Copy link
Member

obra commented Jul 26, 2019 via email

@jdlien
Copy link
Author

jdlien commented Jul 26, 2019

Well... I'm using the key names assigned by Keyboardio for this. If you define a Dvorak layout in firmware using the appropriate key names, this should work, correct? But if you define a normal QWERTY layout and let the OS remap everything, then that's when semicolon gets changed to S, etc, right?

In that case it seems reasonable to rely on the key names... because how would you know if the OS has remapped a bunch of scan codes? I guess you'd have to make a different version of keygroups for each layout (or possibly pass a parameter that will adjust it appropriately). That sounds very hard to create and maintain for every possible remapping scheme.

@obra
Copy link
Member

obra commented Jul 26, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants