User Tools

Site Tools


editing_point_min_and_max_number

Editing Point Min And Max Number

To edit the number of touch points that will trigger a gesture match; set the cluster “point_number”, “point_number_min” and “point_number_max” values. Setting the “point_number” to “2” will only allow 2 points to activate a defined gesture. Otherwise setting “point_number” to “0” and then explicitly setting “point_number_max” and “point_number_min” will determine a range of values that will activate gesture analysis.

For example this gesture will only trigger when 2 touch points are registered on an associated touch object:

<Gesture id="2-finger-drag" type="drag">
    <match>
        <action>
            <initial>
                <cluster point_number="2"/>
            </initial>
        </action>
    </match>       
    <analysis>
        <algorithm>
            <library module="translate"/>
            <returns>
                <property id="drag_dx" result="dx"/>
                <property id="drag_dy" result="dy"/>
            </returns>
        </algorithm>
    </analysis>    
    <mapping>
        <update dispatch_type="continuous">
            <gesture_event type="drag">
                <property ref="drag_dx" target="x"/>
                <property ref="drag_dy" target="y"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>

This gesture will trigger when only 4 touch points are registered on an associated touch object:

<Gesture id="4-finger-drag" type="drag">
    <match>
        <action>
            <initial>
                <cluster point_number="4"/>
            </initial>
        </action>
    </match>       
    <analysis>
        <algorithm>
            <library module="translate"/>
            <returns>
                <property id="drag_dx" result="dx"/>
                <property id="drag_dy" result="dy"/>
            </returns>
        </algorithm>
    </analysis>    
    <mapping>
        <update dispatch_type="continuous">
            <gesture_event type="drag">
                <property ref="drag_dx" target="x"/>
                <property ref="drag_dy" target="y"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>

If you want to configure a gesture to trigger across a range of point values you will need to explicitly set the “point_number” to zero and then define the match range using “point_number_min” and “point_number_max”. For example this rotate gesture will initialize and trigger when 2 to 5 touch points are registered with an associated touch object:

<Gesture id="n-rotate" type="rotate">
    <match>
        <action>
            <initial>
                <cluster point_number="0" point_number_min="2" point_number_max="5"/>
            </initial>
        </action>
    </match>
    <analysis>
        <algorithm class="kinemetric" type="continuous">
            <library module="rotate"/>
            <returns>
                <property id="rotate_dtheta" result="dtheta"/>
            </returns>
        </algorithm>
    </analysis>  
    <mapping>
        <update dispatch_type="continuous">
            <gesture_event type="rotate">
                <property ref="rotate_dtheta" target="rotate"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>

Note that when two gestures of similar gesture action and GML description use the same touch point number as their primary matching criteria they will tend to trigger at the same time. If these gestures use the same gesture “type” and then it is recommended that one be distinguished using a custom gesture event type so as not to create gesture conflict in an application. See: How To Avoid Gesture Conflict.

editing_point_min_and_max_number.txt · Last modified: 2019/01/29 19:06 (external edit)