[OnePlus X Themes and Apps] J0kker:
Hi all, i've jumped from OOS to CM12.1 and CM13 (and cm13 based roms) for some time, but today i wanted to give another shot to OOS 2.2.0 (and wanted to try boeffla's kernel as CM isn't official yet).

And i remembered why i could not stay on OOS after a few seconds... i really hate the hardware keys setup (recents-home-back).

I'm used to have Menu-Home-Back (and recents access from long press home, or press home from nova launcher).

I've been reading and then learning many things in the past few weeks, so i though i should try to edit those keys just like we did on CM, even if before switching to CM i've looked around and didn't find anything working to change these.

So, here it is.

What you need:

Rooted phone and file manager with root access (there are many but i love FX file explorer, and the root add-on is free).

You need to go to /system/usr/keylayout

Then make a backup of the Generic.kl file (to make it easier i make an archive of it by long press on the file, then archive, but a simple copy and paste will do).

After that, don't forget to unlock the system partition if needed (tap the little lock and accept to open it on fx file explorer).

Open Generic.kl with file editor.

What you need to know is that left key is key number 139, middle one is number 172 and right one is 158.

Functions that can be affected are: MENU HOME BACK APP_SWITCH VOICE_ASSIST.

But for some obscure reason, MENU acts like APP_SWITCH in oxygen OS, so the trick is to replace MENU with MENU VIRTUAL (this will emulate Menu button from on screen navbar, but you don't need to activate the navbar).

So, if you want for example this layout: Menu-Home-Back

You'll need to edit the Generic.kl and replace the Line

key 139 MENU

with

key 139 MENU VIRTUAL

(key 158 BACK and key 172 HOME don't need to change).

Another interesting point is that if you use xposed installer and Gravity Box LP, you can assign different functions to double press or long press on buttons, but it's working only with on screen navbar buttons... you see where i'm trying to get ?

If you modify the generic.kl file and replace MENU with MENU VIRTUAL and BACK with BACK VIRTUAL... then you'll be able to add custom actions with Gravity Box... like the one I really miss, hold back to kill.

I didn't try to replace HOME with HOME VIRTUAL as i can configure long press and double tap home from oxygen OS, but it may work exactly the same if you want something special from Gravity box.

For exemple, my setup is like that:

Menu-home-back

Menu long press => Switch last app

Home long press => Recent apps

Back long press => Kill foreground app

Double Tap Menu => Google Now

Double Tap Home => Screen off

Double Tap Back => Nothing

To sum up, on the phone, keys are:

key 139 - key 172 - key 158

You can affect different general functions to these, like:

MENU

HOME

BACK

APP_SWITCH

VOICE_ASSIST

and maybe more

You can add VIRTUAL behind the function to emulate the on screen navbar buttons (and it seems required for the menu, as it still calls the recent apps in OOS), and then you can add double tap or long press functions with gravity box.

You don't need to enable the navbar to get them working.

I don't know if i've been clear enough, as i'm not used to this kind of things (i wonder if that's not my first thread on XDA...), but i just hope this will be useful to some of you,

have a great day.

[Edit: Forgot to mention you need to reboot the device when it's done]