.comment-link {margin-left:.6em;}
Moriash Moreau: My Second Life
Sunday, August 06, 2006
Just finished a little weekend project I've been kicking around for a while now. I've taken a USB numeric keypad, ripped out its innards, and wired a set of contacts to the six main SL-related movement keys (forward, back, left, right, page up, page down- I seldom use the strafe keys). Basically, at this point, it's just a bare interface board for future use. But now I have a handy way to easily wire all sorts of things into SL movement.

Of course, the controller will require a script within SL to use it properly. Some people (see below) have used external hardware and software to intercept the signals and pre-process them before sending them to SL (by programming keypress lengths, detecting time-outs for key release, and so on). Given that my real-world programming skills are virtually non-existent, I'm shifting the processing burden onto LSL scripts in game. That, at least, I know pretty well. Ultimately, I don't see this being any more demanding than the typical vehicle script, or simply walking your avatar from one end of the room to the other. As far as SL is concerned, a keypress is a keypress, no matter the actual hardware source behind it.

I have a few nebulous plans, but nothing terribly concrete at this point. I'd originally wanted to come up with a virtual flying bicycle kind of thing, similar to the vehicle used in Prop Cycle. Unfortunately, I've had a bear of a time finding a cheap, used stationary exercise bike. I guess they're sufficiently out of style that they're not even being sold used anymore.

I'm still looking for an exer-cycle, mostly because I loved that video game, and I can't seem to find it anymore. But, in the interim, I'm kicking around wiring up my existing treadmill to map into in-world walks. Recently, I've taken up walking on said treadmill, in order to cope with the ever-expanding case of swivel-chair spread caused by spending all day sitting in front of a computer, followed by coming home to spend all night in front of a computer. And since playing Second Life for hours on end has been a major contributing factor to my voluminous spare tire, it seems fitting that SL at least make working it off again a little more entertaining.

Also, at least in my pipe dreams, I'd like to look into walking next year's SL Relay for Life using such a setup. It'd be kind of neat to walk the virtual track for real. But that will ultimately depend on whether I can come up with a reasonable vehicle and/or attachment that can walk the path without causing problems with things like climbing stairs and maneuvering around other pedestrians. That, and on my general willingness to be a spectacle and/or laughing-stock if I publicize it.

For the sake of completeness, I should mention that this kind of externally-controlled virtual movement has been done in SL before, by Kyle Machulis (AKA qDot Bunnyhug in SL), and possibly others. I've pretty much given up on originality in SL. It's all been done before. But it should still be fun to play with. I'm sure I'll post more when I come up with some applications for the controller.

Addendum, 8/14/06:
This project was posted in Make blog! How cool is that? I guess I'll have to get my rear in gear and use it for something. Thanks to Mark Wallace (aka Walker Spaight) for the post and the heads-up.

Since I didn't give any specifics earlier, I thought I'd take a moment to briefly describe how I wired this mess up. There's nothing too exotic about it, really. The main issue was coming up with a way to make solder points on the keyboard membrane. As you may already know, most cheap keyboards nowadays use thin plastic sheets as substrates for the switches and associated conductors. Under each key, a contact is painted on the plastic with metallic paint. The key pushes down and mashes the plastic sheets together in such a way that two of these contacts meet.

That works fine for the intended purpose, but it doesn't lend itself to tinkering. I wasn't brave enough to try and solder directly to the plastic, and I was too cheap to spend $25 on conductive silver epoxy cement, so I came up with a mechanical connection, instead. I don't claim that this is the best way to do it, but it seems to work well enough for my purposes.

First, take apart the keyboard. Profuse swearing seems to help here. Inside, you'll find the circuit board, USB cable wiring (careful- thin wires!), and the aforementioned sandwich of plastic sheets. The "bread" is actually a single sheet of plastic, folded in half. The "meat" is another sheet with holes cut out under each switch contact. This acts both as an insulator and a spacer. You'll probably end up cutting this piece out before the project is done. Don't expect to use the keyboard for anything else (such as, say, a functional keyboard) after this process.

We're interested in the outer layer of plastic. Carefully fold this layer open. You may not want to press it completely flat, as the plastic at the fold (and the associated wiring that runs through it) is sharply creased, and could easily crack or break.

Now figure out which contacts you wish to bridge, by referring back to the keys themselves and finding where they'd land when pressed. Next, take a straight pin and carefully punch two holes in the plastic at the contact: one off to the side, and one inside the conductive paint (see the bottom view, above). I found it useful to place it against a stiff, but easily pierced, surface when doing this. (I used the bull's-eye core from a plastic foam archery target, but a flat chunk of Styrofoam would do just as well.) Make the hole in the conductive paint somewhat off center (as shown), in order to maximize contact area.

That brings us to the wire. Find a short length of stiff, solid-core wire. (I used 22 gauge, just because I had it handy.) Bend it into a rough "J" shape. Then, bend the bottom cross-piece of the "J" into a horizontal "S" curve. This both maximizes contact area with the conductive paint and lends the wire some stability, once it's installed. It also makes it easy to make minor width adjustments if you misjudged the distance between the pin holes.

Once you have your bent wire, push the two vertical segments into the pin holes. The short leg should penetrate the painted contactor, while the long leg penetrates the empty plastic. This order is probably not required, but it put another couple millimeters of unimportant, empty plastic between the heated portion of the wire and the metallic paint conductor. It seemed like a good idea to have a little bit of a buffer, in case the plastic started melting during soldering later on.

Be careful not to bend, crease, or tear the plastic. And don't apply too much force to the connection between the plastic sheet/circuit and the main circuit board. (The connecting socket on mine looked a bit fragile.) Once the wire is seated, it should rest flat against the plastic and the painted contact. See step one in the side view, above.

Then, once the wire is in place, carefully bend the short leg over such that it clamps onto the plastic (as shown in step two, above). Crimp it as tight as you can without damaging the plastic.

Now, all that remains is to insulate and stiffen the connection. You'll want to find something relatively stiff to glue over the connection. I ended up using scrap Velcro patches (about 1/2" square), because they were made with stiff plastic and had a foam tape backing. (And I already had them, a big plus.) I expect thin double-sided foam tape and a piece of plastic would work just as well. I added a smaller piece on the opposite side of the plastic, just to lend the assembly additional stiffness. See step three, above.

And that's that. As for soldering, well, I am really bad at that. All I can recommend is that you use a heat sink and take all possible steps to avoid melting the plastic sheets. Be sure to avoid twisting the wire as you work. The mechanical connection created is reasonably stiff, but it is very easy to tear the plastic and loosen the connection under torque.

Oh, in case you're wondering, the little plastic button in the picture above is wired to the NumLock key on the keypad. You'll probably want to do the same thing, so you can turn off number lock when you're using your board to control movement in-game. On most systems, number lock defaults to "on" when the computer reboots or when a new keyboard is installed

Addendum, 8/20/06:
I've just finished my first project using the controller box. Seems to work pretty well.
Whoa. I seriously wish I had something like this, like a foot pedal, mapped to the forward arrow, or maybe something more akin to a Dance Dance Revolution pad with different directions. Then I could walk and talk at the same time... at last.
Earlier today at the local electronics supply, I even ran across some surplus foot pedal switches. I almost bought three of them to hook up to left, right, and forward contacts on the controller, just for this purpose.

But I got to wondering how well it would work if you were the only one able to walk and talk at the same time. You'd still have to stop when other members of the conversation were typing. (Or I suppose you could walk in circles around them.) And you can't move while the IM window is in the foreground. I suppose it could be useful if you were leading a tour, or something similar where you'll be the one doing most of the talking, though.
Hey! First off, neat to see someone else doing control projects with SL! However, in terms of interface, you may want to start looking at libsl versus key hooks/simulation, if you're going specifically for SL control. That way you can just form the messages directly versus trying to get window focus and key sends correct. I'll be doing an article on this sometime this week since I demoed my new interface based on it at SLCC.
Yeah, it would be nice to bypass the focus issues. I'll definitely be reading the article- I saw mention of it in one of the SLCC followup articles, as well. I don't expect I'll understand it, but I'll sure be reading it.
Post a Comment

Links to this post:

Create a Link

Return to Main Page