-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
45 changed files
with
370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# b0xx-input-viewer | ||
|
||
The B0XX Input Viewer uses electron-serialport and is derived from one if its examples. To install this dependency follow the following instruction and move the node-modules from electron-serialport into the main directory. It can then be run using npm start and compiled. | ||
|
||
To clone and run this repository you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer. From your command line: | ||
|
||
```bash | ||
# Clone this repository | ||
git clone https://github.com/serialport/electron-serialport.git | ||
# Go into the repository | ||
cd electron-serialport | ||
# Install dependencies | ||
npm install | ||
# Run the app | ||
npm start | ||
``` | ||
|
||
This app may be used by third parties with disclosure. It is easy to change the background by simply changing bg.png. Layout changes are done by changing the images (assigned to each button) as they are just layered and shown and masked accordingly. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "1x", | ||
"filename" : "icon_16@1x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "2x", | ||
"filename" : "icon_16@2x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "1x", | ||
"filename" : "icon_32@1x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "2x", | ||
"filename" : "icon_32@2x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "1x", | ||
"filename" : "icon_128@1x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "2x", | ||
"filename" : "icon_128@2x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "1x", | ||
"filename" : "icon_256@1x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "2x", | ||
"filename" : "icon_256@2x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "1x", | ||
"filename" : "icon_512@1x.png" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "2x", | ||
"filename" : "icon_512@2x.png" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>B0XX Input Viewer</title> | ||
<style> | ||
table { border-collapse: collapse; } | ||
table, th, td { border: 1px solid black; } | ||
body {background-color: black;} | ||
</style> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
|
||
</style> | ||
|
||
|
||
<div> | ||
<img id="bgimg" src="images/bg.png" style="visibility:visible"/> | ||
<img id="abtn" src="images/A.png" style="visibility:hidden"/> | ||
<img id="bbtn" src="images/B.png" style="visibility:hidden"/> | ||
<img id="xbtn" src="images/X.png" style="visibility:hidden"/> | ||
<img id="ybtn" src="images/Y.png" style="visibility:hidden"/> | ||
<img id="zbtn" src="images/Z.png" style="visibility:hidden"/> | ||
<img id="rbtn" src="images/R.png" style="visibility:hidden"/> | ||
<img id="lbtn" src="images/L.png" style="visibility:hidden"/> | ||
<img id="upbtn" src="images/UP.png" style="visibility:hidden"/> | ||
<img id="dnbtn" src="images/DN.png" style="visibility:hidden"/> | ||
<img id="ltbtn" src="images/LT.png" style="visibility:hidden"/> | ||
<img id="rtbtn" src="images/RT.png" style="visibility:hidden"/> | ||
<img id="m1btn" src="images/M1.png" style="visibility:hidden"/> | ||
<img id="m2btn" src="images/M2.png" style="visibility:hidden"/> | ||
<img id="stbtn" src="images/ST.png" style="visibility:hidden"/> | ||
<img id="cubtn" src="images/CU.png" style="visibility:hidden"/> | ||
<img id="clbtn" src="images/CL.png" style="visibility:hidden"/> | ||
<img id="cdbtn" src="images/CD.png" style="visibility:hidden"/> | ||
<img id="crbtn" src="images/CR.png" style="visibility:hidden"/> | ||
<img id="lsbtn" src="images/LS.png" style="visibility:hidden"/> | ||
<img id="msbtn" src="images/MS.png" style="visibility:hidden"/> | ||
<img id="r2" src="images/R2.png" style="visibility:hidden"/> | ||
<img id="recon" src="images/recconect.png" style="visibility:hidden"/> | ||
|
||
</div> | ||
|
||
<script src="./serial.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const electron = require('electron') | ||
// Module to control application life. | ||
const app = electron.app | ||
// Module to create native browser window. | ||
const BrowserWindow = electron.BrowserWindow; | ||
|
||
//var usbDetect = require('usb-detection'); | ||
|
||
const path = require('path') | ||
const url = require('url') | ||
|
||
// Keep a global reference of the window object, if you don't, the window will | ||
// be closed automatically when the JavaScript object is garbage collected. | ||
let mainWindow | ||
|
||
function createWindow() { | ||
// Create the browser window. | ||
mainWindow = new BrowserWindow({ | ||
width: 1600, | ||
height: 840, | ||
resizable : true, | ||
autoHideMenuBar: true, | ||
webPreferences: { | ||
nodeIntegration: true, // to allow require | ||
contextIsolation: false, // allow use with Electron 12+ | ||
preload: path.join(__dirname, 'preload.js') | ||
} | ||
}) | ||
|
||
// and load the index.html of the app. | ||
mainWindow.loadURL(url.format({ | ||
pathname: path.join(__dirname, 'index.html'), | ||
protocol: 'file:', | ||
slashes: true | ||
})) | ||
|
||
// Open the DevTools. | ||
//mainWindow.webContents.openDevTools() | ||
|
||
|
||
// Emitted when the window is closed. | ||
mainWindow.on('closed', function() { | ||
// Dereference the window object, usually you would store windows | ||
// in an array if your app supports multi windows, this is the time | ||
// when you should delete the corresponding element. | ||
mainWindow = null | ||
}) | ||
} | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
app.on('ready', createWindow) | ||
|
||
// Quit when all windows are closed. | ||
app.on('window-all-closed', function() { | ||
// On OS X it is common for applications and their menu bar | ||
// to stay active until the user quits explicitly with Cmd + Q | ||
app.quit() | ||
}) | ||
|
||
app.on('activate', function() { | ||
// On OS X it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
if (mainWindow === null) { | ||
createWindow() | ||
} | ||
}) | ||
|
||
// In this file you can include the rest of your app's specific main process | ||
// code. You can also put them in separate files and require them here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "B0XX", | ||
"version": "1.0.0", | ||
"description": "B0XX Input Viewer using NodeJS and Electron.", | ||
"main": "main.js", | ||
"scripts": { | ||
"start": "electron ." | ||
}, | ||
"repository": { | ||
"url": "https://b0xx.com/pages/resources" | ||
}, | ||
"keywords": [ | ||
"B0XX", | ||
"Input", | ||
"Viewer", | ||
"Game", | ||
"Controller" | ||
], | ||
"author": "20XX Corp", | ||
"license": "GNU-LGPL-2.1", | ||
"devDependencies": { | ||
"electron": "^17.0.0" | ||
}, | ||
"dependencies": { | ||
"serialport": "^10.3.0", | ||
"tableify": "^1.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// All of the Node.js APIs are available in the preload process. | ||
// It has the same sandbox as a Chrome extension. | ||
window.addEventListener('DOMContentLoaded', () => { | ||
for (const versionType of['chrome', 'electron', 'node']) { | ||
document.getElementById(`${versionType}-version`).innerText = process.versions[versionType] | ||
} | ||
|
||
document.getElementById('serialport-version').innerText = require('serialport/package').version | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
//const SerialPort = require('serialport') | ||
//var serialport = require("serialport"); | ||
//var SerialPort = serialport.SerialPort; | ||
|
||
//const SerialPort = require('serialport'); | ||
|
||
const { SerialPort } = require('serialport') | ||
const { ReadlineParser } = require('@serialport/parser-readline') | ||
|
||
//const Readline = SerialPort.parsers.Readline; | ||
//const { dialog } = require('electron') | ||
|
||
|
||
function serialCon(){ | ||
SerialPort.list().then(ports => { | ||
var port = ports.find(port => (/2341/.test(port.vendorId) && /8036/.test(port.productId)) || (/2E8A/.test(port.vendorId) && /102F/.test(port.productId))) | ||
|
||
if (!port) { | ||
console.log("B0XX Not Found") | ||
//console.log(dialog.showMessageBox(mainWindow, {message: "B0XX Not Found"})) | ||
//const response = dialog.showMessageBox(null); | ||
//console.log(response); | ||
document.getElementById('recon').style.visibility='visible'; | ||
} | ||
else { | ||
console.log("B0XX Found") | ||
console.log(port) | ||
console.log(port.vendorId) | ||
console.log(comport) | ||
var comport = port.path; | ||
|
||
try{ | ||
var myPort = new SerialPort({ | ||
path: comport, | ||
baudRate: 115200 | ||
//delimiter: '\n' | ||
//parser: SerialPort.parsers.readline('\n') | ||
}); | ||
|
||
const parser = myPort.pipe(new ReadlineParser({delimiter: '\n'})) | ||
parser.on('data', onData); | ||
myPort.on('close', onClose); | ||
document.getElementById('recon').style.visibility='hidden'; | ||
} | ||
|
||
catch (err){ | ||
console.log("issue opening comport"); | ||
} | ||
|
||
} | ||
}) | ||
} | ||
|
||
document.getElementById("recon").addEventListener("click", reconButton); | ||
serialCon(); | ||
|
||
function reconButton(){ | ||
serialCon(); | ||
} | ||
|
||
function onData(data){ | ||
//console.log(data); | ||
//if(data.charAt(0) === '1')document.getElementById('abtn').style.visibility='visible'; | ||
//else document.getElementById('abtn').style.visibility='hidden'; | ||
showhide('stbtn', data.charAt(0)); | ||
showhide('ybtn', data.charAt(1)); | ||
showhide('xbtn', data.charAt(2)); | ||
showhide('bbtn', data.charAt(3)); | ||
showhide('abtn', data.charAt(4)); | ||
showhide('lbtn', data.charAt(5)); | ||
showhide('rbtn', data.charAt(6)); | ||
showhide('zbtn', data.charAt(7)); | ||
showhide('upbtn', data.charAt(8)); | ||
showhide('dnbtn', data.charAt(9)); | ||
showhide('rtbtn', data.charAt(10)); | ||
showhide('ltbtn', data.charAt(11)); | ||
showhide('m1btn', data.charAt(12)); | ||
showhide('m2btn', data.charAt(13)); | ||
showhide('clbtn', data.charAt(14)); | ||
showhide('crbtn', data.charAt(15)); | ||
showhide('cubtn', data.charAt(16)); | ||
showhide('cdbtn', data.charAt(17)); | ||
showhide('lsbtn', data.charAt(18)); | ||
showhide('msbtn', data.charAt(19)); | ||
showhide('r2', data.charAt(23)); | ||
} | ||
|
||
function showhide(imgname, vis){ | ||
if(vis === '1')document.getElementById(imgname).style.visibility='visible'; | ||
else document.getElementById(imgname).style.visibility='hidden'; | ||
} | ||
|
||
function onClose(){ | ||
//console.log('Closed') | ||
document.getElementById('recon').style.visibility='visible'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
body { | ||
background-color: black; | ||
overflow-x: hidden; | ||
} | ||
|
||
img { | ||
width: 100%; | ||
height: auto; | ||
|
||
position: absolute; | ||
top:0; | ||
|
||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
.button { | ||
background-color: aqua; | ||
border: none; | ||
color: white; | ||
padding: 15px 25px; | ||
text-align: center; | ||
font-size: 16px; | ||
cursor: pointer; | ||
top:0; | ||
left:0; | ||
position: absolute; | ||
} | ||
|
||
.button:hover { | ||
background-color: #0099cc; | ||
} |