src/video/gem/SDL_gemevents.c
author Patrice Mandin <patmandin@gmail.com>
Thu, 12 Oct 2017 22:49:00 +0200
branchSDL-1.2
changeset 11608 850f1a16dc81
parent 11576 b3255371e439
permissions -rw-r--r--
atari:gem: Simplify palette changes by removing most temp variables
slouken@281
     1
/*
slouken@281
     2
    SDL - Simple DirectMedia Layer
slouken@6137
     3
    Copyright (C) 1997-2012 Sam Lantinga
slouken@281
     4
slouken@281
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@281
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@281
     9
slouken@281
    10
    This library is distributed in the hope that it will be useful,
slouken@281
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@281
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@281
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@281
    18
slouken@281
    19
    Sam Lantinga
slouken@281
    20
    slouken@libsdl.org
slouken@281
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@281
    23
slouken@281
    24
/*
slouken@281
    25
 * GEM SDL video driver implementation
slouken@281
    26
 * inspired from the Dummy SDL driver
patmandin@11554
    27
 *
slouken@281
    28
 * Patrice Mandin
slouken@281
    29
 * and work from
slouken@281
    30
 * Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
slouken@281
    31
 */
slouken@281
    32
slouken@281
    33
#include <gem.h>
slouken@281
    34
patmandin@9042
    35
#include "SDL_timer.h"
slouken@1361
    36
#include "../../events/SDL_sysevents.h"
slouken@1361
    37
#include "../../events/SDL_events_c.h"
slouken@281
    38
#include "SDL_gemvideo.h"
slouken@281
    39
#include "SDL_gemevents_c.h"
patmandin@5649
    40
#include "SDL_gemmouse_c.h"
patmandin@1412
    41
#include "../ataricommon/SDL_atarikeys.h"	/* for keyboard scancodes */
patmandin@1412
    42
#include "../ataricommon/SDL_atarievents_c.h"
patmandin@1412
    43
#include "../ataricommon/SDL_xbiosevents_c.h"
patmandin@1420
    44
#include "../ataricommon/SDL_ataridevmouse_c.h"
slouken@281
    45
patmandin@9042
    46
/* Duration after which we consider key released */
patmandin@9042
    47
patmandin@9042
    48
#define KEY_PRESS_DURATION 100
patmandin@9042
    49
patmandin@9132
    50
#define MSG_SDL_ID	(('S'<<8)|'D')
patmandin@9132
    51
slouken@281
    52
/* Variables */
slouken@281
    53
slouken@281
    54
static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS];
slouken@281
    55
static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];
patmandin@9042
    56
static Uint32 keyboard_ticks[ATARIBIOS_MAXKEYS];
slouken@281
    57
patmandin@6647
    58
static short prevmx=0,prevmy=0,prevmb=0;
patmandin@9132
    59
static short dummy_msgbuf[8] = {MSG_SDL_ID,0,0,0, 0,0,0,0};
patmandin@6647
    60
slouken@281
    61
/* Functions prototypes */
slouken@281
    62
patmandin@9132
    63
static int do_messages(_THIS, short *message, short latest_msg_id);
patmandin@9042
    64
static void do_keyboard(short kc, Uint32 tick);
patmandin@9042
    65
static void do_keyboard_special(short ks, Uint32 tick);
patmandin@6583
    66
static void do_mouse_motion(_THIS, short mx, short my);
patmandin@6583
    67
static void do_mouse_buttons(_THIS, short mb);
patmandin@6585
    68
static int mouse_in_work_area(int winhandle, short mx, short my);
patmandin@9042
    69
static void clearKeyboardState(Uint32 tick);
slouken@281
    70
slouken@281
    71
/* Functions */
slouken@281
    72
slouken@281
    73
void GEM_InitOSKeymap(_THIS)
slouken@281
    74
{
slouken@1336
    75
	SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
slouken@1336
    76
	SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard));
patmandin@9042
    77
	SDL_memset(keyboard_ticks, 0, sizeof(keyboard_ticks));
slouken@281
    78
slouken@281
    79
	/* Mouse init */
slouken@281
    80
	GEM_mouse_relative = SDL_FALSE;
patmandin@3861
    81
patmandin@3861
    82
	SDL_Atari_InitInternalKeymap(this);
slouken@281
    83
}
slouken@281
    84
slouken@281
    85
void GEM_PumpEvents(_THIS)
slouken@281
    86
{
patmandin@6647
    87
	short prevkc=0, mousex, mousey, mouseb, kstate;
patmandin@9132
    88
	int i, quit = 0;
patmandin@6647
    89
	SDL_keysym keysym;
patmandin@9042
    90
	Uint32 cur_tick;
patmandin@9132
    91
	static Uint32 prev_now = 0, prev_msg = 0;
patmandin@9132
    92
	static short latest_msg_id = 0;
slouken@281
    93
patmandin@9042
    94
	cur_tick = SDL_GetTicks();
patmandin@9132
    95
	if (prev_now == cur_tick) {
patmandin@9132
    96
		return;
patmandin@9132
    97
	}
patmandin@9132
    98
	prev_now = cur_tick;
patmandin@9132
    99
patmandin@9132
   100
	SDL_AtariMint_BackgroundTasks();
patmandin@9042
   101
	clearKeyboardState(cur_tick);
patmandin@4564
   102
patmandin@9132
   103
	if (prev_msg) {
patmandin@9132
   104
		/* Wait at least 20ms before each event processing loop */
patmandin@9132
   105
		if (cur_tick-prev_msg < 20) {
patmandin@9132
   106
			return;
patmandin@9132
   107
		}
patmandin@9132
   108
	}
patmandin@9132
   109
	prev_msg = cur_tick;
patmandin@9132
   110
patmandin@9132
   111
	dummy_msgbuf[1] = ++latest_msg_id;
patmandin@9132
   112
	if (appl_write(GEM_ap_id, sizeof(dummy_msgbuf), dummy_msgbuf) == 0) {
patmandin@9132
   113
		/* If it fails, wait for previous id */
patmandin@9132
   114
		--latest_msg_id;
patmandin@9132
   115
	}
patmandin@9132
   116
patmandin@9132
   117
	while (!quit) {
patmandin@9132
   118
		int resultat;
patmandin@6647
   119
		short buffer[8], kc, dummy;
slouken@281
   120
slouken@281
   121
		resultat = evnt_multi(
patmandin@6649
   122
			MU_MESAG|MU_TIMER|MU_KEYBD,
patmandin@6649
   123
			0,0,0,
patmandin@6649
   124
			0,0,0,0,0,
patmandin@1089
   125
			0,0,0,0,0,
slouken@281
   126
			buffer,
patmandin@9132
   127
			1000,
patmandin@6649
   128
			&dummy,&dummy,&dummy,&kstate,&kc,&dummy
slouken@281
   129
		);
slouken@281
   130
slouken@281
   131
		/* Message event ? */
slouken@281
   132
		if (resultat & MU_MESAG)
patmandin@9132
   133
			quit = do_messages(this, buffer, latest_msg_id);
slouken@281
   134
slouken@281
   135
		/* Keyboard event ? */
slouken@319
   136
		if (resultat & MU_KEYBD) {
patmandin@9042
   137
			do_keyboard_special(kstate, cur_tick);
patmandin@6582
   138
			if (prevkc != kc) {
patmandin@9042
   139
				do_keyboard(kc, cur_tick);
patmandin@6572
   140
				prevkc = kc;
slouken@319
   141
			}
slouken@319
   142
		}
slouken@281
   143
patmandin@9132
   144
		/* Timer event ? Just used as a safeguard */
patmandin@9132
   145
		if (resultat & MU_TIMER) {
patmandin@9132
   146
			quit = 1;
patmandin@9132
   147
		}
slouken@281
   148
	}
slouken@281
   149
patmandin@9130
   150
	GEM_CheckMouseMode(this);
patmandin@9130
   151
patmandin@6649
   152
	/* Update mouse state */
patmandin@6649
   153
	graf_mkstate(&mousex, &mousey, &mouseb, &kstate);
patmandin@9042
   154
	do_keyboard_special(kstate, cur_tick);
patmandin@6649
   155
	do_mouse_motion(this, mousex, mousey);
patmandin@6649
   156
	do_mouse_buttons(this, mouseb);
patmandin@6649
   157
slouken@319
   158
	/* Now generate keyboard events */
slouken@281
   159
	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
slouken@281
   160
		/* Key pressed ? */
slouken@281
   161
		if (gem_currentkeyboard[i] && !gem_previouskeyboard[i])
patmandin@1209
   162
			SDL_PrivateKeyboard(SDL_PRESSED,
patmandin@3861
   163
				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
patmandin@11554
   164
slouken@281
   165
		/* Key unpressed ? */
slouken@281
   166
		if (gem_previouskeyboard[i] && !gem_currentkeyboard[i])
patmandin@1209
   167
			SDL_PrivateKeyboard(SDL_RELEASED,
patmandin@3861
   168
				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
slouken@281
   169
	}
slouken@281
   170
slouken@1336
   171
	SDL_memcpy(gem_previouskeyboard,gem_currentkeyboard,sizeof(gem_previouskeyboard));
patmandin@996
   172
patmandin@996
   173
	/* Refresh window name ? */
patmandin@996
   174
	if (GEM_refresh_name) {
patmandin@4059
   175
		const char *window_name =
patmandin@4059
   176
			(SDL_GetAppState() & SDL_APPACTIVE)
patmandin@4059
   177
			? GEM_title_name : GEM_icon_name;
patmandin@4059
   178
		if (window_name) {
patmandin@4059
   179
			wind_set(GEM_handle,WF_NAME,
patmandin@4059
   180
				(short)(((unsigned long)window_name)>>16),
patmandin@4059
   181
				(short)(((unsigned long)window_name) & 0xffff),
patmandin@4059
   182
				0,0);
patmandin@996
   183
		}
patmandin@996
   184
		GEM_refresh_name = SDL_FALSE;
patmandin@996
   185
	}
slouken@281
   186
}
slouken@281
   187
patmandin@9132
   188
static int do_messages(_THIS, short *message, short latest_msg_id)
slouken@281
   189
{
patmandin@11569
   190
	int quit, update_work_area, sdl_resize;
slouken@281
   191
patmandin@11569
   192
	quit = update_work_area = sdl_resize = 0;
slouken@281
   193
	switch (message[0]) {
patmandin@9132
   194
		case MSG_SDL_ID:
patmandin@9132
   195
			quit=(message[1] == latest_msg_id);
patmandin@9132
   196
			break;
slouken@281
   197
		case WM_CLOSED:
patmandin@11554
   198
		case AP_TERM:
patmandin@5867
   199
			SDL_PrivateQuit();
slouken@281
   200
			quit=1;
slouken@281
   201
			break;
slouken@281
   202
		case WM_MOVED:
slouken@281
   203
			wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]);
patmandin@11561
   204
			update_work_area = 1;
slouken@281
   205
			break;
slouken@281
   206
		case WM_TOPPED:
slouken@281
   207
			wind_set(message[3],WF_TOP,message[4],0,0,0);
patmandin@1091
   208
			/* Continue with TOP event processing */
patmandin@1091
   209
		case WM_ONTOP:
slouken@281
   210
			SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
patmandin@11608
   211
			VDI_setpalette(this, VDI_curpalette);
slouken@281
   212
			break;
slouken@281
   213
		case WM_REDRAW:
patmandin@964
   214
			if (!GEM_lock_redraw) {
patmandin@11576
   215
				GEM_wind_redraw(this, message[3], &message[4], SDL_FALSE);
patmandin@964
   216
			}
slouken@281
   217
			break;
slouken@281
   218
		case WM_ICONIFY:
slouken@281
   219
		case WM_ALLICONIFY:
patmandin@11555
   220
			wind_set (message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]);
slouken@281
   221
			/* If we're active, make ourselves inactive */
slouken@281
   222
			if ( SDL_GetAppState() & SDL_APPACTIVE ) {
slouken@281
   223
				/* Send an internal deactivate event */
patmandin@1088
   224
				SDL_PrivateAppActive(0, SDL_APPACTIVE);
slouken@281
   225
			}
patmandin@736
   226
			/* Update window title */
patmandin@736
   227
			if (GEM_refresh_name && GEM_icon_name) {
patmandin@11554
   228
				wind_set(GEM_handle,WF_NAME,
patmandin@11554
   229
					(short)(((unsigned long)GEM_icon_name)>>16),
patmandin@11554
   230
					(short)(((unsigned long)GEM_icon_name) & 0xffff),
patmandin@11554
   231
					0,0);
patmandin@736
   232
				GEM_refresh_name = SDL_FALSE;
patmandin@736
   233
			}
patmandin@11568
   234
			GEM_iconified = SDL_TRUE;
patmandin@11568
   235
			update_work_area = 1;
slouken@281
   236
			break;
slouken@281
   237
		case WM_UNICONIFY:
patmandin@11555
   238
			wind_set (message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
slouken@281
   239
			/* If we're not active, make ourselves active */
slouken@281
   240
			if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) {
slouken@281
   241
				/* Send an internal activate event */
slouken@281
   242
				SDL_PrivateAppActive(1, SDL_APPACTIVE);
slouken@281
   243
			}
patmandin@736
   244
			if (GEM_refresh_name && GEM_title_name) {
patmandin@11554
   245
				wind_set(GEM_handle,WF_NAME,
patmandin@11554
   246
					(short)(((unsigned long)GEM_title_name)>>16),
patmandin@11554
   247
					(short)(((unsigned long)GEM_title_name) & 0xffff),
patmandin@11554
   248
					0,0);
patmandin@736
   249
				GEM_refresh_name = SDL_FALSE;
patmandin@736
   250
			}
patmandin@11568
   251
			GEM_iconified = SDL_FALSE;
patmandin@11561
   252
			update_work_area = 1;
slouken@281
   253
			break;
slouken@281
   254
		case WM_SIZED:
slouken@281
   255
			wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
patmandin@11561
   256
			update_work_area = sdl_resize = 1;
slouken@281
   257
			GEM_win_fulled = SDL_FALSE;		/* Cancel maximized flag */
patmandin@964
   258
			GEM_lock_redraw = SDL_TRUE;		/* Prevent redraw till buffers resized */
slouken@281
   259
			break;
slouken@281
   260
		case WM_FULLED:
slouken@281
   261
			{
slouken@281
   262
				short x,y,w,h;
slouken@281
   263
slouken@281
   264
				if (GEM_win_fulled) {
slouken@281
   265
					wind_get (message[3], WF_PREVXYWH, &x, &y, &w, &h);
slouken@281
   266
					GEM_win_fulled = SDL_FALSE;
slouken@281
   267
				} else {
slouken@281
   268
					x = GEM_desk_x;
slouken@281
   269
					y = GEM_desk_y;
slouken@281
   270
					w = GEM_desk_w;
slouken@281
   271
					h = GEM_desk_h;
slouken@281
   272
					GEM_win_fulled = SDL_TRUE;
slouken@281
   273
				}
slouken@281
   274
				wind_set (message[3], WF_CURRXYWH, x, y, w, h);
patmandin@11561
   275
				update_work_area = sdl_resize = 1;
patmandin@964
   276
				GEM_lock_redraw = SDL_TRUE;		/* Prevent redraw till buffers resized */
slouken@281
   277
			}
slouken@281
   278
			break;
slouken@281
   279
		case WM_BOTTOMED:
patmandin@1091
   280
			wind_set(message[3],WF_BOTTOM,0,0,0,0);
patmandin@1091
   281
			/* Continue with BOTTOM event processing */
slouken@281
   282
		case WM_UNTOPPED:
slouken@281
   283
			SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
patmandin@11608
   284
			VDI_setpalette(this, VDI_oldpalette);
slouken@281
   285
			break;
slouken@281
   286
	}
patmandin@11554
   287
patmandin@11557
   288
	if (update_work_area) {
patmandin@11576
   289
		GEM_align_work_area(this, message[3], SDL_TRUE);
patmandin@11559
   290
patmandin@11557
   291
		if (sdl_resize) {
patmandin@11557
   292
			SDL_PrivateResize(GEM_work_w, GEM_work_h);
patmandin@11557
   293
		}
patmandin@11557
   294
	}
patmandin@11557
   295
slouken@281
   296
	return quit;
slouken@281
   297
}
slouken@281
   298
patmandin@9042
   299
static void do_keyboard(short kc, Uint32 tick)
slouken@281
   300
{
patmandin@3861
   301
	int scancode;
slouken@281
   302
slouken@281
   303
	if (kc) {
patmandin@3861
   304
		scancode=(kc>>8) & (ATARIBIOS_MAXKEYS-1);
slouken@281
   305
		gem_currentkeyboard[scancode]=0xFF;
patmandin@9042
   306
		keyboard_ticks[scancode]=tick;
slouken@281
   307
	}
patmandin@6582
   308
}
slouken@281
   309
patmandin@9042
   310
static void do_keyboard_special(short ks, Uint32 tick)
patmandin@6582
   311
{
patmandin@9042
   312
	int scancode=0;
patmandin@9042
   313
slouken@281
   314
	/* Read special keys */
slouken@281
   315
	if (ks & K_RSHIFT)
patmandin@9042
   316
		scancode=SCANCODE_RIGHTSHIFT;
slouken@281
   317
	if (ks & K_LSHIFT)
patmandin@9042
   318
		scancode=SCANCODE_LEFTSHIFT;
slouken@281
   319
	if (ks & K_CTRL)
patmandin@9042
   320
		scancode=SCANCODE_LEFTCONTROL;
slouken@281
   321
	if (ks & K_ALT)
patmandin@9042
   322
		scancode=SCANCODE_LEFTALT;
patmandin@9042
   323
patmandin@9042
   324
	if (scancode) {
patmandin@9042
   325
		gem_currentkeyboard[scancode]=0xFF;
patmandin@9042
   326
		keyboard_ticks[scancode]=tick;
patmandin@9042
   327
	}
slouken@281
   328
}
slouken@281
   329
patmandin@6583
   330
static void do_mouse_motion(_THIS, short mx, short my)
slouken@281
   331
{
patmandin@926
   332
	short x2, y2, w2, h2;
patmandin@926
   333
patmandin@6648
   334
	if (this->input_grab == SDL_GRAB_OFF) {
patmandin@6648
   335
		/* Switch mouse focus state */
patmandin@6648
   336
		if (!GEM_fullscreen && (GEM_handle>=0)) {
patmandin@6648
   337
			SDL_PrivateAppActive(
patmandin@6648
   338
				mouse_in_work_area(GEM_handle, mx,my),
patmandin@6648
   339
				SDL_APPMOUSEFOCUS);
patmandin@6648
   340
		}
patmandin@6648
   341
	}
patmandin@6648
   342
	GEM_CheckMouseMode(this);
patmandin@6648
   343
patmandin@1067
   344
	/* Don't return mouse events if out of window */
patmandin@1067
   345
	if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)==0) {
patmandin@1067
   346
		return;
patmandin@1067
   347
	}
patmandin@1067
   348
patmandin@6584
   349
	/* Relative mouse motion ? */
patmandin@6584
   350
	if (GEM_mouse_relative) {
patmandin@6584
   351
		if (GEM_usedevmouse) {
patmandin@6584
   352
			SDL_AtariDevMouse_PostMouseEvents(this, SDL_FALSE);
patmandin@6584
   353
		} else {
patmandin@6584
   354
			SDL_AtariXbios_PostMouseEvents(this, SDL_FALSE);
patmandin@6584
   355
		}
patmandin@6584
   356
		return;
patmandin@6584
   357
	}
patmandin@6584
   358
patmandin@926
   359
	/* Retrieve window coords, and generate mouse events accordingly */
patmandin@926
   360
	x2 = y2 = 0;
patmandin@928
   361
	w2 = VDI_w;
patmandin@928
   362
	h2 = VDI_h;
patmandin@926
   363
	if ((!GEM_fullscreen) && (GEM_handle>=0)) {
patmandin@11558
   364
		x2 = GEM_work_x;
patmandin@11558
   365
		y2 = GEM_work_y;
patmandin@11558
   366
		w2 = GEM_work_w;
patmandin@11558
   367
		h2 = GEM_work_h;
patmandin@926
   368
	}
slouken@319
   369
patmandin@6647
   370
	if ((prevmx!=mx) || (prevmy!=my)) {
patmandin@6584
   371
		int posx, posy;
patmandin@926
   372
patmandin@6584
   373
		/* Give mouse position relative to window position */
patmandin@6584
   374
		posx = mx - x2;
patmandin@6584
   375
		if (posx<0) posx = 0;
patmandin@6584
   376
		if (posx>w2) posx = w2-1;
patmandin@6584
   377
		posy = my - y2;
patmandin@6584
   378
		if (posy<0) posy = 0;
patmandin@6584
   379
		if (posy>h2) posy = h2-1;
patmandin@926
   380
patmandin@6584
   381
		SDL_PrivateMouseMotion(0, 0, posx, posy);
slouken@281
   382
	}
patmandin@6647
   383
patmandin@6647
   384
	prevmx = mx;
patmandin@6647
   385
	prevmy = my;
patmandin@6583
   386
}
slouken@281
   387
patmandin@6583
   388
static void do_mouse_buttons(_THIS, short mb)
patmandin@6583
   389
{
patmandin@6583
   390
	int i;
slouken@281
   391
patmandin@6583
   392
	/* Don't return mouse events if out of window */
patmandin@6583
   393
	if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)==0)
patmandin@6583
   394
		return;
patmandin@6583
   395
patmandin@6647
   396
	if (prevmb==mb)
patmandin@6583
   397
		return;
patmandin@6583
   398
patmandin@6583
   399
	for (i=0;i<3;i++) {
patmandin@6583
   400
		int curbutton, prevbutton;
patmandin@11554
   401
patmandin@6583
   402
		curbutton = mb & (1<<i);
patmandin@6647
   403
		prevbutton = prevmb & (1<<i);
patmandin@11554
   404
patmandin@6583
   405
		if (curbutton && !prevbutton) {
patmandin@6583
   406
			SDL_PrivateMouseButton(SDL_PRESSED, i+1, 0, 0);
slouken@281
   407
		}
patmandin@6583
   408
		if (!curbutton && prevbutton) {
patmandin@6583
   409
			SDL_PrivateMouseButton(SDL_RELEASED, i+1, 0, 0);
patmandin@6583
   410
		}
slouken@281
   411
	}
patmandin@6583
   412
patmandin@6647
   413
	prevmb = mb;
slouken@281
   414
}
patmandin@6585
   415
patmandin@6585
   416
/* Check if mouse in visible area of the window */
patmandin@6585
   417
static int mouse_in_work_area(int winhandle, short mx, short my)
patmandin@6585
   418
{
patmandin@6585
   419
	short todo[4];
patmandin@6585
   420
	short inside[4] = {mx,my,1,1};
patmandin@6585
   421
patmandin@6585
   422
	/* Browse the rectangle list */
patmandin@6585
   423
	if (wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])!=0) {
patmandin@6585
   424
		while (todo[2] && todo[3]) {
patmandin@6585
   425
			if (rc_intersect((GRECT *)inside,(GRECT *)todo)) {
patmandin@6585
   426
				return 1;
patmandin@6585
   427
			}
patmandin@6585
   428
patmandin@6585
   429
			if (wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])==0) {
patmandin@6585
   430
				break;
patmandin@6585
   431
			}
patmandin@6585
   432
		}
patmandin@6585
   433
patmandin@6585
   434
	}
patmandin@6585
   435
patmandin@6585
   436
	return 0;
patmandin@6585
   437
}
patmandin@9042
   438
patmandin@9042
   439
/* Clear key state for which we did not receive events for a while */
patmandin@9042
   440
patmandin@9042
   441
static void clearKeyboardState(Uint32 tick)
patmandin@9042
   442
{
patmandin@9042
   443
	int i;
patmandin@9042
   444
patmandin@9042
   445
	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
patmandin@9042
   446
		if (keyboard_ticks[i]) {
patmandin@9042
   447
			if (tick-keyboard_ticks[i] > KEY_PRESS_DURATION) {
patmandin@9042
   448
				gem_currentkeyboard[i]=0;
patmandin@9042
   449
				keyboard_ticks[i]=0;
patmandin@9042
   450
			}
patmandin@9042
   451
		}
patmandin@9042
   452
	}
patmandin@9042
   453
}