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


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

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

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

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

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

            return(deviceList);
        }
        private static void RequestPermission(string[] permissionNames)
        {
            if (GetPermissionsService() == null)
            {
                return;
            }

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

            return(AndroidUtils.CallNativeBoolMethod(
                       permissionObjectPtr, IsPermissionGrantedPtr, new object[] { permissionName }));
        }
Exemple #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;
         }
     }
 }
Exemple #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);
        }