3D Navigation in Pascal
There's a 3D navigation device out there that helps navigating Google Sketchup (or Google Earth if you just want to us it for fun) by getting rid of the need to constantly switch between navigation tools to get to the view you want. This device is called SpaceNavigator, from 3DConnexion. The downside of this device is that it can only be used with applications that do support it. There is a special driver from a committed SpaceNavigator fan available on their support forums, but this driver works only on 32-bit Windows, emulating a mouse, keyboard or joystick.
Using a 64-bit Windows, I could not use that driver, but wanted mouse emulation at least myself. Looking at the installed files, I noticed a type library that seemed to be part of the interface, so I hacked together a small unit making use of this library: pk3DConnexion.pas, which also needs the typelib unit TDxInput_TLB.pas. Using these two units, you can easily add SpacePilot support (or that for any other 3DConnexion device probably) to your Delphi application, just create a T3dConnexionDevice object, check if Loaded is true, set the event handlers for OnRotation, OnTranslation and OnKeyChange/OnKeyUp/OnKeyDown, and poll your required information with PollRotation, PollTranslation, PollKeys or Poll (polls them all). The property MouseEmulation conversts, as the name says, the device to a system-wide mouse, including left and right button and the scrollwheel (support for horizontal scrollwheel under Vista pending).
Left to implement might be to detect newly connected devices while the application is running, for example, but hey, this is just some quick demonstration code.
