FlightStick FlightStick FlightStick FlightStick Class

Definition

Represents a flight stick.

public : sealed class FlightStick : IFlightStick, IGameController, IGameControllerBatteryInfopublic sealed class FlightStick : IFlightStick, IGameController, IGameControllerBatteryInfoPublic NotInheritable Class FlightStick Implements IFlightStick, IGameController, IGameControllerBatteryInfo// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

FlightStick is targeted at simple, arcade-style flight games. It provides several basic inputs, which are derived from the lowest common denominator of inputs available across the majority of popular flight stick devices. These inputs include:

  • Two buttons for firing primary and secondary weapons.
  • A hat switch for camera view and/or target selection.
  • Axis data for pitch, roll, yaw, and throttle position.

Instances of the FlightStick class cannot be created directly; instead, instances of the class are retrieved through the FlightStick.FlightSticks property listing all connected flight sticks or through the FlightStick.FlightStickAdded event.

See Flight stick for more information about how to use the FlightStick class.

Supported Devices

FlightStick supports any Xbox One-certified or Xbox 360-compatible flight stick.

Properties

FlightSticks FlightSticks FlightSticks FlightSticks

The list of all connected flight sticks.

public : static IVectorView<FlightStick> FlightSticks { get; }public static IReadOnlyList<FlightStick> FlightSticks { get; }Public Static ReadOnly Property FlightSticks As IReadOnlyList<FlightStick>// You can use this property in JavaScript.
Value
IVectorView<FlightStick> IReadOnlyList<FlightStick> IReadOnlyList<FlightStick> IReadOnlyList<FlightStick>

The list of all connected flight sticks.

Examples

The following example copies all connected flight sticks into a new collection:

auto myFlightSticks = ref new Vector<FlightStick^>();

for (auto flightStick : FlightStick::FlightSticks)
{
    // This code assumes that you're interested in all flight sticks.
    myFlightSticks->Append(flightStick);
}

Remarks

FlightStick objects are managed by the system, therefore you don't have to create or initialize them. Instead, you can access connected flight sticks through this property. Because you might only be interested in some of the connected flight sticks, we recommend that you maintain your own collection.

HatSwitchKind HatSwitchKind HatSwitchKind HatSwitchKind

The type of hat switch on the flight stick.

public : GameControllerSwitchKind HatSwitchKind { get; }public GameControllerSwitchKind HatSwitchKind { get; }Public ReadOnly Property HatSwitchKind As GameControllerSwitchKind// You can use this property in JavaScript.

Remarks

A hat switch is a control often used for camera view and/or target selection. It can be two-way, four-way, or eight-way, and its current position can be described by a cardinal coordinate system. A hat switch can be in exactly one position at any given time.

Headset Headset Headset Headset

The audio headset attached to the flight stick.

public : Headset Headset { get; }public Headset Headset { get; }Public ReadOnly Property Headset As Headset// You can use this property in JavaScript.
Value
Headset Headset Headset Headset

The audio headset attached to the flight stick.

Remarks

See Headset for information about programming for headsets.

IsWireless IsWireless IsWireless IsWireless

Gets a value that indicates the wireless state of the flight stick.

public : PlatForm::Boolean IsWireless { get; }public bool IsWireless { get; }Public ReadOnly Property IsWireless As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

True if the flight stick is wireless. Otherwise, false.

User User User User

The user associated with the flight stick.

public : User User { get; }public User User { get; }Public ReadOnly Property User As User// You can use this property in JavaScript.
Value
User User User User

The user associated with the flight stick.

Remarks

See Tracking users and their devices for information about how to keep track of users.

See Also

Methods

FromGameController(IGameController) FromGameController(IGameController) FromGameController(IGameController) FromGameController(IGameController)

Returns the given game controller as a flight stick.

public : static FlightStick FromGameController(IGameController gameController)public static FlightStick FromGameController(IGameController gameController)Public Static Function FromGameController(gameController As IGameController) As FlightStick// You can use this method in JavaScript.
Parameters
gameController
IGameController IGameController IGameController IGameController

The game controller to be returned as a flight stick.

Returns

The flight stick that was returned from the given game controller.

Examples

In the following example, the app gets the first available RawGameController object, and tries to access this game controller via the FlightStick class:

FlightStick^ flightStick;

if (RawGameController::RawGameControllers->Size > 0)
{
    RawGameController^ rawGameController = 
        RawGameController::RawGameControllers->GetAt(0);

    flightStick = FlightStick::FromGameController(rawGameController);
}

if (flightStick != nullptr)
{
    // Assign a standard button mapping to this controller.
}

Remarks

This method checks if the provided game controller has a flight stick implementation, and if so, it returns that implementation. You might use this method if you want to first get the controller as a RawGameController, and then see if it can be used as a FlightStick—if so, you can use a default control scheme for flight sticks, otherwise you can let the player do their own input mapping.

GetButtonLabel(FlightStickButtons) GetButtonLabel(FlightStickButtons) GetButtonLabel(FlightStickButtons) GetButtonLabel(FlightStickButtons)

Retrieves the button label for the specified button.

public : GameControllerButtonLabel GetButtonLabel(FlightStickButtons button)public GameControllerButtonLabel GetButtonLabel(FlightStickButtons button)Public Function GetButtonLabel(button As FlightStickButtons) As GameControllerButtonLabel// You can use this method in JavaScript.
Parameters
button
FlightStickButtons FlightStickButtons FlightStickButtons FlightStickButtons

The button for which to retrieve the label.

Returns

The label for the specified button. If the button label is blank or there is no known label for the controller’s button, then None is returned.

Remarks

The following example gets the label on the FirePrimary button on the flight stick, and shows an icon based on the label:

void ShowFlightStickFirePrimaryButtonIcon(FlightStick flightStick)
{
    GameControllerButtonLabel label =
        flightStick.GetButtonLabel(FlightStickButtons::FirePrimary);

    switch (label)
    {
        case (GameControllerButtonLabel::RightTrigger):
        {
            // Show the right trigger icon.
        }
        // ...
    }
}

GetCurrentReading() GetCurrentReading() GetCurrentReading() GetCurrentReading()

Gets a snapshot of the flight stick state.

public : FlightStickReading GetCurrentReading()public FlightStickReading GetCurrentReading()Public Function GetCurrentReading() As FlightStickReading// You can use this method in JavaScript.
Returns

Remarks

To gather input from a flight stick, you must poll the flight stick using this method. The method returns a FlightStickReading that has information about which buttons are being pressed, the joystick's roll, pitch, and yaw, and so on. See Reading the flight stick for more information about how to read input from a flight stick.

TryGetBatteryReport() TryGetBatteryReport() TryGetBatteryReport() TryGetBatteryReport()

Gets information about the flight stick's current battery state.

public : BatteryReport TryGetBatteryReport()public BatteryReport TryGetBatteryReport()Public Function TryGetBatteryReport() As BatteryReport// You can use this method in JavaScript.
Returns

Information about the flight stick's current battery state.

Events

FlightStickAdded FlightStickAdded FlightStickAdded FlightStickAdded

Signals when a new flight stick is connected.

public : static event EventHandler FlightStickAdded<FlightStick>public static event EventHandler FlightStickAdded<FlightStick>Public Static Event FlightStickAdded<FlightStick>// You can use this event in JavaScript.

Examples

The following example starts tracking a flight stick that's been added. myFlightSticks is a Vector<FlightStick^> that contains the flight sticks that your game is tracking.

FlightStick::FlightStickAdded += 
    ref new EventHandler<FlightStick^>([] (Platform::Object^, FlightStick^ args)
{
    // This code assumes that you're interested in all new flight sticks.
    myFlightSticks->Append(args);
});

Remarks

To identify flight sticks that have already been added, you query the list of connected flight sticks using FlightStick.FlightSticks. However, because you might only be interested in some of the connected flight sticks, we recommend that you maintain your own collection instead of accessing them through FlightSticks.

FlightStickRemoved FlightStickRemoved FlightStickRemoved FlightStickRemoved

Signals when a flight stick is disconnected.

public : static event EventHandler FlightStickRemoved<FlightStick>public static event EventHandler FlightStickRemoved<FlightStick>Public Static Event FlightStickRemoved<FlightStick>// You can use this event in JavaScript.

Remarks

The following example stops tracking a flight stick that's been removed. myFlightSticks is a Vector<FlightStick^> that contains the flight sticks that your game is tracking.

FlightStick::FlightStickRemoved += 
    ref new EventHandler<FlightStick^>([] (Platform::Object^, FlightStick^ args)
{
    unsigned int indexRemoved;

    if (myFlightSticks->IndexOf(args, &indexRemoved))
    {
        myFlightSticks->RemoveAt(indexRemoved);
    }
});

HeadsetConnected HeadsetConnected HeadsetConnected HeadsetConnected

Signals when a headset is attached to the flight stick.

public : event TypedEventHandler HeadsetConnected<IGameController,  Headset>public event TypedEventHandler HeadsetConnected<IGameController,  Headset>Public Event HeadsetConnected<IGameController,  Headset>// You can use this event in JavaScript.

Examples

The following example shows how to register a handler for this event. flightStick is a FlightStick that's connected to the device.

flightStick.HeadsetConnected += ref new TypedEventHandler<IGameController^, Headset^>(
    [] (IGameController^ device, Headset^ headset)
{
    // Enable headset capture and playback on this device.
});

Remarks

For more information on detecting, tracking, and using headsets, see Headset.

HeadsetDisconnected HeadsetDisconnected HeadsetDisconnected HeadsetDisconnected

Signals when a headset is disconnected from the flight stick.

public : event TypedEventHandler HeadsetDisconnected<IGameController,  Headset>public event TypedEventHandler HeadsetDisconnected<IGameController,  Headset>Public Event HeadsetDisconnected<IGameController,  Headset>// You can use this event in JavaScript.

Examples

The following example shows how to register a handler for this event. flightStick is a FlightStick that's connected to the device.

flightStick.HeadsetDisconnected += ref new TypedEventHandler<IGameController^, Headset^>(
    [] (IGameController^ device, Headset^ headset)
{
    // Enable headset capture and playback on this device.
});

Remarks

For more information on detecting, tracking, and using headsets, see Headset.

UserChanged UserChanged UserChanged UserChanged

Signals when the user associated with the flight stick has changed.

public : event TypedEventHandler UserChanged<IGameController,  UserChangedEventArgs>public event TypedEventHandler UserChanged<IGameController,  UserChangedEventArgs>Public Event UserChanged<IGameController,  UserChangedEventArgs>// You can use this event in JavaScript.

Remarks

See Tracking users and their devices for more information about how to keep track of users.