PC Gaming
  Home arrow PC Gaming arrow Page 4 - Improving Input with Joysticks
Dev Hardware Forums 
Computer Cases  
Computer Processors  
Computer Systems  
Digital Cameras  
Flat Panels  
Hardware Guides  
Hardware News  
Input Devices  
Memory  
Mobile Devices  
Motherboards  
Networking Hardware  
Opinions  
PC Cooling  
PC Gaming  
PC Speakers  
Peripherals  
Power Supply Units  
Software  
Sound Cards  
Storage Devices  
Tech Interviews  
User Experiences  
Video Cards  
Mobile Linux 
APP Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PC GAMING

Improving Input with Joysticks
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 13
    2004-09-27

    Table of Contents:
  • Improving Input with Joysticks
  • Calibrating Joysticks
  • Tracking Joystick Movements
  • Revamping the Game Engine for Joysticks
  • Developing the Joystick Code
  • Building the UFO 2 Example
  • Testing the Finished Product

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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):

    #include <mmsystem.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:

    1. Open the project in Visual Studio (Visual C++).

    2. Right-click on the project's folder in Solution Explorer and click Properties in the pop-up menu.

    3. Click the Linker folder in the left pane of the Properties window and then click Input.

    4. 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.

    5. 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.


    SamsThis chapter is from Beginning Game Programming, by Michael Morrison (Sams, ISBN: 0672326590). Check it out at your favorite bookstore today.

    Buy this book now.

    More PC Gaming Articles
    More By Sams Publishing


       · First, I would like to say that a person shouldn't write an article on calibrating...
     

    PC GAMING ARTICLES

    - WoW-ing Online Gamers: What to Expect From t...
    - Age of Conan Review
    - Harnessing Video Game Power for Good
    - Grand Theft Auto IV Review
    - PC Games, a Dying Breed?
    - The Art and Psychology of Gaming
    - Halo 3 Hands On
    - GTA IV: Going Too Far?
    - FEAR Combat Review
    - Prey Review
    - Elder Scrolls IV Oblivion Review
    - PS3: Playing at a Whole New Level
    - F.E.A.R. Video Game Review
    - They Don`t Have to See It to Frag It
    - Do Violent Games Make Violent People?






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT