You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.3 KiB
77 lines
2.3 KiB
var BOB_mod_express = require('express');
|
|
var BOB_mod_router = BOB_mod_express.Router();
|
|
var BOB_mod_path = require('path');
|
|
var BOB_mod_mkdirp = require('mkdirp');
|
|
|
|
var BOB_tol_gphotos = null;
|
|
var BOB_tol_booth = null;
|
|
var BOB_cfg_config = null;
|
|
|
|
var BOB_var_boothInProgress = 0;
|
|
|
|
var BOB_var_gamepad = require("gamepad");
|
|
|
|
/* GET home page. */
|
|
BOB_mod_router.get('/bobinoscope', function(req, res, next) {
|
|
res.render('index', { title: 'Express' });
|
|
});
|
|
/* GET view page. */
|
|
BOB_mod_router.get('/', function(req, res, next) {
|
|
res.render('view', {});
|
|
});
|
|
|
|
BOB_mod_router.get('/booth/build/:boothId', function(req, res, next) {
|
|
BOB_var_boothInProgress += 1;
|
|
BOB_cfg_config.io.emit('boothState');
|
|
BOB_tol_booth.buildBooth(req.params.boothId, function(pErr) {
|
|
BOB_cfg_config.io.emit('boothState');
|
|
BOB_var_boothInProgress -= 1;
|
|
res.send(pErr);
|
|
});
|
|
})
|
|
|
|
BOB_mod_router.get('/booth/list/:from', function(req, res, next) {
|
|
BOB_tol_booth.getBoothList(req.params.from, function(pErr, pList) {
|
|
res.json({error: pErr, booths: pList, inProgress : BOB_var_boothInProgress});
|
|
})
|
|
})
|
|
|
|
/* GET home page. */
|
|
BOB_mod_router.get('/dslr/takepicture/:boothId/:pictId', function(req, res, next) {
|
|
// BOB_cfg_config.io.emit('boothState');
|
|
BOB_tol_gphotos.takePicture(req.params.boothId, req.params.pictId, function(pErr) {
|
|
res.json({ error: pErr, data : null});
|
|
})
|
|
});
|
|
|
|
/* GET view page. */
|
|
BOB_mod_router.get('/download/final/hd/:pictId', function(req, res, next) {
|
|
res.download('public/img/final/'+req.params.pictId);
|
|
});
|
|
|
|
|
|
// Initialize the library
|
|
BOB_var_gamepad.init()
|
|
// List the state of all currently attached devices
|
|
for (var i = 0, l = BOB_var_gamepad.numDevices(); i < l; i++) {
|
|
console.log(i, BOB_var_gamepad.deviceAtIndex());
|
|
}
|
|
// Create a game loop and poll for events
|
|
setInterval(BOB_var_gamepad.processEvents, 16);
|
|
// Scan for new gamepads as a slower rate
|
|
setInterval(BOB_var_gamepad.detectDevices, 500);
|
|
// Listen for button down events on all gamepads
|
|
BOB_var_gamepad.on("down", function (pId, pNum) {
|
|
BOB_cfg_config.io.emit('boothClick', {
|
|
id : pId,
|
|
num : pNum
|
|
});
|
|
})
|
|
|
|
|
|
module.exports = function(pConfig) {
|
|
BOB_cfg_config = pConfig;
|
|
BOB_tol_gphotos = require('../tools/tools-gphoto2')(pConfig);
|
|
BOB_tol_booth = require('../tools/tools-photobooth')(pConfig);
|
|
return BOB_mod_router;
|
|
}
|