Esempio n. 1
0
        private void SetDevice()
        {
            USBDevice dev = usbDevices[46084, 4099];

            if (dev != null)
            {
                cyDevice        = (CyUSBDevice)dev;
                controlEndPoint = null;
                bulkInEndPoint  = null;

                GetEndpointsOfNode(cyDevice.Tree);
                if (controlEndPoint != null)
                {
                    isReady = true;

                    name     = dev.FriendlyName;
                    version  = GetFirmwareVer();
                    revision = GetRevision();

                    DeviceReadyEventArgs args = new DeviceReadyEventArgs();
                    args.DeviceName = name;
                    args.VidPid     = new[] { dev.VendorID, dev.ProductID };
                    args.Version    = version;
                    args.Revision   = revision;

                    DeviceReady?.Invoke(this, args);
                }
            }
            else
            {
                isReady = false;
                DeviceNotReady?.Invoke(this, null);
            }
        }
        public override void MovedToWindow()
        {
            base.MovedToWindow();

            var swapchainSource      = SwapchainSource.CreateUIView(Handle);
            var swapchainDescription = new SwapchainDescription(swapchainSource, (uint)Frame.Width, (uint)Frame.Height, null, true, true);

            if (_backend == GraphicsBackend.Metal)
            {
                GraphicsDevice = GraphicsDevice.CreateMetal(_deviceOptions);
            }

            MainSwapchain = GraphicsDevice.ResourceFactory.CreateSwapchain(swapchainDescription);

            DeviceReady?.Invoke();

            _displayLink = CADisplayLink.Create(HandleDisplayLinkOutputCallback);
            _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default);
        }
Esempio n. 3
0
        public override void ViewDidMoveToWindow()
        {
            base.ViewDidMoveToWindow();

            var swapchainSource      = SwapchainSource.CreateNSView(Handle);
            var swapchainDescription = new SwapchainDescription(swapchainSource, (uint)Frame.Width, (uint)Frame.Height, null, true, true);

            if (_backend == GraphicsBackend.Metal)
            {
                GraphicsDevice = GraphicsDevice.CreateMetal(_deviceOptions);
            }

            MainSwapchain = GraphicsDevice.ResourceFactory.CreateSwapchain(swapchainDescription);

            DeviceReady?.Invoke();

            _displayLink = new CVDisplayLink();
            _displayLink.SetOutputCallback(HandleDisplayLinkOutputCallback);
            _displayLink.Start();
        }
Esempio n. 4
0
        private void ProcessResponse(byte[] req, byte[] res)
        {
            if (res[0] != (byte)hid_pkt_res.HID_PKT_RES_ERR)
            {
                switch ((hid_pkt_req)req[0])
                {
                case hid_pkt_req.HID_PKT_REQ_CONFIG_KEY_GET:
                {
                    var keyConfig = new KeyConfig((KeyPressAction)res[1], res[2], res[3]);
                    KeyConfigReceived?.Invoke(this, new KeyConfigReceivedEventArgs(keyConfig));
                }
                break;

                case hid_pkt_req.HID_PKT_REQ_CONFIG_LED_GET:
                {
                    byte[] raw = new byte[31];
                    Array.Copy(res, 1, raw, 0, 31);
                    var ledConfig = new LedConfig(raw);
                    if (!ledConfig.Equals(_CurrentLedConfig))
                    {
                        _CurrentLedConfig = ledConfig;
                        LedConfigReceived?.Invoke(this, new LedConfigReceivedEventArgs(ledConfig));
                    }
                }
                break;

                case hid_pkt_req.HID_PKT_REQ_LED_COUNT:
                    DeviceReady?.Invoke(this, new DeviceReadyEventArgs(_ActiveDevice.Instance, res[1]));
                    break;
                }
            }
            else
            {
                _Logger.Error("Device responded with error condition: req = {0} request data = {1}", (hid_pkt_req)req[0], FormatByteArray(req.Skip(1)));
            }
        }
            //
            // Messages from Clover SDK to route through to the Keypad Example classes
            //

            public override void OnDeviceReady(MerchantInfo merchantInfo) => DeviceReady?.Invoke(merchantInfo);
Esempio n. 6
0
 private IoTCentral()
 {
     MessagingCenter.Subscribe <ResultMessage <IDevice> >(this, Constants.BLE_DEVICE_READY, (dev) => { DeviceReady?.Invoke(this, dev.Data); });
     MessagingCenter.Subscribe <ResultMessage <IoTCConnectionState> >(this, Constants.IOTC_DEVICE_CLIENT_CONNECTED, result =>
     {
         DeviceConnectionChanged?.Invoke(this, result.Data);
     });
     MessagingCenter.Subscribe <ResultMessage <IList <BluetoothServiceModel> > >(this, Constants.BLE_SERVICES_FETCHED, (services) => { ServicesFetched?.Invoke(this, services.Data); });
 }
Esempio n. 7
0
 public void OnDeviceReady(MerchantInfo merchantInfo) => DeviceReady?.Invoke(this, merchantInfo);