+ APC40MidiInput(MidiEngine midiEngine, MidiInputDevice d) {
+ super(midiEngine, d);
+ }
+
+ private class GridPosition {
+ public final int row, col;
+ GridPosition(int r, int c) {
+ row = r;
+ col = c;
+ }
+ }
+
+ private GridPosition getGridPosition(Note note) {
+ int channel = note.getChannel();
+ int pitch = note.getPitch();
+ if (channel < 8) {
+ if (pitch >= 53 && pitch <=57) return new GridPosition(pitch-53, channel);
+ else if (pitch == 52) return new GridPosition(5, channel);
+ }
+ return null;
+ }
+
+ protected boolean handleGridNoteOn(Note note) {
+ GridPosition p = getGridPosition(note);
+ if (p != null) {
+ return midiEngine.grid.gridPressed(p.row, p.col);
+ }
+ return false;
+ }
+
+ protected boolean handleGridNoteOff(Note note) {
+ GridPosition p = getGridPosition(note);
+ if (p != null) {
+ return midiEngine.grid.gridReleased(p.row, p.col);
+ }
+ return false;