From 3943b439bb7561caf6829b88391f6652d67d237f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=B1=AA=E6=9D=B0?= Date: Fri, 12 Apr 2019 20:27:07 +0800 Subject: [PATCH] fix ios12 --- README.md | 4 +++- app.js | 8 ++++---- package.json | 3 +++ static.html | 19 ++++++++++++++++--- 4 files changed, 26 insertions(+), 8 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 app.js mode change 100644 => 100755 package.json mode change 100644 => 100755 static.html diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 3bbcceb..a0a9f9b --- a/README.md +++ b/README.md @@ -16,7 +16,9 @@ Load the game and enjoy it~ ## Notie in IOS 12.2+ -If you are using ios 12.2+, please enable 'Settings > Safari > Motion and Orientation access' and use HTTPS to access +If you are using ios 12.2+, please enable 'Settings > Safari > Motion and Orientation access' and use HTTPS to access. + +Since safari's websocket does not support self-signed certificates, when using HTTPS access, socket.io will probably use XHR instead of websocket, which will increase communication latency. ## Quote diff --git a/app.js b/app.js old mode 100644 new mode 100755 index 7045073..5461618 --- a/app.js +++ b/app.js @@ -6,8 +6,8 @@ const fs = require("fs"); const path = require("path"); var https = require('https'); -var privateKey = fs.readFileSync('ssl/private.pem', 'utf8'); -var certificate = fs.readFileSync('ssl/file.crt', 'utf8'); +var privateKey = fs.readFileSync(__dirname+'/ssl/private.pem', 'utf8'); +var certificate = fs.readFileSync(__dirname+'/ssl/file.crt', 'utf8'); var credentials = { key: privateKey, cert: certificate }; const server = dgram.createSocket("udp4"); @@ -25,7 +25,7 @@ const MessageType = { DSUC_PadDataReq: 0x100002, DSUS_PadDataRsp: 0x100002 }; -const serverID = 0 + Math.floor(Math.random() * 9007199254740992); +const serverID = 0 + Math.floor(Math.random() * 4294967295); console.log(`serverID: ${serverID}`); var connectedClient = null; @@ -329,7 +329,7 @@ var httpServer = http.createServer( httpServer.listen(8080, function () { console.log(` ---------------------------------------- - Version 1.5 by hjmmc + Version 1.6 by hjmmc ----------------------------------------- ##Usage diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 86f9096..7c6415c --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "scripts": { "start": "node app.js" }, + "pkg": { + "assets": "ssl/**/*" + }, "repository": { "type": "git", "url": "git+https://github.com/denismr/iOSGyroForCemuhook.git" diff --git a/static.html b/static.html old mode 100644 new mode 100755 index f53992e..4ff2ff3 --- a/static.html +++ b/static.html @@ -5,12 +5,25 @@ Gyro Client - + -

Version: 1.5 (by hjmmc)

+

Version: 1.6 (by hjmmc)

Tips:Please keep the screen bright when you use it.

+

Notice: If you are using ios 12.2+, please enable 'Settings > Safari > Motion and Orientation access' and use HTTPS to access + this page

+

Since safari's websocket does not support self-signed certificates, when using HTTPS access, socket.io will probably use XHR instead of websocket, which will increase communication latency.

Sensitivity:
Screen direction: @@ -74,7 +87,7 @@ z: 0 } } - ws.emmit('report',JSON.stringify(data, function (key, val) { + ws.emit('report',JSON.stringify(data, function (key, val) { return val.toFixed ? Number(val.toFixed(20)) : val; })); };