-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic-example.js
30 lines (25 loc) · 962 Bytes
/
basic-example.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
const ffi = require("ffi")
// Define the functions from the DLL
const wootingRgb = ffi.Library('./libs/wooting-rgb-sdk.dll', {
"wooting_rgb_kbd_connected": [ 'bool', [] ],
"wooting_rgb_reset": [ 'bool', [] ],
"wooting_rgb_direct_set_key": [ 'bool', ['uint8', 'uint8', 'uint8', 'uint8', 'uint8'] ],
"wooting_rgb_direct_reset_key": [ 'bool', ['uint8', 'uint8'] ],
});
const keyboardConnected = wootingRgb.wooting_rgb_kbd_connected()
if(!keyboardConnected) {
console.log('Keyboard not connected')
} else {
const row = 2
const column = 2
const red = 255
const green = 0
const blue = 255
// Set the key to a color and reset it after 2 seconds (2000 milliseconds)
wootingRgb.wooting_rgb_direct_set_key(row, column, red, green, blue)
setTimeout(() => wootingRgb.wooting_rgb_direct_reset_key(row, column), 2000)
}
// Make sure the lights go back to normal after process exits
process.on('exit', () => {
wootingRgb.wooting_rgb_reset()
})