91 lines
3.5 KiB
JavaScript
91 lines
3.5 KiB
JavaScript
/**
|
|
* The First-Time User Experience (FTUE) Screen to be shown
|
|
* to users who have not set up their audio hardware yet.
|
|
* Corresponds to the route #/ftue3
|
|
*/
|
|
(function(context,$) {
|
|
|
|
"use strict";
|
|
|
|
context.JK = context.JK || {};
|
|
context.JK.FTUEScreen = function(app) {
|
|
var logger = context.JK.logger;
|
|
var jamClient = context.jamClient;
|
|
|
|
function beforeShow(data) {
|
|
loadDevices();
|
|
}
|
|
|
|
function afterShow(data) {
|
|
}
|
|
|
|
function loadDevices() {
|
|
$('#choose-input-audio-device select').empty();
|
|
$('#choose-output-audio-device select').empty();
|
|
var optionTemplate = $('#template_audio_device_item').html();
|
|
var devices = context.jamClient.GetASIODevices();
|
|
var inputOptions = [];
|
|
var outputOptions = [];
|
|
// We're going to build a list of individual choices...
|
|
// Each 'value' will be device id.interface id.pin id (dot separated).
|
|
// example: 1.1.1
|
|
// Label will be a string with device name, interface name, pin name.
|
|
var d, i, p;
|
|
var deviceName, deviceId;
|
|
var interfaceName, interfaceId;
|
|
var pinName, pinId, isInput;
|
|
var value, label, option;
|
|
for (d=0; d<devices.length; d++) {
|
|
deviceName = devices[d].device_name;
|
|
deviceId = devices[d].device_id;
|
|
for (i=0; i<devices[d].interfaces.length; i++) {
|
|
interfaceName = devices[d].interfaces[i].interface_name;
|
|
interfaceId = devices[d].interfaces[i].interface_id;
|
|
for (p=0; p<devices[d].interfaces[i].pins.length; p++) {
|
|
pinName = devices[d].interfaces[i].pins[p].pin_name;
|
|
pinId = devices[d].interfaces[i].pins[p].pin_id;
|
|
value = deviceId + "." + interfaceId + "." + pinId;
|
|
label = deviceName + ":" + interfaceName + ":" + pinName;
|
|
option = context.JK.fillTemplate(optionTemplate, { value: value, label: label});
|
|
isInput = devices[d].interfaces[i].pins[p].is_input;
|
|
if (isInput) {
|
|
inputOptions.push(option);
|
|
} else {
|
|
outputOptions.push(option);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$('#choose-input-audio-device select').html(inputOptions.join(''));
|
|
$('#choose-output-audio-device select').html(outputOptions.join(''));
|
|
}
|
|
|
|
function enableAudioDevices() {
|
|
var input = $('#choose-input-audio-device select').val().split('.');
|
|
var output = $('#choose-output-audio-device select').val().split('.');
|
|
context.jamClient.SetASIOEnabled(
|
|
parseInt(input[0], 10),
|
|
parseInt(input[1], 10),
|
|
parseInt(input[2], 10),
|
|
parseInt(output[0], 10),
|
|
parseInt(output[1], 10),
|
|
parseInt(output[2], 10));
|
|
}
|
|
|
|
function events() {
|
|
$('#enableDevices').click(enableAudioDevices);
|
|
}
|
|
|
|
function initialize() {
|
|
events();
|
|
var screenBindings = { 'beforeShow': beforeShow, 'afterShow': afterShow };
|
|
app.bindScreen('ftue3', screenBindings);
|
|
}
|
|
|
|
// Expose publics
|
|
this.initialize = initialize;
|
|
|
|
return this;
|
|
};
|
|
|
|
})(window,jQuery); |