analog control

Just as a warning, I have little to no scripting/coding experience and have just jumped into this in the past week.

I’m trying to get a mouth opening and closing using an analog joystick control on a gamepad. I can get it to work with the mouse, but no so much with the gamepad controls. So my question is do I use something like pygame (if so, where do I stick it so that “import pygame” will actually find pygame?) or can I use the “directdevices” to get info about what I have running and thentry to figure out what it calls itself so I can map it’s X,Y values to X and Y trans values.

This is probably trivial, but I’m just not getting anywhere with it.


pygame is the tool to use. You should use pygame’s setup tool to install it with the version of Python 2.2 that ships with Panda. I’m not personally familiar with pygame’s installation mechanism. If pygame uses a file to install itself, this is easy:

ppython install

Otherwise, if pygame uses some custom installer, then you will have to specify the full path to your Panda python installation.


I have been able to use analog controls with pygame, but installing it wasnt straightforward. For some reason, the pygame installation exe doesnt recognize Panda’s python as a valid python directory. So I had to first install another version of python 2.2 on my machine. I then installed pygame into that version of python and checked the installation log. I took all of what was installed in the “official” python directory and copied it into the same folders of pandas python directory. There were two folders that I had to copy from one python path to another:


Then I could type import pygame into my panda files without error. Overall, it wasn’t too big of a hassle. I would like to know why pygame’s installation executable didn’t find panda’s version of python though.

I got an error when trying to install…cl.exe failed.
Should I have pygame within the same directory as panda or should it be installed in a directory at the same level as panda?

usually these installers try to detect your installed python version, the panda version isnt in the registery, so cant find it.
Easy solution is to install python 2.2 , then install your module (pygame) to that. Then copy the pygame dir from your 2.2 version to the panda version:





This seems to work with psycho and py2exe, havent actually tried with pygame. Hope this helps, almost the same thing russ told you though ^^

You can also force detection of panda as the good python version by adding this key in the registry:
Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.2\Help\Main Python Documentation]


@=“Python 2.2”



where python path must match Panda3D installation and pythonCore must be the level of python wished (ie 2.2 here).

Thanks! Works great now…I needed the right version of pygame to match with Python2.2. Apparently I was compiling it to go along with version2.4, but never got any messages telling me that. Anyway, thanks for all the help!

Could someone list some benefits of using the pygame library with panda? Or some examples of what the pygame libraries do that I wouldn’t have to recode from scratch ? I’m doing an exploration game

thanks in advance