Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,808,448 Members 40,952 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] How to get good Ctrl and Alt keys in SSH while keeping Fn

Tip us?
 
zx2c4
Old
(Last edited by zx2c4; 7th November 2013 at 10:42 PM.)
#1  
Junior Member - OP
Thanks Meter 2
Posts: 6
Join Date: Sep 2013

 
DONATE TO ME
Prompt [GUIDE] How to get good Ctrl and Alt keys in SSH while keeping Fn

Hi folks. I use JuiceSSH. In the current CM settings, it interprets the hardware alt key as an actual console alt. This is nice for changing windows in irssi (Alt+1, Alt+2, ...), but it's not useful for getting at the Fn keys for special characters. It would be nice to have Fn, Ctrl, and Alt, all working. Here's how to get this done:

View this: hxxp://data.zx2c4.com/galaxy-relay-keyboard-map.jpg

The file /system/usr/keylayout/sec_keypad.kl contains correlations of keycodes and keychars. It turns out JuiceSSH interprets ALT_LEFT as console alt, ALT_RIGHT as Fn, and CTRL_LEFT as console ctrl. So in that file, we want to remap ALT_LEFT to ALT_RIGHT, and then remap the MAIL and CHAT keys to CTRL_LEFT and ALT_LEFT respectively:

Code:
key 56    ALT_RIGHT         WAKE_DROPPED
key 155  CTRL_LEFT          WAKE_DROPPED
key 429  ALT_LEFT           WAKE_DROPPED
key 217  META_LEFT          WAKE_DROPPED
The full keycode file is available at hxxp://data.zx2c4.com/sec_keypad_modified.kl .

Here's a command listing of how I enable this using adb:

Code:
zx2c4@thinkpad ~ $ adb shell
shell@android:/ $ su
root@android:/ # mount -o rw,remount /system
root@android:/ # wget -O /system/usr/keylayout/sec_keypad.kl hxxp://data.zx2c4.com/sec_keypad_modified.kl
root@android:/ # reboot
In practice, this thus far works very well.

Remember to change "hxxp" in this post; as a new member of XDA, I'm not allowed to post links.
The Following 2 Users Say Thank You to zx2c4 For This Useful Post: [ Click to Expand ]
 
Calchan
Old
#2  
Junior Member
Thanks Meter 1
Posts: 8
Join Date: Aug 2013
I don't use JuiceSSH (but I'll definitely try it at some point if only for mosh), so I tried that with the built-in terminal app. By the way I don't know what version of CM 10.2 you're using, but here on the 20130909 nightly I found the kymaps in /system/usr/keylayout and not in /system/usr/keymap.

I didn't remap ALT_LEFT, but did remap 155 to CTRL_LEFT and 429 to META_LEFT like you did. I also remapped 217 to ESCAPE which is very handy in vim. Here's the diff:

--- sec_keypad.kl.orig 2013-09-12 17:55:28.434192677 -0600
+++ sec_keypad.kl 2013-09-12 18:12:08.876521089 -0600
@@ -81,3 +81,3 @@
-key 155 ENVELOPE WAKE_DROPPED
-key 429 CONTACTS WAKE_DROPPED
-key 217 SEARCH WAKE_DROPPED
+key 155 CTRL_LEFT WAKE_DROPPED
+key 429 META_LEFT WAKE_DROPPED
+key 217 ESCAPE WAKE_DROPPED

The ESCAPE works but not the CTRL_LEFT and META_LEFT. The remapping does seem to work since the keys don't do any longer what they used to do. So I'm guessing it's the key compositing that doesn't work.

I'll keep looking.
The Following User Says Thank You to Calchan For This Useful Post: [ Click to Expand ]
 
zx2c4
Old
#3  
Junior Member - OP
Thanks Meter 2
Posts: 6
Join Date: Sep 2013

 
DONATE TO ME
Quote:
Originally Posted by Calchan View Post
I found the kymaps in /system/usr/keylayout and not in /system/usr/keymap.
Typo! My bad; fixed above.

Quote:
Originally Posted by Calchan View Post
ESCAPE which is very handy in vim.
That does indeed seem quite handy. I'm tempted to remap the mic button away from META how it is now (which is a bit useful but not super) and toward escape for vim. Good idea.

Having a working ctrl and alt key for android itself, not just the terminal, is proving invaluable. Ctrl+A, ctrl+C, ctrl+V, alt+left, alt+shift+left, etc -- all really nice to have when editing text.
 
Nardholio
Old
#4  
Nardholio's Avatar
Senior Member
Thanks Meter 749
Posts: 699
Join Date: Sep 2009
Location: Connecticut
You will most likely have to recompile the kernel to change those to alt and ctrl keys. The keys are laid out in board-apexq.c and they are mapped with standard linux keycode names from input.h.
 
zx2c4
Old
#5  
Junior Member - OP
Thanks Meter 2
Posts: 6
Join Date: Sep 2013

 
DONATE TO ME
Quote:
Originally Posted by Nardholio View Post
You will most likely have to recompile the kernel to change those to alt and ctrl keys. The keys are laid out in board-apexq.c and they are mapped with standard linux keycode names from input.h.
I didn't have any such problem, and just changed the keycode association in the .kl file.
 
Calchan
Old
#6  
Junior Member
Thanks Meter 1
Posts: 8
Join Date: Aug 2013
Quote:
Originally Posted by zx2c4 View Post
That does indeed seem quite handy. I'm tempted to remap the mic button away from META how it is now (which is a bit useful but not super) and toward escape for vim. Good idea.
Key 214 is indeed the microphone key, and having that mapped to ESCAPE like I did is very handy. What is META used for?

Can you please try the CTRL and ALT keys in the defaut CM terminal and tell me if they work for you? I haven't had time yet to try in JuiceSSH yet, but they don't work in the default terminal here.
 
zx2c4
Old
#7  
Junior Member - OP
Thanks Meter 2
Posts: 6
Join Date: Sep 2013

 
DONATE TO ME
Default cm 10.2

To make the ALT keys work as described in cm 10.2, you need to delete /system/usr/idc/sec_keypad.idc .
 
zx2c4
Old
#8  
Junior Member - OP
Thanks Meter 2
Posts: 6
Join Date: Sep 2013

 
DONATE TO ME
I've found a more careful change, submitted here:

hxxp://review.cyanogenmod.org/#/c/53130/
 
cybertim
Old
(Last edited by cybertim; 12th May 2014 at 10:25 AM.)
#9  
Junior Member
Thanks Meter 3
Posts: 15
Join Date: Jan 2013
I used your fix to make JuiceSSH working on my Relay (yes i bought one only for the keyboard/ssh - can't do that on my expensive N5)

It looks like the arrow keys are mapped 'backward' and some alt-<combination> keys (like the '.com') arn't working, is this correct?

[edit]
I fixed it (or it has been fixed by updating to a newer nightly of CM11). But I did also remove the 'idc' file as suggested in this thread, by placing it back things seemed to work correctly (the arrow keys)
[/edit]
 
dstahlke
Old
#10  
Junior Member
Thanks Meter 0
Posts: 4
Join Date: Jan 2013
I also had to edit Generic.kl.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes