Changeset 29943


Ignore:
Timestamp:
2015-06-01T09:59:43+12:00 (9 years ago)
Author:
davidb
Message:

More careful control of keyboard events so text can reach the custom chord part of the system without accidentally playing notes on the piano at the same time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/respooled/collect/popup-video-respooled/js/audiosynth.view.js

    r29888 r29943  
    22
    33    var isMobile = !!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i);
     4    //isMobile = true;
    45    if(isMobile) { var evtListener = ['touchstart', 'touchend']; } else { var evtListener = ['mousedown', 'mouseup']; }
     6
     7    //console.log("*** pointerEnabled: " + window.navigator.pointerEnabled);
     8
     9    //var evtListener = ['pointerdown', 'pointerup'];
     10    //var evtListener = ['touchstart', 'touchend'];
     11
    512
    613    var __audioSynth = new AudioSynth();
     
    256263    var fnPlayNote = function(note, octave) {
    257264
    258     //console.log("**** Note started: " + Date.now()/1000.0)
     265    console.log("**** Note started: " + Date.now()/1000.0)
    259266
    260267    playedNoteStartTime = Date.now();
     
    301308
    302309    console.log("**** testing keyboard event key: '" + e.key + "' keycode = " + e.keyCode);
     310
     311    var $focused = $(':focus');
     312    console.log("focused.id = " + $focused.attr("id"));
     313
     314    if ($focused.attr("id") == "addCustomChordText") {
     315        // The keyboard event isn't for us (i.e. the piano/drum input chain). 
     316        // Return 'true' so the event can reach customGuitar keyboard handler
     317        return true;
     318    }
     319
    303320
    304321    if (e.keyCode == 32) { // <space-bar>
     
    402419        // console.log("**** " + playedNotePitch + " (midi pitch = " + playedMidiPitch+ ") startTime = ", relativePlayStartTime + ", duration = " + playedDuration);
    403420
     421        // ***** xxxx
    404422        mediaPlayedNotes[String(mediaStartPlayTime)].push(
    405423        { 'midiPitch'    : playedMidiPitch,
     
    417435    var fnRemoveKeyBinding = function(e) {
    418436   
    419     //console.log("**** key up at: " + Date.now())
     437    console.log("**** key up at: " + Date.now())
    420438    // console.log("*** event e = " + JSON.stringify(e));
    421439
     
    483501    }
    484502
    485     e.preventDefault();
    486     return false;
     503    //e.preventDefault();
     504    return true; // let other things outside of this piano/drum chain (such as the customGuitar input) see the event
    487505    }
    488506
Note: See TracChangeset for help on using the changeset viewer.