public TouchEvent DecodeTouch(UnPacker unpacker) { int length = unpacker.UnpackByte(); Touch[] touches = new Touch[length]; for (int i = 0; i < length; i++) { Touch touch; touch.Location.X = unpacker.UnpackShort(); touch.Location.Y = unpacker.UnpackShort(); touch.Pressure = unpacker.UnpackByte() / 256.0f; touches[i] = touch; } return new TouchEvent(touches); }
private int UnpackID(UnPacker unpacker) { if (this.nextID < sbyte.MaxValue) { return unpacker.UnpackByte(); } else if (this.nextID < short.MaxValue) { return unpacker.UnpackShort(); } else { return unpacker.UnpackInteger(); } }