mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Feature to enable Gamestream optimization or not (#309)
* Added new feature. Menu option added (and helper code) to enable or disable Geforce Experience option to modify/optimize game settings or not. * Revert manifest.json change
This commit is contained in:
parent
f45a2c22d5
commit
f32a35607b
17
index.html
17
index.html
@ -21,7 +21,23 @@
|
|||||||
<div class="mdl-layout-spacer"></div>
|
<div class="mdl-layout-spacer"></div>
|
||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<nav class="mdl-navigation">
|
<nav class="mdl-navigation">
|
||||||
|
<div class="nav-menu-parent">
|
||||||
|
<div id="optimizeMenu">
|
||||||
|
<button id="selectOptimize" data-value="1" class="mdl-button mdl-js-button">
|
||||||
|
GFE Optimization
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="optimizeMenu mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
|
||||||
|
for="selectOptimize">
|
||||||
|
<li class="mdl-menu__item" data-value="1">GFE Optimization</li>
|
||||||
|
<li class="mdl-menu__item" data-value="0">No GFE Optimization</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div id="optimizeTooltip" class="mdl-tooltip" for="optimizeMenu">
|
||||||
|
Allow Geforce Experience to optimize game settings for stream
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="nav-menu-parent">
|
<div class="nav-menu-parent">
|
||||||
<div id="resolutionMenu">
|
<div id="resolutionMenu">
|
||||||
<button id="selectResolution" data-value="1280:720" class="mdl-button mdl-js-button">
|
<button id="selectResolution" data-value="1280:720" class="mdl-button mdl-js-button">
|
||||||
@ -40,7 +56,6 @@
|
|||||||
Resolution
|
Resolution
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav-menu-parent">
|
<div class="nav-menu-parent">
|
||||||
<div id="framerateMenu">
|
<div id="framerateMenu">
|
||||||
<button id="selectFramerate" data-value="60" class="mdl-button mdl-js-button">
|
<button id="selectFramerate" data-value="60" class="mdl-button mdl-js-button">
|
||||||
|
@ -12,6 +12,7 @@ function attachListeners() {
|
|||||||
changeUiModeForNaClLoad();
|
changeUiModeForNaClLoad();
|
||||||
|
|
||||||
$('.resolutionMenu li').on('click', saveResolution);
|
$('.resolutionMenu li').on('click', saveResolution);
|
||||||
|
$('.optimizeMenu li').on('click', saveOptimize);
|
||||||
$('.framerateMenu li').on('click', saveFramerate);
|
$('.framerateMenu li').on('click', saveFramerate);
|
||||||
$('#bitrateSlider').on('input', updateBitrateField); // input occurs every notch you slide
|
$('#bitrateSlider').on('input', updateBitrateField); // input occurs every notch you slide
|
||||||
//$('#bitrateSlider').on('change', saveBitrate); //FIXME: it seems not working
|
//$('#bitrateSlider').on('change', saveBitrate); //FIXME: it seems not working
|
||||||
@ -567,11 +568,12 @@ function startGame(host, appID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var frameRate = $('#selectFramerate').data('value').toString();
|
var frameRate = $('#selectFramerate').data('value').toString();
|
||||||
|
var optimize = $('#selectOptimize').data('value').toString();
|
||||||
var streamWidth = $('#selectResolution').data('value').split(':')[0];
|
var streamWidth = $('#selectResolution').data('value').split(':')[0];
|
||||||
var streamHeight = $('#selectResolution').data('value').split(':')[1];
|
var streamHeight = $('#selectResolution').data('value').split(':')[1];
|
||||||
// we told the user it was in Mbps. We're dirty liars and use Kbps behind their back.
|
// we told the user it was in Mbps. We're dirty liars and use Kbps behind their back.
|
||||||
var bitrate = parseInt($("#bitrateSlider").val()) * 1000;
|
var bitrate = parseInt($("#bitrateSlider").val()) * 1000;
|
||||||
console.log('%c[index.js, startGame]','color:green;', 'startRequest:' + host.address + ":" + streamWidth + ":" + streamHeight + ":" + frameRate + ":" + bitrate);
|
console.log('%c[index.js, startGame]','color:green;', 'startRequest:' + host.address + ":" + streamWidth + ":" + streamHeight + ":" + frameRate + ":" + bitrate + ":" + optimize);
|
||||||
|
|
||||||
var rikey = generateRemoteInputKey();
|
var rikey = generateRemoteInputKey();
|
||||||
var rikeyid = generateRemoteInputKeyId();
|
var rikeyid = generateRemoteInputKeyId();
|
||||||
@ -593,7 +595,7 @@ function startGame(host, appID) {
|
|||||||
|
|
||||||
host.launchApp(appID,
|
host.launchApp(appID,
|
||||||
streamWidth + "x" + streamHeight + "x" + frameRate,
|
streamWidth + "x" + streamHeight + "x" + frameRate,
|
||||||
1, // Allow GFE to optimize game settings
|
optimize, // DON'T Allow GFE (0) to optimize game settings, or ALLOW (1) to optimize game settings
|
||||||
rikey, rikeyid,
|
rikey, rikeyid,
|
||||||
remote_audio_enabled, // Play audio locally too?
|
remote_audio_enabled, // Play audio locally too?
|
||||||
0x030002 // Surround channel mask << 16 | Surround channel count
|
0x030002 // Surround channel mask << 16 | Surround channel count
|
||||||
@ -715,6 +717,13 @@ function saveResolution() {
|
|||||||
updateDefaultBitrate();
|
updateDefaultBitrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveOptimize() {
|
||||||
|
var chosenOptimize = $(this).data('value');
|
||||||
|
$('#selectOptimize').text($(this).text()).data('value', chosenOptimize);
|
||||||
|
storeData('optimize', chosenOptimize, null);
|
||||||
|
updateDefaultBitrate();
|
||||||
|
}
|
||||||
|
|
||||||
function saveFramerate() {
|
function saveFramerate() {
|
||||||
var chosenFramerate = $(this).data('value');
|
var chosenFramerate = $(this).data('value');
|
||||||
$('#selectFramerate').text($(this).text()).data('value', chosenFramerate);
|
$('#selectFramerate').text($(this).text()).data('value', chosenFramerate);
|
||||||
@ -722,6 +731,8 @@ function saveFramerate() {
|
|||||||
updateDefaultBitrate();
|
updateDefaultBitrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// storing data in chrome.storage takes the data as an object, and shoves it into JSON to store
|
// storing data in chrome.storage takes the data as an object, and shoves it into JSON to store
|
||||||
// unfortunately, objects with function instances (classes) are stripped of their function instances when converted to a raw object
|
// unfortunately, objects with function instances (classes) are stripped of their function instances when converted to a raw object
|
||||||
// so we cannot forget to revive the object after we load it.
|
// so we cannot forget to revive the object after we load it.
|
||||||
@ -818,6 +829,18 @@ function onWindowLoad(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// load stored optimization prefs
|
||||||
|
chrome.storage.sync.get('optimize', function(previousValue) {
|
||||||
|
if(previousValue.optimize != null) {
|
||||||
|
$('.optimizeMenu li').each(function () {
|
||||||
|
if ($(this).data('value') === previousValue.optimize) {
|
||||||
|
$('#selectOptimize').text($(this).text()).data('value', previousValue.optimize);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// load stored bitrate prefs
|
// load stored bitrate prefs
|
||||||
chrome.storage.sync.get('bitrate', function(previousValue) {
|
chrome.storage.sync.get('bitrate', function(previousValue) {
|
||||||
$('#bitrateSlider')[0].MaterialSlider.change(previousValue.bitrate != null ? previousValue.bitrate : '10');
|
$('#bitrateSlider')[0].MaterialSlider.change(previousValue.bitrate != null ? previousValue.bitrate : '10');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user