Yet another crazy idea from team 810. this time, instead of the serial port, we need help with the gameport. my friend found out how to hook up two joy sticks to the gameport, and has some crazy idea for a program. i can’t say what it is, for that will ruin the surprise.
basically, what i need is a simple way (prefereablly just a console app) that can read the gameport. something similar to the serial white paper (the author’s name escapes me at the moment) would help a lot. we do know how to make it work if we were to use two serial ports, but we’re not sure if that’s possible (i think it is, but i can’t be sure).
so, if anyone has any information on how to use the gameport in a C++ program, or how to set up a joystick on a serial port (i’m not sure how you would read back analog values), i’d be very thankful.
OK, you’ve got a few options. Let me know which one appeals to you and I’ll write another paper (the serial one was mine).
Option 1: DirectX. Advantages: Industry standard. Can support more axes/buttons than the next method. Disadvantages: a lot of overhead for setting up DirectInput, only works under Windows
Option 2: Assembly!!! Yup, you can do it straight from assembly. Advantages: none of the DirectX stuff, can be used w/o windows. Disadvantages: it’s assembly. 'nuf said.
In all honesty, assembly isn’t really that bad, especially if you have someone tell you exactly what to write in your code–it’s the method I’d recomend for a simple project like this.
However, as I said before DirectInput is the industry standard nowadays, so if you want to learn it for the pure sake of learning some introductory DirectX, I’d be happy to write a paper on that too.
As for doing it through a serial port, it just isn’t going to happen. A joystick uses a different pin for each axis/set of buttons, but a serial port has only one pin for data.
My Linux box just died a slow, painful death with lots of pretty colors, so I’m off to remedy that (and maybe sleep?), but let me know which you’d prefer.
–Rob
(I could have the assembly one done in about 20 mins. The DirectInput might take a few days)
i was kind of hoping there’d be a nice happy thing like the serial port (the readfile thing). i finally understand that now :).
i’m mostly a C++/PBASIC programmer, but i guess i could learn either assembly or directx (isn’t that a library extension onto C++ or something like that?). one thing though, i believe like the dashboard program i made, it will be creating a text file that is read into a flash program. that means there needs to be enough resources to let the flash program work (which there should be either way if we use a good computer, but i believe we’ll be using this at school, and well, the school computers pretty much suck :p). if you can write something up in assembly in 20 minutes, then it never hurts to try. if you can find the directx stuff it’d be interesting to try, but don’t kill yourself trying to do it. and thanks for the help ;).
i second that motion that school computers suck. Board of Ed in NYC stinks all together and needs to start chippin and gettin us robotics schools something decent to work with other then the old 486’s / penitium 100’s and pros etc. how does a 486 make it in the year 2002 must create thread on this. cya
Well, I tried the assembly stuff I had lying around and it worked fine under DOS but gave a BSOD under Windows. I know I’ve asked this before, but what compiler are you using? If it’s VC++, I think I have a fairly painless solution for you. Otherwise, things could get difficult. Also, do you normally use the Win32 SDK (with Windows, WndProc, etc)? If not, this could get very interesting very fast.
If you want to see some DirectInput code, it’s included in RoboEmu 1.03(?) and higher in order to allow binding to real joysticks.
In order to use this stuff, you’ll have to tell your compiler to link in the winmm.lib library.
Calibration comes from the Gaming Options control panel, but you’ll probably want to check the values yourself just to make sure.
Finally, to access joystick #2, replace JOYSTICKID1 with JOYSTICKID2 in the joyGetPosEx function.
Anyway, I hope this helps. Let me know if something goes wrong or if you want some more detail/additional options. Alternatively, check out the MSDN library entry for JOYINFOEX.
Anybody had a chance to try this yet? If it works on other peoples’ systems, I’ll write up a formal white paper, but I want to make sure it’s going to work first. Anyway, let me know if you have questions or want more info.
I haven’t had a chance to try it yet because I’m in the middle of installing gentoo on my computer, but i should be able to give it a whirl sometime this weekend. If it works i’ll tell you, but i’ll need a bit of time to try it out. thanks for the help.