示例#1
0
        public static PSVRSensor parseSensor(byte[] data)
        {
            PSVRSensor sensor = new PSVRSensor();

            if (data == null)
            {
                return(sensor);
            }

            sensor.Buttons = (HeadsetButtons)data[0];
            sensor.Volume  = data[2];

            sensor.Worn          = (data[8] & 0x1) == 0x1 ? true : false;        //confirmed
            sensor.DisplayActive = (data[8] & 0x2) == 0x2 ? false : true;
            sensor.Muted         = (data[8] & 0x8) == 0x8 ? true : false;        //confirmed

            sensor.EarphonesConnected = (data[8] & 0x10) == 0x10 ? true : false; //confirmed

            sensor.GroupSequence1 = getIntFromInt16(data, 18);

            sensor.GyroYaw1   = getIntFromInt16(data, 20);
            sensor.GyroPitch1 = getIntFromInt16(data, 22);
            sensor.GyroRoll1  = getIntFromInt16(data, 24);

            sensor.MotionX1 = getIntFromInt16(data, 26);
            sensor.MotionY1 = getIntFromInt16(data, 28);
            sensor.MotionZ1 = getIntFromInt16(data, 30);

            sensor.GroupSequence2 = getIntFromInt16(data, 34);

            sensor.GyroYaw2   = getIntFromInt16(data, 36);
            sensor.GyroPitch2 = getIntFromInt16(data, 38);
            sensor.GyroRoll2  = getIntFromInt16(data, 40);

            sensor.MotionX2 = getIntFromInt16(data, 42);
            sensor.MotionY2 = getIntFromInt16(data, 44);
            sensor.MotionZ2 = getIntFromInt16(data, 46);

            sensor.CalStatus = data[48];
            sensor.Ready     = data[49];

            sensor.A = data[50];
            sensor.B = data[51];
            sensor.C = data[52];

            sensor.VoltageValue     = data[53];
            sensor.VoltageReference = data[54];
            sensor.IRSensor         = getIntFromInt16(data, 55);

            sensor.D = data[58];
            sensor.E = data[59];
            sensor.F = data[60];
            sensor.G = data[61];
            sensor.H = data[62];

            sensor.PacketSequence = data[63];

            return(sensor);
        }
示例#2
0
        //public static PSVRSensor parseSensor(byte[] data)
        //{

        //    PSVRSensor sensor = new PSVRSensor();
        //    if (data == null)
        //    {
        //        return sensor;
        //    }


        //    /*
        //     * sample data
        //        00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
        //        00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-AB-D7-69-00-FE-FF-F4-FF-16-00-E1-CF-1F-E0-E1-E9-9F-D9-69-00-FC-FF-EF-FF-24-00-C1-CF-1F-E0-B1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-BC-01-6D
        //        00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-93-DB-69-00-FF-FF-FA-FF-13-00-D1-CF-2F-E0-81-E9-88-DD-69-00-FC-FF-0A-00-FC-FF-11-D0-FF-DF-D1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-7D-01-6E
        //        00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-7B-DF-69-00-08-00-0E-00-EE-FF-F1-CF-EF-DF-01-EA-70-E1-69-00-04-00-09-00-F9-FF-E1-CF-1F-E0-B1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-84-01-6F

        //        [byte 3]
        //        Volume (0~50)
        //        [byte 9]
        //        0000 0001 Worn (Mounted on Player)
        //        0000 0010 Display is On
        //        0000 0100 ??
        //        0000 1000 Mute
        //        0001 0000 Earphone
        //        0010 0000
        //        0100 0000
        //        1000 0000
        //        reference:
        //        https://github.com/hrl7/node-psvr/blob/master/lib/psvr.js
        //     */


        //    sensor.volume = data[3];

        //    sensor.isWorn = (data[9] & 0x1) == 0x1 ? true : false;//confirmed
        //    sensor.isDisplayActive = (data[9] & 0x2) == 0x2 ? false : true;
        //    sensor.isMute = (data[9] & 0x8) == 0x8 ? true : false;//confirmed

        //    sensor.isEarphoneConnected = (data[9] & 0x10) == 0x10 ? true : false;//confirmed


        //    sensor.MotionX1 = getIntFromInt16(data, 27);
        //    sensor.MotionY1 = getIntFromInt16(data, 29);
        //    sensor.MotionZ1 = getIntFromInt16(data, 31);

        //    sensor.MotionX2 = getIntFromInt16(data, 43);
        //    sensor.MotionY2 = getIntFromInt16(data, 45);
        //    sensor.MotionZ2 = getIntFromInt16(data, 47);

        //    sensor.GyroYaw1 = getIntFromInt16(data, 21);
        //    sensor.GyroPitch1 = getIntFromInt16(data, 23);
        //    sensor.GyroRoll1 = getIntFromInt16(data, 25);

        //    sensor.GyroYaw2 = getIntFromInt16(data, 37);
        //    sensor.GyroPitch2 = getIntFromInt16(data, 39);
        //    sensor.GyroRoll2 = getIntFromInt16(data, 41);


        //    sensor.A = convert(data[19], data[20]);
        //    sensor.B = convert(data[21], data[22]);
        //    sensor.C = convert(data[23], data[24]);

        //    sensor.D = convert(data[25], data[26]);
        //    sensor.E = convert(data[27], data[28]);//下方向加速度
        //    sensor.F = convert(data[29], data[30]);//左方向加速度

        //    sensor.G = convert(data[31], data[32]);//後ろ方向加速度
        //    sensor.H = convert(data[33], data[34]);
        //    sensor.I = convert(data[35], data[36]);

        //    sensor.J = convert(data[37], data[38]);
        //    sensor.K = convert(data[39], data[40]);
        //    sensor.L = convert(data[41], data[42]);

        //    sensor.M = convert(data[43], data[44]);//下方向加速度
        //    sensor.N = convert(data[45], data[46]);//左方向加速度
        //    sensor.O = convert(data[47], data[48]);//後ろ方向加速度


        //    return sensor;

        //}

        public static PSVRSensor parseSensor(byte[] data)
        {
            PSVRSensor sensor = new PSVRSensor();

            if (data == null)
            {
                return(sensor);
            }


            /*
             * sample data
             *  00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
             *  00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-AB-D7-69-00-FE-FF-F4-FF-16-00-E1-CF-1F-E0-E1-E9-9F-D9-69-00-FC-FF-EF-FF-24-00-C1-CF-1F-E0-B1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-BC-01-6D
             *  00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-93-DB-69-00-FF-FF-FA-FF-13-00-D1-CF-2F-E0-81-E9-88-DD-69-00-FC-FF-0A-00-FC-FF-11-D0-FF-DF-D1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-7D-01-6E
             *  00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-7B-DF-69-00-08-00-0E-00-EE-FF-F1-CF-EF-DF-01-EA-70-E1-69-00-04-00-09-00-F9-FF-E1-CF-1F-E0-B1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-84-01-6F
             *
             *  [byte 3]
             *  Volume (0~50)
             *  [byte 9]
             *  0000 0001 Worn (Mounted on Player)
             *  0000 0010 Display is On
             *  0000 0100 ??
             *  0000 1000 Mute
             *  0001 0000 Earphone
             *  0010 0000
             *  0100 0000
             *  1000 0000
             *  reference:
             *  https://github.com/hrl7/node-psvr/blob/master/lib/psvr.js
             */


            sensor.volume = data[2];

            sensor.isWorn          = (data[8] & 0x1) == 0x1 ? true : false;       //confirmed
            sensor.isDisplayActive = (data[8] & 0x2) == 0x2 ? false : true;
            sensor.isMute          = (data[8] & 0x8) == 0x8 ? true : false;       //confirmed

            sensor.isEarphoneConnected = (data[8] & 0x10) == 0x10 ? true : false; //confirmed


            sensor.MotionX1 = getIntFromInt16(data, 26);
            sensor.MotionY1 = getIntFromInt16(data, 28);
            sensor.MotionZ1 = getIntFromInt16(data, 30);

            sensor.MotionX2 = getIntFromInt16(data, 42);
            sensor.MotionY2 = getIntFromInt16(data, 44);
            sensor.MotionZ2 = getIntFromInt16(data, 46);

            sensor.GyroYaw1   = getIntFromInt16(data, 20);
            sensor.GyroPitch1 = getIntFromInt16(data, 22);
            sensor.GyroRoll1  = getIntFromInt16(data, 24);

            sensor.GyroYaw2   = getIntFromInt16(data, 36);
            sensor.GyroPitch2 = getIntFromInt16(data, 38);
            sensor.GyroRoll2  = getIntFromInt16(data, 40);


            sensor.A = convert(data[18], data[19]);
            sensor.B = convert(data[20], data[21]);
            sensor.C = convert(data[22], data[23]);

            sensor.D = convert(data[24], data[25]);
            sensor.E = convert(data[26], data[27]); //下方向加速度
            sensor.F = convert(data[28], data[29]); //左方向加速度

            sensor.G = convert(data[30], data[31]); //後ろ方向加速度
            sensor.H = convert(data[32], data[33]);
            sensor.I = convert(data[34], data[37]);

            sensor.J = convert(data[36], data[37]);
            sensor.K = convert(data[38], data[39]);
            sensor.L = convert(data[40], data[41]);

            sensor.M = convert(data[42], data[43]); //下方向加速度
            sensor.N = convert(data[44], data[45]); //左方向加速度
            sensor.O = convert(data[46], data[47]); //後ろ方向加速度


            return(sensor);
        }