Mercurial > hg > touchkeys
changeset 10:1afe374c4511
TouchKeys OSC emulation: pass frames by copy to keep internal state consistent (still bugs left to fix here)
author | Andrew McPherson <andrewm@eecs.qmul.ac.uk> |
---|---|
date | Wed, 20 Nov 2013 01:06:53 +0000 |
parents | f943785252fc |
children | c6f30c1e2bda |
files | Builds/MacOSX/TouchKeys.xcodeproj/project.xcworkspace/xcuserdata/apm.xcuserdatad/UserInterfaceState.xcuserstate Source/TouchKeys/TouchkeyOscEmulator.cpp |
diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
Binary file Builds/MacOSX/TouchKeys.xcodeproj/project.xcworkspace/xcuserdata/apm.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/Source/TouchKeys/TouchkeyOscEmulator.cpp Wed Nov 20 00:38:15 2013 +0000 +++ b/Source/TouchKeys/TouchkeyOscEmulator.cpp Wed Nov 20 01:06:53 2013 +0000 @@ -140,6 +140,7 @@ for(int i = 0; i < 3; i++) { if(touchFrames_[noteNumber].ids[i] == touchId) { // Found continuing touch + std::cout << "matched touch " << touch << " to ID " << touchId << std::endl; updateTouchInFrame(noteNumber, i, x, y); updatedExistingTouch = true; } @@ -155,8 +156,14 @@ } } - if(keyboard_.key(noteNumber) != 0) - keyboard_.key(noteNumber)->touchInsertFrame(touchFrames_[noteNumber], keyboard_.schedulerCurrentTimestamp()); + if(keyboard_.key(noteNumber) != 0) { + // Pass the frame to the keyboard by copy since PianoKey does its own ID number tracking. + // The important thing is that the Y values are always ordered. If ID tracking later changes + // in PianoKey it's of no consequence here as long as we retain the ability to track OSC + // touch IDs. + KeyTouchFrame copyFrame(touchFrames_[noteNumber]); + keyboard_.key(noteNumber)->touchInsertFrame(copyFrame, keyboard_.schedulerCurrentTimestamp()); + } } // Touch removed @@ -188,8 +195,10 @@ if(keyboard_.key(noteNumber) != 0) keyboard_.key(noteNumber)->touchOff(keyboard_.schedulerCurrentTimestamp()); } - else if(keyboard_.key(noteNumber) != 0) - keyboard_.key(noteNumber)->touchInsertFrame(touchFrames_[noteNumber], keyboard_.schedulerCurrentTimestamp()); + else if(keyboard_.key(noteNumber) != 0) { + KeyTouchFrame copyFrame(touchFrames_[noteNumber]); + keyboard_.key(noteNumber)->touchInsertFrame(copyFrame, keyboard_.schedulerCurrentTimestamp()); + } break; } }