Added a few more toggles.

This commit is contained in:
devl0rd 2020-04-24 13:14:48 -06:00
parent fb7056c56b
commit 91d7c02d46
5 changed files with 179 additions and 100 deletions

View file

@ -14,6 +14,8 @@ var sheight = screenSize.height;
var swidth = screenSize.width;
var hidStreamClient = new net.Socket();
var usingVideo = true;
var usingAudio = true;
var abxySwap = false;
function connect() {
hidStreamClient.connect({
host: ip,
@ -84,7 +86,9 @@ hidStreamClient.on('connect', function () {
if (usingVideo) {
startVideoProcess();
}
startAudioProcess();
if (usingAudio) {
startAudioProcess();
}
});
var switchHidBuffer = new Buffer.alloc(0);
function parseInputStruct(buff) {
@ -186,10 +190,18 @@ function handleControllerInput(hid, controllerId, playerNumber) {
var inputStates = heldKeysBitmask(heldKeys);
//Button mapping
vgen.setButton(controllerId, vgen.Buttons.B, inputStates.A);
vgen.setButton(controllerId, vgen.Buttons.A, inputStates.B);
vgen.setButton(controllerId, vgen.Buttons.X, inputStates.Y);
vgen.setButton(controllerId, vgen.Buttons.Y, inputStates.X);
if (!abxySwap) {
vgen.setButton(controllerId, vgen.Buttons.B, inputStates.A);
vgen.setButton(controllerId, vgen.Buttons.A, inputStates.B);
vgen.setButton(controllerId, vgen.Buttons.X, inputStates.Y);
vgen.setButton(controllerId, vgen.Buttons.Y, inputStates.X);
} else {
vgen.setButton(controllerId, vgen.Buttons.B, inputStates.B);
vgen.setButton(controllerId, vgen.Buttons.A, inputStates.A);
vgen.setButton(controllerId, vgen.Buttons.X, inputStates.X);
vgen.setButton(controllerId, vgen.Buttons.Y, inputStates.Y);
}
vgen.setButton(controllerId, vgen.Buttons.BACK, inputStates.Minus);
vgen.setButton(controllerId, vgen.Buttons.START, inputStates.Plus);
vgen.setButton(controllerId, vgen.Buttons.LEFT_SHOULDER, inputStates.L);
@ -326,7 +338,9 @@ hidStreamClient.on('end', function () {
if (usingVideo) {
ffmpegProcess.kill();
}
ffmpegAudioProcess.kill();
if (usingAudio) {
ffmpegAudioProcess.kill();
}
setTimeout(connect, 1000);
});
@ -346,9 +360,19 @@ if (args.length > 1) {
} else {
usingVideo = true;
}
if (args.includes("/noAudio")) {
usingAudio = false;
} else {
usingAudio = true;
}
if (args.includes("/abxySwap")) {
abxySwap = true;
} else {
abxySwap = false;
}
connect();
} else {
console.log('Error: Usage NXStreamer.exe ip 0.0.0.0 q 5');
console.log('Error: Usage NXStreamer.exe ip 0.0.0.0 q 5 /noVideo /noAudio /abxySwap');
}
} else {
console.log('Error: Usage NXStreamer.exe ip 0.0.0.0 q 5');

View file

@ -59,102 +59,116 @@
Disable Video
</label>
</div>
<hr />
<div class="comment">Useful for using your JoyCons on PC and streaming the audio to headphones or the switch
speakers.</div>
<div class="form-group">
<label class="switch">
<input id="disableAudio" type="checkbox">
<span class="slider round"></span>
</label>
<label class="form-check-label" for="rainbowEnabled">
Disable Audio
</label>
</div>
<div class="form-group">
<label class="switch">
<input id="abxySwap" type="checkbox">
<span class="slider round"></span>
</label>
<label class="form-check-label" for="rainbowEnabled">
Swap A-B X-Y
</label>
</div>
</div>
</div>
</div>
<div id="stats" class="contentArea contentAreaScrollable customScroll" style="display: none;">
<div class="chartpanel">
<h5 class="chartTitle">FPS</h5>
<div style="width: 100%; height: 150px;">
<canvas id="fpsChart"></canvas>
<div id="stats" class="contentArea contentAreaScrollable customScroll" style="display: none;">
<div class="chartpanel">
<h5 class="chartTitle">FPS</h5>
<div style="width: 100%; height: 150px;">
<canvas id="fpsChart"></canvas>
</div>
</div>
</div>
</div>
<div id="settings" class="contentArea contentAreaScrollable customScroll" style="display: none;">
<hr />
<h2>General</h2>
<hr />
<div class="form-group">
<label class="switch">
<input id="autoStart" type="checkbox">
<span class="slider round"></span>
</label>
<label class="form-check-label" for="autoStart">
Start streamer automatically
</label>
</div>
<div class="form-group">
<label class="switch">
<input id="rainbowEnabled" type="checkbox">
<span class="slider round"></span>
</label>
<label class="form-check-label" for="rainbowEnabled">
Enable Rainbow Accents
</label>
</div>
<div id="settings" class="contentArea contentAreaScrollable customScroll" style="display: none;">
<hr />
<h2>General</h2>
<hr />
<div class="form-group">
<label class="switch">
<input id="autoStart" type="checkbox">
<span class="slider round"></span>
</label>
<label class="form-check-label" for="autoStart">
Start streamer automatically
</label>
</div>
<div class="form-group">
<label class="switch">
<input id="rainbowEnabled" type="checkbox">
<span class="slider round"></span>
</label>
<label class="form-check-label" for="rainbowEnabled">
Enable Rainbow Accents
</label>
</div>
<hr />
<h2>Drivers</h2>
<hr />
<form class="form-group">
<div class="row">
<div class="col">
<button id="installScpVBusBtn" type="button" class="btn btn-dark btn-block">Install Controller</button>
<hr />
<h2>Drivers</h2>
<hr />
<form class="form-group">
<div class="row">
<div class="col">
<button id="installScpVBusBtn" type="button" class="btn btn-dark btn-block">Install Controller</button>
</div>
<div class="col">
<button id="unInstallScpVBusBtn" type="button" class="btn btn-danger btn-block">Un-Install
Controller</button>
</div>
</div>
<div class="col">
<button id="unInstallScpVBusBtn" type="button" class="btn btn-danger btn-block">Un-Install
Controller</button>
</form>
<form class="form-group">
<div class="row">
<div class="col">
<button id="installAudioDriverBtn" type="button" class="btn btn-dark btn-block">Install Audio
Driver</button>
</div>
<div class="col">
<button id="unInstallAudioDriverBtn" type="button" class="btn btn-danger btn-block">Un-Install Audio
Driver</button>
</div>
</div>
</div>
</form>
<form class="form-group">
<div class="row">
<div class="col">
<button id="installAudioDriverBtn" type="button" class="btn btn-dark btn-block">Install Audio
Driver</button>
</div>
<div class="col">
<button id="unInstallAudioDriverBtn" type="button" class="btn btn-danger btn-block">Un-Install Audio
Driver</button>
</div>
</div>
</form>
</form>
</div>
<div id="console" class="contentArea" style="display: none;">
<div id="consoleContainer" class="customScroll"></div>
<input id="consoleInput" type="text" placeholder="Console command"><br>
</div>
</div>
<div id="console" class="contentArea" style="display: none;">
<div id="consoleContainer" class="customScroll"></div>
<input id="consoleInput" type="text" placeholder="Console command"><br>
<div id="statusbar" class="rainbowBackgroundColor2">
<span id="statusbartext">Streamer stopped.</span>
</div>
</div>
<div id="statusbar" class="rainbowBackgroundColor2">
<span id="statusbartext">Streamer stopped.</span>
</div>
<div id="loadingCover">
<div class="centerVert">
<img src="img/loading.gif" class="loadingGif">
<h1 style="color:rgb(206, 206, 206); font-size: 16px;">
Application loading...
</h1>
<div id="loadingCover">
<div class="centerVert">
<img src="img/loading.gif" class="loadingGif">
<h1 style="color:rgb(206, 206, 206); font-size: 16px;">
Application loading...
</h1>
</div>
</div>
</div>
<script src="js/fontawesome-all.min.js"></script>
<script src="js/Chart.min.js"></script>
<script>
let $ = require('jquery');
require('popper.js');
require('bootstrap');
$(function () {
$('[data-toggle="tooltip"]').tooltip({ boundary: 'window' })
})
</script>
<script src="./js/animations.js"></script>
<script src="./js/window.js"></script>
<script src="./js/settings.js"></script>
<script src="./js/main.js"></script>
<script src="./js/stats.js"></script>
<script src="./js/console.js"></script>
<script src="js/fontawesome-all.min.js"></script>
<script src="js/Chart.min.js"></script>
<script>
let $ = require('jquery');
require('popper.js');
require('bootstrap');
$(function () {
$('[data-toggle="tooltip"]').tooltip({ boundary: 'window' })
})
</script>
<script src="./js/animations.js"></script>
<script src="./js/window.js"></script>
<script src="./js/settings.js"></script>
<script src="./js/main.js"></script>
<script src="./js/stats.js"></script>
<script src="./js/console.js"></script>
</body>
</html>

View file

@ -11,13 +11,13 @@ ipcRenderer.on('started', function (event, data) {
})
var running = false;
function connect() {
ipcRenderer.send('connect', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo });
ipcRenderer.send('connect', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap });
}
function disconnect() {
ipcRenderer.send('kill');
}
function restart() {
ipcRenderer.send('restart', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo });
ipcRenderer.send('restart', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap });
}
$('#startBtn').click(function () {
if (!running) {

View file

@ -38,6 +38,12 @@ function initSettings() {
if (!clientSettings.hasOwnProperty("disableVideo")) {
clientSettings.disableVideo = false;
}
if (!clientSettings.hasOwnProperty("disableAudio")) {
clientSettings.disableAudio = false;
}
if (!clientSettings.hasOwnProperty("abxySwap")) {
clientSettings.abxySwap = false;
}
if (!clientSettings.hasOwnProperty("firstInstall")) {
clientSettings.firstInstall = false;
}
@ -57,7 +63,8 @@ function applyClientSettings() {
$("#qualitySlider").val(clientSettings.quality);
$('#qualityLabel').html("Quality: " + clientSettings.quality + "Mbps");
$('#disableVideo').prop("checked", clientSettings.disableVideo);
$('#disableAudio').prop("checked", clientSettings.disableAudio);
$('#abxySwap').prop("checked", clientSettings.abxySwap);
$("#ipInput").val(clientSettings.ip);
if (clientSettings.debug) {
$("#dev-btn").fadeIn(400);
@ -122,11 +129,11 @@ var qualityChangeTimeout;
$(document).on('input', '#qualitySlider', function () {
$('#qualityLabel').html("Quality: " + $(this).val() + "Mbps");
clientSettings.quality = $(this).val();
saveClientSettings();
if (running) {
clearTimeout(qualityChangeTimeout);
qualityChangeTimeout = setTimeout(restart, 1000)
}
saveClientSettings();
});
$(document).on('input', '#ipInput', function () {
@ -135,7 +142,25 @@ $(document).on('input', '#ipInput', function () {
});
$("#disableVideo").on('change', function () {
clientSettings.disableVideo = $("#disableVideo").prop("checked");
restart();
if (running) {
restart();
}
saveClientSettings();
applyClientSettings();
});
$("#disableAudio").on('change', function () {
clientSettings.disableAudio = $("#disableAudio").prop("checked");
if (running) {
restart();
}
saveClientSettings();
applyClientSettings();
});
$("#abxySwap").on('change', function () {
clientSettings.abxySwap = $("#abxySwap").prop("checked");
if (running) {
restart();
}
saveClientSettings();
applyClientSettings();
});

View file

@ -82,7 +82,7 @@ app.on('browser-window-created', function (e, window) {
});
var streamerProcess;
var clientSender;
var streamerProcessIsRunning = false;
function startStreamer(arg) {
var cwd = './NxStreamingService/';
if (!isDev) {
@ -92,22 +92,38 @@ function startStreamer(arg) {
if (arg.disableVideo) {
args.push("/noVideo");
}
if (arg.disableAudio) {
args.push("/noAudio");
}
if (arg.abxySwap) {
args.push("/abxySwap");
}
streamerProcess = spawn(
"./NxStreamingService.exe",
args,
{ cwd: cwd, stdio: "pipe" }
);
streamerProcess.stdout.on("data", data => {
log(`${data}`);
if (!streamerProcessIsRunning) {
streamerProcessIsRunning = true;
clientSender.send("started");
}
});
streamerProcess.stderr.on('data', (data) => {
log(`${data}`);
if (!streamerProcessIsRunning) {
streamerProcessIsRunning = true;
clientSender.send("started");
}
});
streamerProcess.on('close', (code) => {
clientSender.send("close");
log(`streamerProcess process exited with code ${code}`);
streamerProcessIsRunning = false;
});
clientSender.send("started");
}
ipcMain.on('connect', (event, arg) => {
clientSender = event.sender;