Wednesday, February 27, 2008

Time

For as long as I can remember now, time has only ever got faster. I never feel like I can do more than I used to - I'm always thinking how there just isn't as much time as there used to be.

Thursday, February 21, 2008

Powermate in C#

Well about four months ago I bought a Griffin Powermate. It's pretty much as good as they say except I think it could have been a little more solid. It looks a lot heavier in the pictures.

Now the only real gripe I had with the Powermate was the drivers. I battled for, I kid you not, days. I installed, connected, uninstalled, disconnected, reinstalled, reconnected this darn powermate so many times, that even by chance I should have got it to work.

The retailer I bought it from, SimplyMac.co.za in Johannesburg, wanted nothing to do with me. They simply denied me warranty on the item and told me to search Griffins site for help - Which I had already done by then! All I'm saying is that I will never buy from them again. Griffin was more helpfull,.. well nothing they suggested actually helped, but it didn't stop them from trying. I believe that if I carried on emailing their support team they probably would have got me to ship it over to get repaired.

I don't know how many people out there have battled with Powermates, but mine just seemed to move the cursor horizontally across the screen. The Powermate registers itself as a mouse-type device and thus without drivers will just cause the cursor to move slowly across the screen. With drivers and software you are meant to be able to assign more helpful actions to the Powermate; like changing the volume or scrolling your current document up and down. So since my Powermate made the mouse move without drivers, I reckon the problem must reside in the drivers. Surely if there was a fault in the Powermate itself then the device wouldn't register on the computer at all. Well whatever the problem is, shipping it over to the States is gonna cost be money. So some DIY was sounding good.

Yesterday I started snooping around C#, and hey,.. Presto! In half a day I managed to hack together a small app which:
1) Detects all the mouse HID's installed.
2) Links in to the data sent from the Powermate, and ..
3) Adjust the system volume or pump a page scroll.

Now I really did hack it together, I'm not even going to try take credit for the source. Having a good knowledge of Java and some C++ I managed to interpret the C# syntax without too much trouble but,... I'm not a C# guy so keep that in mind if you looking through the code.

Here's the source with binaries included: http://b22222.com/pmate.zip
Note: I coded this using MS Visual C# Express which I think uses dotNet 3.5

Directions for use:
Run PMate.exe (duh).
By default the Powermate then controls your volume.
If you press the Powermate it alternates to controlling page scroll.

The three thing's I'm not satisfied with yet in this solution are:
1) The program has a bit of delay while reading from the Powermate - Not ideal.
2) The Powermate still pumps regular mouse events. So pressing the Pmate still invokes context menus :/
3) I don't know how to properly hide the form, so it infact just minimised without a taskbar button. This allows you to still ALT-tab to the app.

At the end of the day though I'm quite happy with the solution. It gives me a bit of a geeky thrill turning the Powermate and knowing that I somehow got it to change my volume.