[DONE] Trackpad to wake/unlock

bponury

Inactive Recognized Developer
Apr 29, 2010
1,394
4,806
0
Sydney
forum.paranoid.me
I've managed to do some dirty hack to wake phone using trackpad.

It's kernel update so i believe it will only work with MCR r3.1 (which I am using)

Thank's to kingchris for his lockscreen apk mod this now should work:

Tested ONLY on MCR r3.1.
Do not flash on ANY Froyo roms

http://ponury.net/desire/tp-wake.zip - trackpad wakes, nothing unlocks
http://ponury.net/desire/tp-wake_unlock.zip - trackpad wakes, trackpad unlocks
http://ponury.net/desire/tp_power-wake_unlock.zip - trackpad + power wakes, trackpad unlocks
http://ponury.net/desire/tp-doubletap_wake_unlock.zip - trackpad wakes AND unlocks when pushed fast twice (slow push does nothing)

Here's that diff: (just a single line added :) )

Always send DPAD_CENTER event!
http://ponury.net/desire/oj_send_dpad_center_ev.patch - download
Code:
--- a/drivers/input/misc/gpio_matrix.c	2010-05-12 08:24:13.000000000 +0200
+++ b/drivers/input/misc/gpio_matrix.c	2010-06-17 08:05:08.223812817 +0200
@@ -162,6 +162,7 @@
 			need_send_spec_key = !pressed;
 			printk(KERN_DEBUG "%s: send key, pressed: %d\n",
 				__func__, need_send_spec_key);
+				    input_report_key(kp->input_devs->dev[dev], keycode, pressed);
 		}
 	}
 #endif

Send DPAD_CENTER event when pushed twice (fast) when screen is OFF:
http://ponury.net/desire/oj_send_dpad_center_when_doubleclicked_ev.patch - download
http://ponury.net/desire/oj_send_dpad_center_when_doubleclicked_ev_mod.patch - download + mod to automatically unlock (this one is used in doubleclick mod)
Code:
--- a/drivers/input/misc/gpio_matrix.c	2010-05-12 08:24:13.000000000 +0200
+++ b/drivers/input/misc/gpio_matrix.c	2010-06-17 12:53:47.893816146 +0200
@@ -29,6 +29,8 @@
 #include <linux/curcial_oj.h>
 #endif
 
+extern struct wake_lock main_wake_lock;
+
 struct gpio_kp {
 	struct gpio_event_input_devs *input_devs;
 	struct gpio_event_matrix_info *keypad_info;
@@ -118,6 +120,8 @@
 	unsigned short keyentry = mi->keymap[key_index];
 	unsigned short keycode = keyentry & MATRIX_KEY_MASK;
 	unsigned short dev = keyentry >> MATRIX_CODE_BITS;
+        static unsigned long    last_jiffies = 0;
+        static bool             sent = 0;
 #ifdef CONFIG_OPTICALJOYSTICK_CRUCIAL
 	static unsigned need_send_spec_key = 1;
 #endif
@@ -162,6 +166,18 @@
 			need_send_spec_key = !pressed;
 			printk(KERN_DEBUG "%s: send key, pressed: %d\n",
 				__func__, need_send_spec_key);
+                                if (!wake_lock_active(&main_wake_lock) && 
+                                    pressed && jiffies - last_jiffies < 75) {
+				        input_report_key(kp->input_devs->dev[dev], keycode, pressed);
+                                        last_jiffies = 0;
+                                        sent = 1;
+                                }
+                                else if (!wake_lock_active(&main_wake_lock) && pressed)
+                                    last_jiffies = jiffies;
+                                else if (wake_lock_active(&main_wake_lock) && sent) {
+				    input_report_key(kp->input_devs->dev[dev], keycode, pressed);
+                                    sent = last_jiffies = 0;
+                                }
 		}
 	}
 #endif
 
Last edited:

oclock

Senior Member
May 1, 2010
52
4
0
Currently it works like that:
Push trackpad - WAKE
Push trackpad again - UNLOCK

MENU and POWER don't unlock screen anymore (no unwanted calls)

It's kernel update so i believe it will only work with MCR r3.1 (which I am using)
Maybe you could describe what you changed in the kernel?
 

ieftm

Retired Recognized Developer
Apr 17, 2008
291
1,761
0
a kernel update? In earlier builds I saw this being done through modifying the services framework for the ROM.
 

bponury

Inactive Recognized Developer
Apr 29, 2010
1,394
4,806
0
Sydney
forum.paranoid.me
Maybe you could describe what you changed in the kernel?
I've changed drivers/input/misc/gpio_matrix.c and drivers/input/opticaljoystick/curcial.c
Also keyboard layout needs to be modified slightly (to disable power button wakeup)

a kernel update? In earlier builds I saw this being done through modifying the services framework for the ROM.
It's my first android phone and I'm just learning how to deal with it :)
And to be honest - I don't have a slightest idea how to change frameworks, I suppose I just live in low-level world.

If this can be achieved by modifying framework than this thread is useless and admin should delete it.
 

Konradwalsh

Senior Member
Aug 10, 2006
117
6
0
Galway
If this can be achieved by modifying framework than this thread is useless and admin should delete it.
To some degree yes... Bu t no one posted how to disable the power button. Also no one worked out how to make the track ball work. Before now, it was only the home, menu and back keys that worked by editing the framework.

So dont give up yet.. you are on to something I tried to do and failed.
 

TheAshMan

Senior Member
Feb 16, 2010
165
6
0
Well the fact that this was discussed earlier a little progress made, then nothing, and then you come along as a newbie to Android (first Android phone at least) with a possible solution, I think it's fair at least to grant you kudos for your work.

It definitely shouldn't be deleted. If it's stable then what's to say people shouldn't use it?

Even if this isn't the most elegant solution, it can at least be used as a base for future development.

Basically: nice work dude.
 

oclock

Senior Member
May 1, 2010
52
4
0
Even if this isn't the most elegant solution, it can at least be used as a base for future development.
Why do you think that a kernel patch is not an elegant solution?
We have the kernel sources, we can compile it, we can patch it, we can transfer it to new kernels and so on.

Modifying the framework means deodexing the hell out of it, disassemble (smali) it, decrypt the listing, assemble it again and so on.

I think a small kernel patch could be a much more elegant solution, also because you don´t change your kernel as often as your underwear :) And you dont´t have to wait for a new service.jar (or whatever framework file has to be modified) each time the software is updated by the vendor.

However, because I don´t know what he changed, it could also be a not so elegant solution ;)

Just my 2 cents.

Basically: nice work dude.
+1
 
Last edited:

lambrospower

Senior Member
Jul 5, 2009
508
2
0
Nicosia
www.mastergenius.net
well how do we do it ???? i want to do it with trackpad...post your guide here please, you can post links with space into the url till you have the necessary posts...

in addition can you tell us if you noticed difference in battery life ??? a xda member posted that since this is an optical trackpad it MIGHT be slept for battery reasons.
 

bponury

Inactive Recognized Developer
Apr 29, 2010
1,394
4,806
0
Sydney
forum.paranoid.me
Well the fact that this was discussed earlier a little progress made, then nothing, and then you come along as a newbie to Android (first Android phone at least) with a possible solution, I think it's fair at least to grant you kudos for your work.

Basically: nice work dude.
Thank you very much :)

Why do you think that a kernel patch is not an elegant solution?
Don't know what's elegant in android world I'm really new to this...

well how do we do it ???? i want to do it with trackpad...post your guide here please, you can post links with space into the url till you have the necessary posts...

in addition can you tell us if you noticed difference in battery life ??? a xda member posted that since this is an optical trackpad it MIGHT be slept for battery reasons.
Just flash zip like any other update (beware it was tested on MCR r3.1 - anything based on stock kernel should work (should) ). Also this update shouldn't have any impact on battery life it doesn't do anything active...

I want a trackball wakeup.
You can have it - first post.
 

Joshhudsy

Senior Member
Jun 7, 2010
108
4
0
26
Re: [DONE] Trackpad to wake

How do you go back to default settings, once flashed ?
Yeah it would be nice to be able to revert, anyone know how to get back?

-------------------------------------
Sent via the XDA taptalk app using my HTC Desire :)
 

ephumuris

Senior Member
Dec 7, 2008
3,678
633
0
33
Hull
Flash the stock kernel. I'd still like power button to work too. So i can use both trackpad and power. I can fix my trackpad but it only seems to last a few days at a time.
 

wuthton

Member
Feb 12, 2010
13
0
0
Excellent, works a treat for me, mcr 3.1.

Thankyou very much, I've wanted this for so long, the phone unlocks far too easy in my pocket with the power button.