00001 #include "TouchEvent.h"
00002 #include "TouchInterface.h"
00003
00004 namespace RenderTools {
00005
00006 TouchEvent::TouchEvent( Type type, const vector< TouchIndex > & indices, const vector< TouchPoint > & points ):
00007 m_type( type ),
00008 m_indices( indices ),
00009 m_points( points ){
00010 switch( m_type ){
00011 case TOUCHES_BEGAN:
00012 for( unsigned int i = 0; i < indices.size(); i++ ){
00013 TouchInterface::s_touches[ indices[ i ] ] = points[ i ];
00014 }
00015 break;
00016 case TOUCHES_MOVED:
00017 for( unsigned int i = 0; i < indices.size(); i++ ){
00018 TouchInterface::s_touches[ indices[ i ] ] = points[ i ];
00019 }
00020 break;
00021 case TOUCHES_CANCELLED:
00022 for( unsigned int i = 0; i < indices.size(); i++ ){
00023 TouchInterface::s_touches.erase( indices[ i ] );
00024 }
00025 break;
00026 case TOUCHES_ENDED:
00027 for( unsigned int i = 0; i < indices.size(); i++ ){
00028 TouchInterface::s_touches.erase( indices[ i ] );
00029 }
00030 break;
00031 case TOUCHES_HOLDING:
00032 for( unsigned int i = 0; i < indices.size(); i++ ){
00033 if( TouchInterface::isTouchPoint( indices[ i ] ) ){
00034 TouchInterface::s_touches[ indices[ i ] ] = points[ i ];
00035 }
00036 }
00037 break;
00038 }
00039 }
00040
00041 TouchEvent::TouchEvent( Type type, TouchIndex & index, const TouchPoint & point ):
00042 m_type( type ){
00043 m_indices.push_back( index );
00044 m_points.push_back( point );
00045 switch( m_type ){
00046 case TOUCHES_BEGAN:
00047 TouchInterface::s_touches[ index ] = point;
00048 break;
00049 case TOUCHES_MOVED:
00050 TouchInterface::s_touches[ index ] = point;
00051 break;
00052 case TOUCHES_CANCELLED:
00053 TouchInterface::s_touches.erase( index );
00054 break;
00055 case TOUCHES_ENDED:
00056 TouchInterface::s_touches.erase( index );
00057 break;
00058 case TOUCHES_HOLDING:
00059 if( TouchInterface::isTouchPoint( index ) ){
00060 TouchInterface::s_touches[ index ] = point;
00061 }
00062 break;
00063 }
00064 }
00065
00066 TouchEvent::Type TouchEvent::getType( void ) const {
00067 return( m_type );
00068 }
00069
00070 const vector< TouchIndex > & TouchEvent::getIndices( void ) const {
00071 return( m_indices );
00072 }
00073
00074 const vector< TouchPoint > & TouchEvent::getPoints( void ) const {
00075 return( m_points );
00076 }
00077
00078 };
00079