Module

# GameInputDevice

<div class="rst-class">

forsearch

</div>

Gaming

<div class="rst-class">

forsearch

</div>

Hardware

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Manages a specific game input device. Not supported on Linux.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                         | Type                               | Read-Only | Shared |
|----------------------------------------------|------------------------------------|-----------|--------|
| `Connected<gameinputdevice.connected>`       | `Boolean</api/data_types/boolean>` | ✓         |        |
| `ElementCount<gameinputdevice.elementcount>` | `Integer</api/data_types/integer>` | ✓         |        |
| `Index<gameinputdevice.index>`               | `Integer</api/data_types/integer>` | ✓         |        |
| `Name<gameinputdevice.name>`                 | `String</api/data_types/string>`   | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                               | Parameters                                  | Returns                                            | Shared |
|------------------------------------|---------------------------------------------|----------------------------------------------------|--------|
| `Element<gameinputdevice.element>` | index As `Integer</api/data_types/integer>` | `GameInputElement</api/hardware/gameinputelement>` |        |

## Property descriptions

<div id="gameinputdevice.connected">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GameInputDevice.Connected

**Connected** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the device is currently connected. `False</api/language/false>` indicates that the device is not connected.
>
> This property is read-only.
>
> This example checks to see that the selected device in a `ListBox</api/user_interface/desktop/desktoplistbox>` is connected.
>
> ``` xojo
> Var i, maxi As Integer
> Var device As GameInputDevice
>
> device = mManager.Device(Listbox1.SelectedRowIndex)
>
> If device.Connected Then
>   MessageBox("connected")
> Else
>   MessageBox("not connected")
> End If
> ```

<div id="gameinputdevice.elementcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GameInputDevice.ElementCount

**ElementCount** As `Integer</api/data_types/integer>`

> The number of elements the device has.
>
> This property is read-only.
>
> This example gets the number of GameInputDevices and then populates a `PopupMenu</api/user_interface/desktop/desktoppopupmenu>` with the names of those devices.
>
> ``` xojo
> Var i, maxi As Integer
> Var device As GameInputDevice
>
> ElementPop.RemoveAllRows
> device = mManager.Device(Me.SelectedRowIndex) ' selected device in Device popup
>
> If device <> Nil Then
>
>   maxi = device.ElementCount - 1
>
>   For i = 0 To maxi
>     ElementPop.AddRow(device.Element(i).Name)
>   Next
>
> End If
>
> mElement = Nil
> ```

<div id="gameinputdevice.index">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GameInputDevice.Index

**Index** As `Integer</api/data_types/integer>`

> The index of this device in the `GameInputManager</api/hardware/gameinputmanager>`.
>
> This property is read-only.
>
> This example reports the number of the selected `GameInputManager</api/hardware/gameinputmanager>` in a `ListBox</api/user_interface/desktop/desktoplistbox>`.
>
> ``` xojo
> Var i, maxi As Integer
> Var device As GameInputDevice
>
> device = mManager.Device(ListBox1.SelectedIndex)
>
> If device.Connected Then
>   MessageBox(device.Index.ToString + " is connected.")
> Else
>   MessageBox("not connected.")
> End If
> ```

<div id="gameinputdevice.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GameInputDevice.Name

**Name** As `String</api/data_types/string>`

> The human-readable unique name of this device.
>
> This property is read-only.
>
> This example loads the names of all the devices into a `PopupMenu</api/user_interface/desktop/desktoppopupmenu>`.
>
> ``` xojo
> Var i, maxi As Integer
> Var device As GameInputDevice
>
> ElementPop.RemoveAllRows
> device = mManager.Device(Me.SelectedRowIndex) ' selected device in Device popup
>
> If device <> Nil Then
>
>   maxi = device.ElementCount - 1
>
>   For i = 0 To maxi
>     ElementPop.AddRow(device.Element(i).Name)
>   Next
>
> End If
>
> mElement = Nil
> ```

## Method descriptions

<div id="gameinputdevice.element">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

GameInputDevice.Element

**Element**(index As `Integer</api/data_types/integer>`) As `GameInputElement</api/hardware/gameinputelement>`

> Returns the `GameInputElement</api/hardware/gameinputelement>` specified by *index*.
>
> ``` xojo
> Var i, maxi As Integer
> Var device As GameInputDevice
>
> ElementPop.RemoveAllRows
> device = mManager.Device(Me.SelectedRowIndex) ' selected device in Device popup
>
> If device <> Nil Then
>
>   maxi = device.ElementCount - 1
>
>   For i = 0 To maxi
>     ElementPop.AddRow(device.Element(i).Name)
>   Next
>
> End If
>
> mElement = Nil
> ```

## Notes

A <span class="title-ref">GameInputDevice</span> is a specialized input device used for gaming, such as a joystick. You can also read the keyboard and the standard mouse as GameInputDevices. The Device and DeviceCount properties of the `GameInputManager</api/hardware/gameinputmanager>` class enable you to read the user's GameInputDevices and the Name property of the <span class="title-ref">GameInputDevice</span> class gives you the name of each device.

Each of the device's controls is a `GameInputElement</api/hardware/gameinputelement>`.

## Compatibility

|                       |                |
|-----------------------|----------------|
| **Project Types**     | Desktop        |
| **Operating Systems** | macOS, Windows |

<div class="seealso">

`GameInputElement</api/hardware/gameinputelement>`, `GameInputManager</api/hardware/gameinputmanager>` classes.

</div>
