forked from jehervy/node-virtual-gamepads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
60 lines (44 loc) · 1.35 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Generated by CoffeeScript 1.9.1
/*
Created by MIROOF on 04/03/2015
Virtual gamepad application
*/
(function() {
var app, config, express, gamepad_hub, http, hub, io, path, uinput;
uinput = require('./lib/uinput');
path = require('path');
express = require('express');
app = express();
http = require('http').Server(app);
io = require('socket.io')(http);
config = require('./config.json');
gamepad_hub = require('./app/virtual_gamepad_hub');
hub = new gamepad_hub();
app.use(express["static"](__dirname + '/public'));
io.on('connection', function(socket) {
socket.on('disconnect', function() {
if (socket.gamePadId !== void 0) {
return hub.disconnectGamepad(socket.gamePadId, function() {});
}
});
socket.on('connectGamepad', function() {
return hub.connectGamepad(function(gamePadId) {
if (gamePadId !== -1) {
socket.gamePadId = gamePadId;
return socket.emit('gamepadConnected', {
padId: gamePadId
});
}
});
});
return socket.on('padEvent', function(data) {
if (socket.gamePadId !== void 0 && data) {
return hub.sendEvent(socket.gamePadId, data);
}
});
});
http.listen(config.port, function() {
return console.info("Listening on " + config.port);
});
}).call(this);
//# sourceMappingURL=main.js.map