HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Intercept.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_Intercept.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  *
10  * This class is used to intercept and reroute
11  * input events to interested listeners.
12  *
13  */
14 
15 #ifndef __UT_Intercept__
16 #define __UT_Intercept__
17 
18 #include "UT_API.h"
19 #include "UT_ValArray.h"
20 
21 
22 class UT_InterceptEvent;
23 
24 typedef int (*UT_InterceptCallback)(int handle_idx, void *data,
26  int poll, short xres, short yres);
27 
28 
29 enum UT_Key : int
30 {
32  // Values of 0x00000001 through 0x0010FFFF represent unicode code points.
33  //
34  // We provide enumerators for a very small subset of these here. Which
35  // values in this range are actually used will depend on the keyboard
36  // layout. We generally use the upper-case code point for any code point
37  // that is considered lower-case.
38  //
39  // Some of the keys representing control characters have special values
40  // that differ from their unicode code point.
41 
42  UT_KEY_ZERO = 0x30,
43  UT_KEY_ONE = 0x31,
44  UT_KEY_TWO = 0x32,
45  UT_KEY_THREE = 0x33,
46  UT_KEY_FOUR = 0x34,
47  UT_KEY_FIVE = 0x35,
48  UT_KEY_SIX = 0x36,
49  UT_KEY_SEVEN = 0x37,
50  UT_KEY_EIGHT = 0x38,
51  UT_KEY_NINE = 0x39,
52  UT_KEY_A = 0x41,
53  UT_KEY_B = 0x42,
54  UT_KEY_C = 0x43,
55  UT_KEY_D = 0x44,
56  UT_KEY_E = 0x45,
57  UT_KEY_F = 0x46,
58  UT_KEY_G = 0x47,
59  UT_KEY_H = 0x48,
60  UT_KEY_I = 0x49,
61  UT_KEY_J = 0x4A,
62  UT_KEY_K = 0x4B,
63  UT_KEY_L = 0x4C,
64  UT_KEY_M = 0x4D,
65  UT_KEY_N = 0x4E,
66  UT_KEY_O = 0x4F,
67  UT_KEY_P = 0x50,
68  UT_KEY_Q = 0x51,
69  UT_KEY_R = 0x52,
70  UT_KEY_S = 0x53,
71  UT_KEY_T = 0x54,
72  UT_KEY_U = 0x55,
73  UT_KEY_V = 0x56,
74  UT_KEY_W = 0x57,
75  UT_KEY_X = 0x58,
76  UT_KEY_Y = 0x59,
77  UT_KEY_Z = 0x5A,
78 
80  UT_KEY_COMMA = 0x2C,
81  UT_KEY_PERIOD = 0x2E,
82  UT_KEY_QUOTE = 0x27,
85  UT_KEY_MINUS = 0x2D,
86  UT_KEY_EQUAL = 0x3D,
87  UT_KEY_SLASH = 0x2F,
89 
90  // Values for special keys not represented by a unicode code point start
91  // at 0x00110000.
92 
93  UT_KEY_PAD0 = 0x00110000,
94  UT_KEY_PAD1 = 0x00110001,
95  UT_KEY_PAD2 = 0x00110002,
96  UT_KEY_PAD3 = 0x00110003,
97  UT_KEY_PAD4 = 0x00110004,
98  UT_KEY_PAD5 = 0x00110005,
99  UT_KEY_PAD6 = 0x00110006,
100  UT_KEY_PAD7 = 0x00110007,
101  UT_KEY_PAD8 = 0x00110008,
102  UT_KEY_PAD9 = 0x00110009,
103  UT_KEY_ESC = 0x0011000A,
104  UT_KEY_SPACE = 0x0011000B,
105 
106 };
107 
108 // The following sentinel should only be used for validity checks, not for
109 // allocating fixed size arrays.
110 #define UT_KEY_MAX UT_KEY_SPACE;
111 
113 
114 public:
115 
117  short mx;
118  short my;
119 
120 
121  unsigned alt_state : 1,
122  ctl_state : 1,
123  key_state : 1;
124 };
125 
127 {
128 public:
129 
130  UT_Intercept();
131 
132  int numListeners() const
133  { return myListeners.entries(); }
134 
135  int addListener(UT_InterceptCallback func, void *data);
136  void removeListener(int idx);
137 
138  int distributeEvent(UT_InterceptEvent *event);
139 
140  void setPollMode(int mode)
141  { myPollMode = mode; }
142 
143  int getPollMode() const
144  { return myPollMode; }
145 
146  void setModeNotifier(void *data)
147  { myModeNotifier = data; }
148 
149  void *getModeNotifier() const
150  { return myModeNotifier; }
151 
152  void setResolution(short x, short y)
153  { myResolutionX = x; myResolutionY = y;}
154 
155 private:
156 
158  UT_ValArray<void *> myData;
159  int myPollMode;
160  short myResolutionX;
161  short myResolutionY;
162  void *myModeNotifier;
163 };
164 
165 UT_API extern UT_Intercept *UTgetIntercept(); // Get the app intercept ptr
166 
167 #endif
168 
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
GLboolean * data
Definition: glcorearb.h:131
void setModeNotifier(void *data)
Definition: UT_Intercept.h:146
#define UT_API
Definition: UT_API.h:14
GLint y
Definition: glcorearb.h:103
struct _cl_event * event
Definition: glcorearb.h:2961
void setResolution(short x, short y)
Definition: UT_Intercept.h:152
int getPollMode() const
Definition: UT_Intercept.h:143
GLint GLenum GLint x
Definition: glcorearb.h:409
void setPollMode(int mode)
Definition: UT_Intercept.h:140
GLenum mode
Definition: glcorearb.h:99
GLenum func
Definition: glcorearb.h:783
UT_API UT_Intercept * UTgetIntercept()
UT_Key
Definition: UT_Intercept.h:29
void * getModeNotifier() const
Definition: UT_Intercept.h:149
int(* UT_InterceptCallback)(int handle_idx, void *data, UT_InterceptEvent *event, int poll, short xres, short yres)
Definition: UT_Intercept.h:24
int numListeners() const
Definition: UT_Intercept.h:132
Definition: format.h:895