Skip to content

Commit

Permalink
ACTUALLY VERIFIED STREAM CORRECTLY!
Browse files Browse the repository at this point in the history
  • Loading branch information
DevL0rd committed Apr 29, 2020
1 parent 1d41a03 commit a3d4c7c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
20 changes: 11 additions & 9 deletions SkyNX-Streamer/NxStreamingService/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ hidStreamClient.on('connect', function () {
var switchHidBuffer = new Buffer.alloc(0);
function parseInputStruct(buff) {
var input = Struct()
.word8('streamStart')
.word64Ule('streamStart')
.word32Ule('HeldKeys1')
.word32Sle('LJoyX1')
.word32Sle('LJoyY1')
Expand Down Expand Up @@ -161,7 +161,7 @@ function parseInputStruct(buff) {
.floatle('gyroZ')
.word32Ule('controllerCount')
.word32Ule('frameRate')
.word8('streamEnd')
.word64Ule('streamEnd')
input._setBuff(buff);
return input;
};
Expand Down Expand Up @@ -478,19 +478,21 @@ function handleGyroAndAccel(hid) {
GyroServ.sendMotionData(gyro, accel);
}
var fpsPrintTimer = 0;
var hidDataBuffer;
hidStreamClient.on('data', function (data) {
if (data.length < 208) {
if (data.length < 224) {
console.log("HID data too short. Data length: " + data.length)
return;
} //packet is 208 in length. anyless then the data is bad
if (data.length > 208) {
data.length = 208; //ignore extra data
// console.log(data.length / 208)
} //packet is 216 in length. anyless then the data is bad
if (data.length > 224) {
data.length = 224; //ignore extra data
//console.log("Duplicate Data: " + (data.length / 224))
}
switchHidBuffer = new Buffer.from(data);
var hid = parseInputStruct(switchHidBuffer)
if (!(hid.get("streamStart") === 255 && hid.get("streamEnd") === 255)) {
console.log("HID data malformed: " + data.length);
if (!(hid.get("streamStart") === "18446744073709551615" && hid.get("streamEnd") === "9223372036854775807")) {
console.log("HID Data malformed. Data length: " + data.length);
console.log(hid.get("streamStart") + " - " + hid.get("streamEnd"))
return;
}

Expand Down
8 changes: 4 additions & 4 deletions SkyNX/source/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ void gamePadSend(JoyConSocket *connection)
controllersConnected++;
}
}
pkg.streamStart = 255;
pkg.streamEnd = 255;
pkg.frameRate = frameRate;
pkg.controllerCount = controllersConnected;
pkg.streamStart = (uint64_t)UINT64_MAX; //easy identifiers for the start and stop of tcp stream
pkg.streamEnd = (uint64_t)UINT64_MAX / 2;
pkg.frameRate = (uint32_t)frameRate;
pkg.controllerCount = (uint32_t)controllersConnected;

pkg.heldKeys1 = (uint32_t)hidKeysHeld(player1Id);
hidJoystickRead(&lJoy, player1Id, JOYSTICK_LEFT);
Expand Down
4 changes: 2 additions & 2 deletions SkyNX/source/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/* Data to send to server */
typedef struct
{
uint8_t streamStart;
uint64_t streamStart;
uint32_t heldKeys1;
int32_t lJoyX1;
int32_t lJoyY1;
Expand Down Expand Up @@ -63,7 +63,7 @@ typedef struct
float_t gyroZ;
uint32_t controllerCount;
uint32_t frameRate;
uint8_t streamEnd;
uint64_t streamEnd;
} JoyPkg;

/* Init nx network and av network */
Expand Down

0 comments on commit a3d4c7c

Please sign in to comment.