Home arrow Gaming arrow Page 4 - Improving Input with Joysticks
Watch our Tech Videos 
Dev Hardware Forums 
Computer Cases  
Computer Processors  
Computer Systems  
Digital Cameras  
Flat Panels  
Hardware Guides  
Hardware News  
Input Devices  
Mobile Devices  
Networking Hardware  
PC Cooling  
PC Speakers  
Power Supply Units  
Sound Cards  
Storage Devices  
Tech Interviews  
User Experiences  
Video Cards  
Weekly Newsletter
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Contact Us 
Site Map 
Privacy Policy 
  >>> SIGN UP!  
  Lost Password? 

Improving Input with Joysticks
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 14

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


    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 Gaming Articles
    More By Sams Publishing

    blog comments powered by Disqus


    - An Ugly Side to Gaming`s Boy`s Club
    - Wii U Offers Secretly Cool Features
    - OUYA Raises Millions for Open Console Game P...
    - OUYA Kickstarter Project: Bring Back Great G...
    - WWE 13 Video Game: First Look
    - Game Review: Max Payne 3
    - The Top MUD Games
    - Game Review: Tiger Woods PGA Tour 13
    - Game Review:MLB 12 The Show
    - Game Review: Twisted Metal
    - The Top PS Vita Games
    - PlayStation Vita Review
    - Game Review: Star Wars The Old Republic
    - Game Review: WWE 12
    - Video Game Review: X-Men Destiny

    Developer Shed Affiliates


    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
    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