Gaming

  Home arrow Gaming arrow Improving Input with Joysticks
Watch our Tech Videos 
Dev Hardware Forums 
Computer Cases  
Computer Processors  
Computer Systems  
Digital Cameras  
Flat Panels  
Gaming  
Hardware Guides  
Hardware News  
Input Devices  
Memory  
Mobile Devices  
Motherboards  
Networking Hardware  
Opinions  
PC Cooling  
PC Speakers  
Peripherals  
Power Supply Units  
Software  
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 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
GAMING

Improving Input with Joysticks
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 14
    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
     
     

    SEARCH DEV HARDWARE

    Improving Input with Joysticks


    (Page 1 of 7 )

    When designing games, it's important to know how to interpret and respond to joystick input in your own games. Learn how to properly calibrate a joystick in Windows XP, how to add joystick support to the game engine, and more. (From Beginning Game Programming, by Michael Morrison, 2005, Sams, ISBN: 0672326590.)

    morrisonNote - Released in 1980 by Atari, Centipede is one of the first games to rely on a trackball for user input. Centipede was quite popular in its day and still has some devoted fans. Centipede owns the distinction of being the first video game created by a woman, Dona Bailey, which is no small feat considering how few women worked in the video game industry in its early days.

    From its inception, the joystick has been used chiefly as an input device for game systems. Admittedly, its name alone limits its usage to the entertainment industry, as I doubt too many accountants would purchase a "joystick" for crunching numbers in a spreadsheet. At any rate, joysticks and game pads both play an important role in modern video games of all kinds, including computer games. For this reason, it's important for you to have an understanding of how to interpret and respond to joystick input in your own games. This chapter introduces you to joysticks and what makes them tick, along with providing you with the knowledge and source code to handle joystick input in games.

    In this chapter, you'll learn

    • The basics of responding to joystick input in games

    • How to properly calibrate a joystick in Windows XP

    • How to add joystick support to the game engine

    • How to use the new and improved game engine to create interesting programs that respond to a joystick

    Understanding Joystick Basics

    The concept of a joystick is straightforward, although you might be surprised by how loosely a joystick is defined in terms of Windows programming. In Windows, a joystick is a physical input device that allows variable movement along different axes with multiple pushbuttons. That's the geeky description of a joystick. What it means is that a joystick is an input device that can move in several different directions. Notice that I said several directions, not just two. Although a traditional joystick is thought of in terms of two axes (X and Y), a joystick in Windows can actually have up to six axes. Fortunately, we aren't going to worry about more than two joystick axes in this chapter, which helps simplify things considerably.


    Note - The six possible joystick axes supported by Windows can be arranged in many different ways. A traditional joystick has two axes that correspond to moving the joystick handle from side-to-side (one axis) and forward and back (another axis). A third axis of movement can be added by allowing the joystick handle to be pushed and pulled vertically. A fourth axis can be the twisting of the joystick handle. The fifth and sixth axes apply to more advanced input devices and are typically used for keeping track of moving the entire joystick in 3D space, such as with an input glove.


    Because a traditional joystick has only two axes of motion, you can think of the joystick in much the same way as you think of the mouse. Although a mouse can be moved in any direction, its movement is limited to a single plane. In other words, you can always resolve mouse movement into an XY value. Joysticks are similar in this manner because you can identify their movement according to how far the handle is being pushed along each axis. If side-to-side movement is along the x axis and forward and back movement is along the y axis, a joystick can be tracked in a manner similar to the mouse by using an XY value.

    Also similar to the mouse are the buttons on a joystick. Just as mouse devices are capable of supporting multiple buttons (typically three at most), joysticks are also capable of having several buttons. In fact, joysticks are much more flexible than mouse devices in terms of how many buttons they can have; joysticks in Windows are allowed to have up to 32 buttons. It would probably take super-human memory skills and hand/eye coordination to figure out how to use a joystick with that many buttons, but the option is there if someone wants to make a joystick for the truly gifted among us. A more realistic number for joystick buttons is six, which is still a lot to keep track of for the average game player. Similar to mouse button and keyboard key presses, handling joystick button presses is relatively straightforward, as you learn a little later in the chapter.

    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

    GAMING ARTICLES

    - 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