-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
48 lines (44 loc) · 1.2 KB
/
app.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
import robot from "robotjs"
import Leap from 'leapjs'
import {
handEntry,
handSwipe,
handDrag,
handFlip,
handFist
} from 'leapjs-gesture'
Leap.Controller.plugin('handEntry', handEntry.handEntry)
Leap.Controller.plugin('handSwipe', handSwipe.handSwipe)
Leap.Controller.plugin('handDrag', handDrag.handDrag)
Leap.Controller.plugin('handFlip', handFlip.handFlip)
Leap.Controller.plugin('handFist', handFist.handFist)
Leap
.loop((f) => {
// console.log(f)
})
.use('handEntry')
.use('handSwipe', {
vertical: 120,
horizontal: 120
})
.on('handSwipe', function (hand) {
console.log(hand.swipeDirection)
if (hand.swipeDirection === 'left') {
robot.keyTap("left");
} else if (hand.swipeDirection === 'right') {
robot.keyTap("right");
}
})
.on('handLost', function (hand) {
if (hand)
console.log("Lost!")
})
.on('handFound', function (hand) {
if (hand)
console.log("Found!")
})
process.on('uncaughtException', function (err) {
console.error((new Date).toUTCString() + ' uncaughtException:', err.message)
console.error(err.stack)
process.exit(1)
})