Active Input Source

Get the information about the active input source

To get the currently active input device in JMRSDK. JMRSDK provides a method to fetch it.

Controller Device State

The JMRInteractionManager.InteractionDeviceType is an enum as follows:

public enum JMRInteractionManager.InteractionDeviceType

JIOGLASS_CONTROLLER = 1 KEYBOARD = 2 MOUSE = 3 VIRTUAL_CONRTOLLER = 4 VIRTUAL_KEYBOARD = 5 EDITOR_MOUSE = 6 GAZE_AND_CLICK = 7 GAZE_AND_DWELL = 8 GAMEPAD = 9 INVALID_DEVICE_TYPE = 0

To make a complete system that returns the currently active input source, use the code below. The currently active device can be fetched by calling the function GetInteractionDeviceType() in the below code. It returns the value of the enum JMRInteractionManager.InteractionDeviceType

using JMRSDK.InputModule;
using UnityEngine;

public class InteractionDeviceFetcher : MonoBehaviour
{
    JMRInteractionManager.InteractionDeviceType _addedDevice = 0;

    private JMRInteractionManager.InteractionDeviceType InteractionDeviceType => 
        _addedDevice == 0 ? JMRInteractionManager.Instance.GetSupportedInteractionDeviceType() : _addedDevice;
    
    public JMRInteractionManager.InteractionDeviceType GetInteractionDeviceType() => InteractionDeviceType;

    private void OnEnable()
    {
        JMRInteractionManager.OnConnected += OnConnect;
        JMRInteractionManager.OnDisconnected += OnDisconnect;
    } 
    private void OnDisable()
    {
        JMRInteractionManager.OnConnected -= OnConnect;
        JMRInteractionManager.OnDisconnected -= OnDisconnect;
    }

    private void OnConnect(JMRInteractionManager.InteractionDeviceType devType, int index, string val)
    {
        _addedDevice = devType;
    }
    private void OnDisconnect(JMRInteractionManager.InteractionDeviceType devType, int index, string val)
    {
        _addedDevice = 0;
    }
}
Device State