I'm not really good with C++ and if I open a compiler like C++ Builder 6 I have no idea what's going on. I wrote a program in C++ BuilderX to control a robot and I built a parallel port controller for the motors but I need feedback for the position of the parts.
I had an old analog joystick that I wanted to take apart and use the potentiometers from but I don't know how to read the game port. I can do the parallel port with inpout32.
Question about the port: Is it just the game port that can accept analog input? I have to build an Analog to Digital converter for COM1-COM4 right?
I downloaded this source code but I get these errors:
aggregate 'REGS regs' has incomplete type and cannot be defined
'int86' undeclared
Code:
/* +++Date last modified: 05-Jul-1997 */
/*
** JOYSTICK.C
**
** Joystick support functions
**
** Public domain demo by Bob Stout
*/
#include <dos.h>
#include "snpdosys.h"
struct joystick JoyStick;
main()
{
read_joystick();
}
/*
** read_joystick()
**
** returns Success_ or Error_
**
** fills in global JoyStick structure
*/
Boolean_T read_joystick(void)
{
union REGS regs;
regs.h.ah = 0x84; /* Read the switches */
regs.x.dx = 0;
int86(0x15, ®s, ®s);
if (regs.x.cflag)
return Error_;
JoyStick.switch_0 = TOBOOL(regs.h.al & 0x10);
JoyStick.switch_1 = TOBOOL(regs.h.al & 0x20);
JoyStick.switch_2 = TOBOOL(regs.h.al & 0x40);
JoyStick.switch_3 = TOBOOL(regs.h.al & 0x80);
regs.h.ah = 0x84; /* Read positions */
regs.x.dx = 1;
int86(0x15, ®s, ®s);
if (regs.x.cflag)
return Error_;
JoyStick.pos_Ax = regs.x.ax;
JoyStick.pos_Ay = regs.x.bx;
JoyStick.pos_Bx = regs.x.cx;
JoyStick.pos_By = regs.x.dx;
return Success_;
}
It's funny, I have no idea what's going on. Sorry to post it here but I haven't had any time to teach myself. I really want to get the hardware operational.