Using game joysticks in C + + Builder

Source: Internet
Author: User
Tags data structures

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.