コード例 #1
0
        private HidDevice getHidDevice()
        {
            var devices = HidDeviceManager.GetManager().SearchDevices(VID, PID);

            if (manuallySelectedDevice == null)
            {
                foreach (var dev in devices)
                {
                    if (dev.Path().Contains("col02"))
                    {
                        return(dev);
                    }
                }

                if (devices.Count > 0)
                {
                    return(devices.FirstOrDefault());
                }

                return(null);
            }
            else
            {
                foreach (HidDevice dev in devices)
                {
                    if (dev.Path().Equals(manuallySelectedDevice))
                    {
                        return(dev);
                    }
                }
                return(null);
            }
        }
コード例 #2
0
        public FlipViewPage()
        {
            // save a pointer to ourself
            FlipViewPage.Current = this;

            // We use NavigationCacheMode.Required to keep track the selected item on navigation. For further information see the following links.
            // https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.page.navigationcachemode.aspx
            // https://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh771188.aspx
            NavigationCacheMode = NavigationCacheMode.Required;
            InitializeComponent();

            // disappear the title bar
            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;

            // configure focus
            this.FocusVisualMargin             = new Thickness(0);
            this.FocusVisualPrimaryBrush       = new SolidColorBrush(Colors.Transparent);
            this.FocusVisualPrimaryThickness   = new Thickness(0);
            this.FocusVisualSecondaryBrush     = new SolidColorBrush(Colors.Transparent);
            this.FocusVisualSecondaryThickness = new Thickness(0);

            // initialize the navigation bar
            foreach (NavigationSection section in ViewModel.Sections)
            {
                this.BottomNavBar.NavigationSections.Add(section);
            }
            this.BottomNavBar.IsHomeEnabled = true;

            // initialize the navigation bar root
            this.BottomNavBar.Root = ViewModel.Root;

            // initialize the music bar
            this.MusicBar.Volume         = ViewModel.Volume;
            this.MusicBar.PlayerPlaylist = ViewModel.Playlist;
            this.MusicBar.Background     = StyleHelper.GetAcrylicBrush(AcrylicColors.Light);

            // configure for joplin updates
            _loggerService    = new Logger("FG", "JLog.txt", null);
            _hidDeviceManager = new HidDeviceManager(_loggerService, HidDevice.GetDeviceSelector(0xFF01, 0x0000, 0x045E, 0x0A1B));
            _dispatcher       = CoreApplication.MainView.CoreWindow.Dispatcher;

            // is joplin enabled?
            _isJoplinEnabled = Services.ConfigurationService.Current.GetIsJoplinUpdateEnabled();

            // configure our page move timer
            _pageMoveTimer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(PAGE_TIMER_DURATION)
            };
            _pageMoveTimer.Tick += PageMoveTimer_Tick;
            _pageMoveTimer.Start();
        }
コード例 #3
0
        // If we move back to doing the firmware update on the FirmwareUpdatePage, remove everything below this.

        #region Joplin Upgrade Event Handlers

        private async void HidDeviceManager_HidConnectedDeviceStatusChanged(object sender, HidDeviceStatusChangedEventArgs e)
        {
            if (_isJoplinEnabled)
            {
                await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    // if joplin is connected
                    if (e.HidDeviceConnectionStatus == HidDeviceConnectionStatus.Connected)
                    {
                        // set up for update
                        _numberOfRetries   = 0;
                        _btDeviceId        = e.BTDeviceId;
                        _hidRequestManager = HidDeviceManager.GetConnectedDevicesRequestManager(_btDeviceId);

                        // if we didn't get what we needed, return
                        if ((null == _hidRequestManager) ||
                            (null == _hidRequestManager.SoftwareVersion) ||
                            (_hidRequestManager.SoftwareVersion.ToString() == VERSION_FIRMWARE))
                        {
                            return;
                        }

                        // get the firmware file
                        StorageFile file = null;
                        try
                        {
                            file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(URI_FIRMWARE));
                        }
                        catch { }

                        if (file == null)
                        {
                            return;
                        }

                        // get its contents as a byte array
                        _fileBytes = null;
                        using (IRandomAccessStreamWithContentType stream = await file.OpenReadAsync())
                        {
                            _fileBytes = new byte[stream.Size];
                            using (DataReader reader = new DataReader(stream))
                            {
                                await reader.LoadAsync((uint)stream.Size);
                                reader.ReadBytes(_fileBytes);
                            }
                        }

                        await StartUpgrade();
                    }
                });
            }
        }
コード例 #4
0
ファイル: HidDeviceComponent.cs プロジェクト: mpyzhov/CMTest
        public List <CoolitDevice> EnumerateCoolitBridgeDevices()
        {
            var result  = new List <CoolitDevice>();
            var manager = new HidDeviceManager();

            foreach (var device in devicesCache.GetCachedDevices())
            {
                var deviceEntity = DeviceFactory.DeviceEntityFromDevice(device);
                if (deviceEntity is CoolitDeviceEntity)
                {
                    result.Add(new CoolitDevice(new CoolitHidDevice((CoolitDeviceEntity)deviceEntity, manager)));
                }
            }

            return(result);
        }
コード例 #5
0
        private static void ShowDevices()
        {
            var deviceManager = HidDeviceManager.GetManager();

            //trying to find any device
            var devices = deviceManager.SearchDevices(0, 0);

            if (devices.Any())
            {
                foreach (var device in devices)
                {
                    device.Connect();
                    ShowDeviceInfo(device);
                    device.Disconnect();
                }
            }
            else
            {
                Console.WriteLine("no devices found");
            }
        }