free5lot / hid-apple-patched

Allows to swap the Fn key and left Control key and other tweaks on Macbook Pro and Apple keyboards in GNU/Linux
GNU General Public License v2.0
349 stars 61 forks source link

Added possibility to use fn+hjkl as arrow keys #50

Open ermyril opened 5 years ago

ermyril commented 5 years ago

Hello! I highly doubt that it change will be approved, but I've struggled with it, and tried to find ways how to do it, and if mappings like caps+hkjl are possible via xmodmap (although I didn't really succeded with them, cuz it's conflicting with multiple keyboard layouts)

So I tried to hack this module to acquire that functionality, and now I'm so happy to have it on my machine.

That to be said, I'm not experienced in C and have only vague understanding of what's happening in this module, so I'm not aware of possible errors etc.

One thing that I've found is that it option is working even if fnmode setted to 0, not sure if it's good or not

Anyway, I think I can share it in case if someone will find it useful :)

free5lot commented 5 years ago

Wow, nice hack! I will leave this pull request open for a while, perhaps other people will also find it useful for themselves and provide additional feedback. In this case the pull request or the idea can be considered to be accepted. Thanks @shiasyn for sharing this trick.

ermyril commented 5 years ago

@free5lot, sure, thanks!

free5lot commented 4 years ago

Guys, we are waiting for anyone's second opinion on this feature...

vasilakisfil commented 4 years ago

That's super cool feature, thanks!

free5lot commented 4 years ago

@vasilakisfil does this PR it work for you? Does it work as you would expected it to?

vasilakisfil commented 4 years ago

@free5lot yes works as expected. @ermyril the PR should also update the README.

ermyril commented 4 years ago

@vasilakisfil, thans for your feedback, I'll update the README.

Although I've found a bug here, if fn is pressed after ohe of hjkl keys (hjkl should still be pressed when you push fn button) - it start repeating that (one of hjkl) keypress. I'll try to look at this at holidays

free5lot commented 4 years ago

@ermyril while fixing the issue you mentioned, please also think about possible issues with other hid-apple flags, the user can set any combination and I hope it won't break your PR.

vasilakisfil commented 4 years ago

I have been using that for some months now, haven't seen any issue. @free5lot did you figure out ?

free5lot commented 4 years ago

@vasilakisfil thanks for feedback on this PR. I believe @ermyril were planing to modify the PR for fixing issue they noticed themselves, were they not?

vasilakisfil commented 4 years ago

yes sorry, I meant to mention @ermyril.

ermyril commented 4 years ago

@free5lot, @vasilakisfil, sorry, I still didn't fixed those issues, still planning to do it though

free5lot commented 4 years ago

@ermyril OK, no worries.

almson commented 4 years ago

Brilliant idea!

However, Fn+Arrows is already a shortcut for Home/End/PgUp/PgDown. How to enter these keys? Perhaps Fn+Tab+hjkl? I don't think there's any Tab+Arrows shortcuts to cause conflict.

Why hjkl? Of course I know the reason, but I think Vim has awful UX, and ijkl (a triangle like normal arrow keys) is more intuitive for most people. With this feature, one never has to use hjkl even in vim! I think it should be configurable.

The code could be a lot simpler. You can do if (fn_hjkl_as_arrows) trans = apple_find_translation(fn_hjkl_as_arrows_keys, trans); right after trans = apple_find_translation (table, usage->code); I'll try it out and post a PR.

I'm starting to wonder (as another user who posted an issue) whether the original macOS convention of making the key next to the spacebar act like Control and the key in the corner be Fn is the best, especially if Fn should get even more use.

free5lot commented 4 years ago

I'm starting to wonder (as another user who posted an issue) whether the original macOS convention of making the key next to the spacebar act like Control and the key in the corner be Fn is the best, especially if Fn should get even more use.

Offtopic here: I doubt it as not only because it's uncomfortable to have it different from all other keyboard layouts in the world but also because developers (at least on GNU+Linux and Windows) use ctrl and shift quite often - moving and selecting words. Like select last word is ctrl+shift+← and etc. Alternatives for this do exist, e.g. vim hotkeys, but still, ctrl is also used quite often.

almson commented 4 years ago

I tried to figure out how to accomplish this using userspace utils, but I haven't been able to figure it out yet. It's quite confusing. Here are some leads:

I actually like the idea of using Right-Alt (AltGr) more than Fn and I would also like to preserve Fn as a modified for Home/PgUp. As much as I like the idea of doing this with userspace tools, modifying the module might be the path of least resistance (or only path).

Offtopic here: I doubt it as not only because it's uncomfortable to have it different from all other keyboard layouts in the world but also because developers (at least on GNU+Linux and Windows) use ctrl and shift quite often - moving and selecting words. Like select last word is ctrl+shift+← and etc. Alternatives for this do exist, e.g. vim hotkeys, but still, ctrl is also used quite often.

Not sure why Ctrl+Shift is a problem. I meant that reaching Alt (on PC, or Command on Mac) is a bit easier than Control (on PC, or Fn on Mac), so Apple's decision to use it for shortcuts like Copy (Command+C) makes sense. I got in the habit early on to use my palm to hit Control, but that's less comfortable on a slim Apple keyboard. Some people don't even do that and reach with their finger.

free5lot commented 4 years ago

Not sure why Ctrl+Shift is a problem. I meant that reaching Alt (on PC, or Command on Mac) is a bit easier than Control (on PC, or Fn on Mac), so Apple's decision to use it for shortcuts like Copy (Command+C) makes sense. I got in the habit early on to use my palm to hit Control, but that's less comfortable on a slim Apple keyboard. Some people don't even do that and reach with their finger.

Well, maybe you're right. Then it's only about a habit and uniformity.