mirror of
https://github.com/DevL0rd/SkyNX
synced 2025-02-16 17:28:23 +00:00
detect corrupt packets. hid
This commit is contained in:
parent
3f918ffb1a
commit
1dea781e36
5 changed files with 12 additions and 4 deletions
|
@ -96,6 +96,7 @@ function startVideoProcess() {
|
|||
});
|
||||
}
|
||||
hidStreamClient.on('connect', function () {
|
||||
hidStreamClient.setNoDelay(true);
|
||||
console.log('Connected to Switch!');
|
||||
if (usingVideo) {
|
||||
startVideoProcess();
|
||||
|
@ -476,8 +477,15 @@ function handleGyroAndAccel(hid) {
|
|||
}
|
||||
var fpsPrintTimer = 0;
|
||||
hidStreamClient.on('data', function (data) {
|
||||
if (data.length < 208) {
|
||||
console.log("Data incorrect length. 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)
|
||||
}
|
||||
switchHidBuffer = new Buffer.from(data);
|
||||
|
||||
var hid = parseInputStruct(switchHidBuffer)
|
||||
var controllerCount = hid.get("controllerCount");
|
||||
if (controllerCount > controllerIds.length) {
|
||||
|
|
|
@ -134,7 +134,6 @@ void audioHandlerLoop()
|
|||
resample((unsigned short *)in_buf, sizeof(in_buf), (unsigned short *)buf_data[curBuf], FACT);
|
||||
play_buf(buffer_size, DATA_SIZE);
|
||||
played++;
|
||||
// svcSleepThread(16666665); //Nano sleep to keep at 60fps
|
||||
}
|
||||
|
||||
for (int curBuf = 0; curBuf < BUF_COUNT; curBuf++)
|
||||
|
|
|
@ -136,7 +136,7 @@ void inputHandlerLoop(void *dummy)
|
|||
while (appletMainLoop())
|
||||
{
|
||||
handleInput(connection);
|
||||
svcSleepThread(23333333);
|
||||
svcSleepThread(23333333ULL);
|
||||
}
|
||||
|
||||
freeJoyConSocket(connection);
|
||||
|
|
|
@ -153,7 +153,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
drawSplash(renderContext);
|
||||
}
|
||||
svcSleepThread(14285714); //Nano sleep to keep at 70fps to handle drop frames without stutter
|
||||
svcSleepThread(14285714ULL); //Nano sleep to keep at 70fps to handle drop frames without stutter
|
||||
}
|
||||
/* Deinitialize all used systems */
|
||||
unInit();
|
||||
|
|
|
@ -81,6 +81,7 @@ int connectJoyConSocket(JoyConSocket *connection, int port)
|
|||
|
||||
void sendJoyConInput(JoyConSocket *connection, const JoyPkg *pkg)
|
||||
{
|
||||
// printf("%lu\n", sizeof(JoyPkg));
|
||||
if (send(connection->sock, pkg, sizeof(JoyPkg), 0) != sizeof(JoyPkg))
|
||||
{
|
||||
connection->sock = -1;
|
||||
|
|
Loading…
Add table
Reference in a new issue