private void OnUnpair()
 {
     if (device.IsConnected ||
         (AndroidUtils.ConvertConnectionStatus(device.ConnectionStatus) == 2 && device.IsPaired))
     {
         BhapticsAndroidManager.Unpair(device.Address);
     }
 }
예제 #2
0
        public List <HapticDevice> GetDevices()
        {
            string[] result = androidJavaObject.Call <string[]>("getDeviceList");
            deviceList = AndroidUtils.ConvertToBhapticsDevices(result);


            return(deviceList);
        }
예제 #3
0
        public bool CheckPermission()
        {
            if (androidJavaObject == null)
            {
                return(false);
            }

            return(AndroidUtils.CallNativeBoolMethod(AndroidJavaObjectPtr, HasPermissionPtr, EmptyParams));
        }
예제 #4
0
        public void RequestPermission()
        {
            if (androidJavaObject == null)
            {
                return;
            }

            AndroidUtils.CallNativeVoidMethod(AndroidJavaObjectPtr, RequestPermissionPtr, EmptyParams);
        }
예제 #5
0
        private bool CallNativeBoolMethod(IntPtr methodPtr, object[] param)
        {
            if (androidJavaObject == null)
            {
                return(false);
            }

            return(AndroidUtils.CallNativeBoolMethod(AndroidJavaObjectPtr, methodPtr, param));
        }
예제 #6
0
        private void CallNativeVoidMethod(IntPtr methodPtr, object[] param)
        {
            if (androidJavaObject == null)
            {
                return;
            }

            AndroidUtils.CallNativeVoidMethod(AndroidJavaObjectPtr, methodPtr, param);
        }
예제 #7
0
        public List <HapticDevice> GetDevices(bool force = false)
        {
            if (force)
            {
                string result = hapticPlayer.Call <string>("getDeviceList");
                deviceList = AndroidUtils.ConvertToBhapticsDevices(result);
            }

            return(deviceList);
        }
예제 #8
0
        private static void RequestPermission(string[] permissionNames)
        {
            if (GetPermissionsService() == null)
            {
                return;
            }

            AndroidUtils.CallNativeVoidMethod(
                permissionObjectPtr, RequestPermissionAsyncPtr, new object[] { permissionNames });
        }
예제 #9
0
        private static bool IsPermissionGranted(string permissionName)
        {
            if (GetPermissionsService() == null)
            {
                return(false);
            }

            return(AndroidUtils.CallNativeBoolMethod(
                       permissionObjectPtr, IsPermissionGrantedPtr, new object[] { permissionName }));
        }
예제 #10
0
        public static bool CanPairDevice(PositionType position)
        {
            var deviceList = GetDevices();

            foreach (var device in deviceList)
            {
                if (AndroidUtils.CanPair(device, position))
                {
                    return(true);
                }
            }
            return(false);
        }
 private void OnSwap()
 {
     if (device.IsConnected)
     {
         BhapticsAndroidManager.TogglePosition(device.Address);
         if (AndroidUtils.IsLeft(device.Position))
         {
             toggleButton.image.sprite = leftSide;
         }
         else
         {
             toggleButton.image.sprite = rightSide;
         }
     }
 }
예제 #12
0
        public static bool IsNeededToScan()
        {
            var devices = GetDevices();

            if (IsScanning())
            {
                return(false);
            }

            if (devices != null)
            {
                for (int i = 0; i < devices.Count; i++)
                {
                    if (devices[i].IsPaired && AndroidUtils.ConvertConnectionStatus(devices[i].ConnectionStatus) == 2)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }