-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInputController.java
More file actions
45 lines (38 loc) · 1.36 KB
/
InputController.java
File metadata and controls
45 lines (38 loc) · 1.36 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
import java.awt.Point;
import java.awt.MouseInfo;
import java.awt.PointerInfo;
import java.util.ArrayList;
import com.leapmotion.leap.*;
public class InputController {
public static ArrayList<Handle> handles = new ArrayList<Handle>();
public static Handle mouseHandle = null; //new Handle();//only for testing with the mouse
static boolean madeMouseusician = false;
public static class Handle {
public double x, y, z;
public Hand hand;
public int fingers = 0, fingersChangeTo = -1, pinchedInControlZone = -1 /*the knob or slider index of what is pinched*/, closestControlZone = -1;
public boolean isValid = true;
public long lastFrameId, lastFingerChangeTime;
public float pinchAmount = 0, pinchAmountPrevious = 0;
public MidiControl.HandleMusician musician;
public float pinchDrawRadius = 0;
//todo: extend this for other leap motion bs
public Handle() {
}
}
public static void update() {
if (mouseHandle != null) {
Point mouseLoc = MouseInfo.getPointerInfo().getLocation();
mouseHandle.x = mouseLoc.getX();
mouseHandle.y = mouseLoc.getY();
mouseHandle.fingers = 1;
if (!handles.contains(mouseHandle) && mouseHandle.isValid) {
handles.add(mouseHandle);
if (!madeMouseusician) {
MidiControl.addNewPitchHandle(mouseHandle);
madeMouseusician = true;
}
}
}
}
}