Showing posts with label thinkpad. Show all posts
Showing posts with label thinkpad. Show all posts

Thinkpad Accelerometer: I did it!

No comments:
Quick update: I did it! I dug in a little further and solved the problem - turns out wrapping sensor.dll was the right approach after all.

However, it was quite a learning experience. It turns out that JNative comes with a bunch of pre-wrapped windows libraries including all of kernel32.dll's exports. It also turns out that JNative has a utility method that enumerates a DLL's exports (although it remains silent on expected arguments, alas). It also turns out that working with kernel32.CreateFile was a dead end (which I discovered only after trying to run the Perl and first version of the C# code on my machine.) Perhaps that strange file hand \\.\ShockMgr was for older thinkpads, I dunno.

Now I need to program a game to use the data. But first I need to write a calibration routine. It's funny how similar 2D accel data is to a joystick (it's analogue data which measures force)...

...and so I have discovered another example of a wildly over-designed Java API, called JInput. Check it out:

http://www.newdawnsoftware.com/resources/jinput/apidocs/ (javadocs)
https://jinput.dev.java.net/ (project home)
http://www.javagaming.org/forums/index.php?topic=16866.0 (getting started)

JInput comes with it's own sizable JNI baggage, apart from a silly API, so I think I'll skip it for now. I may look at it later for examples on how to do high resolution polling with JNI if I need that.

Future directions: I think it would be great to get this working on Linux. I know that accel data is present in 2.6 kernels. It would also be cool to get this working on powerbooks (and what's really cool is that I guess they have a 3rd axis). In fact it looks like that would be easier because the code already exists:

http://homepage.mac.com/dave_chatting/boiling-frogs/motion/README.html

Eventually I'll get something running on the iPhone, too. :)

http://blog.medallia.com/2007/08/iphone_accelerometer_source_co.html

Do you want to see the code? You can check it out at sourceforge. Here are some handy URLS:

http://ocjug.wiki.sourceforge.net/Thinkpad+Acceleromter+project (project page)
http://ocjug.svn.sourceforge.net/viewvc/ocjug/trunk/thinkpad-accel/src/JNativeTest3.java?view=markup (code)

https://ocjug.svn.sourceforge.net/svnroot/ocjug/trunk/thinkpad-accel (svn access)

Note that I tacked on a DLL export routine to main() for giggles.

I'll be integrating with the included space invaders code, and perhaps JInput, in the coming weeks.

Thinkpad Accelerometer: mystery solved

No comments:
According to MSDN, that strange path-like structure is a "communication resource handle" on which there are several possible operations. These operations are fully documented (for example the CreateFile function).

Oddly, I noticed similar path strings in Windows Services. Take this executable path: "C:\bin\Tomcat 5.5\bin\tomcat5.exe" //RS//Tomcat5. My guess is this is an internal attempt to avoid running tomcat twice, similar to using a PID file. But that's probably not what it is since tomcat won't start again because of port conflicts - a sort of port PID.

Here's another - "C:\bin\Tomcat 5.5\bin\tomcat5w.exe" //MS//Tomcat5 (for monitoring tomcat)

Thinkpad software woes

No comments:
First, I have to give props: IBM (well, Lenovo I guess) really does a good job including some useful software with their laptops. I like the presentation manager, and the new Access Connections is useful too, and their backup software is excellent as well. Their hardware/software security stuff is top notch. And of course, the Thinkpad is the best business laptop hardware money can buy - they aren't always the fastest, but they take a beating.

But I have to admit being exasperated by some recent issues.

IBM's backup utility "Rescue and Recovery" started crashing on me after System Update updated some other software. But System Update didn't offer an update for R&R. So I went to IBM's site to see wassup - sure enough, there was an update (and a whopping 440M update at that).

So I download the enormous file, and try to install. Turns out it needs Client Security Solution 8.0 or better to install. OK.

So I download that file (another 60M) and try to install. Turns out CSS needs IBM Fingerprint Software 5.5 or better to install. OK.

So I download and install the Fingerprint software. It mostly works, except it wants a BIOS password from me for "TPM" and I have no idea what it is. I pray.

It turned out that password didn't screw everything up, and I installed CSS, and now R&R is installing and I just pray that I have enough disk space to get it all on. I know I won't have enough to defrag (which usually requires about 15% free space).

OK, it's working. I was able to get through this - but heaven help the poor shmo who isn't as tenacious as me.