示例#1
0
        public DolphinConfig(Joycon joy = null)
        {
            typeChanged = 0;
            this.joy    = joy;
            InitializeComponent();
            sensibilityBar.Value = joy.GetPack().GetForce();

            if (!joy.isPro && joy.isLeft)
            {
                LeftRadio.Checked = true;
            }
            else if (!joy.isPro && !joy.isLeft)
            {
                RightRadio.Checked = true;
            }
            else
            {
                ProRadio.Checked = true;
            }

            int[] inverted = joy.GetPack().GetInverted();

            checkBoxX.Checked = inverted[0] < 1 ? true : false;
            checkBoxY.Checked = inverted[1] < 1 ? true : false;
            checkBoxZ.Checked = inverted[2] < 1 ? true : false;

            serialNumberLabel.Text = joy.serial_number;
        }
示例#2
0
 public void configBtnClick(object sender, EventArgs e, Joycon v)
 {
     if (v != null)
     {
         Form df = new DolphinConfig(v);
         df.ShowDialog();
     }
 }
示例#3
0
        void CleanUp()           // removes dropped controllers from list
        {
            List <Joycon> rem = new List <Joycon>();

            for (int i = 0; i < j.Count; i++)
            {
                Joycon v = j[i];
                if (v.state == Joycon.state_.DROPPED)
                {
                    // remove Config event handler
                    foreach (Button b in form.configBtn)
                    {
                        if (b.Enabled & b.Tag == v)
                        {
                            b.Click -= ((Joycon)b.Tag).configAction;
                            b.Invoke(new MethodInvoker(delegate
                            {
                                b.Enabled = false;
                            }));
                        }
                    }

                    if (v.other != null)
                    {
                        v.other.other = null;                         // The other of the other is the joycon itself
                    }
                    v.GetPack().CloseSock();
                    v.GetPack().SetActive(false);
                    v.Detach(); rem.Add(v);

                    foreach (Button b in form.con)
                    {
                        if (b.Enabled & b.Tag == v)
                        {
                            b.Invoke(new MethodInvoker(delegate {
                                b.BackColor       = System.Drawing.Color.FromArgb(0x00, System.Drawing.SystemColors.Control);
                                b.Enabled         = false;
                                b.BackgroundImage = Properties.Resources.cross;
                            }));
                            break;
                        }
                    }

                    form.AppendTextBox("Removed dropped controller to list. Can be reconnected.\r\n");
                }
            }

            foreach (Joycon v in rem)
            {
                j.Remove(v);
            }
        }
示例#4
0
        void ReenableXinput(Joycon v)
        {
            if (showAsXInput)
            {
                v.xin = new Xbox360Controller(Program.emClient);

                if (toRumble)
                {
                    v.xin.FeedbackReceived += v.ReceiveRumble;
                }
                v.report = new Xbox360Report();
            }
        }
示例#5
0
        public void locBtnClick(object sender, EventArgs e)
        {
            Button bb = sender as Button;

            if (bb.Tag.GetType() == typeof(Button))
            {
                Button button = bb.Tag as Button;

                if (button.Tag.GetType() == typeof(Joycon))
                {
                    Joycon v = (Joycon)button.Tag;
                    v.SetRumble(20.0f, 400.0f, 1.0f, 300);
                }
            }
        }
        public JoyUPDPack(Joycon parent, int port, String ip = "127.0.0.1", bool active = true, int force = 10, int[] invertArray = null)
        {
            this.parent = parent;
            if (SetPort(port))
            {
                //SetActive(active);
                SetActive(true);
                SetIP(ip);
                sendBuffer = new byte[27];
                StartSock();

                this.force = force;

                if (invertArray == null)
                {
                    this.invertArray = new int[] { 1, 1, 1 };
                }
                else
                {
                    this.invertArray = invertArray;
                }
            }
        }
示例#7
0
        public void CheckForNewControllers()
        {
            CleanUp();

            // move all code for initializing devices here and well as the initial code from Start()
            bool   isLeft  = false;
            IntPtr ptr     = HIDapi.hid_enumerate(vendor_id, 0x0);
            IntPtr top_ptr = ptr;

            hid_device_info enumerate;             // Add device to list
            bool            foundNew = false;

            while (ptr != IntPtr.Zero)
            {
                enumerate = (hid_device_info)Marshal.PtrToStructure(ptr, typeof(hid_device_info));
                if (form.nonOriginal)
                {
                    enumerate.product_id = product_pro;
                }

                DolphinJoyConfig dolphinJoyConfig = Program.generic_manager.Contains(enumerate.serial_number);

                if (dolphinJoyConfig.serial_number != "-1")
                {
                    enumerate.product_id = dolphinJoyConfig.product_id;
                }

                if ((enumerate.product_id == product_l || enumerate.product_id == product_r || enumerate.product_id == product_pro) && !ControllerAlreadyAdded(enumerate.path))
                {
                    switch (enumerate.product_id)
                    {
                    case product_l:
                        isLeft = true;
                        form.AppendTextBox("Left Joy-Con connected.\r\n"); break;

                    case product_r:
                        isLeft = false;
                        form.AppendTextBox("Right Joy-Con connected.\r\n"); break;

                    case product_pro:
                        isLeft = true;
                        form.AppendTextBox("Pro controller connected.\r\n"); break;

                    default:
                        form.AppendTextBox("Non Joy-Con Nintendo input device skipped.\r\n"); break;
                    }

                    // Add controller to block-list for HidGuardian
                    if (useHIDG)
                    {
                        HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(@"http://*****:*****@"hwids=HID\" + enumerate.path.Split('#')[1].ToUpper();
                        var            data     = Encoding.UTF8.GetBytes(postData);

                        request.Method        = "POST";
                        request.ContentType   = "application/x-www-form-urlencoded; charset=UTF-8";
                        request.ContentLength = data.Length;

                        using (var stream = request.GetRequestStream())
                            stream.Write(data, 0, data.Length);

                        try {
                            var response       = (HttpWebResponse)request.GetResponse();
                            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                        } catch {
                            form.AppendTextBox("Unable to add controller to block-list.\r\n");
                        }
                    }
                    else                         // Remove affected devices from list
                    {
                        try {
                            HttpWebResponse r1 = (HttpWebResponse)WebRequest.Create(@"http://localhost:26762/api/v1/hidguardian/affected/purge/").GetResponse();
                        } catch { }
                    }
                    // -------------------- //

                    IntPtr handle = HIDapi.hid_open_path(enumerate.path);
                    try {
                        HIDapi.hid_set_nonblocking(handle, 1);
                    } catch {
                        form.AppendTextBox("Unable to open path to device - are you using the correct (64 vs 32-bit) version for your PC?\r\n");
                        break;
                    }

                    j.Add(new Joycon(handle, EnableIMU, EnableLocalize & EnableIMU, 0.05f, isLeft, enumerate.path, enumerate.serial_number, j.Count, enumerate.product_id == product_pro));

                    foundNew = true;
                    j.Last().form = form;

                    if (j.Count < 5)
                    {
                        int ii = -1;
                        foreach (Button v in form.con)
                        {
                            ii++;
                            if (!v.Enabled)
                            {
                                System.Drawing.Bitmap temp;
                                switch (enumerate.product_id)
                                {
                                case (product_l):
                                    temp = Properties.Resources.jc_left_s; break;

                                case (product_r):
                                    temp = Properties.Resources.jc_right_s; break;

                                case (product_pro):
                                    temp = Properties.Resources.pro; break;

                                default:
                                    temp = Properties.Resources.cross; break;
                                }

                                v.Invoke(new MethodInvoker(delegate {
                                    v.Tag             = j.Last();                         // assign controller to button
                                    v.Enabled         = true;
                                    v.Click          += new EventHandler(form.conBtnClick);
                                    v.BackgroundImage = temp;
                                }));

                                form.loc[ii].Invoke(new MethodInvoker(delegate {
                                    form.loc[ii].Tag    = v;
                                    form.loc[ii].Click += new EventHandler(form.locBtnClick);
                                }));



                                form.configBtn[ii].Invoke(new MethodInvoker(delegate {
                                    form.configBtn[ii].Tag     = j.Last();
                                    form.configBtn[ii].Enabled = true;

                                    j.Last().configAction = delegate(object sender, EventArgs e)
                                    { form.configBtnClick(sender, e, (Joycon)form.configBtn[ii].Tag); };

                                    form.configBtn[ii].Click += ((Joycon)form.configBtn[ii].Tag).configAction;
                                }));

                                int port = -1;

                                bool success = int.TryParse(dolphinPorts[ii], out port);

                                j.Last().SetPack(port, dolphinJoyConfig.force, dolphinJoyConfig.inverse);

                                break;
                            }
                        }
                    }

                    byte[] mac = new byte[6];
                    for (int n = 0; n < 6; n++)
                    {
                        mac[n] = byte.Parse(enumerate.serial_number.Substring(n * 2, 2), System.Globalization.NumberStyles.HexNumber);
                    }
                    j[j.Count - 1].PadMacAddress = new PhysicalAddress(mac);
                }

                ptr = enumerate.next;
            }

            if (foundNew)               // attempt to auto join-up joycons on connection
            {
                Joycon temp = null;
                foreach (Joycon v in j)
                {
                    if (!v.isPro)
                    {
                        if (temp == null)
                        {
                            temp = v;
                        }
                        else if (temp.isLeft != v.isLeft && v.other == null)
                        {
                            temp.other = v;
                            v.other    = temp;

                            //Set both Joycon LEDs to the one with the lowest ID
                            byte led = temp.LED <= v.LED ? temp.LED : v.LED;
                            temp.LED = led;
                            v.LED    = led;
                            temp.SetPlayerLED(led);
                            v.SetPlayerLED(led);

                            temp.xin.Dispose();
                            temp.xin = null;

                            foreach (Button b in form.con)
                            {
                                if (b.Tag == v || b.Tag == temp)
                                {
                                    Joycon tt = (b.Tag == v) ? v : (b.Tag == temp) ? temp : v;
                                    b.BackgroundImage = tt.isLeft ? Properties.Resources.jc_left : Properties.Resources.jc_right;
                                }
                            }

                            temp = null;                                // repeat
                        }
                    }
                }
            }

            HIDapi.hid_free_enumeration(top_ptr);

            foreach (Joycon jc in j)               // Connect device straight away
            {
                if (jc.state == Joycon.state_.NOT_ATTACHED)
                {
                    if (jc.xin != null)
                    {
                        jc.xin.Connect();
                    }

                    jc.Attach(leds_: jc.LED);

                    bool on = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings["HomeLEDOn"].Value.ToLower() == "true";
                    foreach (Joycon j in Program.mgr.j)
                    {
                        j.SetHomeLight(on);
                    }

                    jc.Begin();
                    if (form.nonOriginal)
                    {
                        jc.getActiveData();
                    }
                }
            }
        }
示例#8
0
        public void conBtnClick(object sender, EventArgs e)
        {
            Button button = sender as Button;

            if (button.Tag.GetType() == typeof(Joycon))
            {
                Joycon v = (Joycon)button.Tag;

                if (v.other == null && !v.isPro)                   // needs connecting to other joycon (so messy omg)
                {
                    bool succ = false;
                    foreach (Joycon jc in Program.mgr.j)
                    {
                        if (!jc.isPro && jc.isLeft != v.isLeft && jc != v && jc.other == null)
                        {
                            v.other  = jc;
                            jc.other = v;

                            if (jc.isLeft == true)
                            {
                                jc.SetActiveOtherPack(false);
                            }
                            else
                            {
                                v.SetActiveOtherPack(false);
                            }

                            //Set both Joycon LEDs to the one with the lowest ID
                            byte led = jc.LED <= v.LED ? jc.LED : v.LED;
                            jc.LED = led;
                            v.LED  = led;
                            jc.SetPlayerLED(led);
                            v.SetPlayerLED(led);

                            v.xin.Dispose();
                            v.xin = null;

                            foreach (Button b in con)
                            {
                                if (b.Tag == jc)
                                {
                                    b.BackgroundImage = jc.isLeft ? Properties.Resources.jc_left : Properties.Resources.jc_right;
                                }
                            }

                            succ = true;
                            break;
                        }
                    }

                    if (succ)
                    {
                        foreach (Button b in con)
                        {
                            if (b.Tag == v)
                            {
                                b.BackgroundImage = v.isLeft ? Properties.Resources.jc_left : Properties.Resources.jc_right;
                            }
                        }
                    }
                }
                else if (v.other != null && !v.isPro)                     // needs disconnecting from other joycon
                {
                    if (v.xin == null)
                    {
                        ReenableXinput(v);
                        v.xin.Connect();
                    }

                    if (v.other.xin == null)
                    {
                        ReenableXinput(v.other);
                        v.other.xin.Connect();
                    }

                    button.BackgroundImage = v.isLeft ? Properties.Resources.jc_left_s : Properties.Resources.jc_right_s;

                    foreach (Button b in con)
                    {
                        if (b.Tag == v.other)
                        {
                            b.BackgroundImage = v.other.isLeft ? Properties.Resources.jc_left_s : Properties.Resources.jc_right_s;
                        }
                    }

                    //Set original Joycon LEDs
                    v.other.LED = (byte)(0x1 << v.other.PadId);
                    v.LED       = (byte)(0x1 << v.PadId);
                    v.other.SetPlayerLED(v.other.LED);
                    v.SetPlayerLED(v.LED);

                    v.other.SetActiveOtherPack(true);
                    v.other.other.SetActiveOtherPack(true);
                    v.other.other = null;
                    v.other       = null;
                }
            }
        }
示例#9
0
        public void NewReportIncoming(Joycon hidReport)
        {
            if (!running)
            {
                return;
            }

            var clientsList = new List <IPEndPoint>();
            var now         = DateTime.UtcNow;

            lock (clients) {
                var clientsToDelete = new List <IPEndPoint>();

                foreach (var cl in clients)
                {
                    const double TimeoutLimit = 5;

                    if ((now - cl.Value.AllPadsTime).TotalSeconds < TimeoutLimit)
                    {
                        clientsList.Add(cl.Key);
                    }
                    else if ((hidReport.PadId >= 0 && hidReport.PadId <= 3) &&
                             (now - cl.Value.PadIdsTime[(byte)hidReport.PadId]).TotalSeconds < TimeoutLimit)
                    {
                        clientsList.Add(cl.Key);
                    }
                    else if (cl.Value.PadMacsTime.ContainsKey(hidReport.PadMacAddress) &&
                             (now - cl.Value.PadMacsTime[hidReport.PadMacAddress]).TotalSeconds < TimeoutLimit)
                    {
                        clientsList.Add(cl.Key);
                    }
                    else                     //check if this client is totally dead, and remove it if so
                    {
                        bool clientOk = false;
                        for (int i = 0; i < cl.Value.PadIdsTime.Length; i++)
                        {
                            var dur = (now - cl.Value.PadIdsTime[i]).TotalSeconds;
                            if (dur < TimeoutLimit)
                            {
                                clientOk = true;
                                break;
                            }
                        }
                        if (!clientOk)
                        {
                            foreach (var dict in cl.Value.PadMacsTime)
                            {
                                var dur = (now - dict.Value).TotalSeconds;
                                if (dur < TimeoutLimit)
                                {
                                    clientOk = true;
                                    break;
                                }
                            }

                            if (!clientOk)
                            {
                                clientsToDelete.Add(cl.Key);
                            }
                        }
                    }
                }

                foreach (var delCl in clientsToDelete)
                {
                    clients.Remove(delCl);
                }
                clientsToDelete.Clear();
                clientsToDelete = null;
            }

            if (clientsList.Count <= 0)
            {
                return;
            }

            byte[] outputData = new byte[100];
            int    outIdx     = BeginPacket(outputData, 1001);

            Array.Copy(BitConverter.GetBytes((uint)MessageType.DSUS_PadDataRsp), 0, outputData, outIdx, 4);
            outIdx += 4;

            outputData[outIdx++] = (byte)hidReport.PadId;
            outputData[outIdx++] = (byte)hidReport.constate;
            outputData[outIdx++] = (byte)hidReport.model;
            outputData[outIdx++] = (byte)hidReport.connection;
            {
                byte[] padMac = hidReport.PadMacAddress.GetAddressBytes();
                outputData[outIdx++] = padMac[0];
                outputData[outIdx++] = padMac[1];
                outputData[outIdx++] = padMac[2];
                outputData[outIdx++] = padMac[3];
                outputData[outIdx++] = padMac[4];
                outputData[outIdx++] = padMac[5];
            }

            outputData[outIdx++] = (byte)hidReport.battery;
            outputData[outIdx++] = 1;

            Array.Copy(BitConverter.GetBytes(hidReport.packetCounter), 0, outputData, outIdx, 4);
            outIdx += 4;

            if (!ReportToBuffer(hidReport, outputData, ref outIdx))
            {
                return;
            }
            else
            {
                FinishPacket(outputData);
            }

            foreach (var cl in clientsList)
            {
                try { udpSock.SendTo(outputData, cl); } catch (SocketException ex) { }
            }
            clientsList.Clear();
            clientsList = null;
        }
示例#10
0
        private bool ReportToBuffer(Joycon hidReport, byte[] outputData, ref int outIdx)
        {
            outputData[outIdx] = 0;

            bool isLeft = hidReport.isLeft;

            if (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_LEFT : Joycon.Button.Y))
            {
                outputData[outIdx] |= 0x80;
            }
            if (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_DOWN : Joycon.Button.B))
            {
                outputData[outIdx] |= 0x40;
            }
            if (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_RIGHT : Joycon.Button.A))
            {
                outputData[outIdx] |= 0x20;
            }
            if (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_UP : Joycon.Button.X))
            {
                outputData[outIdx] |= 0x10;
            }

            if (hidReport.GetButton(Joycon.Button.PLUS))
            {
                outputData[outIdx] |= 0x08;
            }
            if (hidReport.GetButton(isLeft ? Joycon.Button.STICK2 : Joycon.Button.STICK))
            {
                outputData[outIdx] |= 0x04;
            }
            if (hidReport.GetButton(isLeft ? Joycon.Button.STICK : Joycon.Button.STICK2))
            {
                outputData[outIdx] |= 0x02;
            }
            if (hidReport.GetButton(Joycon.Button.MINUS))
            {
                outputData[outIdx] |= 0x01;
            }

            outputData[++outIdx] = 0;

            if (hidReport.GetButton(!swapXY ? (isLeft ? Joycon.Button.Y : Joycon.Button.DPAD_LEFT) : (isLeft ? Joycon.Button.X : Joycon.Button.DPAD_UP)))
            {
                outputData[outIdx] |= 0x80;
            }
            if (hidReport.GetButton(!swapAB ? (isLeft ? Joycon.Button.B : Joycon.Button.DPAD_DOWN) : (isLeft ? Joycon.Button.A : Joycon.Button.DPAD_RIGHT)))
            {
                outputData[outIdx] |= 0x40;
            }
            if (hidReport.GetButton(!swapAB ? (isLeft ? Joycon.Button.A : Joycon.Button.DPAD_RIGHT) : (isLeft ? Joycon.Button.B : Joycon.Button.DPAD_DOWN)))
            {
                outputData[outIdx] |= 0x20;
            }
            if (hidReport.GetButton(!swapXY ? (isLeft ? Joycon.Button.X : Joycon.Button.DPAD_UP) : (isLeft ? Joycon.Button.Y : Joycon.Button.DPAD_LEFT)))
            {
                outputData[outIdx] |= 0x10;
            }

            if (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER2_1 : Joycon.Button.SHOULDER_1))
            {
                outputData[outIdx] |= 0x08;
            }
            if (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER_1 : Joycon.Button.SHOULDER2_1))
            {
                outputData[outIdx] |= 0x04;
            }
            if (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER2_2 : Joycon.Button.SHOULDER_2))
            {
                outputData[outIdx] |= 0x02;
            }
            if (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER_2 : Joycon.Button.SHOULDER2_2))
            {
                outputData[outIdx] |= 0x01;
            }

            outputData[++outIdx] = (hidReport.GetButton(Joycon.Button.HOME)) ? (byte)1 : (byte)0;
            outputData[++outIdx] = 0;                 // no touch pad

            float[] leftStick = hidReport.GetStick(); // 127 is 0
            outputData[++outIdx] = (byte)(Math.Max(0, Math.Min(255, 127 + leftStick[0] * 127)));
            outputData[++outIdx] = (byte)(Math.Max(0, Math.Min(255, 127 + leftStick[1] * 127)));

            float[] rightStick = hidReport.GetStick2();             // 127 is 0
            outputData[++outIdx] = (byte)(Math.Max(0, Math.Min(255, 127 + rightStick[0] * 127)));
            outputData[++outIdx] = (byte)(Math.Max(0, Math.Min(255, 127 + rightStick[1] * 127)));

            //we don't have analog buttons so just use the Button enums (which give either 0 or 0xFF)
            outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_LEFT : Joycon.Button.Y)) ? (byte)0xFF : (byte)0;
            outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_DOWN : Joycon.Button.B)) ? (byte)0xFF : (byte)0;
            outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_RIGHT : Joycon.Button.A)) ? (byte)0xFF : (byte)0;
            outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_UP : Joycon.Button.X)) ? (byte)0xFF : (byte)0;

            outputData[++outIdx] = (hidReport.GetButton(!swapXY ? (isLeft ? Joycon.Button.Y : Joycon.Button.DPAD_LEFT) : (isLeft ? Joycon.Button.X : Joycon.Button.DPAD_UP))) ? (byte)0xFF : (byte)0;
            outputData[++outIdx] = (hidReport.GetButton(!swapAB ? (isLeft ? Joycon.Button.B : Joycon.Button.DPAD_DOWN) : (isLeft ? Joycon.Button.A : Joycon.Button.DPAD_RIGHT))) ? (byte)0xFF : (byte)0;
            outputData[++outIdx] = (hidReport.GetButton(!swapAB ? (isLeft ? Joycon.Button.A : Joycon.Button.DPAD_RIGHT) : (isLeft ? Joycon.Button.B : Joycon.Button.DPAD_DOWN))) ? (byte)0xFF : (byte)0;
            outputData[++outIdx] = (hidReport.GetButton(!swapXY ? (isLeft ? Joycon.Button.X : Joycon.Button.DPAD_UP) : (isLeft ? Joycon.Button.Y : Joycon.Button.DPAD_LEFT))) ? (byte)0xFF : (byte)0;

            outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER2_1 : Joycon.Button.SHOULDER_1)) ? (byte)0xFF : (byte)0;
            outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER_1 : Joycon.Button.SHOULDER2_1)) ? (byte)0xFF : (byte)0;

            outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER2_2 : Joycon.Button.SHOULDER_2)) ? (byte)0xFF : (byte)0;
            outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER_2 : Joycon.Button.SHOULDER2_2)) ? (byte)0xFF : (byte)0;

            outIdx++;

            //DS4 only: touchpad points
            for (int i = 0; i < 2; i++)
            {
                outIdx += 6;
            }

            //motion timestamp
            Array.Copy(BitConverter.GetBytes(hidReport.Timestamp), 0, outputData, outIdx, 8);
            outIdx += 8;

            //accelerometer
            {
                var accel = hidReport.GetAccel();
                if (accel != null)
                {
                    Array.Copy(BitConverter.GetBytes(accel.Y), 0, outputData, outIdx, 4);
                    outIdx += 4;
                    Array.Copy(BitConverter.GetBytes(-accel.Z), 0, outputData, outIdx, 4);
                    outIdx += 4;
                    Array.Copy(BitConverter.GetBytes(accel.X), 0, outputData, outIdx, 4);
                    outIdx += 4;
                }
                else
                {
                    outIdx += 12;
                    Console.WriteLine("No accelerometer reported.");
                }
            }

            //gyroscope
            {
                var gyro = hidReport.GetGyro();
                if (gyro != null)
                {
                    Array.Copy(BitConverter.GetBytes(gyro.Y), 0, outputData, outIdx, 4);
                    outIdx += 4;
                    Array.Copy(BitConverter.GetBytes(gyro.Z), 0, outputData, outIdx, 4);
                    outIdx += 4;
                    Array.Copy(BitConverter.GetBytes(gyro.X), 0, outputData, outIdx, 4);
                    outIdx += 4;
                }
                else
                {
                    outIdx += 12;
                    Console.WriteLine("No gyroscope reported.");
                }
            }

            return(true);
        }