00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __UT_Intercept__
00024 #define __UT_Intercept__
00025
00026 #include "UT_API.h"
00027 #include "UT_PtrArray.h"
00028
00029
00030 class UT_InterceptEvent;
00031
00032 typedef int (*UT_InterceptCallback)(int handle_idx, void *data,
00033 UT_InterceptEvent *event,
00034 int poll, short xres, short yres);
00035
00036
00037 #define MAX_KEYS 47
00038
00039 typedef enum
00040 {
00041 UT_KEY_INVALID,
00042 UT_KEY_ZERO,
00043 UT_KEY_ONE,
00044 UT_KEY_TWO,
00045 UT_KEY_THREE,
00046 UT_KEY_FOUR,
00047 UT_KEY_FIVE,
00048 UT_KEY_SIX,
00049 UT_KEY_SEVEN,
00050 UT_KEY_EIGHT,
00051 UT_KEY_NINE,
00052 UT_KEY_A,
00053 UT_KEY_B,
00054 UT_KEY_C,
00055 UT_KEY_D,
00056 UT_KEY_E,
00057 UT_KEY_F,
00058 UT_KEY_G,
00059 UT_KEY_H,
00060 UT_KEY_I,
00061 UT_KEY_J,
00062 UT_KEY_K,
00063 UT_KEY_L,
00064 UT_KEY_M,
00065 UT_KEY_N,
00066 UT_KEY_O,
00067 UT_KEY_P,
00068 UT_KEY_Q,
00069 UT_KEY_R,
00070 UT_KEY_S,
00071 UT_KEY_T,
00072 UT_KEY_U,
00073 UT_KEY_V,
00074 UT_KEY_W,
00075 UT_KEY_X,
00076 UT_KEY_Y,
00077 UT_KEY_Z,
00078 UT_KEY_PAD0,
00079 UT_KEY_PAD1,
00080 UT_KEY_PAD2,
00081 UT_KEY_PAD3,
00082 UT_KEY_PAD4,
00083 UT_KEY_PAD5,
00084 UT_KEY_PAD6,
00085 UT_KEY_PAD7,
00086 UT_KEY_PAD8,
00087 UT_KEY_PAD9,
00088 UT_KEY_ESC
00089
00090 } UT_Key;
00091
00092 class UT_API UT_InterceptEvent {
00093
00094 public:
00095
00096 UT_Key key;
00097 short mx;
00098 short my;
00099
00100
00101 unsigned alt_state : 1,
00102 ctl_state : 1,
00103 key_state : 1;
00104 };
00105
00106 class UT_API UT_Intercept {
00107
00108 public:
00109
00110 UT_Intercept();
00111 ~UT_Intercept();
00112
00113 int numListeners(void) const
00114 { return myListeners.entries(); }
00115
00116 int addListener(UT_InterceptCallback func, void *data);
00117 void removeListener(int idx);
00118
00119 int distributeEvent(UT_InterceptEvent *event);
00120
00121 void setPollMode(int mode)
00122 { myPollMode = mode; }
00123
00124 int getPollMode() const
00125 { return myPollMode; }
00126
00127 void setModeNotifier(void *data)
00128 { myModeNotifier = data; }
00129
00130 void *getModeNotifier() const
00131 { return myModeNotifier; }
00132
00133 void setResolution(short x, short y)
00134 { myResolutionX = x; myResolutionY = y;}
00135
00136 private:
00137
00138 UT_PtrArray<UT_InterceptCallback> myListeners;
00139 UT_PtrArray<void *> myData;
00140 int myPollMode;
00141 short myResolutionX;
00142 short myResolutionY;
00143 void *myModeNotifier;
00144 };
00145
00146 UT_API extern UT_Intercept *UTgetIntercept();
00147
00148 #endif
00149