00001 /*---------------------------------------------------------------------------- 00002 MoMu: A Mobile Music Toolkit 00003 Copyright (c) 2010 Nicholas J. Bryan, Jorge Herrera, Jieun Oh, and Ge Wang 00004 All rights reserved. 00005 http://momu.stanford.edu/toolkit/ 00006 00007 Mobile Music Research @ CCRMA 00008 Music, Computing, Design Group 00009 Stanford University 00010 http://momu.stanford.edu/ 00011 http://ccrma.stanford.edu/groups/mcd/ 00012 00013 MoMu is distributed under the following BSD style open source license: 00014 00015 Permission is hereby granted, free of charge, to any person obtaining a 00016 copy of this software and associated documentation files (the 00017 "Software"), to deal in the Software without restriction, including 00018 without limitation the rights to use, copy, modify, merge, publish, 00019 distribute, sublicense, and/or sell copies of the Software, and to 00020 permit persons to whom the Software is furnished to do so, subject to 00021 the following conditions: 00022 00023 The authors encourage users of MoMu to include this copyright notice, 00024 and to let us know that you are using MoMu. Any person wishing to 00025 distribute modifications to the Software is encouraged to send the 00026 modifications to the original authors so that they can be incorporated 00027 into the canonical version. 00028 00029 The Software is provided "as is", WITHOUT ANY WARRANTY, express or implied, 00030 including but not limited to the warranties of MERCHANTABILITY, FITNESS 00031 FOR A PARTICULAR PURPOSE and NONINFRINGEMENT. In no event shall the authors 00032 or copyright holders by liable for any claim, damages, or other liability, 00033 whether in an actino of a contract, tort or otherwise, arising from, out of 00034 or in connection with the Software or the use or other dealings in the 00035 software. 00036 -----------------------------------------------------------------------------*/ 00037 00038 /*----------------------------------------------------------------------------*/ 00049 /*----------------------------------------------------------------------------*/ 00050 00051 00052 #ifndef __MO_TOUCH_H__ 00053 #define __MO_TOUCH_H__ 00054 00055 #import <UIKit/UIKit.h> 00056 #include "mo_def.h" 00057 #include <map> 00058 #include <vector> 00059 00060 /*----------------------------------------------------------------------------*/ 00068 /*----------------------------------------------------------------------------*/ 00069 struct MoTouchTrack 00070 { 00071 UITouch * touch; 00072 void * data; 00073 00074 // constructor 00075 MoTouchTrack() : touch(NULL), data(NULL) { } 00076 }; 00077 00078 00079 /*----------------------------------------------------------------------------*/ 00088 /*----------------------------------------------------------------------------*/ 00089 typedef void (* MoTouchCallback)( NSSet * touches, UIView * view, std::vector<MoTouchTrack> & tracks, void * data); 00090 00091 00092 /*----------------------------------------------------------------------------*/ 00097 /*----------------------------------------------------------------------------*/ 00098 class MoTouchUpdater 00099 { 00100 public: 00101 static void myTouchesBegan( id self, SEL _cmd, NSSet * touches, UIEvent * event ); 00102 static void myTouchesMoved( id self, SEL _cmd, NSSet * touches, UIEvent *event ); 00103 static void myTouchesEnded( id self, SEL _cmd, NSSet *touches, UIEvent * event ); 00104 static void myTouchesCancelled( id self, SEL _cmd, NSSet *touches, UIEvent * event ); 00105 }; 00106 00107 00108 00109 /*----------------------------------------------------------------------------*/ 00119 /*----------------------------------------------------------------------------*/ 00120 class MoTouch 00121 { 00122 00123 public: 00124 // client-side stuff 00125 00127 static void addCallback( const MoTouchCallback & callback, void * data ); 00128 00130 static void removeCallback( const MoTouchCallback & callback ); 00131 00133 static void clear(); 00134 00135 private: 00136 00137 friend class MoTouchUpdater; 00138 00139 // updated by the system, not you! 00140 static void update( NSSet * touches, UIView * view ); 00141 00142 // internally check the setup 00143 static void checkSetup(); 00144 00145 // queue of callbacks 00146 static std::vector< MoTouchCallback > m_clients; 00147 static std::vector<void *> m_clientData; 00148 static std::vector<MoTouchTrack> m_touchVec; 00149 }; 00150 00151 00152 00153 00154 #endif