TweetFollow Us on Twitter

Inside InputSprocket

Volume Number: 15 (1999)
Issue Number: 1
Column Tag: Games Programming

Inside InputSprocket

by Brent Schorsch

How to Use InputSprocket to Support User Input in Games

Introduction

Handing user input is a necessary aspect of a game. Without user input, it is not a game, but just a flashy movie. This article will cover what a game developer needs to do in order to handle user input using InputSprocket, Apple's gaming input API. InputSprocket was created to address the lack of a common API for joysticks and other gaming devices on the Macintosh platform. With the introduction of the iMac and USB, InputSprocket has opened the door for numerous gaming hardware manufactures to sell their products to Macintosh customers. Game developers also benefit by supporting InputSprocket because their game will support the latest input gadgets with no extra effort from the game developer. Game players benefit from the increased options.

The Basics

InputSprocket is a relatively simple API to use. There are some more complicated aspects, which will be covered later, but the basics are straightforward. First, an application must provide a list of its input needs to InputSprocket. Example needs a game might have are: fire weapon, jump, turn, look, rudder, lower landing gear. The list of needs determines how the user can interact with the game and therefore will directly affect whether the game is thought to be hard to control or very intuitive and flexible.

Once InputSprocket is initialized and has the list of needs, there is a single API call (ISpConfigure) which will bring up a user interface, provided by InputSprocket, for the user to map the physical elements of the device to needs in the game. InputSprocket maintains the user's settings in a preference file. This dialog is pictured in Figure 1.

During game play, the application can either get events or poll the current value for any of these needs. Typically, applications will get events on 'button kind' needs (and others) and poll the value of 'axis kind' needs once per game loop. The different 'kinds' of needs is covered later.


Figure 1. InputSprocket Configure Dialog.

The 'Low Level' Interface

In fact, there are two different ways an application can use InputSprocket: 'low-level' and 'high-level'. The 'low-level' interface provides a means for the developer to get a list of the devices currently available and manually check the state of each device. This interface is strongly discouraged. It is provided for those developers who wish to provide their own user interface to configuring device, but it puts a much greater burden on the game developer. With this interface, the game developer is responsible for determining how each kind of device might be configured to work with their game and to provide a complete user interface to make this configuration. Games that use the 'low-level' interface lose any extra functionality that is provided by the high level interface. The rest of this article will focus on the 'high-level' interface, which is the one that all game developers are encouraged to use.

Determining the Game's Needs

There are four basic need kinds: button, direction pad (dpad), axis and delta. (There is also a movement kind, but its use is discouraged.) Each kind has a different data format. The button kind is the simplest, with values of up or down. A dpad has nine possible values: idle, left, up-left, up, up-right, right, down-right, down, and down-left. An axis kind's value is a 32 bit unsigned number, regardless of whether it is symmetric. Finally, the value of a delta type is a 32 bit Fixed point number of inches moved.

When deciding what kind to make a particular need, one should prefer the axis kind to button and dpad kinds when applicable. This will allow game players to get the full functionality out of their equipment. Sure, keyboard users may only be able to either walk or run (forwards or backwards), but if someone has a device with enough 'analog' inputs, the game should let him continuously vary his speed. In some cases, it may be necessary to provide some extra information to InputSprocket so that the keyboard user experience is maintained which is covered later. Delta kinds are provide data similar to 'raw mouse' data but due to limitations in the current InputSprocket drivers, are most useful in the more complex InputSprocket cases, where once again extra information is provided.

In some cases, it may make sense to provide several needs that affect the same thing in the game world. For example, in addition to a 'next weapon' and 'previous weapon' need, it often makes sense to provide needs to switch to specific weapons, e.g. 'use machine gun', 'use plasma rifle'. The code necessary to support these different means to switch weapons is trivial, but the added functionality to certain users (with the right hardware) is immense. The speech recognition InputSprocket driver does not add much if you can only say 'next weapon', but if you can say 'use plasma rifle', then it might start to be appealing. Another case where multiple needs might make sense is where the need is some form of toggle, such as 'map mode' or 'landing gear'. One button may be sufficient for most users, but if the hardware physically has two states, like the caps lock key on some keyboards or any sort of lever, then it is very easy for the physical device to become out of sync with the game. However, by adding two more needs, switch to map view (or landing gear up) and switch to non-map view (or landing gear down), it is impossible, when properly configured, for the hardware to be out of sync with the game, regardless of the starting state of the game and the hardware.

Finally, it often makes sense to use the native data types as input for the game. This is a case where the game essentially gives InputSprocket extra information so that it can behave better. It does this by providing multiple needs, of different data kinds, to change the same thing in the game state. An example where this is useful is for the traditional rudder controls on a flight-sim. Typically, the keyboard commands to change the rudder are 'Increase Left Rudder', 'Center Rudder', and 'Increase Right Rudder'. Each time either of the 'Increase ...' keys are pressed, the current rudder value is changed. In order to restore the plane back to no rudder, you have to either manually press the keys enough times to get back to center, or press the 'Center Rudder' key. The current 'InputSprocket Keyboard' driver does not allow the user to configure an axis need to three keys like this, so this case calls for using extra needs. In addition to the rudder axis need (for those who have a device such as a rudder or twisting joystick), the game will have three button needs: left rudder, center rudder, and right rudder. The axis need should set the kISpNeedFlag_Axis_AlreadyButton bit in the ISpNeed, flags field and the button needs should set the kISpNeedFlag_Button_AlreadyAxis bit. Another common case for using button and axis types is for a throttle in a flight-sim.

Listing 1 contains the complete list of needs chosen for the sample application. Listing 2 is an excerpt from the sample application which demonstrates using axis and button types to change yaw angle. The kISpNeedFlag_Button_AlreadyDelta bit is also set, because the sample application also reads delta types separately. Typically, delta types are used when the developer wants the 'feel' of using a mouse to be similar to how it typically feels in a first person shooter, like Unreal or Quake.

Listing 1: ISp_Sample.h

This is an excerpt from ISp_Sample.h containing the enumeration
of all the needs.

enum
{
    // primary needs
    
    kNeed_FireWeapon,
    kNeed_NextWeapon,
    kNeed_PreviousWeapon,
    
    kNeed_Roll,
    kNeed_Pitch,
    kNeed_Yaw,
    kNeed_Throttle,
    
    kNeed_StartPause,
    kNeed_Quit,
    
    // secondary needs for alternative input kinds
    
    kNeed_Weapon_MachineGun,
    kNeed_Weapon_Cannon,
    kNeed_Weapon_Laser,
    kNeed_Weapon_Missle,
    kNeed_Weapon_PrecisionBomb,
    kNeed_Weapon_ClusterBomb,
    
    kNeed_Roll_AsDelta,
    kNeed_Pitch_AsDelta,
    kNeed_Yaw_AsDelta,
    
    kNeed_Yaw_Left,
    kNeed_Yaw_Center,
    kNeed_Yaw_Right,
    
    kNeed_Throttle_Min,
    kNeed_Throttle_Decrease,
    kNeed_Throttle_Increase,
    kNeed_Throttle_Max,
    
    kNeed_NeedCount
};

Listing 2: ISp_Sample.c

Input_Initialize
This is an excerpt from Input_Initialize which initializes
the needs array.

    //* we'll init all the player 1 items now 
    //* (everything but quit unless we add a second player)
    tempNeed.playerNum = 1;
    // [snip - code removed from this listing]    
    // Now group 4, which is for changing yaw
    tempNeed.group = 4;

    GetIndString (tempNeed.name, kSTRn_NeedNames, 
                      kNeed_Yaw + 1);
    tempNeed.iconSuiteResourceId = 1000 + kNeed_Yaw;
    tempNeed.theKind = kISpElementKind_Axis;
    tempNeed.theLabel = kISpElementLabel_Axis_Yaw;
    tempNeed.flags = kISpNeedFlag_Axis_AlreadyButton;
    myNeeds[kNeed_Yaw] = tempNeed;
    
    GetIndString (tempNeed.name, kSTRn_NeedNames,
                    kNeed_Yaw_Left + 1);
    tempNeed.iconSuiteResourceId = 1000 + kNeed_Yaw_Left;
    tempNeed.theKind = kISpElementKind_Button;
    tempNeed.theLabel = kISpElementLabel_None;
    tempNeed.flags = kISpNeedFlag_Button_AlreadyAxis | 
                   kISpNeedFlag_Button_AlreadyDelta |
                   kISpNeedFlag_EventsOnly;
    myNeeds[kNeed_Yaw_Left] = tempNeed;
    
    GetIndString (tempNeed.name, kSTRn_NeedNames,
                 kNeed_Yaw_Center + 1);
    tempNeed.iconSuiteResourceId = 1000 + kNeed_Yaw_Center;
    tempNeed.theKind = kISpElementKind_Button;
    tempNeed.theLabel = kISpElementLabel_None;
    tempNeed.flags = kISpNeedFlag_Button_AlreadyAxis | 
                   kISpNeedFlag_Button_AlreadyDelta | 
                   kISpNeedFlag_EventsOnly;
    myNeeds[kNeed_Yaw_Center] = tempNeed;
    
    GetIndString (tempNeed.name, kSTRn_NeedNames, 
                kNeed_Yaw_Right + 1);
    tempNeed.iconSuiteResourceId = 1000 + kNeed_Yaw_Right;
    tempNeed.theKind = kISpElementKind_Button;
    tempNeed.theLabel = kISpElementLabel_None;
    tempNeed.flags = kISpNeedFlag_Button_AlreadyAxis | 
                   kISpNeedFlag_Button_AlreadyDelta | 
                   kISpNeedFlag_EventsOnly;
    myNeeds[kNeed_Yaw_Right] = tempNeed;

Listing 2 also demonstrates the other fields that must be filled in the ISpNeed structure. The name field contains a string to be displayed to the user in the configuration dialog (shown in Figure 1), typically in the popup menus for each device element (although the strings appear directly for keyboard devices). The iconSuiteResourceId field contains the resource ID for an icon family that represents that need. Typically 'ics#' and 'ics8' icons are provided, since all the current drivers only display 16x16 icons. The theKind field determines whether the need is a button, delta, axis, dpad, or something else. The theLabel field is used to give hints to InputSprocket about how the need is used. There will inevitably be needs in every game that are not described by one of the labels in InputSprocket.h, those needs should use the kISpElementLabel_None label. Another bit set in the flags field in this listing is kISpNeedFlag_EventsOnly which tells InputSprocket that it does not have to maintain state information for this need. The group was set at the top of the listing, so that it is the same for all these needs. By convention, all the needs which affect the same game state are set to the same group. The full source for Input_Initialize in ISp_Sample.c uses five groups: changing weapon, roll, pitch, yaw, throttle.

Initialization

There are several InputSprocket functions which will typically be necessary during initialization. First, ISpGetVersion should be used to confirm that InputSprocket is available and of a minimum version for the game. Next, ISpStartup should be called to get InputSprocket up and running. ISpElement_NewVirtualFromNeeds is used to create and allocate virtual elements for each need. Virtual elements are the objects that are used to get events or are polled. Now ISpInit can be called to initialize the 'high-level' interface to InputSprocket. ISpInit provides InputSprocket with the needs list and the previously allocated virtual elements. It is often convenient to get events on an element list, which is just a grouping of (in this case virtual) elements. ISpElementList_New is used to allocate a new elements list and ISpElementList_AddElements is used to add one or more elements. Typically, one element list is used for all the regular button needs and an additional element list is created for each group of buttons which correspond to an axis need. Listing 3 is an excerpt from Input_Initialize which demonstrates all of these functions.

Listing 3: ISp_Sample.c

Input_Initialize
This is an excerpt from Input_Initialize which initializes
InputSprocket with the needs list and builds an element list.

    //* Alright, now that the array is set up, we can call ISp to init stuff
    err = ISpStartup ();
    if (err)
        ErrorAlert("\pCould not Initialize InputSprocket.", err, true);

    //*    Setup the input sprocket elements
    err = ISpElement_NewVirtualFromNeeds(kNeed_NeedCount, 
            myNeeds, gInputElements, 0);
    if (err)
        ErrorAlert("\pCould not create ISp virtual controls from needs.", 
               err, true);

    //*    Init InputSprocket and tell it our needs
    err = ISpInit (kNeed_NeedCount, myNeeds, gInputElements, 
                    kISpSampleCreator, kISpSampleNeedsVersion, 
                    0, ksetl_ISpSample, 0); 
    if (err)
        ErrorAlert("\pCould not initialize high-level ISp.", err, true);

    //* Create a element list containg all the 'normal' buttons (we get events on these)
    err = ISpElementList_New(0, NULL, &gEventsElementList, 0);
    if (err)
        ErrorAlert("\pCould not create button element list.", err, true);
    
    //* we set the refcon to the need enum value, so we can use it later
    //* doing some shortcut error checking for readability
    err  = ISpElementList_AddElements (gEventsElementList, 
                    kNeed_FireWeapon,         1, 
           &gInputElements[kNeed_FireWeapon]);
    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_StartPause,         1, 
           &gInputElements[kNeed_StartPause]);

    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_NextWeapon,         1, 
           &gInputElements[kNeed_NextWeapon]);
    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_PreviousWeapon,     1,
           &gInputElements[kNeed_PreviousWeapon]);

    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_Weapon_MachineGun, 1,
           &gInputElements[kNeed_Weapon_MachineGun]);
    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_Weapon_Cannon,     1, 
           &gInputElements[kNeed_Weapon_Cannon]);
    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_Weapon_Laser,     1, 
           &gInputElements[kNeed_Weapon_Laser]);
    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_Weapon_Missle,     1, 
           &gInputElements[kNeed_Weapon_Missle]);
    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_Weapon_PrecisionBomb,1, 
           &gInputElements[kNeed_Weapon_PrecisionBomb]);
    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_Weapon_ClusterBomb,1, 
           &gInputElements[kNeed_Weapon_ClusterBomb]);

    err |= ISpElementList_AddElements (gEventsElementList, 
                    kNeed_Quit,             1, 
           &gInputElements[kNeed_Quit]);

    if (err)
        ErrorAlert(
      "\pCould not fill button element list. Error number may be inaccurate.", 
       err, true);

Cooperating with Mac OS

By default, InputSprocket assumes that a game has its own method, using traditional Mac OS techniques, to get user input from all mice and keyboards. If a game wants to use InputSprocket for keyboard and/or mouse input, it must enable those classes of device with ISpDevices_ActivateClass. Activating the mouse class will disconnect all mice and trackballs from controlling the cursor, so should only be done while the game is in progress and only if the Mac OS cursor is not necessary to play the game. Activating the keyboard class will prevent the keyboard from generating any Mac OS events, although GetKeys will still function.

The game developer must decide whether to use InputSprocket for mouse and/or keyboard input. Using InputSprocket for mouse input is recommended for games that do not use the Mac OS cursor during play. The primary advantages in this case are that multi-button mice are easily supported and configured, and that the user interface is consistent with other gaming devices. For those game developers who do not already have a method they prefer to get keyboard data, using InputSprocket for this purpose will save time. However, InputSprocket is not an appropriate way to get 'typing' input from the user (such as a message that the user is sending to other players), so the keyboard class should be deactivated and traditional Mac OS means used whenever 'typing' is initiated.

Because InputSprocket assumes control of all the active devices when it is active, it is necessary to suspend it when the application is placed in the background. When the application is placed in the foreground again, InputSprocket may be resumed. It is very important that InputSprocket not be left active when the application is not front-most. These operations are normally performed on the response of a suspend/resume OS event and are performed by the functions ISpSuspend and ISpResume. It is safe to use these functions at other times while the application is front-most if desired. However, a slightly better experience may be possible if just the keyboard and mouse classes are disabled. This way, for example, the 'start' button on a gamepad can still be used to start a game. The sample application takes the latter approach.

Getting User Events

The sample application sets up a element list for all the normal button elements with the refcon value the same as the enum value for that need. This makes taking action based on the event almost trivial, as listing 4 demonstrates. ISpElementList_GetNextEvent is used to get the next event on the queue for the element list. ISpTickle is a way to give time to InputSprocket drivers even if the game does not call WaitNextEvent. It must be called at task level (not interrupt level), but is only required for drivers which must be manually enabled (like speech recognition). It is recommended that all games give time, but it is not necessary. It is also reasonable for a game to limit calls to ISpTickle to a few per second.

Listing 4: ISp_Sample.c

Input_ GetButtonEvents
This function is used to modify the gameState structure
if any of the primary buttons have been pressed. This
function is called as part of the normal game loop.

void    Input_GetButtonEvents (Input_GameState * gameState)
{
    OSStatus            error = noErr;
    ISpElementEvent        event;
    Boolean             wasEvent;
    
    // give time to some non-interrupt driven input drivers (like speech recognition)
    ISpTickle ();
    
    // get all pending events
    do
    {
        error = ISpElementList_GetNextEvent (gEventsElementList, 
                                        sizeof (event), &event, &wasEvent);
        
        if (wasEvent && !error)
        {
            switch (event.refCon)
            {
                case kNeed_FireWeapon:
                    if (event.data == kISpButtonDown)
                    {
                        gameState->fireWeaponState = true;
                        gameState->fireWeaponCount++;
                    }
                    else // (event.data == kISpButtonUp)
                        gameState->fireWeaponState = false;
                    break;
                    
                case kNeed_StartPause:
                    if (event.data == kISpButtonDown)
                    {
                        if (!gameState->gameInProgress)
                            gameState->gameInProgress = true;
                        else
                            gameState->gamePaused = 
                                !gameState->gamePaused;
                    }
                    break;
                    
                case kNeed_NextWeapon:
                    if (event.data == kISpButtonDown)
                    {
                        gameState->currentWeapon++;
                        if (gameState->currentWeapon >= 
                                    kWeapon_WeaponCount)
                            gameState->currentWeapon = 0;
                    }
                    break;
                    
                case kNeed_PreviousWeapon:
                    if (event.data == kISpButtonDown)
                    {
                        gameState->currentWeapon-;
                        if (gameState->currentWeapon < 0)
                            gameState->currentWeapon = 
                                    kWeapon_WeaponCount - 1;
                    }
                    break;
                    
                case kNeed_Weapon_MachineGun:
                    if (event.data == kISpButtonDown)
                        gameState->currentWeapon = kWeapon_MachineGun;
                    break;
                    
                case kNeed_Weapon_Cannon:
                    if (event.data == kISpButtonDown)
                        gameState->currentWeapon = kWeapon_Cannon;
                    break;
                    
                case kNeed_Weapon_Laser:
                    if (event.data == kISpButtonDown)
                        gameState->currentWeapon = kWeapon_Laser;
                    break;
                    
                case kNeed_Weapon_Missle:
                    if (event.data == kISpButtonDown)
                        gameState->currentWeapon = kWeapon_Missle;
                    break;
                    
                case kNeed_Weapon_PrecisionBomb:
                    if (event.data == kISpButtonDown)
                        gameState->currentWeapon = 
                            kWeapon_PrecisionBomb;
                    break;
                    
                case kNeed_Weapon_ClusterBomb:
                    if (event.data == kISpButtonDown)
                        gameState->currentWeapon = kWeapon_ClusterBomb;
                    break;
                    
                case kNeed_Quit:
                    gameState->gameInProgress = false;
                    break;
            }
        }
    }
    while (wasEvent && !error);
}

Polling Axis Values

The sample application reads axis values for roll, pitch, yaw, and throttle. The most complicated one is yaw, which is shown in listing 5. When there are both an axis and button needs that map to the same game state, there is an easy technique to get the correct behavior. First, ISpElement_GetNextEvent is used on the axis element just to check to see if the axis value changed. If it did change, then ISpElement_GetSimpleState is used to poll the current value of that axis element. Both the axis element and the element list are then flushed. However, if the axis value has not changed (wasEvent is false), then ISpElementList_GetNextEvent is used to get all the button events on the element list containing the buttons for the axis. Delta values are actually handled differently at a higher level, so they are read and accumulated into a separate value in the state structure.

Listing 5: ISp_Sample.c

Input_GetYaw
This function is used to modify the gameState structure to include
the latest changes in yaw based on user input. This function is
called as part of the normal game loop.

void    Input_GetYaw (Input_GameState * gameState)
{
    OSStatus                    error = noErr;
    ISpElementEvent        event;
    Boolean                     wasEvent;
    ISpAxisData            axisValue;
    SInt32                        yawValue = gameState->yawInput;
    
    // we check the axis, to see if _it_ was moved, if so, we use that value
    error = ISpElement_GetNextEvent (gInputElements[kNeed_Yaw], 
                    sizeof (event), &event, &wasEvent);
    if (!error && wasEvent)
    {
        // we wish to ignore all button presses _prior_ to this moment
        ISpElementList_Flush(gYawElementList);

        // get the current value
        error = ISpElement_GetSimpleState 
                                    (gInputElements[kNeed_Yaw], &axisValue);
        if (!error) 
            yawValue = 
                ISpAxisToSampleAxis (axisValue, kMin_Yaw, kMax_Yaw);

        ISpElement_Flush(gInputElements[kNeed_Yaw]);
    }
    // otherwise, we check to see if one of the yaw buttons was pressed
    else do
    {
        error = ISpElementList_GetNextEvent (gYawElementList,
                                     sizeof (event), &event, &wasEvent);
        
        // only process valid keydown events (all the yaw events ignore button ups)
        if (wasEvent && !error && (event.data == kISpButtonDown))
        {
            switch (event.refCon)
            {
                case kNeed_Yaw_Left:
                    yawValue -= kIncrement_Yaw;
                    if (yawValue < kMin_Yaw) yawValue = kMin_Yaw; 
                    break;
                case kNeed_Yaw_Center:
                    yawValue = kMin_Yaw + ((kMax_Yaw - kMin_Yaw) / 2);
                    break;
                case kNeed_Yaw_Right:
                    yawValue += kIncrement_Yaw;
                    if (yawValue > kMax_Yaw) yawValue = kMax_Yaw; 
                    break;
            }
        }
    }
    while (wasEvent && !error);
    
    gameState->yawInput = yawValue;
    
    //* also check the delta values
    gameState->deltaYaw = 0;
    do
    {
        error = ISpElement_GetNextEvent
                         (gInputElements[kNeed_Yaw_AsDelta], 
                            sizeof (event), &event, &wasEvent);
        if (wasEvent && !error)
            gameState->deltaYaw += (Fixed) event.data;
    }
    while (wasEvent && !error);
}

InputSprocket Resources

InputSprocket checks for certain resources inside an application. First, the application should have an InputSprocket application resource ('isap') which simply specifies how the application uses InputSprocket. Next, the application should have a set list resource ('setl'). It is ok if there are no sets contained in this resource, but it should be present. The set list resource contains pointers to individual saved-set resources ('tset'). Saved set resources contain a set of configuration information for a single device for a specific application. InputSprocket.r contains a resource template for a saved-set resource that corresponds to a keyboard device. This template can be used to put keyboard defaults in a '.r' file. The saved set resources for all the other devices do not have templates. This means that the developer must execute the built game, manually create each set he wants to include with the game, and then copy these sets from the active 'Input Sprocket Preferences' file (in the Preferences folder) to his '.r' file. The sample application includes two sets for the keyboard and two for the mouse. Fortunately the default settings for most drivers (other than the keyboard) are pretty good if the developer is careful about ordering his needs list, so it is usually not necessary to provide sets besides those for the keyboard. Listing 6 contains the resource description for the default keyboard set in the sample application. If the keyboard saved set resource does not have the correct number of items, then it will not function even though it may still be displayed in the sets menu. The easiest way to debug this is to compare a saved set resource generated by a '.r' file with one created by the 'InputSprocket Keyboard' driver in the 'InputSprocket Preferences' file. Also note that the default sets are only copied once from the application to the 'InputSprocket Preferences' file, so it usually will be necessary to delete the 'InputSprocket Preferences' file from the preferences folder several times during development.

Listing 5: ISp_Sample.r

ktset_DefaultKeyboard
This is the resource description for the default keyboard
set in the sample application.

#define        rNoModifiers    rControlOff, rOptionOff, rShiftOff, \
                   controlOff, optionOff, shiftOff, commandOff
 
resource 'tset' (ktset_DefaultKeyboard, "Default (Keyboard)")
{
    supportedVersion,
    {    
        /* kNeed_FireWeapon */
        kpd0Key, rNoModifiers,
        
        /* kNeed_NextWeapon */
        kpd9Key, rNoModifiers,
        
        /* kNeed_PreviousWeapon */
        kpd7Key, rNoModifiers,
        
        /* kNeed_Roll */
        /* min (left/down/back) */
        kpd4Key, rNoModifiers,
         
        /* max (right/up/forward) */
        kpd6Key, rNoModifiers,

        /* kNeed_Pitch */
        /* min (left/down/back) */
        kpd5Key, rNoModifiers,
         
        /* max (right/up/forward) */
        kpd8Key, rNoModifiers,
        
        /* kNeed_Yaw */
    /* this need does not generate any items, because it has later button equivalents */
        /* kNeed_Throttle */
    /* this need does not generate any items, because it has later button equivalents */
    
        /* kNeed_StartPause */
        tildeKey, rNoModifiers,
        
        /* kNeed_Quit */
        qKey, rControlOff, rOptionOff, rShiftOff, 
         controlOff, optionOff, shiftOff, commandOn,
        
        /* kNeed_Weapon_MachineGun */
        n1Key, rNoModifiers,
        /* kNeed_Weapon_Cannon */
        n2Key, rNoModifiers,
        /* kNeed_Weapon_Laser */
        n3Key, rNoModifiers,
        /* kNeed_Weapon_Missle */
        n4Key, rNoModifiers,
        /* kNeed_Weapon_PrecisionBomb */
        n5Key, rNoModifiers,
        /* kNeed_Weapon_ClusterBomb */
        n6Key, rNoModifiers,

        /* kNeed_Roll_AsDelta */
        /* this need does not generate any items - the keyboard does not do deltas */
        /* kNeed_Pitch_AsDelta */
        /* this need does not generate any items - the keyboard does not do deltas */
        /* kNeed_Yaw_AsDelta */
        /* this need does not generate any items - the keyboard does not do deltas */

        /* kNeed_Yaw_Left */
        aKey, rNoModifiers,
        /* kNeed_Yaw_Center */
        sKey, rNoModifiers,
        /* kNeed_Yaw_Right */
        dKey, rNoModifiers,

        /* kNeed_Throttle_Min */
        kpdEqualKey, rNoModifiers,
        /* kNeed_Throttle_Decrease */
        kpdMinusKey, rNoModifiers,
        /* kNeed_Throttle_Increase */
        kpdPlusKey, rNoModifiers,
        /* kNeed_Throttle_Max */
        kpdSlashKey, rNoModifiers,

    };
};

Final Word

Using InputSprocket for user input in games is a good idea. It is relatively simple to implement, and both the developer and game player benefit. With the introduction of the iMac, and its USB ports, the number of input devices available to Macintosh customers is ballooning. At the time this was written, the current version of InputSprocket was 1.4. The latest version and information is available at http://developer.apple.com/games/sprockets. Examining the sample application, which was written using the techniques in this article, should be the next step for a developer interested in using InputSprocket. The finished application is pictured in Figure 2.


Figure 2. ISp_Sample in action.


Brent Schorsch is the engineer at Apple Computer, Inc. responsible for InputSprocket. Brent enjoys reading science fiction novels, reading a dozen or so books a month. In addition, Brent is an avid game enthusiast. His favorite games are those that can be played against human opponents. In such battles, he answers to the handle 'Ender' which he acquired playing Bungie's 'Minotaur' back in the dark ages. You might find him online on iMagicOnline's WWII flight-sim, Warbirds, using the handle '-endr-' flying for purple.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

TextSoap 8.4.1 - Automate tedious text d...
TextSoap can automatically remove unwanted characters, fix up messed up carriage returns, and do pretty much anything else that we can think of to text. Save time and effort. Be more productive. Stop... Read more
Backblaze 4.3.0.44 - Online backup servi...
Backblaze is an online backup service designed from the ground-up for the Mac. With unlimited storage available for $5 per month, as well as a free 15-day trial, peace of mind is within reach with... Read more
Numi 3.15 - Menu-bar calculator supports...
Numi is a calculator that magically combines calculations with text, and allows you to freely share your computations. Numi combines text editor and calculator Support plain English. For example, '5... Read more
EtreCheck 3.3.3 - For troubleshooting yo...
EtreCheck is an app that displays the important details of your system configuration and allow you to copy that information to the Clipboard. It is meant to be used with Apple Support Communities to... Read more
BusyContacts 1.1.8 - Fast, efficient con...
BusyContacts is a contact manager for OS X that makes creating, finding, and managing contacts faster and more efficient. It brings to contact management the same power, flexibility, and sharing... Read more
TunnelBear 3.0.14 - Subscription-based p...
TunnelBear is a subscription-based virtual private network (VPN) service and companion app, enabling you to browse the internet privately and securely. Features Browse privately - Secure your data... Read more
Apple Final Cut Pro X 10.3.4 - Professio...
Apple Final Cut Pro X is a professional video editing solution.Completely redesigned from the ground up, Final Cut Pro adds extraordinary speed, quality, and flexibility to every part of the post-... Read more
Hopper Disassembler 4.2.1- - Binary disa...
Hopper Disassembler is a binary disassembler, decompiler, and debugger for 32-bit and 64-bit executables. It will let you disassemble any binary you want, and provide you all the information about... Read more
Slack 2.6.2 - Collaborative communicatio...
Slack is a collaborative communication app that simplifies real-time messaging, archiving, and search for modern working teams. Version 2.6.2: Fixed Inexplicably, context menus and spell-check... Read more
Arq 5.8.5 - Online backup to Google Driv...
Arq is super-easy online backup for Mac and Windows computers. Back up to your own cloud account (Amazon Cloud Drive, Google Drive, Dropbox, OneDrive, Google Cloud Storage, any S3-compatible server... Read more

Latest Forum Discussions

See All

The best new games we played this week
We were quite busy this week. A bunch of big mobile games launched over the past few days, alongside a few teeny surprises. There're lots of quality games to load your phone with. We've gone and picked out five of our favorites for the week. [... | Read more »
Magikarp Jump beginner's guide
Magikarp Jump is a mystifying little game. Part Tamagotchi, part idle clicker, there's not a whole lot of video game there, per se, but for some reason we can't help coming back to it again and again. Your goal is to train up a little Magikarp to... | Read more »
Goat Simulator PAYDAY (Games)
Goat Simulator PAYDAY 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: ** IMPORTANT - SUPPORTED DEVICES **iPhone 4S, iPad 2, iPod Touch 5 or better Goat Simulator: Payday is the most... | Read more »
GRID Autosport delayed until autumn
Sorry mobile racing fans -- GRID Autosport has been delayed a few months. The game is now expected to launch this fall on iOS. Feral Interactive announced that they wanted more time to work on the game's UI and overall performance before launching... | Read more »
Zombie Gunship Survival Beginner's...
The much anticipated Zombie Gunship Survival is here. In this latest entry in the Zombie Gunship franchise, you're tasked with supporting ground troops and protecting your base from the zombie horde. There's a lot of rich base building fun, and... | Read more »
Mordheim: Warband Skirmish (Games)
Mordheim: Warband Skirmish 1.2.2 Device: iOS Universal Category: Games Price: $3.99, Version: 1.2.2 (iTunes) Description: Explore the ruins of the City of Mordheim, clash with other scavenging warbands and collect Wyrdstone -... | Read more »
Mordheim: Warband Skirmish brings tablet...
Legendary Games has just launched Mordheim: Warband Skirmish, a new turn-based action game for iOS and Android. | Read more »
Magikarp Jump splashes onto Android worl...
If you're tired ofPokémon GObut still want something to satisfy your mobilePokémon fix,Magikarp Jumpmay just do the trick. It's out now on Android devices the world over. While it looks like a simple arcade jumper, there's quite a bit more to it... | Read more »
Purrfectly charming open-world RPG Cat Q...
Cat Quest, an expansive open-world RPG from former Koei-Tecmo developers, got a new gameplay trailer today. The video showcases the combat and exploration features of this feline-themed RPG. Cat puns abound as you travel across a large map in a... | Read more »
Jaipur: A Card Game of Duels (Games)
Jaipur: A Card Game of Duels 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: ** WARNING: iPad 2, iPad Mini 1 & iPhone 4S are NOT compatible. ** *** Special Launch Price for a limited... | Read more »

Price Scanner via MacPrices.net

Memorial Day savings: 13-inch Touch Bar MacBo...
B&H Photo has the 2016 Apple 13″ Touch Bar MacBook Pros in stock today and on sale for up to $150 off MSRP. Shipping is free, and B&H charges NY & NJ sales tax only: - 13″ 2.9GHz/512GB... Read more
Apple refurbished 13-inch MacBook Airs availa...
Apple has Certified Refurbished 2016 13″ MacBook Airs available starting at $849. An Apple one-year warranty is included with each MacBook, and shipping is free: - 13″ 1.6GHz/8GB/128GB MacBook Air: $... Read more
Apple restocks refurbished 11-inch MacBook Ai...
Apple has Certified Refurbished 11″ MacBook Airs (the latest models recently discontinued by Apple), available for up to $170 off original MSRP. An Apple one-year warranty is included with each... Read more
12-inch 1.2GHz Retina MacBooks on sale for up...
B&H has 12″ 1.2GHz Retina MacBooks on sale for up to $150 off MSRP. Shipping is free, and B&H charges NY & NJ sales tax only: - 12″ 1.2GHz Space Gray Retina MacBook: $1449.99 $150 off... Read more
15-inch 2.7GHz Silver Touch Bar MacBook Pro o...
MacMall has the 15-inch 2.7GHz Silver Touch Bar MacBook Pro (MLW82LL/A) on sale for $2569 as part of their Memorial Day sale. Shipping is free. Their price is $230 off MSRP. Read more
Free Tread Wisely Mobile App Endorsed By Fath...
Just in time for the summer driving season, Cooper Tire & Rubber Company has announced the launch of a new Tread Wisely mobile app. Designed to promote tire and vehicle safety among teens and... Read more
Commercial Notebooks And Detachable Tablets W...
Worldwide shipments of personal computing devices (PCDs), comprised of traditional PCs (a combination of desktop, notebook, and workstations) and tablets (slates and detachables), are forecast to... Read more
Best value this Memorial Day weekend: Touch B...
Apple has Certified Refurbished 2016 15″ and 13″ MacBook Pros available for $230 to $420 off original MSRP. An Apple one-year warranty is included with each model, and shipping is free: - 15″ 2.6GHz... Read more
13-inch MacBook Airs on sale for up to $130 o...
Overstock.com has 13″ MacBook Airs on sale for up to $130 off MSRP including free shipping: - 13″ 1.6GHz/128GB MacBook Air (sku MMGF2LL/A): $869.99 $130 off MSRP - 13″ 1.6GHz/256GB MacBook Air (sku... Read more
2.8GHz Mac mini available for $973 with free...
Adorama has the 2.8GHz Mac mini available for $973, $16 off MSRP, including a free copy of Apple’s 3-Year AppleCare Protection Plan. Shipping is free, and Adorama charges sales tax in NY & NJ... Read more

Jobs Board

*Apple* Media Products - Commerce Engineerin...
Apple Media Products - Commerce Engineering Manager Job Number: 57037480 Santa Clara Valley, California, United States Posted: Apr. 18, 2017 Weekly Hours: 40.00 Job Read more
Best Buy *Apple* Computing Master - Best Bu...
**509643BR** **Job Title:** Best Buy Apple Computing Master **Location Number:** 001482- Apple Valley-Store **Job Description:** **What does a Best Buy Apple Read more
*Apple* Media Products - Commerce Engineerin...
Apple Media Products - Commerce Engineering Manager Job Number: 57037480 Santa Clara Valley, California, United States Posted: Apr. 18, 2017 Weekly Hours: 40.00 Job Read more
*Apple* Mac and Mobility Engineer - Infogrou...
Title: Apple Mac and Mobility Engineer Location: Portland, OR Area Type: 12 month contract Job: 17412 Here's a chance to take your skills to the limit, learn new Read more
*Apple* Retail - Multiple Positions, White P...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.