19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*
29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    SDL - Simple DirectMedia Layer
39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 1997-2012 Sam Lantinga
49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is free software; you can redistribute it and/or
69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    modify it under the terms of the GNU Lesser General Public
79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License as published by the Free Software Foundation; either
89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    version 2.1 of the License, or (at your option) any later version.
99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is distributed in the hope that it will be useful,
119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    but WITHOUT ANY WARRANTY; without even the implied warranty of
129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Lesser General Public License for more details.
149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    You should have received a copy of the GNU Lesser General Public
169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License along with this library; if not, write to the Free Software
179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Sam Lantinga
209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    slouken@libsdl.org
219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h"
239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <support/UTF8.h>
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdio.h>
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <string.h>
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_error.h"
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_events.h"
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_BWin.h"
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_lowvideo.h"
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDLKey keymap[128];
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint mouse_relative = 0;
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" {
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../../events/SDL_sysevents.h"
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../../events/SDL_events_c.h"
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_sysevents_c.h"
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_cursor_c.h"
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid BE_PumpEvents(_THIS)
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid BE_InitOSKeymap(_THIS)
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		for ( uint i=0; i<SDL_TABLESIZE(keymap); ++i )
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			keymap[i] = SDLK_UNKNOWN;
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x01]		= SDLK_ESCAPE;
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F1_KEY]	= SDLK_F1;
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F2_KEY]	= SDLK_F2;
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F3_KEY]	= SDLK_F3;
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F4_KEY]	= SDLK_F4;
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F5_KEY]	= SDLK_F5;
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F6_KEY]	= SDLK_F6;
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F7_KEY]	= SDLK_F7;
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F8_KEY]	= SDLK_F8;
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F9_KEY]	= SDLK_F9;
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F10_KEY]	= SDLK_F10;
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F11_KEY]	= SDLK_F11;
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_F12_KEY]	= SDLK_F12;
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_PRINT_KEY]	= SDLK_PRINT;
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_SCROLL_KEY]	= SDLK_SCROLLOCK;
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[B_PAUSE_KEY]	= SDLK_PAUSE;
669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x11]		= SDLK_BACKQUOTE;
679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x12]		= SDLK_1;
689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x13]		= SDLK_2;
699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x14]		= SDLK_3;
709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x15]		= SDLK_4;
719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x16]		= SDLK_5;
729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x17]		= SDLK_6;
739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x18]		= SDLK_7;
749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x19]		= SDLK_8;
759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x1a]		= SDLK_9;
769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x1b]		= SDLK_0;
779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x1c]		= SDLK_MINUS;
789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x1d]		= SDLK_EQUALS;
799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x1e]		= SDLK_BACKSPACE;
809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x1f]		= SDLK_INSERT;
819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x20]		= SDLK_HOME;
829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x21]		= SDLK_PAGEUP;
839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x22]		= SDLK_NUMLOCK;
849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x23]		= SDLK_KP_DIVIDE;
859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x24]		= SDLK_KP_MULTIPLY;
869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x25]		= SDLK_KP_MINUS;
879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x26]		= SDLK_TAB;
889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x27]		= SDLK_q;
899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x28]		= SDLK_w;
909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x29]		= SDLK_e;
919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x2a]		= SDLK_r;
929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x2b]		= SDLK_t;
939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x2c]		= SDLK_y;
949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x2d]		= SDLK_u;
959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x2e]		= SDLK_i;
969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x2f]		= SDLK_o;
979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x30]		= SDLK_p;
989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x31]		= SDLK_LEFTBRACKET;
999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x32]		= SDLK_RIGHTBRACKET;
1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x33]		= SDLK_BACKSLASH;
1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x34]		= SDLK_DELETE;
1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x35]		= SDLK_END;
1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x36]		= SDLK_PAGEDOWN;
1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x37]		= SDLK_KP7;
1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x38]		= SDLK_KP8;
1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x39]		= SDLK_KP9;
1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x3a]		= SDLK_KP_PLUS;
1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x3b]		= SDLK_CAPSLOCK;
1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x3c]		= SDLK_a;
1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x3d]		= SDLK_s;
1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x3e]		= SDLK_d;
1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x3f]		= SDLK_f;
1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x40]		= SDLK_g;
1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x41]		= SDLK_h;
1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x42]		= SDLK_j;
1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x43]		= SDLK_k;
1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x44]		= SDLK_l;
1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x45]		= SDLK_SEMICOLON;
1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x46]		= SDLK_QUOTE;
1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x47]		= SDLK_RETURN;
1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x48]		= SDLK_KP4;
1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x49]		= SDLK_KP5;
1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x4a]		= SDLK_KP6;
1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x4b]		= SDLK_LSHIFT;
1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x4c]		= SDLK_z;
1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x4d]		= SDLK_x;
1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x4e]		= SDLK_c;
1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x4f]		= SDLK_v;
1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x50]		= SDLK_b;
1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x51]		= SDLK_n;
1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x52]		= SDLK_m;
1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x53]		= SDLK_COMMA;
1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x54]		= SDLK_PERIOD;
1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x55]		= SDLK_SLASH;
1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x56]		= SDLK_RSHIFT;
1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x57]		= SDLK_UP;
1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x58]		= SDLK_KP1;
1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x59]		= SDLK_KP2;
1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x5a]		= SDLK_KP3;
1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x5b]		= SDLK_KP_ENTER;
1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x5c]		= SDLK_LCTRL;
1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x5d]		= SDLK_LALT;
1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x5e]		= SDLK_SPACE;
1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x5f]		= SDLK_RALT;
1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x60]		= SDLK_RCTRL;
1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x61]		= SDLK_LEFT;
1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x62]		= SDLK_DOWN;
1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x63]		= SDLK_RIGHT;
1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x64]		= SDLK_KP0;
1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x65]		= SDLK_KP_PERIOD;
1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x66]		= SDLK_LMETA;
1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x67]		= SDLK_RMETA;
1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x68]		= SDLK_MENU;
1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x69]		= SDLK_EURO;
1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x6a]		= SDLK_KP_EQUALS;
1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keymap[0x6b]		= SDLK_POWER;
1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; /* Extern C */
1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_BWin::DispatchMessage(BMessage *msg, BHandler *target)
1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	switch (msg->what) {
1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_MOUSE_MOVED:
1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		{
1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			SDL_VideoDevice *view = current_video;
1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			BPoint where;
1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int32 transit;
1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			if (msg->FindPoint("where", &where) == B_OK && msg->FindInt32("be:transit", &transit) == B_OK) {
1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				int x, y;
1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				GetXYOffset(x, y);
1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				x = (int)where.x - x;
1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				y = (int)where.y - y;
1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				//BeSman: I need another method for cursor catching !!!
1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (view->input_grab != SDL_GRAB_OFF)
1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				{
1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					bool clipped = false;
1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if ( x < 0 ) {
1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						x = 0;
1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						clipped = true;
1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					} else if ( x >= SDL_VideoSurface->w ) {
1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						x = (SDL_VideoSurface->w-1);
1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						clipped = true;
1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					}
1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if ( y < 0 ) {
1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						y = 0;
1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						clipped = true;
1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					} else if ( y >= SDL_VideoSurface->h ) {
1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						y = (SDL_VideoSurface->h-1);
1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						clipped = true;
1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					}
1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if ( clipped ) {
1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						BPoint edge;
1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						GetXYOffset(edge.x, edge.y);
1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						edge.x += x;
1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						edge.y += y;
1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						ConvertToScreen(&edge);
2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						set_mouse_position((int)edge.x, (int)edge.y);
2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					}
2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					transit = B_INSIDE_VIEW;
2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (transit == B_EXITED_VIEW) {
2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					// for some reason, SDL_EraseCursor fails for OpenGL
2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if (this->the_view != this->SDL_GLView)
2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							SDL_EraseCursor(SDL_VideoSurface);
2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						be_app->SetCursor(B_HAND_CURSOR);
2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					}
2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				} else {
2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if ( !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					// for some reason, SDL_EraseCursor fails for OpenGL
2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if (this->the_view != this->SDL_GLView)
2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							SDL_EraseCursor(SDL_VideoSurface);
2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						SDL_SetCursor(NULL);
2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					}
2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if ( mouse_relative ) {
2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						int half_w = (SDL_VideoSurface->w/2);
2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						int half_h = (SDL_VideoSurface->h/2);
2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						x -= half_w;
2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						y -= half_h;
2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						if ( x || y ) {
2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							BPoint center;
2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							GetXYOffset(center.x, center.y);
2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							center.x += half_w;
2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							center.y += half_h;
2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							ConvertToScreen(&center);
2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							set_mouse_position((int)center.x, (int)center.y);
2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							SDL_PrivateMouseMotion(0, 1, x, y);
2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						}
2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					} else {
2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						SDL_PrivateMouseMotion(0, 0, x, y);
2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					}
2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			}
2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			break;
2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_MOUSE_DOWN:
2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		{
2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			/*	it looks like mouse down is send only for first clicked
2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				button, each next is not send while last one is holded */
2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int32 buttons;
2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int sdl_buttons = 0;
2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			if (msg->FindInt32("buttons", &buttons) == B_OK) {
2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				/* Add any mouse button events */
2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (buttons & B_PRIMARY_MOUSE_BUTTON) {
2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					sdl_buttons |= SDL_BUTTON_LEFT;
2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (buttons & B_SECONDARY_MOUSE_BUTTON) {
2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					sdl_buttons |= SDL_BUTTON_RIGHT;
2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (buttons & B_TERTIARY_MOUSE_BUTTON) {
2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					sdl_buttons |= SDL_BUTTON_MIDDLE;
2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				SDL_PrivateMouseButton(SDL_PRESSED, sdl_buttons, 0, 0);
2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				last_buttons = buttons;
2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			}
2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			break;
2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_MOUSE_UP:
2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		{
2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			/*	mouse up doesn't give which button was released,
2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				only state of buttons (after release, so it's always = 0),
2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				which is not what we need ;]
2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				So we need to store button in mouse down, and restore
2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				in mouse up :(
2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				mouse up is (similarly to mouse down) send only for
2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				first button down (ie. it's no send if we click another button
2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				without releasing previous one first) - but that's probably
2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				because of how drivers are written?, not BeOS itself. */
2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int32 buttons;
2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int sdl_buttons = 0;
2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			if (msg->FindInt32("buttons", &buttons) == B_OK) {
2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				/* Add any mouse button events */
2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if ((buttons ^ B_PRIMARY_MOUSE_BUTTON) & last_buttons) {
2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					sdl_buttons |= SDL_BUTTON_LEFT;
2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if ((buttons ^ B_SECONDARY_MOUSE_BUTTON) & last_buttons) {
2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					sdl_buttons |= SDL_BUTTON_RIGHT;
2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if ((buttons ^ B_TERTIARY_MOUSE_BUTTON) & last_buttons) {
2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					sdl_buttons |= SDL_BUTTON_MIDDLE;
2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				SDL_PrivateMouseButton(SDL_RELEASED, sdl_buttons, 0, 0);
2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				last_buttons = buttons;
2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			}
2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			break;
3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_MOUSE_WHEEL_CHANGED:
3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		{
3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			float x, y;
3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			x = y = 0;
3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (x < 0 || y < 0) {
3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0);
3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0);
3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				} else if (x > 0 || y > 0) {
3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0);
3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0);
3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			}
3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			break;
3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_KEY_DOWN:
3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		{
3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int32 key;
3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int32 modifiers;
3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int32 key_repeat;
3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			/* Workaround for SDL message queue being filled too fast because of BeOS own key-repeat mechanism */
3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			if (msg->FindInt32("be:key_repeat", &key_repeat) == B_OK && key_repeat > 0)
3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				break;
3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) {
3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				SDL_keysym keysym;
3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				keysym.scancode = key;
3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (key < 128) {
3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					keysym.sym = keymap[key];
3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				} else {
3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					keysym.sym = SDLK_UNKNOWN;
3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				/*	FIX THIS?
3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					it seems SDL_PrivateKeyboard() changes mod value
3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					anyway, and doesn't care about what we setup here */
3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				keysym.mod = KMOD_NONE;
3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				keysym.unicode = 0;
3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (SDL_TranslateUNICODE) {
3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					const char *bytes;
3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if (msg->FindString("bytes", &bytes) == B_OK) {
3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						/*	FIX THIS?
3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							this cares only about first "letter",
3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							so if someone maps some key to print
3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall							"BeOS rulez!" only "B" will be used. */
3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						keysym.unicode = Translate2Unicode(bytes);
3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					}
3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			}
3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			break;
3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_KEY_UP:
3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		{
3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int32 key;
3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			int32 modifiers;
3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) {
3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				SDL_keysym keysym;
3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				keysym.scancode = key;
3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (key < 128) {
3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					keysym.sym = keymap[key];
3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				} else {
3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					keysym.sym = SDLK_UNKNOWN;
3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				keysym.mod = KMOD_NONE; /* FIX THIS? */
3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				keysym.unicode = 0;
3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				if (SDL_TranslateUNICODE) {
3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					const char *bytes;
3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					if (msg->FindString("bytes", &bytes) == B_OK) {
3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall						keysym.unicode = Translate2Unicode(bytes);
3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					}
3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				}
3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			}
3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			break;
3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		default:
3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			/* move it after switch{} so it's always handled
3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				that way we keep BeOS feautures like:
3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				- CTRL+Q to close window (and other shortcuts)
3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				- PrintScreen to make screenshot into /boot/home
3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				- etc.. */
3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			//BDirectWindow::DispatchMessage(msg, target);
3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			break;
3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	BDirectWindow::DispatchMessage(msg, target);
3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_BWin::DirectConnected(direct_buffer_info *info) {
3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	switch (info->buffer_state & B_DIRECT_MODE_MASK) {
3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_DIRECT_START:
3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		case B_DIRECT_MODIFY:
3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			{
3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				int32 width = info->window_bounds.right -
4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					info->window_bounds.left;
4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				int32 height = info->window_bounds.bottom -
4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall					info->window_bounds.top;
4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				SDL_PrivateResize(width, height);
4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				break;
4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			}
4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		default:
4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			break;
4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	// If it is a BGLView, it is apparently required to
4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	// call DirectConnected() on it as well
4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if (this->the_view == this->SDL_GLView)
4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		this->SDL_GLView->DirectConnected(info);
4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
416