Zorac (zorac) wrote,
Zorac
zorac

  • Mood:
  • Music:

Keyboard hacking

Once upon a time, many moons ago, I came into possession of an exciting Multimedia Keyboard on the grounds that it was cheap. I never used the multimedia stuff because it was, frankly, pants. This evening I decided to play around with it again...

[ Image of the multimedia keys ]

Having grabbed the latest drivers, I did some poking around and discovered a handy .reg file containing the default registry settings. While the UI only allows you to change the actions of a few of the "multimedia keys" the .reg file suggested I might be able to do better than that. A quick bit of registry hacking later, and the "Play" button that was previously locked to the useless player supplied with the drivers now opens notepad.

Now to do something useful: tie the Msg button to open Pine instead of Lookout Express, the X'fer (?) button to open Directory Opus and the Menu button to open (for want of something better) SSH. The calculator and WWW buttons I left unchanged.

Next job: To get the nifty "You've Got Mail!" LED working. The software that comes with the keyboard only speaks POP3, and I use IMAP, so there's always something in the INBOX. That's OK, I have a nice Linux box sitting as a server/firewall between my network and the ADSL line to the Internet, so all I need is a little POP3->IMAP proxy to handle this simple request. 29 lines of Perl later, and I've got a nice little daemon that takes connections from the keyboard app, uses the username and password supplied to log onto the imap server, get the count of unread messages and return that to the client. (It helps that I've peen playing around with the 2 protocols a fair bit recently). I now get a blinking LED if (and only if) I do indeed have new mail.

Last thing: To replace the naff "Media Player" with control of Winamp - this is where I needed the registry hacking to override the default actions. The main difficulty here was that the command line utils I found wouldn't work with Winamp 3β - a quick downgrade to version 2.81 (still plays Ogg Vorbis, thankfully) later, and that was working too. Juggling the play/pause/stop functionality onto two buttons proved a bit of a problem, soon overcome (why do I need stop?).

So, there you have it. Useless junk to useful features in just a couple of hours' work. Now I just have to remember to use the buttons instead of, say, a Win-P-N-P-Enter key combo...
Subscribe

  • Not quite the Neverending Story

    I mentioned a couple of weeks back that I was playing The Longest Journey - an entry of that oft-neglected genre of computer games, the…

  • Random media ramblings...

    SomethingAwful has a bunch of B-Movie-style poster spoofs which are well worth a look. Page 8 has the HP one, most of the rest are pretty good…

  • Movie misdirection...

    And the "totally misleading trailer of the week" award goes to Bridge to Terabithia. Given the current cinematic drought, I was happy to catch a…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 4 comments
*clap clap clap clap*

Not just because of the choice of music but because of the hack, which seems to me to be a true hacker's hack. I particularly like the "You've Got Mail!" LED hack. Be careful - everyone at work will want one...

I may be demonstrating more misunderstanding of mail transfer protocol than usual but how frequently is your IMAP server polled for new mail?

Next challenge: can you get your "scroll lock" light to flash three times whenever there's a new entry on your Friends page? ;-)
Problem is, at work I use Linux on my desktop, and I still need the keyboard driver to read the extra keys (could probably map those from within X) and flash the LED (there I'm a bit stuck). Plus I've got a *really* nice DIGITAL (pre-Compaq, pre-HP) keyboard that I'd be loathe to give up.

Erm... OK, I'll try to explain (from first principles - ish). POP is designed to hold mail on the server until you download it onto your local machine, IMAP is designed to store email on the server and be read from there (possibly cached by local clients). This means that my INBOX always has loads of messages in it. The keyboard app talks POP, so it always sees messages in m INBOX, which it assumes are new and unread. Hence the problem, hence the proxy. The polling is done by the keyboard app, which I have talking to the proxy. When the proxy receives the POP STAT command (to return the number of messages), it connects to the IMAP server and does a STATUS INBOX (UNSEEN) which gives the count of unread messages rather than the total number of messages, and then returns this to the keyboard app. Phew. In answer to your question, the IMAP server is polled for new mail whenever the keyboard app polls the proxy (once a minute at the moment).

Well... The Windows LJ client flashes its system tray icon when there are new Friends entries, if there's some way to flash the keyboard LEDs thru' the windows APIs (I know you can in Linux - there's even a feature to flash kernel panic in morse code) then it would be possible to add this feature (source code is available).
Oh dear. I was hoping that I would be proposing something impossible or almost impossible and you already have a sound-looking plan of attack... :-)

Damn, you're good!
And a quick google turned up evidence of existing email apps that do the scroll-lock-flahsing thing to alert to new mail, so it's definately possible.

On the downside, my Windows programming skills amount to a bit of Delphi a few years back, so don't expect to see any actual code ;-)