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.