src/video/qtopia/SDL_sysevents.cc
author Ozkan Sezer <sezeroz@gmail.com>
Sun, 14 Oct 2018 15:25:04 +0300
branchSDL-1.2
changeset 12325 c4f2eeda176f
parent 6137 4720145f848b
permissions -rw-r--r--
remove symlink for libSDL-1.0.so.0 from the rpm spec file.

also fix a changelog date.
slouken@371
     1
/*
slouken@371
     2
    SDL - Simple DirectMedia Layer
slouken@6137
     3
    Copyright (C) 1997-2012 Sam Lantinga
slouken@371
     4
slouken@371
     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@371
     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@371
     9
slouken@371
    10
    This library is distributed in the hope that it will be useful,
slouken@371
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@371
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@371
    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@371
    18
slouken@371
    19
    Sam Lantinga
slouken@371
    20
    slouken@libsdl.org
slouken@371
    21
*/
slouken@1403
    22
#include "SDL_config.h"
slouken@371
    23
slouken@371
    24
#include <qpe/qpeapplication.h>
slouken@371
    25
slouken@371
    26
#include <stdio.h>
slouken@371
    27
#include <string.h>
slouken@371
    28
#include "SDL_error.h"
slouken@371
    29
#include "SDL_events.h"
slouken@371
    30
#include "SDL_QWin.h"
slouken@371
    31
#include "SDL_lowvideo.h"
slouken@371
    32
#include "SDL_timer.h"
slouken@371
    33
slouken@371
    34
extern "C" {
slouken@1361
    35
#include "../../events/SDL_sysevents.h"
slouken@1361
    36
#include "../../events/SDL_events_c.h"
slouken@371
    37
#include "SDL_sysevents_c.h"
slouken@371
    38
slouken@371
    39
  //  static SDLKey keymap[128];
slouken@371
    40
/* This is special because we know it will be run in a loop in a separate
slouken@371
    41
   thread.  Normally this function should loop as long as there are input
slouken@371
    42
   states changing, i.e. new events arriving.
slouken@371
    43
*/
slouken@371
    44
void QT_PumpEvents(_THIS)
slouken@371
    45
{
slouken@371
    46
  if(!qApp) {
slouken@371
    47
    return; 
slouken@371
    48
  }
slouken@371
    49
  //  printf("processing events: %p\n", qApp);
slouken@371
    50
  //qApp->processOneEvent(); // wait for a event
slouken@371
    51
  qApp->processEvents(); // and process all outstanding ones
slouken@371
    52
#if 0
slouken@371
    53
  BView *view;
slouken@371
    54
	BRect bounds;
slouken@371
    55
	BPoint point;
slouken@371
    56
	uint32 buttons;
slouken@371
    57
	const uint32 button_masks[3] = {
slouken@371
    58
		B_PRIMARY_MOUSE_BUTTON,
slouken@371
    59
		B_TERTIARY_MOUSE_BUTTON, 
slouken@371
    60
		B_SECONDARY_MOUSE_BUTTON,
slouken@371
    61
	};
slouken@371
    62
	unsigned int    i, j;
slouken@371
    63
slouken@371
    64
	/* Check out the mouse buttons and position (slight race condition) */
slouken@371
    65
	if ( SDL_Win->Lock() ) {
slouken@371
    66
		/* Don't do anything if we have no view */
slouken@371
    67
		view = SDL_Win->View();
slouken@371
    68
		if ( ! view ) {
slouken@371
    69
			SDL_Win->Unlock();
slouken@371
    70
			return;
slouken@371
    71
		}
slouken@371
    72
		bounds = view->Bounds();
slouken@371
    73
		/* Get new input state, if still active */
slouken@371
    74
		if ( SDL_Win->IsActive() ) {
slouken@371
    75
			key_flip = !key_flip;
slouken@371
    76
			get_key_info(&keyinfo[key_flip]);
slouken@371
    77
			view->GetMouse(&point, &buttons, true);
slouken@371
    78
		} else {
slouken@371
    79
			key_flip = key_flip;
slouken@371
    80
			point = last_point;
slouken@371
    81
			buttons = last_buttons;
slouken@371
    82
		}
slouken@371
    83
		SDL_Win->Unlock();
slouken@371
    84
	} else {
slouken@371
    85
		return;
slouken@371
    86
	}
slouken@371
    87
slouken@371
    88
	/* If our view is active, we'll find key changes here */
slouken@1336
    89
	if ( SDL_memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0 ) {
slouken@371
    90
		for ( i=0; i<16; ++i ) {
slouken@371
    91
			Uint8 new_state, transition;
slouken@371
    92
slouken@371
    93
			new_state = keyinfo[key_flip].key_states[i];
slouken@371
    94
			transition = keyinfo[!key_flip].key_states[i] ^
slouken@371
    95
					keyinfo[ key_flip].key_states[i];
slouken@371
    96
			for ( j=0; j<8; ++j ) {
slouken@371
    97
				if ( transition&0x80 )
slouken@371
    98
					QueueKey(i*8+j, new_state&0x80);
slouken@371
    99
				transition <<= 1;
slouken@371
   100
				new_state <<= 1;
slouken@371
   101
			}
slouken@371
   102
		}
slouken@371
   103
	}
slouken@371
   104
slouken@371
   105
	/* We check keyboard, but not mouse if mouse isn't in window */
slouken@371
   106
	if ( ! bounds.Contains(point) ) {
slouken@371
   107
		/* Mouse moved outside our view? */
slouken@371
   108
		if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
slouken@371
   109
			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
slouken@371
   110
			be_app->SetCursor(B_HAND_CURSOR);
slouken@371
   111
		}
slouken@371
   112
		return;
slouken@371
   113
	}
slouken@371
   114
	/* Has the mouse moved back into our view? */
slouken@371
   115
	if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
slouken@371
   116
		/* Reset the B_HAND_CURSOR to our own */
slouken@371
   117
		SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
slouken@371
   118
		SDL_SetCursor(NULL);
slouken@371
   119
	}
slouken@371
   120
slouken@371
   121
	/* Check for mouse motion */
slouken@371
   122
	if ( point != last_point ) {
slouken@371
   123
		int x, y;
slouken@371
   124
slouken@371
   125
		SDL_Win->GetXYOffset(x, y);
slouken@371
   126
		x = (int)point.x - x;
slouken@371
   127
		y = (int)point.y - y;
slouken@371
   128
		SDL_PrivateMouseMotion(0, 0, x, y);
slouken@371
   129
	}
slouken@371
   130
	last_point = point;
slouken@371
   131
slouken@371
   132
	/* Add any mouse button events */
slouken@371
   133
	for ( i=0; i<SDL_TABLESIZE(button_masks); ++i ) {
slouken@371
   134
		if ( (buttons ^ last_buttons) & button_masks[i] ) {
slouken@371
   135
			if ( buttons & button_masks[i] ) {
slouken@371
   136
				SDL_PrivateMouseButton(SDL_PRESSED, 1+i, 0, 0);
slouken@371
   137
			} else {
slouken@371
   138
				SDL_PrivateMouseButton(SDL_RELEASED, 1+i, 0, 0);
slouken@371
   139
			}
slouken@371
   140
		}
slouken@371
   141
	}
slouken@371
   142
	last_buttons = buttons;
slouken@371
   143
#endif
slouken@371
   144
}
slouken@371
   145
slouken@371
   146
void QT_InitOSKeymap(_THIS)
slouken@371
   147
{
slouken@371
   148
#if 0
slouken@371
   149
  unsigned int i;
slouken@371
   150
slouken@371
   151
  /* Initialize all the key states as "up" */
slouken@371
   152
  key_flip = 0;
slouken@1336
   153
  SDL_memset(keyinfo[key_flip].key_states, 0, 16);
slouken@371
   154
slouken@371
   155
  /* Initialize the key translation table */
slouken@371
   156
  for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
slouken@371
   157
    keymap[i] = SDLK_UNKNOWN;
slouken@371
   158
slouken@371
   159
  //  keymap[0x01]		= SDLK_ESCAPE;
slouken@371
   160
  //  keymap[B_F1_KEY]	= SDLK_F1;
slouken@371
   161
  //  keymap[B_F2_KEY]	= SDLK_F2;
slouken@371
   162
  //  keymap[B_F3_KEY]	= SDLK_F3;
slouken@371
   163
  //  keymap[B_F4_KEY]	= SDLK_F4;
slouken@371
   164
  //  keymap[B_F5_KEY]	= SDLK_F5;
slouken@371
   165
  //  keymap[B_F6_KEY]	= SDLK_F6;
slouken@371
   166
  //  keymap[B_F7_KEY]	= SDLK_F7;
slouken@371
   167
  //  keymap[B_F8_KEY]	= SDLK_F8;
slouken@371
   168
  //  keymap[B_F9_KEY]	= SDLK_F9;
slouken@371
   169
  //  keymap[B_F10_KEY]	= SDLK_F10;
slouken@371
   170
  //  keymap[B_F11_KEY]	= SDLK_F11;
slouken@371
   171
  //  keymap[B_F12_KEY]	= SDLK_F12;
slouken@371
   172
  //  keymap[B_PRINT_KEY]	= SDLK_PRINT;
slouken@371
   173
  //keymap[B_SCROLL_KEY]	= SDLK_SCROLLOCK;
slouken@371
   174
  //  keymap[B_PAUSE_KEY]	= SDLK_PAUSE;
slouken@371
   175
  keymap[0x11]		= SDLK_BACKQUOTE;
slouken@371
   176
  keymap[0x12]		= SDLK_1;
slouken@371
   177
  keymap[0x13]		= SDLK_2;
slouken@371
   178
  keymap[0x14]		= SDLK_3;
slouken@371
   179
  keymap[0x15]		= SDLK_4;
slouken@371
   180
  keymap[0x16]		= SDLK_5;
slouken@371
   181
  keymap[0x17]		= SDLK_6;
slouken@371
   182
  keymap[0x18]		= SDLK_7;
slouken@371
   183
  keymap[0x19]		= SDLK_8;
slouken@371
   184
  keymap[0x1a]		= SDLK_9;
slouken@371
   185
  keymap[0x1b]		= SDLK_0;
slouken@371
   186
  keymap[0x1c]		= SDLK_MINUS;
slouken@371
   187
  keymap[0x1d]		= SDLK_EQUALS;
slouken@371
   188
  keymap[0x1e]		= SDLK_BACKSPACE;
slouken@371
   189
  keymap[0x1f]		= SDLK_INSERT;
slouken@371
   190
  keymap[0x20]		= SDLK_HOME;
slouken@371
   191
  keymap[0x21]		= SDLK_PAGEUP;
slouken@371
   192
  //keymap[0x22]		= SDLK_NUMLOCK;
slouken@371
   193
  keymap[0x23]		= SDLK_KP_DIVIDE;
slouken@371
   194
  keymap[0x24]		= SDLK_KP_MULTIPLY;
slouken@371
   195
  keymap[0x25]		= SDLK_KP_MINUS;
slouken@371
   196
  keymap[0x26]		= SDLK_TAB;
slouken@371
   197
  keymap[0x27]		= SDLK_q;
slouken@371
   198
  keymap[0x28]		= SDLK_w;
slouken@371
   199
  keymap[0x29]		= SDLK_e;
slouken@371
   200
  keymap[0x2a]		= SDLK_r;
slouken@371
   201
  keymap[0x2b]		= SDLK_t;
slouken@371
   202
  keymap[0x2c]		= SDLK_y;
slouken@371
   203
  keymap[0x2d]		= SDLK_u;
slouken@371
   204
  keymap[0x2e]		= SDLK_i;
slouken@371
   205
  keymap[0x2f]		= SDLK_o;
slouken@371
   206
  keymap[0x30]		= SDLK_p;
slouken@371
   207
  keymap[0x31]		= SDLK_LEFTBRACKET;
slouken@371
   208
  keymap[0x32]		= SDLK_RIGHTBRACKET;
slouken@371
   209
  keymap[0x33]		= SDLK_BACKSLASH;
slouken@371
   210
  keymap[0x34]		= SDLK_DELETE;
slouken@371
   211
  keymap[0x35]		= SDLK_END;
slouken@371
   212
  keymap[0x36]		= SDLK_PAGEDOWN;
slouken@371
   213
  keymap[0x37]		= SDLK_KP7;
slouken@371
   214
  keymap[0x38]		= SDLK_KP8;
slouken@371
   215
  keymap[0x39]		= SDLK_KP9;
slouken@371
   216
  keymap[0x3a]		= SDLK_KP_PLUS;
slouken@371
   217
  //keymap[0x3b]		= SDLK_CAPSLOCK;
slouken@371
   218
  keymap[0x3c]		= SDLK_a;
slouken@371
   219
  keymap[0x3d]		= SDLK_s;
slouken@371
   220
  keymap[0x3e]		= SDLK_d;
slouken@371
   221
  keymap[0x3f]		= SDLK_f;
slouken@371
   222
  keymap[0x40]		= SDLK_g;
slouken@371
   223
  keymap[0x41]		= SDLK_h;
slouken@371
   224
  keymap[0x42]		= SDLK_j;
slouken@371
   225
  keymap[0x43]		= SDLK_k;
slouken@371
   226
  keymap[0x44]		= SDLK_l;
slouken@371
   227
  keymap[0x45]		= SDLK_SEMICOLON;
slouken@371
   228
  keymap[0x46]		= SDLK_QUOTE;
slouken@371
   229
  keymap[0x47]		= SDLK_RETURN;
slouken@371
   230
  keymap[0x48]		= SDLK_KP4;
slouken@371
   231
  keymap[0x49]		= SDLK_KP5;
slouken@371
   232
  keymap[0x4a]		= SDLK_KP6;
slouken@371
   233
  keymap[0x4b]		= SDLK_LSHIFT;
slouken@371
   234
  keymap[0x4c]		= SDLK_z;
slouken@371
   235
  keymap[0x4d]		= SDLK_x;
slouken@371
   236
  keymap[0x4e]		= SDLK_c;
slouken@371
   237
  keymap[0x4f]		= SDLK_v;
slouken@371
   238
  keymap[0x50]		= SDLK_b;
slouken@371
   239
  keymap[0x51]		= SDLK_n;
slouken@371
   240
  keymap[0x52]		= SDLK_m;
slouken@371
   241
  keymap[0x53]		= SDLK_COMMA;
slouken@371
   242
  keymap[0x54]		= SDLK_PERIOD;
slouken@371
   243
  keymap[0x55]		= SDLK_SLASH;
slouken@371
   244
  keymap[0x56]		= SDLK_RSHIFT;
slouken@371
   245
  keymap[0x57]		= SDLK_UP;
slouken@371
   246
  keymap[0x58]		= SDLK_KP1;
slouken@371
   247
  keymap[0x59]		= SDLK_KP2;
slouken@371
   248
  keymap[0x5a]		= SDLK_KP3;
slouken@371
   249
  keymap[0x5b]		= SDLK_KP_ENTER;
slouken@371
   250
  //keymap[0x5c]		= SDLK_LCTRL;
slouken@371
   251
  //keymap[0x5d]		= SDLK_LALT;
slouken@371
   252
  keymap[0x5e]		= SDLK_SPACE;
slouken@371
   253
  //keymap[0x5f]		= SDLK_RALT;
slouken@371
   254
  //keymap[0x60]		= SDLK_RCTRL;
slouken@371
   255
  keymap[0x61]		= SDLK_LEFT;
slouken@371
   256
  keymap[0x62]		= SDLK_DOWN;
slouken@371
   257
  keymap[0x63]		= SDLK_RIGHT;
slouken@371
   258
  keymap[0x64]		= SDLK_KP0;
slouken@371
   259
  keymap[0x65]		= SDLK_KP_PERIOD;
slouken@371
   260
  //keymap[0x66]		= SDLK_LMETA;
slouken@371
   261
  //keymap[0x67]		= SDLK_RMETA;
slouken@371
   262
  //keymap[0x68]		= SDLK_MENU;
slouken@371
   263
  keymap[0x69]		= SDLK_EURO;
slouken@371
   264
  keymap[0x6a]		= SDLK_KP_EQUALS;
slouken@371
   265
  keymap[0x6b]		= SDLK_POWER;
slouken@371
   266
#endif
slouken@371
   267
}
slouken@371
   268
slouken@371
   269
}; /* Extern C */