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

Viber 11.9.1 - Send messages and make fr...
Viber lets you send free messages and make free calls to other Viber users, on any device and network, in any country! Viber syncs your contacts, messages and call history with your mobile device, so... Read more
Vallum 3.3.2 - $15.00
Vallum is a little tool that helps you monitor and block apps connections and throttle apps bandwidth. It is able to intercept connections at the application layer, and hold them while you decide... Read more
Microsoft OneNote 16.31 - Free digital n...
OneNote is your very own digital notebook. With OneNote, you can capture that flash of genius, that moment of inspiration, or that list of errands that's too important to forget. Whether you're at... Read more
Apple Pages 8.2.1 - Apple's word pr...
Apple Pages is a powerful word processor that gives you everything you need to create documents that look beautiful. And read beautifully. It lets you work seamlessly between Mac and iOS devices, and... Read more
Numbers 6.2.1 - Apple's spreadsheet...
With Apple Numbers, sophisticated spreadsheets are just the start. The whole sheet is your canvas. Just add dramatic interactive charts, tables, and images that paint a revealing picture of your data... Read more
f.lux 39.9873 - Adjusts the color of you...
f.lux makes the color of your computer's display adapt to the time of day, warm at night and like sunlight during the day. Ever notice how people texting at night have that eerie blue glow? Or wake... Read more
Deeper 2.5.0 - Enable hidden features in...
Deeper is a personalization utility for macOS which allows you to enable and disable the hidden functions of the Finder, Dock, QuickTime, Safari, iTunes, login window, Spotlight, and many of Apple's... Read more
NTFS 15.5.71 - Provides full read and wr...
NTFS breaks down the barriers between Windows and macOS. Paragon NTFS effectively solves the communication problems between the Mac system and NTFS. Write, edit, copy, move, delete files on NTFS... Read more
MTR 5.3.0.0 - The Mac's oldest and...
MTR (was MacTheRipper)--the Mac's oldest and smartest DVD-backup app. MTR - the complete toolbox, not a one-trick, point-and-click extractor. MTR is intended for making fair-use, backup copies of... Read more
Keynote 9.2.1 - Apple's presentatio...
Easily create gorgeous presentations with the all-new Keynote, featuring powerful yet easy-to-use tools and dazzling effects that will make you a very hard act to follow. The Theme Chooser lets you... Read more

Latest Forum Discussions

See All

Black Desert Mobile gets an official rel...
Pearl Abyss has just announced that its highly-anticipated MMO, Black Desert Mobile, will launch globally for iOS and Android on December 11th. [Read more] | Read more »
Another Eden receives new a episode, cha...
Another Eden, WFS' popular RPG, has received another update that brings new story content to the game alongside a few new heroes to discover. [Read more] | Read more »
Overdox guide - Tips and tricks for begi...
Overdox is a clever battle royale that changes things up by adding MOBA mechanics and melee combat to the mix. This new hybrid game can be quite a bit to take in at first, so we’ve put together a list of tips to help you get a leg up on the... | Read more »
Roterra Extreme - Great Escape is a pers...
Roterra Extreme – Great Escape has been described by developers Dig-It Games as a mini-sequel to their acclaimed title Roterra: Flip the Fairytale. It continues that game's tradition of messing with which way is up, tasking you with solving... | Read more »
Hearthstone: Battlegrounds open beta lau...
Remember earlier this year when auto battlers were the latest hotness? We had Auto Chess, DOTA Underlords, Chess Rush, and more all gunning for our attention. They all had their own reasons to play, but, at least from where I'm standing, most... | Read more »
The House of Da Vinci 2 gets a new gamep...
The House of Da Vinci launched all the way back in 2017. Now, developer Blue Brain Games is gearing up to deliver a second dose of The Room-inspired puzzling. Some fresh details have now emerged, alongside the game's first official trailer. [Read... | Read more »
Shoot 'em up action awaits in Battl...
BattleBrew Productions has just introduced another entry into its award winning, barrelpunk inspired, BattleSky Brigade series. Whilst its previous title BattleSky Brigade TapTap provided fans with idle town building gameplay, this time the... | Read more »
Arcade classic R-Type Dimensions EX blas...
If you're a long time fan of shmups and have been looking for something to play lately, Tozai Games may have just released an ideal game for you on iOS. R-Type Dimensions EX brings the first R-Type and its sequel to iOS devices. [Read more] | Read more »
Intense VR first-person shooter Colonicl...
Our latest VR obsession is Colonicle, an intense VR FPS, recently released on Oculus and Google Play, courtesy of From Fake Eyes and Goboogie Games. It's a pulse-pounding multiplayer shooter which should appeal to genre fanatics and newcomers alike... | Read more »
PUBG Mobile's incoming update bring...
PUGB Mobile's newest Royale Pass season they're calling Fury of the Wasteland arrives tomorrow and with it comes a fair chunk of new content to the game. We'll be seeing a new map, weapon and even a companion system. [Read more] | Read more »

Price Scanner via MacPrices.net

New 2019 16″ MacBook Pros on sale for $100 of...
Apple Authorized Reseller Adorama has new 2019 16″ MacBook Pros on sale today for $100 off Apple’s MSRP, each including free shipping. In addition, Adorama charges sales tax for NY & NJ residents... Read more
Apple Watch Series 3 GPS models on sale for l...
Amazon has Apple Watch Series 3 GPS models on sale starting at only $179. There prices are the lowest we’ve ever seen for these models from any Apple reseller. Choose Amazon as the seller rather than... Read more
iOS Bug In Facebook News Feed Lets Device Ca...
NEWS: 11.15.19- Users of the Facebook social media platform’s mobile app running on iOS devices won’t, like, this piece of news one bit in where a bug in the News Feed gave access to the camera... Read more
16″ MacBook Pros on sale! Preorder at Amazon...
Apple’s new 16″ MacBook Pros were only introduced yesterday, but Amazon is already offering a $100 discount on preorders. Prices for the base 6-Core 16″ MacBook Pros start at $2299: – 2019 16″ 2.6GHz... Read more
Use our exclusive MacBook Price Trackers to f...
Our Apple award-winning MacBook price trackers are the best place to look for the best sales & lowest prices on new and clearance MacBook Airs and MacBook Pros–including Apple’s new 16″ MacBook... Read more
New November Verizon iPhone deal: Get an iPho...
Verizon has the 64GB iPhone Xr on sale for 50% off for a limited time, plus they will include a free $200 prepaid MasterCard and a free Amazon Echo Dot. That reduces their price for the 64GB iPhone... Read more
Apple cuts prices on clearance, refurbished 2...
Apple has clearance 2018 15″ 6-Core Touch Bar MacBook Pros, Certified Refurbished, now available starting at only $1829. Each model features a new outer case, shipping is free, and an Apple 1-year... Read more
Up to $450 price drop on clearance 15″ MacBoo...
B&H Photo has dropped prices Apple’s 2019 15″ 6-Core and 8-Core MacBook Pros by $400-$450 off original MSRP, starting at $1999, with free overnight shipping available to many addresses in the US... Read more
Here’s how to save $200 on Apple’s new 16″ Ma...
Apple has released details of their Education discount associated with the new 2019 16″ 6-Core and 8-Core MacBook Pros. Take $200 off the price of the new 8-Core model (now $2599) and $200 off the 16... Read more
Price drop! 2019 15″ 2.6GHz 6-Core MacBook Pr...
Focus Camera has dropped their price for clearance 2019 15″ 2.6GHz 6-Core Space Gray MacBook Pros by $400 to $1999 shipped. Apple’s original MSRP for this model was $2399. Focus charges sales tax for... Read more

Jobs Board

Best Buy *Apple* Computing Master - Best Bu...
**746655BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Sales **Store NUmber or Department:** 002518-Atlantic Center-Store **Job Description:** Read more
*Apple* Mobility Pro - Best Buy (United Stat...
**744973BR** **Job Title:** Apple Mobility Pro **Job Category:** Store Associates **Store NUmber or Department:** 000949-Rochester Hills-Store **Job Description:** Read more
AV Systems Engineer at *Apple* - Theorem, L...
Job Summary Apple Retail Technology is looking for an Audio Visual Systems Engineer to design and implement scalable, next-generation A/V solutions for Apple ?s Read more
Nurse Practitioner - Field Based (San Bernard...
Nurse Practitioner - Field Based (San Bernardino, CA, Apple Valley, Hesperia) **Location:** **United States** **New** **Requisition #:** PS30312 **Post Date:** 3 Read more
Best Buy *Apple* Computing Master - Best Bu...
**746510BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Store Associates **Store NUmber or Department:** 001407-Milford-Store **Job Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.