In the Windows environment by programming to manipulate the mouse, keyboard is a simple thing, but have you ever thought to try another one of our more common input tools-game joystick? In some cases, especially in the form of small game software, the addition of support to the joystick can provide users with a more user-friendly man-machine interface, greatly improve the game software to play.
There is no specific control bar function in the C++builder (which is essentially not in common programming languages), so to increase support for the joystick is to deal with the MCI API functions of Windows, and here we'll start with some of the properties, states that read the joystick, The API functions, constants, and data structures to use for location and button information.
Related constants:
#define MM_JOY1MOVE 0X3A0/* Some messages to pass the current state of the joystick * *
#define Mm_joy2move 0X3A1
#define Mm_joy1zmove 0x3a2
#define Mm_joy2zmove 0X3A3
#define Mm_joy1buttondown 0X3B5
#define Mm_joy2buttondown 0x3b6
#define MM_JOY1BUTTONUP 0x3b7
#define MM_JOY2BUTTONUP 0X3B8
#define JOY_BUTTON1 0x0001/* Used to indicate the status of the current joystick * * *
#define JOY_BUTTON2 0x0002
#define JOY_BUTTON3 0x0004
#define JOY_BUTTON4 0x0008
#define JOY_BUTTON1CHG 0x0100
#define JOY_BUTTON2CHG 0x0200
#define JOY_BUTTON3CHG 0x0400
#define JOY_BUTTON4CHG 0x0800
/* Game Joystick Error return value * *
#define JOYERR_BASE 160
#define JOYERR_NOERROR (0)/* Normal */
#define JOYERR_PARMS (JOYERR_BASE+5)//Parameter Error * *
#define Joyerr_nocando (JOYERR_BASE+6)/* Not working properly * *
#define JOYERR_UNPLUGGED (JOYERR_BASE+7)//Joystick Not connected * *
/* Joystick Identification number */
#define JOYSTICKID1 0
#define JOYSTICKID2 1