private void InternalBind(int roleValue, string deviceSN)
            {
                m_sn2role[deviceSN] = roleValue;
                m_role2sn[m_info.ToRoleOffset(roleValue)] = deviceSN;

                if (m_handler != null)
                {
                    m_handler.OnBindingRoleValueChanged(roleValue, deviceSN, true);
                }
            }
Beispiel #2
0
            // deviceSN must be valid
            // device can be whether bound or not
            // device can be whether connected or not
            private void InternalBind(string deviceSN, int roleValue)
            {
                var deviceIndex = VRModule.GetConnectedDeviceIndex(deviceSN);

                bool previousIsBound        = false;
                int  previousBoundRoleValue = m_info.InvalidRoleValue;

                if (m_sn2role.TryGetValue(deviceSN, out previousBoundRoleValue))
                {
                    if (previousBoundRoleValue == roleValue)
                    {
                        return;
                    }

                    previousIsBound = true;

                    m_sn2role.Remove(deviceSN);

                    if (VRModule.IsValidDeviceIndex(deviceIndex))
                    {
                        InternalRemoveRoleBoundDevice(deviceSN, deviceIndex, previousBoundRoleValue);
                    }
                }

                m_sn2role[deviceSN] = roleValue;

                if (VRModule.IsValidDeviceIndex(deviceIndex))
                {
                    InternalInsertRoleBoundDevice(deviceSN, deviceIndex, roleValue);
                }

                if (m_handler != null)
                {
                    m_handler.OnBindingRoleValueChanged(deviceSN, previousIsBound, previousBoundRoleValue, true, roleValue);
                }
            }