Improving Input with Joysticks - Revamping the Game Engine for Joysticks
(Page 4 of 7 )
The discussion of joysticks has been leading to a task that you probably knew was coming: another enhancement to the game engine. The idea is to continue beefing up the game engine with features so that the unique code for each game remains as minimal as possible. Knowing this, it's important to place as much joystick handling code in the game engine as possible. Before showing you the code, however, it's important to clarify a compile-time issue related to the Win32 joystick functions and data structures.
Accessing Win32 Multimedia Features
Although joystick support is now a standard part of Win32, this wasn't always the case. A multimedia subsystem was later added separately to the Win32 API—of which joystick support is a part. For this reason, the joystick functions and data structures are not defined in the standard windows.h header file; instead, they are located in the mmsystem.h header file, which is provided as part of the Win32 API. The following is an example of how you include this file in your code (GameEngine.h):
Okay, there's nothing tricky there. However, just importing the header file into GameEngine.h isn't enough because the executable code for the joystick support is located in a separate library that you must link into your games. This library is called winmm.lib, and it is included with all Windows compilers. Before you attempt to compile a Windows program that takes advantage of joystick features of the Win32 API, make sure that you change the link settings for the program so that the winmm.lib library file is linked into the final executable. Refer to the documentation for your specific compiler for how this is done or follow these steps if you're using Microsoft Visual Studio:
Open the project in Visual Studio (Visual C++).
Right-click on the project's folder in Solution Explorer and click Properties in the pop-up menu.
Click the Linker folder in the left pane of the Properties window and then click Input.
Click next to Additional Dependencies in the right pane and type a space followed by winmm.lib. You should already have the msimg32.lib library entered here, which is why it is necessary to type a space before entering winmm.lib.
Click the OK button to accept the changes to the project.
Note - Of course, you don't have to worry about any of these steps if you just use one of the project files provided on the accompanying CD-ROM, which supports Visual Studio, C++Builder, and Dev-C++. For every example in the book, a project file exists with all the correct compiler and linker settings already made.
After completing these steps, you can safely compile a program and know that the winmm.lib library is being successfully linked into the executable program file.
Note - The source code for the examples in the book includes Visual Studio project files with the appropriate linker settings already made.
This chapter is from Beginning Game Programming, by Michael Morrison (Sams, ISBN: 0672326590). Check it out at your favorite bookstore today.
KEITHLEE2zdeconfigurator/configs/INFUSIONSOFT_OVERLAY.phpzdeconfigurator/configs/ OFFLOADING INFUSIONSOFTLOADING INFUSIONSOFT 1debug:overlay status: OFF overlay not displayed overlay cookie defined: TI_CAMPAIGN_1012_D OVERLAY COOKIE set: status off