7. Single Handed Gestures
• You need to include mouse support in
config.xml
<mouse>y</mouse>
• Mouse listener like the web.
• Create a div in scene1.html
<div id="button0">Button</div> <!-- make it as button -->
<div id="div0“></div>
<!-- make it as trial element -->
• Adding listener
document.getElementById('div0').addEventListener('mouseover', function(){
document.getElementById('div0').style.backgroundColor = 'lime';
}, false);
document.getElementById('div0').addEventListener('mouseout', function(){
document.getElementById('div0').style.backgroundColor = 'yellow';
}, false);
document.getElementById('div0').addEventListener('click', function(){
alert("clicked");
}, false);
8. Double Handed Gestures
• Include webapis
<script type="text/javascript"
src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js"></script>
• Usage.
• Check for support and enabled
if (webapis.recognition.IsRecognitionSupported()) {
if (webapis.recognition.IsGestureRecognitionEnabled()) {
// perform Recognition related actions here, e.g. subscribe }
else { alert("ERROR: Gesture recognition is not enabled"); }
} else { alert("ERROR: Gesture recognition not supported"); }
Subscribe to events
webapis.recognition.SubscribeExEvent(webapis.recognition.PL_RECOGNITION_T
YPE_GESTURE, “returnID", function (evt) { that.handleRecognitionEvent.call(that,
evt); });
EVENT_GESTURE_2HAND_ZOOM , EVENT_GESTURE_2HAND_ROTATE etc
10. Voice Recognition
• Embedded Mode
Predefined voice commands.
The engine does more of comparison than recognition
Does NOT require internet.
Limited to comparing between 7 items.
• Server Guide Mode
Free- form speech.
Depends heavily on user’s linguistics and pronunciation.
Voice Data is sent to internet to recognize user’s speech.
No limits.
11. Voice Recognition
• Include webapis and in config.xml
<script type="text/javascript"
src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js
"></script>
<voice>y</voice> in config.xml
• Check for support and if enabled
deviceapis.recognition.IsRecognitionSupported()
deviceapis.recognition.IsVoiceRecognitionEnabled()
deviceapis.recognition.IsVoiceServerLanguageSupported()
12. Voice Recognition
• Subscribe to Voice Events
deviceapis.recognition.SubscribeExEvent(
deviceapis.recognition.PL_RECOGNITION_TYPE_VOICE,
"VoiceEvt",
Main.onVoiceEvent
);
deviceapis.recognition.UnsubscribeExEvent(
deviceapis.recognition.PL_RECOGNITION_TYPE_VOICE,
"VoiceEvt”
);
• Handle voice events
Main.onVoiceEvent = function(evt){
switch (evt.eventtype){
case 'EVENT_VOICE_RECOG_RESULT':
alert('The user say ' + evt.result);
break;
}
};