Browse Source

优化同步

Caner 2 years ago
parent
commit
40d3a3b019
2 changed files with 13 additions and 3 deletions
  1. 2 1
      .eslintrc.json
  2. 11 2
      src/views/index/index.vue

+ 2 - 1
.eslintrc.json

@@ -37,6 +37,7 @@
     "no-shadow": 0,
     "prefer-destructuring": 0,
     "no-new": 0,
-    "func-names": 0
+    "func-names": 0,
+    "no-nested-ternary": 0
   }
 }

+ 11 - 2
src/views/index/index.vue

@@ -192,9 +192,11 @@ function intSoketRtc(host: string) {
           // init Control
           // window.addEventListener('gamepadconnected', conControl)
           // window.addEventListener('gamepaddisconnected', disControl)
-          window.$electron.onContrl((db:ArrayBuffer) => {
+          window.$electron.onContrl((db: ArrayBuffer) => {
             console.log('123', db)
           })
+          console.log('成功?')
+
           await sleep(3000)
           showLoading.value = false
         }
@@ -236,7 +238,14 @@ function intSoketRtc(host: string) {
 // watch(() => warnAudio.value, (v) => {
 //   if (v && socket.value && socket.value.connected) socket.value.emit('msg', { type: 'warnAudio', warnAudio: v })
 // })
-
+window.$electron.onContrl((db: Uint8Array) => {
+  // 拨片 2 是右拨片,1是左拨片,0是取消
+  const bp = db[6] === 2 ? '右拨片' : db[6] === 1 ? '左拨片' : ''
+  const fx = parseInt(db[44].toString(), 10) // 转10进制
+  const fxp = fx < 123 ? `左轮${fx}` : fx > 132 ? `右轮${fx}` : ''
+  const ym = parseInt(db[46].toString(), 10) // 油门
+  console.log(66, bp, fxp, 255 - ym)
+})
 onMounted(() => {
   intSoketRtc(HOST.value)
 })