# Logging Controller Behaviour - Variably working

**URL:** <https://forum.magicleap.cloud/t/logging-controller-behaviour-variably-working/5058>\
**Category:** OpenXR\
**Tags:** openxr, controller\
**Created:** [January 22, 2025, 1:58pm UTC](https://forum.magicleap.cloud/t/logging-controller-behaviour-variably-working/5058 "2025-01-22T13:58:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiltabone](https://avatars.discourse-cdn.com/v4/letter/w/f19dbf/32.png) [@wiltabone](https://forum.magicleap.cloud/u/wiltabone)\
**Post date:** [January 22, 2025, 1:58pm UTC](https://forum.magicleap.cloud/t/logging-controller-behaviour-variably-working/5058/1 "2025-01-22T13:58:13Z")

</div>

**Unity Editor version** : 2022.3.38f1  
**Magic Leap MRTK3** 1.2.0  
**MLSDK** 2.4.0  
**Mixed Reality OpenXR Plugin** 1.10.0  
**OpenXR Plugin** 1.11.0  
**ML OS** 1.9.0

Hi,  
I am trying to log bumper presses and trigger press values (bool and float respectively). Sometimes the log files output the values as expected, other times, when I run the app, I only get 0s or False values, even though I pressed the buttons. I am confused as to what is happening here, and why this is variably working.

Here is how I am logging the controller data:

In `Start()`:

```auto
 // Initialize the InputActionAsset
 _magicLeapInputs = new MagicLeapInputs();
 _magicLeapInputs.Enable();

 //Initialize the ControllerActions using the Magic Leap Input
 _controllerActions = new MagicLeapInputs.ControllerActions(_magicLeapInputs);

```

In `Update()`:

```auto
//Read the input values directly
Debug.Log("Trigger Val:" + _controllerActions.Trigger.ReadValue<float>());
Debug.Log("Bumper Press:" + _controllerActions.Bumper.IsPressed());

 float triggerValue = _controllerActions.Trigger.ReadValue<float>();
 bool bumperPressed = _controllerActions.Bumper.IsPressed();

```

The `triggerValue` and `bumperPressed` are then passed into a string builder which is output into a file.

The following is also added to the logging script game object:  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/2X/2/2e5e58c8a4f3636813067866b87d94d43dc44775.png)

Any tips as to what I might be missing please (ie. what might cause it to not always work)? For contrast, in the same file I am also logging eye data, and that always works.

Thanks

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [January 22, 2025, 6:01pm UTC](https://forum.magicleap.cloud/t/logging-controller-behaviour-variably-working/5058/2 "2025-01-22T18:01:00Z")

</div>



---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [January 22, 2025, 11:08pm UTC](https://forum.magicleap.cloud/t/logging-controller-behaviour-variably-working/5058/3 "2025-01-22T23:08:20Z")

</div>

Hi @wiltabone,

To clarify, the issue occurs the entire time, until you close and reopen it, and it may or may not happen upon reopening?

I would recommend trying this code in the example projects to see if they have the same effect.

Would you mind providing minimal reproduction steps?

Thanks

---

<div class="post-metadata">

**Author:** ![wiltabone](https://avatars.discourse-cdn.com/v4/letter/w/f19dbf/32.png) [@wiltabone](https://forum.magicleap.cloud/u/wiltabone)\
**Post date:** [January 24, 2025, 10:13am UTC](https://forum.magicleap.cloud/t/logging-controller-behaviour-variably-working/5058/4 "2025-01-24T10:13:40Z")

</div>

Hi @etucker, thanks for the info.  
I cannot really provide any replication steps as it is rather random when it worked or not. For the past days, the logging for the controller has not worked. I am now printing `_controllerActions.IsTracked.IsPressed()` in `Update()` and it returns `False`. I am wondering whether I am missing some library steps or hardware steps. My project is built on the original example project so it has everything included. The controller is connected, I can even get the vector line (the white line MRTK provides) from its position and into the world at any time.

Thanks

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [January 28, 2025, 10:19pm UTC](https://forum.magicleap.cloud/t/logging-controller-behaviour-variably-working/5058/5 "2025-01-28T22:19:10Z")

</div>

So I did try to replicate this issue. It seems I can't reproduce it after multiple tries. Have you tried taking a look at the Logcat output using the editor, it may be an issue with the logging of data.

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [January 29, 2025, 4:53pm UTC](https://forum.magicleap.cloud/t/logging-controller-behaviour-variably-working/5058/6 "2025-01-29T16:53:42Z")

</div>

I assume you are using the OpenXR workflow in your project? Can you verify that you are using the Input Action Asset that is meant for OpenXR?

The Magic Leap Example project contains an Input Action asset inside the root Assets folder called `MagicLeapInput` and not `MagicLeapInputs` (notice the lack of the **S** at the end).

You will need to generate the C# scripts associated with the MagicLeapInput Asset and then change your references accordingly.

* * *

You can also see more information and other methods of getting controller input in our developer documentation:

> **[Quick Start | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/controller/quick-start/quick-start-overview/)**
>
> This section covers how to use the Magic Leap 2 Controller Interaction Profile with Input System. For more information about obtaining OpenXR Input see Unity's OpenXR Input Documentation.

> **[Quick Start | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/controller/quick-start/quick-start-overview/#binding-input-actions)**
>
> This section covers how to use the Magic Leap 2 Controller Interaction Profile with Input System. For more information about obtaining OpenXR Input see Unity's OpenXR Input Documentation.

> **[Input Device Feature Values | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/controller/input-device-features/)**
>
> It is recommended that developers read the controller input using Unity's Input System. However, developers can obtain the controller's input directly from the InputDevice. This section provides an example of reading input using the...
