?

Log in

No account? Create an account
LJ as software distribution, as notepad, as changelog... - Blather, Rinse, Repeat
April 22nd, 2004
11:43 pm

[Link]

Previous Entry Share Next Entry
LJ as software distribution, as notepad, as changelog...
So.


So. I program in Python. And I program games. You know, in my spare time. For the daylight hours, I program in C++ and I program games. But that's not important right now.

I was playing around with PyGame (blah blah contest, you're bored of that by now, I'm sure) recently, and I discovered that my configuration of this and that had two interesting behaviors:

a) on my laptop, when I asked for a joystick's name, I'd get something terribly unhelpful like "Microsoft Joystick Driver". Thank you very much, Microsoft.

b) when I plugged in more than two devices, I'd only get the first two. So if I were to, for instance, make a multiplayer game (I could link to Infection Wars, but like I said, you've had enough of that. You're welcome.) and offer the player a choice of 4 characters to control, it might be nice to have 4 joysticks. But, right, like I said, just two. As it happened, I also had two keyboard controllers, so I didn't really notice this problem.


Now, these might be bugs, they might be me not understanding what's going on - things are strange and complex, as a rule, and there's no reason that *I* should be the one whose expectations are met. (Speaking of which, I need to rant about AT&T one of these days.)

Right. So I inspected the code. Good first step. Nothing obvious. No manifest constants MAX_JOYSTICKS_IF_YOURE_DAVE = 2 or anything like that. I searched on the Internet. I don't know if you folk have heard about this thing, but appearantly, all of Mankind's collected knowledge is on this Internet thing. No hints about (b), but I got a lead on how to do (a) on my own. Turns out libsdl is doing something kinda like that already. Well, halfway. Seems like Microsoft has gone and changed stuff (imagine!) and so now you have to grovel around in the registry to find out what the name of your joystick is.

Yeah. So I wrote a little program that uses Microsoft's registry-querying code, and it identified all the controllers, just like I expected. (Well, turns out Microsoft had some bugs, too...).

Anyway, this seemed promising, but it didn't explain why PyGame/SDL/Windows was only seeing two devices. I downloaded SDL and compiled it up, no problem. I compiled a simple test program to link against my SDL library. No problem. Tested out the device count, it enumerated all the devices properly. Huh.

Downloaded the PyGame source, built PyGame wrapped around my (known working) SDL. Lo and behold, that worked fine. Even the test of my little script using pygame.joystick.get_count(), and for the first time, that script actually reported the right number.

So. So. Yeah, it looks like the latest versions of stuff that I built from source worked as expected, while the binary distributions have some weird bug. Perhaps it's a version issue, perhaps it's some other odd issue. Whichever, I had a workaround for issue (b).

I proceeded to plug in the code from here: http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarinput/html/msdn_extdirect.asp into SDL's joystick code. After I teased out Microsoft's bugs, that same script was reporting useful names for all 10 devices I have plugged in.

Yeah, so that's a high point of my evening.


I mowed and collected the tree limbs. Good grief. Something like 8 or 10 tree limbs, each 20 feet long. I now have a fortress in my driveway. I'll maybe post pictures. Or, you know, not. Maybe I'll find my saw instead and cut them down to manageable size. If only I had my own woodchipper. You know, like in "Fargo".

Ok, that's enough for tonight.

(Leave a comment)

My Website Powered by LiveJournal.com