-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWindowsController.js
More file actions
75 lines (75 loc) · 1.76 KB
/
Copy pathWindowsController.js
File metadata and controls
75 lines (75 loc) · 1.76 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class WindowsController {
constructor (vgen) {
this.vgen = vgen
this.id = this.vgen.pluginNext()
}
buttonA(pressed) {
this.vgen.setButton(this.id,this.vgen.Buttons.A,!!pressed)
}
buttonB(pressed) {
this.vgen.setButton(this.id,this.vgen.Buttons.B,!!pressed)
}
buttonX(pressed) {
this.vgen.setButton(this.id,this.vgen.Buttons.X,!!pressed)
}
buttonY(pressed) {
this.vgen.setButton(this.id,this.vgen.Buttons.Y,!!pressed)
}
dPad(up,down,left,right) {
let dir
if(up && left) {
dir = this.vgen.Dpad.UP_LEFT
}
else if(up && right) {
dir = this.vgen.Dpad.UP_RIGHT
}
else if(down && left) {
dir = this.vgen.Dpad.DOWN_LEFT
}
else if(down && right) {
dir = this.vgen.Dpad.DOWN_RIGHT
}
else if(up) {
dir = this.vgen.Dpad.UP
}
else if(down) {
dir = this.vgen.Dpad.DOWN
}
else if(left) {
dir = this.vgen.Dpad.LEFT
}
else if(right) {
dir = this.vgen.Dpad.RIGHT
}
else {
dir = this.vgen.Dpad.NONE
}
this.vgen.setDpad(this.id,dir)
}
leftStick(x,y) {
x = Math.min(Math.max(x,-1),1)
y = Math.min(Math.max(y,-1),1)
this.vgen.setAxisL(this.id,x,y)
}
rightStick(x,y) {
x = Math.min(Math.max(x,-1),1)
y = Math.min(Math.max(y,-1),1)
this.vgen.setAxisR(this.id,x,y)
}
leftButton(pressed) {
this.vgen.setButton(this.id,this.vgen.Buttons.LEFT_SHOULDER,!!pressed)
}
rightButton(pressed) {
this.vgen.setButton(this.id,this.vgen.Buttons.RIGHT_SHOULDER,!!pressed)
}
leftTrigger(pressed) {
this.vgen.setTriggerL(this.id,pressed ? 1:0)
}
rightTrigger(pressed) {
this.vgen.setTriggerR(this.id,pressed ? 1:0)
}
finalize() {
this.vgen.unplug(this.id)
}
}
module.exports = WindowsController