Mercurial > sdl-ios-xcode
comparison src/video/qtopia/SDL_sysevents.cc @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
40 // static SDLKey keymap[128]; | 40 // static SDLKey keymap[128]; |
41 /* This is special because we know it will be run in a loop in a separate | 41 /* This is special because we know it will be run in a loop in a separate |
42 thread. Normally this function should loop as long as there are input | 42 thread. Normally this function should loop as long as there are input |
43 states changing, i.e. new events arriving. | 43 states changing, i.e. new events arriving. |
44 */ | 44 */ |
45 void QT_PumpEvents (_THIS) | 45 void QT_PumpEvents(_THIS) |
46 { | 46 { |
47 if (!qApp) { | 47 if (!qApp) { |
48 return; | 48 return; |
49 } | 49 } |
50 // printf("processing events: %p\n", qApp); | 50 // printf("processing events: %p\n", qApp); |
51 //qApp->processOneEvent(); // wait for a event | 51 //qApp->processOneEvent(); // wait for a event |
52 qApp->processEvents (); // and process all outstanding ones | 52 qApp->processEvents(); // and process all outstanding ones |
53 #if 0 | 53 #if 0 |
54 BView *view; | 54 BView *view; |
55 BRect bounds; | 55 BRect bounds; |
56 BPoint point; | 56 BPoint point; |
57 uint32 buttons; | 57 uint32 buttons; |
61 B_SECONDARY_MOUSE_BUTTON, | 61 B_SECONDARY_MOUSE_BUTTON, |
62 }; | 62 }; |
63 unsigned int i, j; | 63 unsigned int i, j; |
64 | 64 |
65 /* Check out the mouse buttons and position (slight race condition) */ | 65 /* Check out the mouse buttons and position (slight race condition) */ |
66 if (SDL_Win->Lock ()) { | 66 if (SDL_Win->Lock()) { |
67 /* Don't do anything if we have no view */ | 67 /* Don't do anything if we have no view */ |
68 view = SDL_Win->View (); | 68 view = SDL_Win->View(); |
69 if (!view) { | 69 if (!view) { |
70 SDL_Win->Unlock (); | 70 SDL_Win->Unlock(); |
71 return; | 71 return; |
72 } | 72 } |
73 bounds = view->Bounds (); | 73 bounds = view->Bounds(); |
74 /* Get new input state, if still active */ | 74 /* Get new input state, if still active */ |
75 if (SDL_Win->IsActive ()) { | 75 if (SDL_Win->IsActive()) { |
76 key_flip = !key_flip; | 76 key_flip = !key_flip; |
77 get_key_info (&keyinfo[key_flip]); | 77 get_key_info(&keyinfo[key_flip]); |
78 view->GetMouse (&point, &buttons, true); | 78 view->GetMouse(&point, &buttons, true); |
79 } else { | 79 } else { |
80 key_flip = key_flip; | 80 key_flip = key_flip; |
81 point = last_point; | 81 point = last_point; |
82 buttons = last_buttons; | 82 buttons = last_buttons; |
83 } | 83 } |
84 SDL_Win->Unlock (); | 84 SDL_Win->Unlock(); |
85 } else { | 85 } else { |
86 return; | 86 return; |
87 } | 87 } |
88 | 88 |
89 /* If our view is active, we'll find key changes here */ | 89 /* If our view is active, we'll find key changes here */ |
90 if (SDL_memcmp (keyinfo[0].key_states, keyinfo[1].key_states, 16) != | 90 if (SDL_memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0) { |
91 0) { | |
92 for (i = 0; i < 16; ++i) { | 91 for (i = 0; i < 16; ++i) { |
93 Uint8 new_state, transition; | 92 Uint8 new_state, transition; |
94 | 93 |
95 new_state = keyinfo[key_flip].key_states[i]; | 94 new_state = keyinfo[key_flip].key_states[i]; |
96 transition = keyinfo[!key_flip].key_states[i] ^ | 95 transition = keyinfo[!key_flip].key_states[i] ^ |
97 keyinfo[key_flip].key_states[i]; | 96 keyinfo[key_flip].key_states[i]; |
98 for (j = 0; j < 8; ++j) { | 97 for (j = 0; j < 8; ++j) { |
99 if (transition & 0x80) | 98 if (transition & 0x80) |
100 QueueKey (i * 8 + j, new_state & 0x80); | 99 QueueKey(i * 8 + j, new_state & 0x80); |
101 transition <<= 1; | 100 transition <<= 1; |
102 new_state <<= 1; | 101 new_state <<= 1; |
103 } | 102 } |
104 } | 103 } |
105 } | 104 } |
106 | 105 |
107 /* We check keyboard, but not mouse if mouse isn't in window */ | 106 /* We check keyboard, but not mouse if mouse isn't in window */ |
108 if (!bounds.Contains (point)) { | 107 if (!bounds.Contains(point)) { |
109 /* Mouse moved outside our view? */ | 108 /* Mouse moved outside our view? */ |
110 if (SDL_GetAppState () & SDL_APPMOUSEFOCUS) { | 109 if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) { |
111 SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); | 110 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
112 be_app->SetCursor (B_HAND_CURSOR); | 111 be_app->SetCursor(B_HAND_CURSOR); |
113 } | 112 } |
114 return; | 113 return; |
115 } | 114 } |
116 /* Has the mouse moved back into our view? */ | 115 /* Has the mouse moved back into our view? */ |
117 if (!(SDL_GetAppState () & SDL_APPMOUSEFOCUS)) { | 116 if (!(SDL_GetAppState() & SDL_APPMOUSEFOCUS)) { |
118 /* Reset the B_HAND_CURSOR to our own */ | 117 /* Reset the B_HAND_CURSOR to our own */ |
119 SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); | 118 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
120 SDL_SetCursor (NULL); | 119 SDL_SetCursor(NULL); |
121 } | 120 } |
122 | 121 |
123 /* Check for mouse motion */ | 122 /* Check for mouse motion */ |
124 if (point != last_point) { | 123 if (point != last_point) { |
125 int x, y; | 124 int x, y; |
126 | 125 |
127 SDL_Win->GetXYOffset (x, y); | 126 SDL_Win->GetXYOffset(x, y); |
128 x = (int) point.x - x; | 127 x = (int) point.x - x; |
129 y = (int) point.y - y; | 128 y = (int) point.y - y; |
130 SDL_PrivateMouseMotion (0, 0, x, y); | 129 SDL_PrivateMouseMotion(0, 0, x, y); |
131 } | 130 } |
132 last_point = point; | 131 last_point = point; |
133 | 132 |
134 /* Add any mouse button events */ | 133 /* Add any mouse button events */ |
135 for (i = 0; i < SDL_TABLESIZE (button_masks); ++i) { | 134 for (i = 0; i < SDL_TABLESIZE(button_masks); ++i) { |
136 if ((buttons ^ last_buttons) & button_masks[i]) { | 135 if ((buttons ^ last_buttons) & button_masks[i]) { |
137 if (buttons & button_masks[i]) { | 136 if (buttons & button_masks[i]) { |
138 SDL_PrivateMouseButton (SDL_PRESSED, 1 + i, 0, 0); | 137 SDL_PrivateMouseButton(SDL_PRESSED, 1 + i, 0, 0); |
139 } else { | 138 } else { |
140 SDL_PrivateMouseButton (SDL_RELEASED, 1 + i, 0, 0); | 139 SDL_PrivateMouseButton(SDL_RELEASED, 1 + i, 0, 0); |
141 } | 140 } |
142 } | 141 } |
143 } | 142 } |
144 last_buttons = buttons; | 143 last_buttons = buttons; |
145 #endif | 144 #endif |
146 } | 145 } |
147 | 146 |
148 void QT_InitOSKeymap (_THIS) | 147 void QT_InitOSKeymap(_THIS) |
149 { | 148 { |
150 #if 0 | 149 #if 0 |
151 unsigned int i; | 150 unsigned int i; |
152 | 151 |
153 /* Initialize all the key states as "up" */ | 152 /* Initialize all the key states as "up" */ |
154 key_flip = 0; | 153 key_flip = 0; |
155 SDL_memset (keyinfo[key_flip].key_states, 0, 16); | 154 SDL_memset(keyinfo[key_flip].key_states, 0, 16); |
156 | 155 |
157 /* Initialize the key translation table */ | 156 /* Initialize the key translation table */ |
158 for (i = 0; i < SDL_TABLESIZE (keymap); ++i) | 157 for (i = 0; i < SDL_TABLESIZE(keymap); ++i) |
159 keymap[i] = SDLK_UNKNOWN; | 158 keymap[i] = SDLK_UNKNOWN; |
160 | 159 |
161 // keymap[0x01] = SDLK_ESCAPE; | 160 // keymap[0x01] = SDLK_ESCAPE; |
162 // keymap[B_F1_KEY] = SDLK_F1; | 161 // keymap[B_F1_KEY] = SDLK_F1; |
163 // keymap[B_F2_KEY] = SDLK_F2; | 162 // keymap[B_F2_KEY] = SDLK_F2; |