1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*
*/
#include "wince.h"
extern bool select_game;
extern bool _get_key_mapping;
extern bool draw_keyboard;
extern bool hide_toolbar;
extern bool freelook;
extern bool is_simon;
extern bool is_bass;
extern int num_of_dirty_square;
extern bool toolbar_drawn;
extern Engine *engine;
extern bool sound_activated;
extern char is_demo;
extern ToolbarSelected getToolbarSelection(int, int);
extern void redrawSoundItem();
extern int mapKey(int key);
extern void handleSelectGame(int, int);
extern void do_quit();
const char KEYBOARD_MAPPING_ALPHA_HIGH[] = {"abcdefghijklm"};
const char KEYBOARD_MAPPING_NUMERIC_HIGH[] = {"12345"};
const char KEYBOARD_MAPPING_ALPHA_LOW[] = {"nopqrstuvwxyz"};
const char KEYBOARD_MAPPING_NUMERIC_LOW[] = {"67890"};
BOOL PPCWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, OSystem_WINCE3 *wm) {
switch(message) {
case WM_KEYDOWN:
/*
if (wParam == VK_ESCAPE) // FIXME
do_quit();
*/
if(wParam && wParam != 0x84 && wParam != 0x5B) { // WHAT THE ???
if (select_game) {
GAPIKeysHandleSelect((int)wParam);
break;
}
/*
unsigned char GAPI_key;
GAPI_key = getGAPIKeyMapping((short)wParam);
if (GAPI_key) {
*/
if (_get_key_mapping) {
wm->_event.kbd.flags = 0xff;
wm->_event.kbd.ascii = GAPIKeysTranslate((unsigned int)(wParam));
wm->_event.event_code = OSystem::EVENT_KEYDOWN;
break;
}
/*
else
processAction((short)wParam);
*/
/*}*/
if (!processAction(GAPIKeysTranslate((unsigned int)(wParam))))
/*else*/ {
wm->_event.kbd.ascii = mapKey(wParam);
wm->_event.kbd.keycode = tolower(wm->_event.kbd.ascii);
wm->_event.event_code = OSystem::EVENT_KEYDOWN;
}
}
break;
case WM_KEYUP:
if (_get_key_mapping) {
_get_key_mapping = false;
wm->_event.kbd.flags = 0xff;
wm->_event.kbd.ascii = GAPIKeysTranslate((int)wParam);
wm->_event.event_code = OSystem::EVENT_KEYUP;
break;
}
else {
wm->_event.kbd.ascii = mapKey(wParam);
wm->_event.kbd.keycode = mapKey(wParam);
wm->_event.event_code = OSystem::EVENT_KEYUP;
}
break;
case WM_MOUSEMOVE:
{
int x = ((int16*)&lParam)[0];
int y = ((int16*)&lParam)[1];
/*if (select_game) {
handleSelectGame(x, y);
break;
}*/
if (select_game)
break;
Translate(&x, &y);
wm->_event.event_code = OSystem::EVENT_MOUSEMOVE;
wm->_event.mouse.x = x;
wm->_event.mouse.y = y;
wm->_last_mouse_event = wm->_event;
}
break;
case WM_LBUTTONDOWN:
{
ToolbarSelected toolbar_selection;
int x = ((int16*)&lParam)[0];
int y = ((int16*)&lParam)[1];
if (select_game) {
handleSelectGame(x, y);
break;
}
Translate(&x, &y);
wm->_event.kbd.flags = 0;
if (freelook) {
wm->_event.event_code = OSystem::EVENT_MOUSEMOVE;
wm->_event.mouse.x = x;
wm->_event.mouse.y = y;
break;
}
if (draw_keyboard) {
// Handle keyboard selection
int offset_y;
int saved_x = x;
int saved_y = y;
/*
if (!GetScreenMode()) {
x = ((int16*)&lParam)[0];
y = ((int16*)&lParam)[1];
}
*/
offset_y = (GetScreenMode() ? 0 : 40 + 22);
if (x<185 && y>=(200 + offset_y)) {
//Alpha selection
wm->_event.event_code = OSystem::EVENT_KEYDOWN;
wm->_event.kbd.ascii =
(y <= (220 + offset_y)? KEYBOARD_MAPPING_ALPHA_HIGH[((x + 10) / 14) - 1] :
KEYBOARD_MAPPING_ALPHA_LOW[((x + 10) / 14) - 1]);
wm->_event.kbd.keycode = tolower(wm->_event.kbd.ascii);
break;
}
else
if (x>=186 && y>=(200 + offset_y) && x<=255) {
// Numeric selection
wm->_event.event_code = OSystem::EVENT_KEYDOWN;
wm->_event.kbd.ascii =
(y <= (220 + offset_y) ? KEYBOARD_MAPPING_NUMERIC_HIGH[((x - 187 + 10) / 14) - 1] :
KEYBOARD_MAPPING_NUMERIC_LOW[((x - 187 + 10) / 14) - 1]);
wm->_event.kbd.keycode = wm->_event.kbd.ascii;
break;
}
else
if (x>=302 && x <= 316 && y >= (200 + offset_y) && y <= (220 + offset_y)) {
// Backspace
wm->_event.event_code = OSystem::EVENT_KEYDOWN;
wm->_event.kbd.keycode = 8;
wm->_event.kbd.ascii = mapKey(VK_BACK);
break;
}
else
if (x>=302 && x<= 316 && y >= (220 + offset_y)) {
// Enter
wm->_event.event_code = OSystem::EVENT_KEYDOWN;
wm->_event.kbd.keycode = '\n';
wm->_event.kbd.ascii = mapKey(VK_RETURN);
break;
}
x = saved_x;
y = saved_y;
wm->_event.event_code = OSystem::EVENT_LBUTTONDOWN;
wm->_event.mouse.x = x;
wm->_event.mouse.y = y;
wm->_last_mouse_event = wm->_event;
break;
}
toolbar_selection = (hide_toolbar || _get_key_mapping ? ToolbarNone :
getToolbarSelection(
(GetScreenMode() ? x : ((int16*)&lParam)[0]),
(GetScreenMode() ? y : ((int16*)&lParam)[1])));
if (toolbar_selection == ToolbarNone) {
wm->_event.event_code = OSystem::EVENT_LBUTTONDOWN;
wm->_event.mouse.x = x;
wm->_event.mouse.y = y;
wm->_last_mouse_event = wm->_event;
}
else {
switch(toolbar_selection) {
case ToolbarSaveLoad:
if (is_simon)
break;
/*if (GetScreenMode()) {*/
/*
draw_keyboard = true;
if (!hide_toolbar)
toolbar_drawn = false;
*/
/*}*/
wm->_event.event_code = OSystem::EVENT_KEYDOWN;
if (is_bass)
wm->_event.kbd.ascii = 63;
else
if (g_scumm->_version <= 2)
wm->_event.kbd.ascii = 5;
else
if ((g_scumm->_features & GF_OLD256) || (g_scumm->_gameId == GID_CMI) || (g_scumm->_features & GF_16COLOR))
wm->_event.kbd.ascii = 319;
else
wm->_event.kbd.ascii = g_scumm->VAR(g_scumm->VAR_SAVELOADDIALOG_KEY);
break;
case ToolbarMode:
SetScreenMode(!GetScreenMode());
num_of_dirty_square = MAX_NUMBER_OF_DIRTY_SQUARES;
if (!hide_toolbar)
toolbar_drawn = false;
break;
case ToolbarSkip:
if (is_demo)
do_quit();
wm->_event.event_code = OSystem::EVENT_KEYDOWN;
if (is_simon || is_bass) {
wm->_event.kbd.ascii = mapKey(VK_ESCAPE);
wm->_event.kbd.keycode = mapKey(VK_ESCAPE);
break;
}
/*
if (g_scumm->vm.cutScenePtr[g_scumm->vm.cutSceneStackPointer] || g_scumm->_insaneState)
wm->_event.kbd.ascii = g_scumm->_vars[g_scumm->VAR_CUTSCENEEXIT_KEY];
else
if (g_scumm->_talkDelay > 0)
wm->_event.kbd.ascii = g_scumm->VAR_TALKSTOP_KEY;
else
wm->_event.kbd.ascii = mapKey(VK_ESCAPE);
*/
wm->_event.kbd.ascii = KEY_ALL_SKIP;
break;
case ToolbarSound:
sound_activated = !sound_activated;
redrawSoundItem();
break;
default:
break;
}
}
}
break;
case WM_LBUTTONUP:
{
// pinched from the SDL code. Distinguishes between taps and not
int x = ((int16*)&lParam)[0];
int y = ((int16*)&lParam)[1];
/*
if (select_game) {
handleSelectGame(x, y);
break;
}
*/
if (select_game)
break;
Translate(&x, &y);
wm->_event.event_code = OSystem::EVENT_LBUTTONUP;
wm->_event.mouse.x = x;
wm->_event.mouse.y = y;
wm->_last_mouse_event = wm->_event;
}
break;
case WM_LBUTTONDBLCLK: // doesn't seem to work right now
//wm->_scumm->_rightBtnPressed |= msClicked | msDown;
break;
default:
return FALSE;
}
return TRUE;
}
|