# HG changeset patch # User Andrew McPherson # Date 1384909613 0 # Node ID 1afe374c4511f45ade48b9bd835ae2b13493fdb2 # Parent f943785252fc045b054670dd845a173f35b1b52d TouchKeys OSC emulation: pass frames by copy to keep internal state consistent (still bugs left to fix here) diff -r f943785252fc -r 1afe374c4511 Builds/MacOSX/TouchKeys.xcodeproj/project.xcworkspace/xcuserdata/apm.xcuserdatad/UserInterfaceState.xcuserstate Binary file Builds/MacOSX/TouchKeys.xcodeproj/project.xcworkspace/xcuserdata/apm.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r f943785252fc -r 1afe374c4511 Source/TouchKeys/TouchkeyOscEmulator.cpp --- 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; } }