-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelgato.js
More file actions
40 lines (34 loc) · 1.36 KB
/
elgato.js
File metadata and controls
40 lines (34 loc) · 1.36 KB
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
function connectElgatoStreamDeckSocket(inPort, inPluginUUID, inRegisterEvent, inInfo) {
pluginUUID = inPluginUUID
// Open the web socket
websocket = new WebSocket("ws://127.0.0.1:" + inPort);
function registerPlugin(inPluginUUID) {
var json = {
"event": inRegisterEvent,
"uuid": inPluginUUID
};
websocket.send(JSON.stringify(json));
}
websocket.onopen = function () {
// WebSocket is connected, send message
registerPlugin(pluginUUID);
};
websocket.onmessage = function (evt) {
// Received message from Stream Deck
var jsonObj = JSON.parse(evt.data);
var event = jsonObj['event'];
var context = jsonObj['context'];
if (event == "keyDown") {
var jsonPayload = jsonObj['payload'];
var settings = jsonPayload['settings'];
var coordinates = jsonPayload['coordinates'];
var userDesiredState = jsonPayload['userDesiredState'];
twitterAction.onKeyDown(context, settings, coordinates, userDesiredState);
} else if (event == "willAppear") {
var jsonPayload = jsonObj['payload'];
var settings = jsonPayload['settings'];
var coordinates = jsonPayload['coordinates'];
twitterAction.onWillAppear(context, settings, coordinates);
}
};
}