Class

# GameInputElement

<div class="rst-class">

forsearch

</div>

Gaming

<div class="rst-class">

forsearch

</div>

Hardware

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

## Description

Manages an element of a `GameInputDevice</api/hardware/gameinputdevice>`. Not supported on Linux.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                              | Type                                             | Read-Only | Shared |
|-----------------------------------|--------------------------------------------------|-----------|--------|
| `Device<gameinputelement.device>` | `GameInputDevice</api/hardware/gameinputdevice>` | ✓         |        |
| `Name<gameinputelement.name>`     | `String</api/data_types/string>`                 | ✓         |        |
| `Value<gameinputelement.value>`   | `Integer</api/data_types/integer>`               | ✓         |        |

## Property descriptions

<div id="gameinputelement.device">

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

</div>

<div class="rst-class">

forsearch

</div>

GameInputElement.Device

**Device** As `GameInputDevice</api/hardware/gameinputdevice>`

> The device that owns this input element.
>
> This property is read-only.
>
> This example displays the name of the device that owns the selected element.
>
> ``` xojo
> Var i, maxi As Integer
> Var device As GameInputDevice
> Var deviceElement As GameInputDevice
>
> ElementPop.RemoveAllRows
> device = mManager.Device(Listbox1.SelectedRowIndex) ' selected device in Device popup
> deviceElement = device.Element(Listbox1.SelectedRowIndex).Device
>
> MessageBox(deviceElement.Name)
> ```

<div id="gameinputelement.name">

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

</div>

<div class="rst-class">

forsearch

</div>

GameInputElement.Name

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

> The human-readable name of the input element.
>
> This property is read-only.
>
> This example loads the list of elements belonging to the selected device into a `PopupMenu</api/user_interface/desktop/desktoppopupmenu>` named ElementPop.
>
> ``` xojo
> Var i, maxi As Integer
> Var device As GameInputDevice
>
> ElementPop.RemoveAllRows
> device = mManager.Device(Listbox1.SelectedRowIndex) ' selected device in Device ListBox
>
> If device <> Nil then
>
>   maxi = device.ElementCount - 1
>
>   For i = 0 To maxi
>     ElementPop.AddRow(device.Element(i).Name)
>   Next
>
> End If
> ```

<div id="gameinputelement.value">

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

</div>

<div class="rst-class">

forsearch

</div>

GameInputElement.Value

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

> The current value of this element.
>
> This property is read-only.
>
> This example loads the names and values corresponding to the selected device into a `PopupMenu</api/user_interface/desktop/desktoppopupmenu>` named ElementPop.
>
> ``` xojo
> Var i, maxi As Integer
> Var device As GameInputDevice
>
> ElementPop.RemoveAllRows
> device = mManager.Device(Listbox1.SelectedRowIndex) ' selected device in Device ListBox
>
> If device <> Nil Then
>
>   maxi = device.ElementCount - 1
>
>   For i = 0 To maxi
>     ElementPop.AddRow(device.Element(i).Name + device.Element(i).Value.ToString)
>   Next
>
> End If
> ```

## Notes

A <span class="title-ref">GameInputElement</span> is a control on an input device used for gaming (or general user input via the keyboard and mouse). For example, the Fire button on a joystick control is an element, as are the standard mouse button and each of the keys on a keyboard. The Element method of the `GameInputDevice</api/hardware/gameinputdevice>` class give you access to the elements of a specified device. You use the WaitForElement method of the `GameInputManager</api/hardware/gameinputmanager>` class to detect input from an element.

## Sample code

This example loads the list of elements belonging to the selected device into a `PopupMenu</api/user_interface/desktop/desktoppopupmenu>` named ElementPop. The connected devices are shown in a `ListBox</api/user_interface/desktop/desktoplistbox>`.

``` xojo
Var i, maxi As Integer
Var device As GameInputDevice

ElementPop.RemoveAllRows
device = mManager.Device(Listbox1.SelectedRowIndex) ' selected device in Device ListBox

If device <> Nil Then

  maxi = device.ElementCount - 1

  For i = 0 To maxi
    ElementPop.AddRow(device.Element(i).Name)
  Next

End If
```

## Compatibility

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

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `GameInputDevice</api/hardware/gameinputdevice>`, `GameInputManager</api/hardware/gameinputmanager>` classes.

</div>
