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

Cocktail 8.4 - General maintenance and o...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
PDFKey Pro 4.3 - Edit and print password...
PDFKey Pro can unlock PDF documents protected for printing and copying when you've forgotten your password. It can now also protect your PDF files with a password to prevent unauthorized access and/... Read more
Kodi 15.0.beta1 - Powerful media center...
Kodi (was XBMC) is an award-winning free and open-source (GPL) software media player and entertainment hub that can be installed on Linux, OS X, Windows, iOS, and Android, featuring a 10-foot user... Read more
DiskCatalogMaker 6.4.12 - Catalog your d...
DiskCatalogMaker is a simple disk management tool which catalogs disks. Simple, light-weight, and fast. Finder-like intuitive look and feel. Super-fast search algorithm. Can compress catalog data... Read more
Macs Fan Control 1.3.0.0 - Monitor and c...
Macs Fan Control allows you to monitor and control almost any aspect of your computer's fans, with support for controlling fan speed, temperature sensors pane, menu-bar icon, and autostart with... Read more
Lyn 1.5.11 - Lightweight image browser a...
Lyn is a lightweight and fast image browser and viewer designed for photographers, graphic artists and Web designers. Featuring an extremely versatile and aesthetically pleasing interface, it... Read more
NeoOffice 2014.11 - Mac-tailored, OpenOf...
NeoOffice is a complete office suite for OS X. With NeoOffice, users can view, edit, and save OpenOffice documents, PDF files, and most Microsoft Word, Excel, and PowerPoint documents. NeoOffice 3.x... Read more
LaunchBar 6.4 - Powerful file/URL/email...
LaunchBar is an award-winning productivity utility that offers an amazingly intuitive and efficient way to search and access any kind of information stored on your computer or on the Web. It provides... Read more
Remotix 3.1.4 - Access all your computer...
Remotix is a fast and powerful application to easily access multiple Macs (and PCs) from your own Mac. Features Complete Apple Screen Sharing support - including Mac OS X login, clipboard... Read more
DesktopLyrics 2.6.6 - Displays current i...
DesktopLyrics is an application that displays the lyrics of the song currently playing in "iTunes" right on your desktop. The lyrics for the song have to be set in iTunes; DesktopLyrics does nothing... Read more

What the Apple Watch Gets Right, and Wha...
| Read more »
Celebrate PAC-MAN's 35th Birthday W...
BANDAI NAMCO Entertainment America is celebrating PAC-MAN's 35th anniversary by releasing updates for PAC-MAN and PAC-MAN Lite for iOS. [Read more] | Read more »
Strike Wing Episode 2 has Landed on the...
Strike Wing: Raptor Rising is an exciting space combat simulator by Crescent Moon Games, which was recently updated to continue the story with Episode 2. [Read more] | Read more »
This Week at 148Apps: May 18-22, 2015
May Days at 148Apps How do you know what apps are worth your time and money? Just look to the review team at 148Apps. We sort through the chaos and find the apps you're looking for. The ones we love become Editor’s Choice, standing out above the... | Read more »
Biz Builder Delux (Games)
Biz Builder Delux 1.0.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.0 (iTunes) Description: Ah, there's nothing like the rhythmic bustle of a burgeoning business burg... especially when you're the one building it... | Read more »
Auroch Digital is Bringing Back Games Wo...
| Read more »
Blades of Brim is a New Endless Runner f...
SYBO Games, the minds behind the ever-popular Subway Surfers, have announced their latest project: Blades of Brim. [Read more] | Read more »
Carbo - Handwriting in the Digital Age...
Carbo - Handwriting in the Digital Age 1.0 Device: iOS Universal Category: Productivity Price: $3.99, Version: 1.0 (iTunes) Description: | Read more »
Draggy Dead (Games)
Draggy Dead 1.1 Device: iOS Universal Category: Games Price: $.99, Version: 1.1 (iTunes) Description: Ditch your dead end job and take up a rewarding career in Grave Robbing today!Guide the recently deceased to a fun filled life of... | Read more »
Bad Dinos (Games)
Bad Dinos 1.0.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0.0 (iTunes) Description: | Read more »

Price Scanner via MacPrices.net

New 13-inch 2.9GHz Retina MacBook Pro on sale...
B&H Photo has the 13″ 2.9GHz/512GB Retina MacBook Pro on sale for $1699.99 including free shipping plus NY tax only. Their price is $100 off MSRP, and it’s the lowest price for this model from... Read more
12-inch MacBook stock status for Monday, May...
The new 12″ Retina MacBooks are still on backorder at The Apple Store with a 3-5 week waiting period. However, a few models are in stock today at Apple resellers. Stock is limited, so act now if you’... Read more
New 27-inch 3.3GHz 5K iMac in stock with free...
Adorama has the new 27″ 3.3GHz 5K iMac in stock today for $1999 including free shipping plus NY & NJ sales tax only. Adorama will include a free copy of Apple’s 3-year AppleCare Protection Plan. Read more
Memorial Day Weekend Sale: New 27-inch 3.3GHz...
Best Buy has the new 27″ 3.3GHz 5K iMac on sale for $1899.99 this weekend. Choose free shipping or free local store pickup (if available). Sale price for online orders only, in-store prices may vary... Read more
OtterBox Maximizes Portability, Productivity...
From the kitchen recipe book to the boarsroom presentation, the OtterBox Agility Tablet System turns tablets into one of the most versatile pieces of handheld technology available. Available now, the... Read more
Launch of New Car App Gallery and Open Develo...
Automatic, a company on a mission to bring the power of the Internet into every car, has announced the launch of the Automatic App Gallery, an app store for nearly every car or truck on the road... Read more
Memorial Day Weekend Sale: 13-inch 1.6GHz Mac...
Best Buy has the new 13″ 1.6GHz/128GB MacBook Air on sale for $849 on their online store this weekend. Choose free shipping or free local store pickup (if available). Sale price for online orders... Read more
Memorial Day Weekend Sale: 27-inch 3.5GHz 5K...
Best Buy has the 27″ 3.5GHz 5K iMac on sale for $2099.99 this weekend. Choose free shipping or free local store pickup (if available). Sale price for online orders only, in-store prices may vary.... Read more
Sale! 16GB iPad mini 3 for $349, save $50
B&H Photo has the 16GB iPad mini 3 WiFi on sale for $349 including free shipping plus NY sales tax only. Their price is $50 off MSRP, and it’s the lowest price available for this model. Read more
Price drop on 2014 15-inch Retina MacBook Pro...
B&H Photo has dropped prices on 2014 15″ Retina MacBook Pros by $200. Shipping is free, and B&H charges NY sales tax only: - 15″ 2.2GHz Retina MacBook Pro: $1799.99 save $200 - 15″ 2.5GHz... Read more

Jobs Board

Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
*Apple* Retail - Multiple Positions (US) - A...
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
*Apple* Online Store UAT Lead - Apple (Unite...
**Job Summary** The Apple Online Store is a fast paced and ever evolving business environment. The User Acceptance Testing (UAT) lead in this organization is able to Read more
Payments Counsel, *Apple* Pay (mobile payme...
**Job Summary** Apple is looking for an atto ey to join Apple 's Legal Department to support Apple Pay. **Key Qualifications** 7+ years of relevant experience Read more
Touch Hardware Design and Integration Enginee...
…Summary** Design, develop, and launch next-generation Touch solutions in the new Apple Watch product category. The Touch team develops cutting-edge Touch solutions and Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.