Browse Source

修复方向盘问题

caner 2 years ago
parent
commit
e8c94af53f
2 changed files with 7 additions and 7 deletions
  1. 2 2
      electron/logiControl.js
  2. 5 5
      electron/main.js

+ 2 - 2
electron/logiControl.js

@@ -5,8 +5,8 @@ try {
     const logitech = devices.filter(el => el.manufacturer === 'Logitech' && el.product.includes('G923'));
     data = new HID.HID(logitech[0].vendorId, logitech[0].productId);
     data.on('data', (db) => {
-        if (process.connected){ process.send(db)}else{
-            throw {type:'err',text:'process.connected=false'}
+        if (process.connected) { process.send(db) } else {
+            throw { type: 'err', text: 'process.connected=false' }
         }
     })
 } catch (error) {

+ 5 - 5
electron/main.js

@@ -107,7 +107,7 @@ class MainSerivce {
 
     // 最小化
     globalShortcut.register('Ctrl+B', () => {
-      if(this.#isMin & 1) {this.mainWin.hide()}else{
+      if (this.#isMin & 1) { this.mainWin.hide() } else {
         this.mainWin.show()
       }
       this.#isMin++
@@ -126,7 +126,7 @@ class MainSerivce {
         return true
       })
     } else if (platform === 'darwin') {
-      app.dock.setIcon(join(__dirname, 'electron/icon/playGame@2x.png'))
+      app.dock.setIcon(join(__dirname, './icon/playGame@2x.png'))
     }
 
     // 通信
@@ -134,7 +134,7 @@ class MainSerivce {
       if (evt === 'close-loading') {
         if (this.loadingWin) this.loadingWin.close()
         this.mainWin.show()
-        // if (this.mainWin.isVisible()) this.connectLogi()
+        if (this.mainWin.isVisible()) this.connectLogi()
       } else if (evt === 'minWin') {
         this.mainWin.minimize()
       } else if (evt === 'closeWin') {
@@ -189,13 +189,13 @@ class MainSerivce {
   }
 
   connectLogi() {
-    this.contrlEvent = fork(join(__dirname, 'electron/logiControl.js'));
+    this.contrlEvent = fork(join(__dirname, './logiControl.js'));
     this.contrlEvent.on('message', msg => {
       if (!msg || msg.type === 'err' || !msg.data || !msg.data[44]) {
         this.contrlEvent.disconnect()
         this.contrlEvent.kill(msg.pid ?? 'SIGKILL')
         this.contrlEvent = null
-        dialog.showMessageBox(this.mainWin, { message: '请尝试旋转方向或重新插入USB或重启客户端!', type: 'error', title: '连接错误' }).then(async ({ response }) => {
+        dialog.showMessageBox(this.mainWin, { message: msg.text, type: 'error', title: '连接错误' }).then(async ({ response }) => {
           if (!response) {
             await sleep(2000)
             this.connectLogi()