-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathModifierBank.js
102 lines (83 loc) · 2.97 KB
/
ModifierBank.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
*
*/
function ModifierBank() {
var clearButton = controls.createButton(MAIN_BUTTONS.CLEAR);
var selectButton = controls.createButton(MAIN_BUTTONS.SELECT);
var duplicateButton = controls.createButton(MAIN_BUTTONS.DUPLICATE);
var lockButton = controls.createButton(MAIN_BUTTONS.LOCK);
var lockbuttonHandler = null;
var selectDown = false;
var macroDown = false;
var shiftDown = false;
var clearDown = false;
var duplicateDown = false;
var dpadRightDown = false;
selectButton.setCallback(function (value) {
//println("select is Down");
selectDown = value === 127;
selectButton.sendValue(value);
currentMode.notifyModifier((selectDown ? ModifierMask.Select : 0) | (shiftDown ? ModifierMask.Shift : 0));
});
/*macrcoButton.setCallback(function(value) {
macroDown = value == 127;
macrcoButton.sendValue(value);
});*/
clearButton.setCallback(function (value) {
clearDown = value === 127;
currentMode.notifyClear(clearDown);
clearButton.sendValue(value);
});
duplicateButton.setCallback(function (value) {
//println("duplicate is down");
duplicateButton.sendValue(value);
duplicateDown = value;
currentMode.notifyModifier((selectDown ? ModifierMask.Select : 0) | (shiftDown ? ModifierMask.Shift : 0) | (duplicateDown ? ModifierMask.Duplicate : 0));
});
lockButton.setCallback(function (value) {
if (lockbuttonHandler) {
lockbuttonHandler(value);
}
});
this.setLockButtonState = function (state) {
lockButton.sendValue(state ? 127 : 0);
};
this.setLockButtonHandler = function (handler) {
lockbuttonHandler = handler;
};
this.setDpadRightDown = function (value) {
dpadRightDown = value;
};
var shiftLock = false;
this.notifyShift = function (shiftDownValue) {
shiftDown = shiftDownValue;
currentMode.notifyModifier((selectDown ? ModifierMask.Select : 0) || (shiftDown ? ModifierMask.Shift : 0) || (duplicateDown ? ModifierMask.Duplicate : 0));
};
this.getShiftLock = function () {
return shiftLock;
};
this.setShiftLock = function (value) {
lockButton.sendValue(value ? 127 : 0);
host.showPopupNotification(value ? "Shift Lock ON" : "Shift Lock OFF");
shiftLock = value;
};
this.isDpadRightDown = function () {
return dpadRightDown;
};
this.isSelectDown = function () {
//println("select down: " + selectDown);
return selectDown;
};
this.isClearDown = function () {
return clearDown;
};
this.isShiftDown = function () {
return shiftDown || shiftLock;
};
this.isDuplicateDown = function () {
return duplicateDown;
};
this.isMacroDown = function () {
return macroDown;
};
}