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.
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.
No comments:
Post a Comment