Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Querying the Touch Observer

Before an application can query the Touch Observer, it must query the root container to obtain the Touch Observer object, as shown in the following example:

nErr = IWidget_GetTouchObserver(IWidget *pif, IObserver **ppiTouchObserver);

After obtaining the Touch Observer object, the application can start observation, retrieve information about the Touch Observer or gestures, and stop observation.

Starting observation

The following gestures can be observed:

  • Last linear movement determination (TOUCHOBSF_LLM)
  • Tap (TOUCHOBSF_TAP)
  • Double tap (TOUCHOBSF_DBLTAP)
  • Tap and Hold (TOUCHOBSF_TAPANDHOLD)
  • Multiple linear movements (TOUCHOBSF_MULT_LM)

To retrieve information about a gesture, an application needs to call IObserver_StartObservation() for that particular gesture, as shown in this example:

int nErr = AEE_SUCCESS;

// if the pointer to the touch observer is not NULL,
// start observation 
if(me->piTO) {
   nErr = IObserver_StartObservation(me->piTO, TOUCHOBSF_LLM);
   if (!nErr) {
      me->bFlickEnabled = TRUE;
      if (me->bDblFlickEnabled) {
         nErr |= IObserver_StartObservation(me->piTO, TOUCHOBSF_MULT_LM);
      }
   }
}

A tap and hold gesture is detected when the screen is touched and not released within a given time period. In addition, any moves observed within this time threshold should be within a limited distance (to avoid conflict with a pan or scroll action).

To check which gestures the Touch Observer is monitoring, call IObserver_GetObservation().

Retrieving information

To retrieve specific information about a gesture, an application can call one of the IObserver APIs associated with the gesture.

The following example shows how to get the speed, angle, and direction information for a flick gesture:

if(!me->piTO ||
   (AEE_SUCCESS != IObserver_GetLLMSpeed(me->piTO, &nLLMSpeed)) || (0 == nLLMSpeed) ||
   (AEE_SUCCESS != IObserver_GetLLMAngle(me->piTO, &nLLMAngle))) {

   ListTC_ResetFlickParameters(me);
   return;
}

// Get Scroll direction
nScrollDir = GetDirectionType(nLLMAngle, me->nMaxLLMAngleRange);
if (TOUCHOBS_DIR_NONE == nScrollDir) {
   ListTC_ResetFlickParameters(me);
   return;
}

Stopping observation

When an application is finished with observation for a gesture, it can stop observation, as follows:

int nErr = AEE_SUCCESS;

if (me->piTO && me->bFlickEnabled) {
   nErr = IObserver_StopObservation(me->piTO, TOUCHOBSF_LLM);
   me->bFlickEnabled = FALSE;

   if (me->bDblFlickEnabled) {
      nErr |= IObserver_StopObservation(me->piTO, TOUCHOBSF_MULT_LM);
}