Lakario ----- Original Message ----- From: botman Sent: Friday, December 07, 2001 6:03 PM To: [EMAIL PROTECTED] Subject: Re: [hlcoders] Joystick Fun > So for that dial thingy I should probably just search the msdn for the reference > code I assume? > > Lakario
If by "dial thingy" you mean the potentiometer inside the joystick, then no, MSDN won't tell you anything about the way the potentiometer works.
<electrical engineering mode=on> The joystick works by adjusting the setting of a potentiometer for each axis (one for the X and one for the Y). The potentiometer is a variable resistor that can increase or decrease the flow of electrons in a wire (i.e. reduce or increase the resistance, respectively). There is a constant voltage applied to one side of the potentiometer (usually +5V) and the other side is fed into an A/D (analog to digital) converter. The A/D converter takes the input voltage from the potentiometer and converts that a binary value (let's assume it's a 16 bit D/A converter). When the voltage is at the higher value (+5V), the A/D converter will output the largest value (32768 if it's a signed 16 bit value). When the potentiometer is moved to the opposite position, the voltage will be at it's lowest value (0V) and the A/D converter will output the lowest value (-32768 if it's a signed 16 bit value). As you adjust the potentiometer between the lowest setting and the highest setting, the potentiometer will adjust the resistance and thus change the voltage (since according to Ohm's law, these are inversly proportional) and the A/D converter will output a binary value between the lowest value and the highest value in proportion to the setting of the potentiometer. <electrical engineering mode=off>
Of course, you don't care HOW the joystick works, all you need to know is that you get a large binary value when the joystick is at one setting, you get a small binary value when the joystick is at the other setting, and you get values in between these when the joystick is moved from one position to the other extreme. The MSDN documents will tell you how these values are returned in the Windows API. You can also just look through the Half-Life SDK code in inputw32.cpp to see what it does with these values that get returned from joyGetPosEx().
Jeffrey "botman" Broome
_______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
|