5. Touch input

Chapters

            Main input of smart device from human to them is touch screen. Some device support over 2 taps in time but some device support only two.

            5.1 Understand touch device.

            5.2 Type of touch

                        5.2.1 Tap

                                    A.) Every tap have own ID, you must specify ID when you

                                                operator with tap.

0 = first tap

1 = second tap

2 = third tap

3 = forth tap

4 = fifth tap

5 = six tap

 

                                     B.) Tap states are DOWN, PRESSED, RELEASED and UP.

Example: First tap down

if( g_input-> getTouchState(0) == irr::EKS_DOWN )

{

}

 

                                    C.) Tap return x and y coordinate as int.

Example: Get touch coordinate

int x = g_input->getTouchX(0);

int y = g_input->getTouchY(0);

 

                                    D.) Double or triple tap

Example: Get double tap

If( g_input->getTouchRepeatCount() == 2 ) // double

{

}

If( g_input->getTouchRepeatCount() == 3 ) // triple

{

}

 

                                    E.) Tap hold time

Example: Tap hold time

If( g_input->getTouchTimeSec(0) == 1 ) // first tap hold 1 sec

{

}

If( g_input->getTouchTimeSec(1) == 0.1f ) // second tap hold 0.1 sec

{

}

 

                        5.2.2 Multi Tap

                                    A.) Second Tap is standard.

                                    B.) Third Tap or more is in medium or latest android device.

Example: Second and third tap released

if( g_input-> getTouchState(1) == irr::EKS_RELEASED)

{

}

if( g_input-> getTouchState(2) == irr::EKS_ RELEASED )

{

}

 

                        5.2.3 Slide 4 or 8 ways, Left, Right, Top and Bottom.

Example: Touch slide

if( g_input->isTouchLeft() )

{

}

if(g_input->isTouchRight() )

{

}

if(g_input->isTouchUp() )

{

}

if(g_input->isTouchDown() )

{

}

 

                        5.2.4 Touch zoom in-out

Example: Touch zoom

if( g_input->isTouchZoomIn() ) // zoom in

{

}

if(g_input->isTouchZoomOut() ) // zoom out

{

}

 

NOTE:

            Reference IARSAInput interface class

A.) Touch state

       irr::EKS_UP

       irr::EKS_DOWN

       irr::EKS_PRESSED

       irr::EKS_RELEASED

 

B.) API

       float mouseWheel() = 0;

       int mouseX() = 0;

       int mouseY() = 0;

       bool leftMouseReleased() = 0;

       bool leftMouseUp() = 0;

       bool leftMousePressed() = 0;

       bool leftMouseDown() = 0;

       bool middleMouseReleased() = 0;

       bool middleMouseUp() = 0;

       bool middleMousePressed() = 0;

       bool middleMouseDown() = 0;

       bool rightMouseReleased() = 0;

       bool rightMouseUp() = 0;

       bool rightMousePressed() = 0;

       bool rightMouseDown() = 0;

       bool keyPressed(unsignedchar keycode) = 0;

       bool keyDown(unsignedchar keycode) = 0;

       bool keyUp(unsignedchar keycode) = 0;

       bool keyReleased(unsignedchar keycode) = 0;

       int isKeyDown( ) = 0;

       int isKeyPressed( ) = 0;

       void endEventProcess( u32 timeMs = 0 ) = 0;

       void startEventProcess() = 0;

       void init() = 0;

       void clear( void ) = 0;

       bool isTouchOk( u8 id ) const = 0;

       // touch data access

       u8 getTouchState( u8 id ) const = 0;

       s32 getTouchId( u8 id ) const = 0;

       bool isTouchLeft( u8 id ) const = 0;

       bool isTouchRight( u8 id ) const = 0;

       bool isTouchUp( u8 id ) const = 0;

       bool isTouchDown( u8 id ) const = 0;

       f32 getTouchTimeSec( u8 id ) const = 0; // sec

       int getTouchStartX( u8 id ) const = 0;

       int getTouchStartY( u8 id ) const = 0;

       int getTouchOldX( u8 id ) const = 0;

       int getTouchOldY( u8 id ) const = 0;

       int getTouchX( u8 id ) const = 0;

       int getTouchY( u8 id ) const = 0;

       int getTouchDiffXY( u8 id ) const = 0;

       int getTouchDiffX( u8 id ) const = 0;

       int getTouchDiffY( u8 id ) const = 0;

       int getTouchDiffStartX( u8 id ) const = 0;

       int getTouchDiffStartY( u8 id ) const = 0;

       bool isTouchMoving( u8 id ) const = 0;

       bool isTouchZoomIn() const = 0;

       bool isTouchZoomOut() const = 0;

       int getTouchRepeatCount( ) const = 0;

       void setScreenSize( const core::dimension2du& size, const core::dimension2du& wantsize = core::dimension2du() ) = 0;

       bool ManualUpdate(constSEvent& event) = 0;

Tags: