Checking for stylus position change

by no2chem 29. April 2009 17:46

Cobaltikus asked if it was possible to detect stylus position change without the registry. After carefully inspecting keyboard driver, it appears that the registry is the best way. You would use code that looks like this:

VOID StylusThread()
{
	HANDLE	hEvents[2];
	HKEY	hKey;
	DWORD	dwSize = sizeof(DWORD);
	DWORD	dwStylusPosition = NULL;

	RegOpenKeyEx(HKEY_CURRENT_USER, _T("ControlPanel\\Keybd"), NULL, NULL, &hKey);
	
	hEvents[0] = CeFindFirstRegChange(hKey, FALSE, REG_NOTIFY_CHANGE_LAST_SET);
	hEvents[1] = CreateEvent(NULL, FALSE, FALSE, _T("NueSIPStylus\\KillSIPThread"));
	
	ResetEvent(hEvents[1]);

	while (TRUE)
	{
		if (WaitForMultipleObjects(2, hEvents, FALSE, INFINITE) == WAIT_OBJECT_0)
		{
			DWORD dwPrevious = dwStylusPosition; //save previous position
			RegQueryValueEx(hKey, _T("StylusOutStatus"), NULL, NULL, (LPBYTE) &dwStylusPosition, &dwSize);
			if (dwPrevious != dwStylusPosition)
			{
				//only change if StylusOutStatus was value that changed
				doSIPChange(dwStylusPosition);
				//don't forget to reset the event
				CeFindNextRegChange(hEvents[0]);
			}
		}

		else
		{
			//Wait failed, or kill event set
			break;
		}
	}

	//Clean up
	CeFindCloseRegChange(hEvents[0]);
	CloseHandle(hEvents[1]);
	RegCloseKey(hKey);
}

Okay, maybe that was a shameless test of if the prettify code plugin is working correctly. And I apologize for the lack of commented code (Actually, this code segment has way more comments than I typically do….)

Also, contrary to what I posted earlier, it is possible to query the current position of the stylus, although there is no nice API to do it. For those who know how to query GPIOs on the device, you want GPIO 0x25, at least on the RAPH800/DIAM500 (CDMA) devices, htc-linux.org doesn’t specify for GSM devices…

On the RAPH100 (GSM), it looks like there is no interrupt, and that the stylus thread waits for a named event - “StylusEvent”, and queries “KSC1:”, the MicroP controller on the position of the stylus. Fortunately, both drivers write the registry “StylusOutStatus” value, so as long as you query that, you’ll be okay.

nueSIPStylus will query the GPIO on CDMA devices and set the stylus position in the registry at boot, remedying the “take stylus out, soft reset, and put stylus back in before OS boots” problem, at least on CDMA devices.

Tags: ,

nueTools | Development

Comments


April 12. 2009 08:32 | Reply
Cobaltikus
This is exactly what I was already doing.  But when I came across the realization that it isn't set correctly on boot I thought I would ask about a different way.

However, I still truly appreciate the time you took to post this.

I will look into querying GPIOs. I'm sure the 0x25 thing will make perfect sense and be of great help when I get to that point. Do you have any recommendations for getting starting? "GPIO query source code" for nueSIPStylus maybe? feel free to email me anytime for anything.  I've been a big fan of nueROM and nueTools for about a year.

Peru hashim gujjar 
September 14. 2011 00:09 | Reply
hashim gujjar
thank's for sharing...<a href="eyewearconnection.com/...c-118.html">prada glasses</a>



July 26. 2010 11:44 | Reply
QQ
shameless test of if the prettify code plugin is working correctly. And I apologize for the lack of commented code (Actually, this code segment has way more comments than I typically do….)



July 26. 2010 11:53 | Reply
add
thought I would ask about a different way.

However, I still truly appreciate the time you took to post this.


April 4. 2011 01:09 | Reply
Buy watch online
This post is so much informative, It is much more regular than other process.Thanks everybody who are working in this project.


May 19. 2011 07:03 | Reply
wholesale costume jewelry
I'm sure the 0x25 thing will make perfect sense and be of great help when I get to that point. Do you have any recommendations for getting starting? "GPIO query source code" for nueSIPStylus maybe? feel free to email me anytime for anything.  


June 28. 2011 04:23 | Reply
coach small bags
A friend is a kind of help. Rain the life on the road, friends can block wind chill for you, for you share sorrow, remove the pain and difficulties, friends will always friendship.
He is you climb up the escalator when you were injured, is a medicine, is you when a bowl of water of hunger, is when you across the river is the boat; He is money can't buy orders not to come of, only the truly can track, and the most valuable for the real thing.
A friend is a kind of acacia, a friend is each other, each other about miss, mutual concerns, each other on. Missing is like a flow of endless river, like a gentle frivolous, like a cloud of a fragrant flowers, like a piece of lingering sound made by the wind.
Sometimes he also is a kind of light memories, light tea, light resonance......


July 6. 2011 04:29 | Reply
Wholesale Air Jordan
Nice post.Thank you for taking the time to publish this information very useful!I’m still waiting for some interesting thoughts from your side in your next post thanks


July 9. 2011 06:18 | Reply
Huge budget
If only the mediocre teams realised this then they could forget about trying to improve http://www.girlsloveshoes.info/ their car and just get a better driver...yup yup that makes sense if you are nutz.


August 8. 2011 11:38 | Reply
Cheap GHD Australia
Thanks for clearing this out


October 24. 2011 11:38 | Reply
Sydney restaurant
I wants to thank you with the endeavors you have produced in publishing this article. I am trusting the same greatest work from you within the future as well. In fact your fanciful writing abilities has inspired me to start my own we-blog now. Truly the blogging is spreading its wings rapidly. Your generate up is a fine example of it.Thanks yet again for discussing this cost-free on the web!


October 27. 2011 13:19 | Reply
Ferragamo sale
<a href="www.ferragamoshoessaleusa.net/belts-c-14.html">Ferragmo belt</a> from <a href="www.ferragamoshoessaleusa.net/vara-c-11.html">ferragamo outlet</a> has top quality with best craftsmanship. Now <a href="http://www.ferragamoshoessaleusa.net/"> Salvatore ferragamo sale</a> belts online with reasonable price and free shipping.


December 10. 2011 18:24 | Reply
pandora jewelry
GHBO[IFGKNPOVBKNPOVBKLVBN,PB


December 18. 2011 13:08 | Reply
barbour chelsea jacket
The ugg boots As the winter comes, you’ll understand how barbour jacket is vital and perhaps you opt to shop . While, in choosing a winter boots one has to be meticulous enough and it is important that the barbour coat you purchase is sturdy Barbour Jackets for Kids for the outside activities http://www.barbourquilted-jacket.net . it’s ugg boots for Kids necessary to think about your budget and raise yourself what proportion cash you’re willing to pay for a Barbour Jackets for Men. Be remembered look ugg boots for women online. http://www.winter-boots-sale.org/


January 2. 2012 08:44 | Reply
essay writing
Thanks for that code! I've been having a hard time in trying to change that one code, kudos!


January 15. 2012 07:22 | Reply
Rise University
Some useful stuff you have listed here. This is same stuff what i was searching for.

Add comment


(Will show your Gravatar icon)
Type If you can out:

  Country flag

biuquote
  • Comment
  • Preview
Loading



Disclaimer
Windows Mobile is a registered trademark of Microsoft Corporation in the United States and other countries.

Wei Enterprises is not affiliated in any way with Microsoft, HTC, Sprint, or any other wireless carrier/phone manufacturer otherwise mentioned on this site.

Copyright 2012 2009 Wei Enterprises