-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from lonelyicer/dev
feat: legacy protocol supported
- Loading branch information
Showing
5 changed files
with
298 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
namespace VRCFTPicoModule.Data; | ||
|
||
public class BlendShape | ||
{ | ||
public enum Index | ||
{ | ||
EyeLookDown_L = 0, | ||
NoseSneer_L = 1, | ||
EyeLookIn_L = 2, | ||
BrowInnerUp = 3, | ||
BrowDown_R = 4, | ||
MouthClose = 5, | ||
MouthLowerDown_R = 6, | ||
JawOpen = 7, | ||
MouthUpperUp_R = 8, | ||
MouthShrugUpper = 9, | ||
MouthFunnel = 10, | ||
EyeLookIn_R = 11, | ||
EyeLookDown_R = 12, | ||
NoseSneer_R = 13, | ||
MouthRollUpper = 14, | ||
JawRight = 15, | ||
BrowDown_L = 16, | ||
MouthShrugLower = 17, | ||
MouthRollLower = 18, | ||
MouthSmile_L = 19, | ||
MouthPress_L = 20, | ||
MouthSmile_R = 21, | ||
MouthPress_R = 22, | ||
MouthDimple_R = 23, | ||
MouthLeft = 24, | ||
JawForward = 25, | ||
EyeSquint_L = 26, | ||
MouthFrown_L = 27, | ||
EyeBlink_L = 28, | ||
CheekSquint_L = 29, | ||
BrowOuterUp_L = 30, | ||
EyeLookUp_L = 31, | ||
JawLeft = 32, | ||
MouthStretch_L = 33, | ||
MouthPucker = 34, | ||
EyeLookUp_R = 35, | ||
BrowOuterUp_R = 36, | ||
CheekSquint_R = 37, | ||
EyeBlink_R = 38, | ||
MouthUpperUp_L = 39, | ||
MouthFrown_R = 40, | ||
EyeSquint_R = 41, | ||
MouthStretch_R = 42, | ||
CheekPuff = 43, | ||
EyeLookOut_L = 44, | ||
EyeLookOut_R = 45, | ||
EyeWide_R = 46, | ||
EyeWide_L = 47, | ||
MouthRight = 48, | ||
MouthDimple_L = 49, | ||
MouthLowerDown_L = 50, | ||
TongueOut = 51, | ||
PP = 52, | ||
CH = 53, | ||
o = 54, | ||
O = 55, | ||
I = 56, | ||
u = 57, | ||
RR = 58, | ||
XX = 59, | ||
aa = 60, | ||
i = 61, | ||
FF = 62, | ||
U = 63, | ||
TH = 64, | ||
kk = 65, | ||
SS = 66, | ||
e = 67, | ||
DD = 68, | ||
E = 69, | ||
nn = 70, | ||
sil = 71 | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace VRCFTPicoModule.Data | ||
{ | ||
public class DataPacket | ||
{ | ||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
public struct DataPackHeader | ||
{ | ||
public byte startCode1; | ||
public byte startCode2; | ||
public byte trackingType; | ||
public byte subType; | ||
public byte multiPack; | ||
public byte currentIndex; | ||
public ushort version; | ||
public ulong timeStamp; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
public struct DataPackBody | ||
{ | ||
public long timeStamp; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 72)] | ||
public float[] blendShapeWeight; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | ||
public float[] videoInputValid; | ||
public float laughingProb; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | ||
public float[] emotionProb; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] | ||
public float[] reserved; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace VRCFTPicoModule.Data | ||
{ | ||
public class LegacyDataPacket | ||
{ | ||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
public struct DataPackBody | ||
{ | ||
public Int64 timestamp; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 72)] | ||
public float[] blendShapeWeight; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | ||
public float[] videoInputValid; | ||
public float laughingProb; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | ||
public float[] emotionProb; | ||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] | ||
public float[] reserved; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace VRCFTPicoModule.Utils | ||
{ | ||
public static class DataPacketHelpers | ||
{ | ||
public static T ByteArrayToStructure<T>(byte[] bytes, int offset = 0) where T : struct | ||
{ | ||
int size = Marshal.SizeOf(typeof(T)); | ||
IntPtr ptr = Marshal.AllocHGlobal(size); | ||
|
||
try | ||
{ | ||
Marshal.Copy(bytes, offset, ptr, size); | ||
return (T)Marshal.PtrToStructure(ptr, typeof(T))!; | ||
} | ||
finally | ||
{ | ||
Marshal.FreeHGlobal(ptr); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.