Jump to content

Customise Hardware Buttons


Guest Epic-Emodude
 Share

Recommended Posts

The key codes are standard as defined in the kernel source /include/linux/input.h

I really need to learn C one day, but here is an interesting chunk of code for you.

static void report_key(struct gpio_kp *kp, int key_index, int out, int in)

{

		struct gpio_event_matrix_info *mi = kp->keypad_info;

		int pressed = test_bit(key_index, kp->keys_pressed);

		unsigned short keycode = mi->keymap[key_index];

		if (pressed != test_bit(keycode, kp->input_dev->key)) {

				if (keycode == KEY_RESERVED) {

						if (mi->flags & GPIOKPF_PRINT_UNMAPPED_KEYS)

								pr_info("gpiomatrix: unmapped key, %d-%d "

										"(%d-%d) changed to %d\n",

										out, in, mi->output_gpios[out],

										mi->input_gpios[in], pressed);

				} else {

						if (mi->flags & GPIOKPF_PRINT_MAPPED_KEYS)

								pr_info("gpiomatrix: key %x, %d-%d (%d-%d) "

										"changed to %d\n", keycode,

										out, in, mi->output_gpios[out],

										mi->input_gpios[in], pressed);

					  if (keycode == KEY_BACKLIGHT)

					  {

						   if(pressed)

						   {

								kp->timeout_flag = FALSE;

								hrtimer_start(&kp->back_key_timer, ktime_set(KTIME_SECS, KTIME_NSECS), HRTIMER_MODE_REL);

							}

							else

							{

								 hrtimer_cancel(&kp->back_key_timer);

								 if (kp->timeout_flag == FALSE)

								 {

									 input_report_key(kp->input_dev, KEY_BACK, 1); /* KEY_BACK 158 */

									 input_report_key(kp->input_dev, KEY_BACK, 0); /* KEY_BACK 158 */

								  }


							}

						}

						input_report_key(kp->input_dev, keycode, pressed);

		  }

	}

}


enum hrtimer_restart back_key_timer_func(struct hrtimer *timer)

{

	struct gpio_kp *kp = container_of(timer, struct gpio_kp, back_key_timer);

	kp->timeout_flag = TRUE;

	input_report_key(kp->input_dev, KEY_HOME, 1); /* KEY_HOME 102 */

	input_report_key(kp->input_dev, KEY_HOME, 0); /* KEY_HOME 102 */

	return HRTIMER_NORESTART;

}

See /drivers/input/misc/gpio_matrix.c for the full source.

We would of course need current kernel source, but I think you could play with the kernel driver to add different key codes for long presses on other buttons.

You're right. This is the section of the code that produces the scancodes. I guess you can even produce a double tap feature for the hardware buttons but I can't find no documentation about this. I guess we have to analyze the code inherance to see what each part of the code is actually doing

Link to comment
Share on other sites

Guest niko1986
Hi. Can you tell what is the difference between the the same keycodes with different scancodes like

key 231   CALL              WAKE_DROPPED
key 61 CALL WAKE_DROPPED
[/codebox]

Is any of them a long press? Which one?

I can't make the keytest right now

I little suggestion, comment the changed code and add the changes next to it.

As you can see your code is getting really messy and that's why a simple thing can get buggy

As far as I can tell alot of the keycodes listed in the file do not apply to the pulse. Long presses are dealt with by android itself.

Edited by niko1986
Link to comment
Share on other sites

Guest whackster
nope it does nothing, because it is no longer the "end button"

I was asking if there is a difference between using the "Go to Home" setting, and using the hack to make it act as a home button, other than when using the hack you can't end calls, is there any difference??

Link to comment
Share on other sites

Guest Epic-Emodude
I was asking if there is a difference between using the "Go to Home" setting, and using the hack to make it act as a home button, other than when using the hack you can't end calls, is there any difference??

If you use the thing in settings it goes to the home screen but when you hold it it does not go to recent apps.

Link to comment
Share on other sites

Guest niko1986
I was asking if there is a difference between using the "Go to Home" setting, and using the hack to make it act as a home button, other than when using the hack you can't end calls, is there any difference??

Holding Home (now the END button) brings up the inbuilt recent apps menu

Link to comment
Share on other sites

Guest whackster
Holding Home (now the END button) brings up the inbuilt recent apps menu

Cool thanks for clearing it up, now we can have a dedicated home button :D

Link to comment
Share on other sites

Guest niko1986

Been messing on with the surf_keypad.kl file and I've chopped it down and make it abit more readable.

You can get it here, its in a flashable signed zip if you want to revert back to the Hauwei original binds.

Also I made a version with few changes to get extra functionality out of the keys we have:

Short Click Trackball - Search

Long Click Trackball - Voice Search

Long Click Back Button - End Call

Short Click Red Button - Home

Long Click Red Button - Recent Apps Menu

You can get these changes here, again its flashable.

And if people want to put together their own flashable keybind they can use this. Just find the surf_keypad.kl file change it how you want. Then zip the keylayout and META-INF folders into a non-compressed zip file, name it update.zip and then run the batch.bat file to make a signed update.

Props to Epic-Emodude for starting looking into this. Hope you don't mind me posting this in your thread mate.

Edited by niko1986
Link to comment
Share on other sites

Guest Epic-Emodude
Been messing on with the surf_keypad.kl file and I've chopped it down and make it abit more readable.

You can get it here, its in a flashable signed zip if you want to revert back to the Hauwei original binds.

Also I made a version with few changes to get extra functionality out of the keys we have:

Short Click Trackball - Search

Long Click Trackball - Voice Search

Long Click Back Button - End Call

Short Click Red Button - Home

Long Click Red Button - Recent Apps Menu

You can get these changes here, again its flashable.

And if people want to put together their own flashable keybind they can use this. Just find the surf_keypad.kl file change it how you want. Then zip the keylayout and META-INF folders into a non-compressed zip file, name it update.zip and then run the batch.bat file to make a signed update.

Props to Epic-Emodude for starting looking into this. Hope you don't mind me posting this in your thread mate.

I'm happy to have you on board. how did you get the long press things? seeing as I don't have access to a pc in the foreseeable future :-( I am happy for you continue development if you want. if you add more functionality I can add it to the first page as 1. 3 giving credit to you.

Link to comment
Share on other sites

Guest niko1986
I'm happy to have you on board. how did you get the long press things? seeing as I don't have access to a pc in the foreseeable future :-( I am happy for you continue development if you want. if you add more functionality I can add it to the first page as 1. 3 giving credit to you.

The long press for the Voice Search and Recent Apps are the android defaults but just making it clear what new functions people got access to.

The Back/Home button is the only one we can control the long press function of; except the camera but that's more of a soft and hard click. By merging the Back and Home buttons Huawei must have made changes in the kernel stopping androids default long presses.

If ya dont mind adding it to the front page that'd be great. I thought giving people easy-ish way of making their own, saves making lots of versions to cover everyones idea of a good key bind :D

Hope ya get your pc back soon ... bad memories of when mine died :D

Edited by niko1986
Link to comment
Share on other sites

Guest Epic-Emodude
The long press for the Voice Search and Recent Apps are the android defaults but just making it clear what new functions people got access to.

The Back/Home button is the only one we can control the long press function of; except the camera but that's more of a soft and hard click. By merging the Back and Home buttons Huawei must have made changes in the kernel stopping androids default long presses.

If ya dont mind adding it to the front page that'd be great. I thought giving people easy-ish way of making their own, saves making lots of versions to cover everyones idea of a good key bind :D

Hope ya get your pc back soon ... bad memories of when mine died :D

hopefully I'll have it back by the end of the month, although that's still too long to wait =(

ill add your things to the start page when I get a chance

Link to comment
Share on other sites

Guest DanWilson
I'm happy to have you on board. how did you get the long press things? seeing as I don't have access to a pc in the foreseeable future :-( I am happy for you continue development if you want. if you add more functionality I can add it to the first page as 1. 3 giving credit to you.

I guess I missed it - what happened to your PC? At least you have a phone... (I have a spare laptop from the 90s, my dad has 3 laptops, and my mum has a laptop - I think I'd be sorted if mine broke, as well as my dad knowing how to fix PCs!) :D

Ya bro hope you get your PC soon!

Link to comment
Share on other sites

Guest IceXcube84

Sorry but i have not read all posts here but i have a question.

Is it possible to make to i get the application list when i long press the red button?

Green - Get up the dialer/answer call - Long press - Recent applications

Red - End call - Long press - home

Can somebody change it to me?

I like the default one but the green button have same functions on short press and long press bit useless for me.

Link to comment
Share on other sites

Guest niko1986
Sorry but i have not read all posts here but i have a question.

Is it possible to make to i get the application list when i long press the red button?

Green - Get up the dialer/answer call - Long press - Recent applications

Red - End call - Long press - home

Can somebody change it to me?

I like the default one but the green button have same functions on short press and long press bit useless for me.

The long press functions are controlled by android. So if we change any button to HOME on a short press, android automatically makes the long press bring up the RECENT APPS.

So you can make any key whatever short press you want but the long press depends on whatever short press you choose. EXCEPT the back home button the long press can be controlled for that.

If you can come up with keybinds that are within the above restrictions, I'll make it for you.

Link to comment
Share on other sites

Holding Home (now the END button) brings up the inbuilt recent apps menu

Yep this is the one I'm interested in.

Everything else to default only this one changed.

What do I need to modify to do that?

Edit: Error...

Amm... Everything to default only the long press the home/back key to be the recent apps. Can this be done?

Edited by D-D-
Link to comment
Share on other sites

Guest whackster
Yep this is the one I'm interested in.

Everything else to default only this one changed.

What do I need to modify to do that?

Edit: Error...

Amm... Everything to default only the long press the home/back key to be the recent apps. Can this be done?

You need to set the red button to act as a home button. That way it will go to home on short press and show recent apps on long press, however you won't be able to hang up calls anymore. We need the kernel source do do any other modifications I think.

Link to comment
Share on other sites

  • 3 weeks later...
Guest DanWilson

UBA SUPA DOOPA BUMPITY BUMP!

Lets revive this great thread! I'm going to use it soon, and I'm sure others would!

Is there any with

Green - Search

Red - Home

Back *LONG PRESS* - Red (For hanging up)

I'd rather Red wasn't the camera button cos then when we try to take pictures we would go home. I also like the trackball for some reason...

Link to comment
Share on other sites

Guest rulerofkaos

Is it possible to get recent apps when I press the back button long? I looked at the surf_keypad files but I had no idea.

edit: Oh sorry I read that we need the kernel source for that :huh:

Edited by rulerofkaos
Link to comment
Share on other sites

Guest niko1986
UBA SUPA DOOPA BUMPITY BUMP!

Lets revive this great thread! I'm going to use it soon, and I'm sure others would!

Is there any with

Green - Search

Red - Home

Back *LONG PRESS* - Red (For hanging up)

I'd rather Red wasn't the camera button cos then when we try to take pictures we would go home. I also like the trackball for some reason...

Try this one, hope you have clockwork recovery cos i've realised my signed zips aren't signed and I cant be arsed to find out why :huh:

Dans Layout

Link to comment
Share on other sites

  • 2 months later...
Guest suriya83

I have following layout and am happy with it:

red button became power button still ends calls with short press

power button became home button (long press for recent apps)

volume keys work when screen is off (short press for volume long press to skip tracks)

everything else remain the same

edit:

key 399   GRAVE
key 2 1
key 3 2
key 4 3
key 5 4
key 6 5
key 7 6
key 8 7
key 9 8
key 10 9
key 11 0
key 158 BACK WAKE_DROPPED
key 230 SOFT_RIGHT WAKE
key 60 SOFT_RIGHT WAKE
key 107 ENDCALL WAKE_DROPPED
key 62 ENDCALL WAKE_DROPPED
key 229 MENU WAKE_DROPPED
key 139 MENU WAKE_DROPPED
key 59 MENU WAKE_DROPPED
key 127 SEARCH WAKE_DROPPED
key 217 SEARCH WAKE_DROPPED
key 228 POUND
key 227 STAR
key 231 CALL WAKE_DROPPED
key 61 CALL WAKE_DROPPED
key 232 DPAD_CENTER WAKE_DROPPED
key 108 DPAD_DOWN WAKE_DROPPED
key 103 DPAD_UP WAKE_DROPPED
key 102 HOME WAKE
key 105 DPAD_LEFT WAKE_DROPPED
key 106 DPAD_RIGHT WAKE_DROPPED
key 115 VOLUME_UP WAKE_DROPPED
key 114 VOLUME_DOWN WAKE_DROPPED
key 116 HOME WAKE
key 212 CAMERA
key 249 FOCUS
[/codebox]

Edited by suriya83
Link to comment
Share on other sites

Guest jamielockeymusic
I have following layout and am happy with it:

red button became power button still ends calls with short press

power button became home button (long press for recent apps)

volume keys work when screen is off (short press for volume long press to skip tracks)

everything else remain the same

qwerty.kl

how do you lock? :rolleyes: and how do you install this?

Link to comment
Share on other sites

Guest suriya83
how do you lock? :rolleyes: and how do you install this?

with end call button (short press)

edit: i don't know how to make a zip anyway i posted the code in my post above the file qwerty.kl in /system/usr/keylayout has to look like that code. you can edit it using root explorer: (klick mount R/W) when you are inside the folder long press on qwerty.kl then open in text editor.

if someone tells me how to make a flashable zip i can try

Edited by suriya83
Link to comment
Share on other sites

  • 2 weeks later...
Guest wolfy200222

Hey,

I know this is a fairly old topic but is the development for this still going?

Basically my home/back button on my pulse has stopped working and ive been trying for about 2 months of internet searching and fixing to try and get it working, but is it possible to change the quick press of the end button to act like the back. Its pretty useless without it and I had to cancel the insurance because of money problems so I cant send it back for replacement.

Cheers

Link to comment
Share on other sites

Guest Epic-Emodude
Hey,

I know this is a fairly old topic but is the development for this still going?

Basically my home/back button on my pulse has stopped working and ive been trying for about 2 months of internet searching and fixing to try and get it working, but is it possible to change the quick press of the end button to act like the back. Its pretty useless without it and I had to cancel the insurance because of money problems so I cant send it back for replacement.

Cheers

I stopped development after I reached a setup that most people seemed fairly happy with. As I havent done any work on it in a while, I cant remember if the back button is mapped. I think it is tho. Use clockwork recovery to find out the key numbers for the back and end buttons, then in the file that mapps them swap them over

Link to comment
Share on other sites

Guest wolfy200222
UBA SUPA DOOPA BUMPITY BUMP!

Lets revive this great thread! I'm going to use it soon, and I'm sure others would!

Is there any with

Green - Search

Red - Home

Back *LONG PRESS* - Red (For hanging up)

I'd rather Red wasn't the camera button cos then when we try to take pictures we would go home. I also like the trackball for some reason...

Try this one, hope you have clockwork recovery cos i've realised my signed zips aren't signed and I cant be arsed to find out why

Dans Layout

When you say back with the long press, i assume it does what i asked for? btw thanks for quick reply

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.