Jump to content

Customise Hardware Buttons


Guest Epic-Emodude

Recommended Posts

Guest niko1986

Epic do you know which hard key these are bound to and if its long or short? I know obviously for the menu key but theres 3 of them, one maybe a hard keyboard key. If one is a long press menu key seems MENU must bring up the soft keyboard.

Soft_Right i guess is likely from the other unused binds for a hard keyboard?


#Green Button - Which is short/long?
key 231 CALL WAKE_DROPPED
key 61 CALL WAKE_DROPPED

key 60 SOFT_RIGHT WAKE
key 229 MENU WAKE_DROPPED
key 59 MENU WAKE_DROPPED
key 139 MENU WAKE_DROPPED
key 102 HOME WAKE_DROPPED[/codebox]

Changed key 59 to SEARCH, though it was a menu key soft press, didnt seem to do anything.

Edited by niko1986
Link to comment
Share on other sites

Guest Epic-Emodude
Epic do you know which hard key these are bound to and if its long or short?

Soft_Right i guess is likely from the other unused binds for a hard keyboard?


#Green Button - Which is short/long?
key 231 CALL WAKE_DROPPED
key 61 CALL WAKE_DROPPED

key 60 SOFT_RIGHT WAKE
key 229 MENU WAKE_DROPPED
key 59 MENU WAKE_DROPPED
key 139 MENU WAKE_DROPPED
key 102 HOME WAKE_DROPPED[/codebox]

I dont know what a couple of them are (e.g. 61 is the green button). Some of them are not on our phones, so yeh I think many are for phones with hard keyboards, as it has key codes for a-z and shift and stuff. The best way to check is to boot into clockwork mod recvoery, then go to advanced, then keytest. Whenever you press a button it will return its key code, which is the key x in the surf_keypad.kl.

As far as I know they are all shot press. In the key test the only key that registers a different key code is the home/back button, as this was added by huawei when they made the phone. The rest of the long presses, like menu to get the keyboard, are controlled by android and are the same on every device. I have found out that the code to controll the long press is part of the framework, and that it can be overwriten within an app. Therefore we could try and find and edit the code or write an app that will edit them. The problem with the app is that it usually only overwrites them in that app. Im not sure where in the framework this code is, so I will have to do a bit more research before I can edit it.

Aaron

Link to comment
Share on other sites

Guest niko1986
I dont know what a couple of them are (e.g. 61 is the green button). Some of them are not on our phones, so yeh I think many are for phones with hard keyboards, as it has key codes for a-z and shift and stuff. The best way to check is to boot into clockwork mod recvoery, then go to advanced, then keytest. Whenever you press a button it will return its key code, which is the key x in the surf_keypad.kl.

As far as I know they are all shot press. In the key test the only key that registers a different key code is the home/back button, as this was added by huawei when they made the phone. The rest of the long presses, like menu to get the keyboard, are controlled by android and are the same on every device. I have found out that the code to controll the long press is part of the framework, and that it can be overwriten within an app. Therefore we could try and find and edit the code or write an app that will edit them. The problem with the app is that it usually only overwrites them in that app. Im not sure where in the framework this code is, so I will have to do a bit more research before I can edit it.

Aaron

Ahh thanks :D Guess this is no different to what you found:

#Camera Button Soft Press
key 249 FOCUS

#Camera Button Hard Press
key 212 CAMERA

#Power Button Short Press
key 116 POWER WAKE

#Back/Home Button Short Press
key 250 BACKLIGHT WAKE
key 158 BACK WAKE_DROPPED

#Back/Home Button Long Press
key 250 BACKLIGHT WAKE
key 102 HOME WAKE_DROPPED

#Green Button Short Press
key 61 CALL WAKE_DROPPED

#Red Button Short Press
key 62 ENDCALL WAKE_DROPPED

#D Pad
key 103 DPAD_UP WAKE_DROPPED
key 108 DPAD_DOWN WAKE_DROPPED
key 105 DPAD_LEFT WAKE_DROPPED
key 106 DPAD_RIGHT WAKE_DROPPED
key 232 DPAD_CENTER WAKE_DROPPED

#Volume Keys Short Press
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE[/codebox]

Edited by niko1986
Link to comment
Share on other sites

@ gusthy gusthy.zip - The first click of the camera button now hangs up calls

@ tido tido.zip - The first click of camera button now skips to next media track

OMG! You're great!!! :D

I wanted to program this myself, but I don't have the time to study the Android developement :S

The other bad thing is that my phone is in the T-mobile service.... -.- Random reboot issues, you know :D

I'll try it out ASAP!

Thanks Epic-Emodude!

Link to comment
Share on other sites

Guest Epic-Emodude
Ahh thanks :D Guess this is no different to what you found:

#Camera Button Soft Press
key 249 FOCUS

#Camera Button Hard Press
key 212 CAMERA

#Power Button Short Press
key 116 POWER WAKE

#Back/Home Button Short Press
key 250 BACKLIGHT WAKE
key 158 BACK WAKE_DROPPED

#Back/Home Button Long Press
key 250 BACKLIGHT WAKE
key 102 HOME WAKE_DROPPED

#Green Button Short Press
key 61 CALL WAKE_DROPPED

#Red Button Short Press
key 62 ENDCALL WAKE_DROPPED

#D Pad
key 103 DPAD_UP WAKE_DROPPED
key 108 DPAD_DOWN WAKE_DROPPED
key 105 DPAD_LEFT WAKE_DROPPED
key 106 DPAD_RIGHT WAKE_DROPPED
key 232 DPAD_CENTER WAKE_DROPPED

#Volume Keys Short Press
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE[/codebox]

oooohh, where did you find that?

Perhaps we can add volume key long press or something.

OMG! You're great!!! biggrin.gif

I wanted to program this myself, but I don't have the time to study the Android developement :S

The other bad thing is that my phone is in the T-mobile service.... -.- Random reboot issues, you know sad.gif

I'll try it out ASAP!

Thanks Epic-Emodude!

No Problem

Link to comment
Share on other sites

Guest niko1986
oooohh, where did you find that?

Just commented the file to make it a bit easier to read. Must be something special about the home/back key as its the only one in the clockwork recovery that registered a different response for a long and short press. Thats probably why when home was changed to the red end call button a long press now brings up recent apps as it should in android.

Edited by niko1986
Link to comment
Share on other sites

Guest HunteronX

Thanks for this; it looks useful :D - I've not been able to do any Pulse modding/hacking anymore though, 'cause my little brother is using the phone now... :D

Edited by HunteronX
Link to comment
Share on other sites

Guest Epic-Emodude
Just commented the file to make it a bit easier to read. Must be something special about the home/back key as its the only one in the clockwork recovery that registered two different responses for a long and short press. Thats probably why when home was changed to the red end call button a long press now brings up recent apps as it should in android.

Oh rite, I thought it was actually a file on the phone that we could do something exciting with.

Perhaps we could find a way to add a key code in for long press of something.

Before that though, I want to try and do something with the camera buttons, and the trackball.

Link to comment
Share on other sites

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.

Edited by Tom G
Link to comment
Share on other sites

Guest Epic-Emodude
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.

When we get the kernel source from t-mobile I will have a look at this then, but I dont know any C yet (I was going to start learning it but then my pc died)

I might need some help from someone with experience with c (and a computer)

Link to comment
Share on other sites

Guest stealthstealer

good work!

looks perfect, except i dont like the look of the media player controls, i mean, if i selecct something with the trackball will my phone start playing P. Diddy? :D

Link to comment
Share on other sites

Guest starkos

Looks like your making great progress with this Epic-Emodude, nice work! Wondered if I could make a small request, basically I just want all the buttons as default but with addition of long-press Red to got to Recent Apps? If you could do that for me I would appreciate it :D

Link to comment
Share on other sites

Guest Epic-Emodude
good work!

looks perfect, except i dont like the look of the media player controls, i mean, if i selecct something with the trackball will my phone start playing P. Diddy? :D

At the moment only the pause/play thing works, and it will only do something if you are listening to music, so if you exited the music app properly it wont be a problem. Althought the use of it as a play pause button disables its use as a clicker, which I did because I thouhgt that seeing as out phones are touch screen the trackball isnt really necessary, althought if you want it then download 0.4 which doesnt have this feature.

Link to comment
Share on other sites

Guest niko1986
At the moment only the pause/play thing works, and it will only do something if you are listening to music, so if you exited the music app properly it wont be a problem. Althought the use of it as a play pause button disables its use as a clicker, which I did because I thouhgt that seeing as out phones are touch screen the trackball isnt really necessary, althought if you want it then download 0.4 which doesnt have this feature.

Does changing the trackball's use effect the recovery controls?

Link to comment
Share on other sites

Guest Epic-Emodude
Does changing the trackball's use effect the recovery controls?

It shouldnt do because the file im editing is in android and so should only affect android.

Link to comment
Share on other sites

Guest Epic-Emodude
Looks like your making great progress with this Epic-Emodude, nice work! Wondered if I could make a small request, basically I just want all the buttons as default but with addition of long-press Red to got to Recent Apps? If you could do that for me I would appreciate it :D

To do that the red key has to become home button. This means you can either have it as home button which will give you the recent apps things, but no longer funtion as end call, or you can have it as end call which will end calls and do everything the home button does except the recent apps.

Link to comment
Share on other sites

Guest whackster
To do that the red key has to become home button. This means you can either have it as home button which will give you the recent apps things, but no longer funtion as end call, or you can have it as end call which will end calls and do everything the home button does except the recent apps.

Has anyone noticed anything different when using this hack, and using the "End Button Behavior" set as "go to home"?

Link to comment
Share on other sites

Guest stealthstealer
At the moment only the pause/play thing works, and it will only do something if you are listening to music, so if you exited the music app properly it wont be a problem. Althought the use of it as a play pause button disables its use as a clicker, which I did because I thouhgt that seeing as out phones are touch screen the trackball isnt really necessary, althought if you want it then download 0.4 which doesnt have this feature.

0.4 is workin perfect for me thanks :D

Link to comment
Share on other sites

Guest Epic-Emodude
Has anyone noticed anything different when using this hack, and using the "End Button Behavior" set as "go to home"?

Ive unchecked that option. Does it do something odd?

Link to comment
Share on other sites

Guest stealthstealer
Has anyone noticed anything different when using this hack, and using the "End Button Behavior" set as "go to home"?

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

Link to comment
Share on other sites

Guest starkos
To do that the red key has to become home button. This means you can either have it as home button which will give you the recent apps things, but no longer funtion as end call, or you can have it as end call which will end calls and do everything the home button does except the recent apps.

Ahh that's a shame, cheers anyway :D

Link to comment
Share on other sites

I dont know what a couple of them are (e.g. 61 is the green button). Some of them are not on our phones, so yeh I think many are for phones with hard keyboards, as it has key codes for a-z and shift and stuff. The best way to check is to boot into clockwork mod recvoery, then go to advanced, then keytest. Whenever you press a button it will return its key code, which is the key x in the surf_keypad.kl.

As far as I know they are all shot press. In the key test the only key that registers a different key code is the home/back button, as this was added by huawei when they made the phone. The rest of the long presses, like menu to get the keyboard, are controlled by android and are the same on every device. I have found out that the code to controll the long press is part of the framework, and that it can be overwriten within an app. Therefore we could try and find and edit the code or write an app that will edit them. The problem with the app is that it usually only overwrites them in that app. Im not sure where in the framework this code is, so I will have to do a bit more research before I can edit it.

Aaron

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

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
×
×
  • Create New...

Important Information

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