-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
34 lines (27 loc) · 855 Bytes
/
init.js
File metadata and controls
34 lines (27 loc) · 855 Bytes
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
const StreamDeck = require("elgato-stream-deck");
const DeckSettings = require("./DeckSettings");
const getConfig = require("./getConfig");
const config = getConfig();
const robo = require("robotjs");
const executeAction = require("./executeAction");
const init = () => {
const streamDeck = new StreamDeck();
const settings = new DeckSettings(config, streamDeck);
streamDeck.on("down", keyIndex => {
console.log("key %d down", keyIndex);
const key = settings.findButton(keyIndex);
key && key.func && key.func(streamDeck, key);
key &&
key.actions &&
key.actions.forEach(action =>
executeAction(action, settings)
);
});
streamDeck.on("error", error => {
console.error(error);
});
console.log("running");
settings.paintButtons();
return [streamDeck, settings];
};
module.exports = init;