elfs: (Default)
[personal profile] elfs
Okay, so tonight I did the geekiest thing I've done in a long time. I owed it to myself after being good and not wasting my time with bad anime or trashy "skiffy" romance novels but instead actually writing five hundred words in Cat In-Law Apartment, so I sat down and hacked some SDL, PyGame and some Linux kernel stuff.

First, I got the Linux kernel's hard-drive active protection system working. HDAPS is available on all late-model IBM Thinkpads, of which mine is one. I don't actually use it for hard-drive protection, as that's a proprietary Windozy thing, apparently, but it has other uses.

I haven't written game code since 1989 or so (no, that's not a typo, and get off my lawn!) so I studied the ins and outs of the SDL event layer, the joystick driver, and the sound file, and within about two hours I had the Linux equivalent of MacSaber.

W0oT! It turns on with the classic lightsaber startup sound, then idles in a low, menacing hum. Swing it and you get various "swing" sounds, come to a stop and it strikes or, if you stop fast enough, hits with a crackling burst. Hit ^C and you get the "vwoop" sound of the saber going off.

This is probably not terribly good for the poor machine, but what fun! Why should Mac geeks get all the fun?

My accelerometer numbers are all way off and I need to fix the event loop to stop the currently playing noise so multiple sounds won't overlap as they do now (except the idle sound, which you kinda want going all the time), but the prototype is completely in the bag.

By the way, this is written entirely with the SDL toolkit, so it's portable across Mac, Windows, and Linux. It uses only the first two axes of rotation, but it really doesn't need the third that Macs provide. (Lenovo makes a strong case that the third axis is unnecessary). Since I don't have a Mac, I have no idea what the device id is for the accelerometer; right now, it's relying on the device identifier 'HDAPS joystick' to find the right device, which isn't portable outside Thinkpads.

Download it: thinksaber.py, version 0.01α. It's really crude. You Have Been Warned. If you do get it running, please hold your Thinkpad firmly while experimenting. Don't do this in front of your SO unless you want to be giggled at.

Requirements: A thinkpad running Linux with the tp_smapi module loaded and hdaps enabled (I believe this is already done on those all-you-can-eat distros like Fedora and Ubuntu), plus SDL, SDL joystick, SDL mixer, and PyGame (It is entirely possible that if you have any games on your system, all of these are already present). You'll also need the sound files. To get the sound files, you'll have to download MacSaber's ZIP file and unpack it. Sound files should go in the same directory as the program, and then "just" (after all that, yeah) run:

python thinksaber.py

... and be a Thinkpad Jedi.

Date: 2008-07-09 06:45 am (UTC)
From: [identity profile] lisakit.livejournal.com
You're so cute when you're being geeky. ;p

Date: 2008-07-09 10:34 am (UTC)
From: [identity profile] woggie.livejournal.com
Wonderful. Now all I need is an accelerometer and knowledge of how to program in Python.

Date: 2009-04-03 12:09 pm (UTC)
ext_642892: (с кувалдою)
From: [identity profile] gvy.livejournal.com
Weeell, packaged for ALT Linux. :) Nice hack!

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 30th, 2025 09:12 pm
Powered by Dreamwidth Studios