C # Programming the game handle to develop-API (1)

Source: Internet
Author: User

Some time ago spent 38 yuan from the Internet to buy a pair of North pass USB game handle, so the weekend and evening leisure time can play when the boy's SFC and arcade simulation game.

One day on a website to play a flash game, suddenly thought, if you can also use the handle to play flash games, it should be more fun. But unfortunately, the current flash is not supported on the game to program the handle, which is unavoidable in flash a regret.

Although the flash does not support the game handle programming, but we can change the way to do an auxiliary program (plug?) To convert the action event in the handle to an acceptable keyboard and mouse action event in Flash, so that you can use the game handles to play flash games?! So, the Internet to check the relevant information, but found that only C + + case, and C # One also find no, this does not matter, their own hands, ample clothing.

(Note: Similar to this function, the network already has off-the-shelf software, is a Japanese development, called Joytokey)

There are probably two ways to manipulate game handles: using system APIs or using DirectInput to manipulate game-handle devices. (There may be other ways, but my knowledge is limited and other ways are unknown)

Using the system API is one of the easiest ways, because the system has helped us to encapsulate all the details, as long as we are in the program to get the status of the game handle equipment (round robin).

The API for manipulating game handles (rods) has the following:

Function name Function description
Joygetnumdevs Gets the number of game devices supported by the current system
Joygetdevcaps Query gets the specified joystick device to determine its performance
Joysetcapture To request the system to capture a game device and periodically send the device's status value through a message to a window
Joyreleasecapture To release a capture of a game device
Joygetpos Get the coordinate position and button status of the game device
Joygetposex Get the coordinate position and button status of the game device
Joygetthreshold Queries the current move threshold for the specified joystick device
Joysetthreshold Sets the move threshold for the specified joystick device

Among them, according to different methods of call can be divided into two ways.

1 Passive mode:

Call the Joysetcapture method, to the system to apply for a game handle capture, if the successful application, the system will be the game handle the status of information through the message way to a window.

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.