Skip to content

Commit

Permalink
initial work for vibration with tappi, see #104
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Apr 18, 2022
1 parent 891ef13 commit 6ac6487
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions js/quadrilateral-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Sim from '../../joist/js/Sim.js';
import simLauncher from '../../joist/js/simLauncher.js';
import { Color, ColorProperty, HBox } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import vibrationManager from '../../tappi/js/vibrationManager.js';
import QuadrilateralSoundOptionsModel from './quadrilateral/model/QuadrilateralSoundOptionsModel.js';
import QuadrilateralQueryParameters from './quadrilateral/QuadrilateralQueryParameters.js';
import QuadrilateralScreen from './quadrilateral/QuadrilateralScreen.js';
Expand Down Expand Up @@ -70,4 +71,6 @@ simLauncher.launch( () => {

const sim = new Sim( quadrilateralTitleString, simScreens, simOptions );
sim.start();

vibrationManager.initialize( sim.browserTabVisibleProperty, sim.activeProperty );
} );
3 changes: 3 additions & 0 deletions js/quadrilateral/view/QuadrilateralScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import QuadrilateralMarkerInput from './QuadrilateralMarkerInput.js';
import QuadrilateralVisibilityControls from './QuadrilateralVisibilityControls.js';
import QuadrilateralGridNode from './QuadrilateralGridNode.js';
import QuadrilateralScreenSummaryContentNode from './QuadrilateralScreenSummaryContentNode.js';
import vibrationManager from '../../../../tappi/js/vibrationManager.js';

const MODEL_BOUNDS = QuadrilateralQueryParameters.calibrationDemoDevice ? new Bounds2( -4.5, -4.5, 4.5, 4.5 ) :
new Bounds2( -1, -1, 1, 1 );
Expand Down Expand Up @@ -333,6 +334,8 @@ class QuadrilateralScreenView extends ScreenView {
this.quadrilateralMarkerInput.step( dt );
}

vibrationManager.step( dt );

this.quadrilateralAlerter.step( dt );
}
}
Expand Down
10 changes: 10 additions & 0 deletions js/quadrilateral/view/VertexNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ class VertexNode extends Voicing( Circle, 1 ) {
}
} );

// vibration
vertex.isPressedProperty.lazyLink( isPressed => {
if ( isPressed ) {
navigator.vibrate( [ 10000 ] );
}
else {
navigator.vibrate( 0 );
}
} );

this.mutate( options );
}
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
],
"phetLibs": [
"tangible",
"bamboo"
"bamboo",
"tappi"
],
"preload": [
"../sherpa/lib/beholder-detection-1.1.12.js"
Expand Down
7 changes: 6 additions & 1 deletion quadrilateral_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
],
"phetLibs": [
"tangible",
"bamboo"
"bamboo",
"tappi"
],
"preload": [
"../sherpa/lib/beholder-detection-1.1.12.js"
Expand Down Expand Up @@ -84,6 +85,10 @@
"repo": "tambo",
"requirejsNamespace": "TAMBO"
},
{
"repo": "tappi",
"requirejsNamespace": "TAPPI"
},
{
"repo": "twixt",
"requirejsNamespace": "TWIXT"
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
},
{
"path": "../bamboo/tsconfig-module.json"
},
{
"path": "../tappi"
}
],
"include": [
Expand Down

0 comments on commit 6ac6487

Please sign in to comment.