-
-
Notifications
You must be signed in to change notification settings - Fork 907
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
Added function key support and key repeat for external keyboards #1718
base: master
Are you sure you want to change the base?
Conversation
The biggest problem here is that this will just break anyone with less than iOS 13.4, and iSH supports iOS 11. |
I can restore the current behaviour for pre 13.4 to coexist but as noted in #1708, if built with the latest XCode there will be many keys that won't work at all or produce the wrong results. |
Two small nits, there are a couple of variables that Xcode flags as unused... iOS 13 is supported on all phones and iPads made in 2015 and later. It even support the iPad Air 2 and the iPhone 6S. I speak only for myself of course, but I wouldn't want to use it on anything older than that. I believe Apple supports the ability to have multiple versions available on the App store to account for older iOS limitations. I have no clue how painful that is to support though. |
One more issue, when built on an M1 Mac the function and control keys still do not appear to work. Here is an example of the output I see in the lldb pane when pressing the up key. 2022-02-11 17:47:58.002371-0800 iSH[56496:1089310] Key up: invalidate Timer (null) init 0 |
Interesting; I did all my builds on M1 Mac using Xcode 13.2.1. Can you change the debugging line that logs the key pressed to: NSLog( @"Modified: %@ Unmodified: %@(%lu) Keycode: %ld init %d", key.characters, key.charactersIgnoringModifiers,(unsigned long)[key.charactersIgnoringModifiers length], key.keyCode, initiateKeyRepeatTimer); so that the keyCode is displayed. When I pressed the Down Arrow before the change I got: Modified: UIKeyInputDownArrow Unmodified: UIKeyInputDownArrow(19) init 0 which is different to you; the "Modified:" string is different. No idea why; that is the value that iOS supplies. For Down Arrow I now get: Modified: UIKeyInputDownArrow Unmodified: UIKeyInputDownArrow(19) Keycode: 81 init 0 I suspect that you are not getting a valid keyCode. |
Sure. I just upgraded to MacOS 12.2.1, so I did a full reboot since my last attempt. I also did an apk update. 2022-02-11 19:24:22.934206-0800 iSH[18594:182899] Modified: Unmodified: UIKeyInputUpArrow(17) Keycode: 82 init 0 Still not working. I'm building from the current iSH master plus your PR. It works fine when I build for my iPad Air 3. Here is what I get when pushing the up and down arrow keys on the iPad Air 3 keyboard 2022-02-11 19:33:15.537012-0800 iSH[12900:7161067] Modified: UIKeyInputUpArrow Unmodified: UIKeyInputUpArrow(17) Keycode: 82 init 0 |
Sorry a bit confused. What still doesn't work? Is it running a simulator on your Mac and pressing the keys on your Mac keyboard that doesn't work, but an external keyboard connected to your iPad Air 3 does work? The deprecations are interesting. |
Got it. I haven't tried building for the Mac. Will try that later. |
When running the Mac build, none of the function keys are passed to the app, so nothing can be done about that. The arrow keys have a NumberPad modifier associated. I've removed that and the arrow keys work, but little else is sent to the app. |
Thank you for testing/fixing this stuff. Some of these issues are likely Apple bugs, some the result of things having been deprecated. I don't think Apple would win any awards in the area of software Q&A, especially in the area of developer tools. :-( |
I have reinstated the pre iOS v13.4 external keyboard handling to coexist with the new function key handling in this PR. I tested the pre-1.34 keyboard handling on an iOS 12.4 simulator on an x86 MacBook Pro using Xcode 13.2.1 (same version as M1 that wouldn't compile). Key handling seems to work fine including arrow keys and key repeat behaviour. |
Wondering if we can use this instead. Will take a look later today. https://developer.apple.com/documentation/uikit/uikeycommand/3780513-wantspriorityoversystembehavior?language=objc |
Update: this worked: 43144e3 I think It would make sense, now, to add UIKeyCommands for the remaining function keys, and not use pressesBegan. |
Ok I'll change the code to extend the current mechanism. |
Only problem I seem to have with this change is that unshifted alpha and number keys do not repeat. Control and shifted alpha and number keys repeat as do function and navigation keys. Also the Backspace and Delete keys are reversed. |
I tried making an issue on this #1628 |
FYI, the pressesBegan function in the current version breaks the External Keyboard->Send ctrl-space to terminal Functionality. Specifically enabling the option no longer does the correct thing I haven't narrowed it down any more than that. |
Can someone please provide me the compiled binary of this PR merged with the base branch? I do not have a Mac, so I cannot build it out myself. Having key repeat would be of great convenience. Thanks. |
My fork, iSH-AOK incorporates portions of this PR. Function keys appear to work, but I haven't had luck with key repeat. Though for some odd reason, ctrl+j and ctrl+h cause key repeat to work for those two keys in both iSH and iSH-AOK, but the same is not true of the k and l keys. |
The function keys working is not useful to me as I’m using the Magic Keyboard. But, the key repeat would be very useful. Does fully incorporating this PR on the main branch makes the key repeat work? And if it does, Would it be possible if you can provide me the compiled binaries with the above feature working? Thank you. |
@rexx-org not support letter key repeat? i build from your branch, but vim not working, hjkl can't repeat |
I am using iSH 1.3.2 (Build 494). F1-F12 still do not work. Is it expected? |
Using version 1.3.2 on iPhone 15 and IOS 17.0.2 key press and hold pop ups occur when using a usb keyboard. Noting that arrow keys, delete, and space do repeat. But "as a vim user" cough cough originality it would be nice if h j k and L could have this feature. |
If you hold down the ctrl key, the h and j keys repeat, but not k and l. I have no clue why this is, and I'm not sure if this is more useful than it is annoying but I figured it was worth mentioning. |
stumbled on this PR from searching. Would love support for repeating h j k l in vim - i use iSH on an iPad with magic keyboard. |
I’m wondering if there is value in splitting this PR in two PRs:
From the conversation it seems one is more problematic than the other. |
For iOS 13.4 or above function key support added. Function keys include F1-F12, PgUp, PgDn, Home, End, Ins/Help and arrow keys. Unmodified, shifted and control modifiers produce relevant escape sequences based on output from infocmp xterm-256color. Further information #1708