Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP zx2c4

12th September 2013, 02:55 PM   |  #1  
OP Junior Member
Thanks Meter: 2
 
6 posts
Join Date:Joined: Sep 2013
Donate to Me
More
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.
Last edited by zx2c4; 7th November 2013 at 11:42 PM.
The Following 2 Users Say Thank You to zx2c4 For This Useful Post: [ View ]
13th September 2013, 02:36 AM   |  #2  
Junior Member
Thanks Meter: 1
 
8 posts
Join Date:Joined: 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: [ View ]
13th September 2013, 03:30 PM   |  #3  
OP Junior Member
Thanks Meter: 2
 
6 posts
Join Date:Joined: Sep 2013
Donate to Me
More
Quote:
Originally Posted by Calchan

I found the kymaps in /system/usr/keylayout and not in /system/usr/keymap.

Typo! My bad; fixed above.

Quote:
Originally Posted by Calchan

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.
13th September 2013, 05:56 PM   |  #4  
Senior Member
Flag Connecticut
Thanks Meter: 859
 
724 posts
Join Date:Joined: Sep 2009
Donate to Me
More
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.
13th September 2013, 05:59 PM   |  #5  
OP Junior Member
Thanks Meter: 2
 
6 posts
Join Date:Joined: Sep 2013
Donate to Me
More
Quote:
Originally Posted by Nardholio

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.
13th September 2013, 06:29 PM   |  #6  
Junior Member
Thanks Meter: 1
 
8 posts
Join Date:Joined: Aug 2013
Quote:
Originally Posted by zx2c4

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.
7th November 2013, 02:07 PM   |  #7  
OP Junior Member
Thanks Meter: 2
 
6 posts
Join Date:Joined: Sep 2013
Donate to Me
More
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 .
7th November 2013, 07:38 PM   |  #8  
OP Junior Member
Thanks Meter: 2
 
6 posts
Join Date:Joined: Sep 2013
Donate to Me
More
I've found a more careful change, submitted here:

hxxp://review.cyanogenmod.org/#/c/53130/
10th May 2014, 08:59 PM   |  #9  
Junior Member
Thanks Meter: 3
 
15 posts
Join Date:Joined: Jan 2013
More
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]
Last edited by cybertim; 12th May 2014 at 11:25 AM.
12th May 2014, 03:30 PM   |  #10  
Junior Member
Thanks Meter: 0
 
4 posts
Join Date:Joined: Jan 2013
I also had to edit Generic.kl.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes