/// <summary> /// Handles device setup /// </summary> /// <param name="device">DirectInput Device</param> private void SetupDevice(Device device) { // Create a temporary DeviceState object and store device information. DeviceState state = new DeviceState(); device = device; #region Step 4: Build the action map against the device // ******************************************************************** // Step 4: Build the action map against the device, inspect the // results, and set the action map. // // It's a good idea to inspect the results after building the action // map against the current device. The contents of the action map // structure indicate how and to what object the action was mapped. // This sample simply verifies the action was mapped to an object on // the current device, and stores the result. Note that not all actions // will necessarily be mapped to an object on all devices. For instance, // this sample did not request that QUIT be mapped to any device other // than the keyboard. // ******************************************************************** #endregion try { // Build the action map against the device device.BuildActionMap(DIActionFormat, ActionMapControl.Default); } catch (DirectXException ex) { UserInterface.ShowException(ex, "BuildActionMap"); return; } // Inspect the results foreach (Action action in DIActionFormat.Actions) { if ((int)action.How != (int)ActionMechanism.Error && (int)action.How != (int)ActionMechanism.Unmapped) { state.IsMapped[(int)action.ApplicationData] = true; } } // Set the action map try { device.SetActionMap(DIActionFormat, ApplyActionMap.Default); } catch (DirectXException ex) { UserInterface.ShowException(ex, "SetActionMap"); return; } state.Device = device; // Store the device's friendly name for display on the chart state.Name = device.DeviceInformation.InstanceName; // Store axis absolute/relative flag state.IsAxisAbsolute = device.Properties.AxisModeAbsolute; DeviceStates.Add(state); UserInterface.UpdateChart(); return; }