src/video/bwindow/SDL_BWin.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 16 Feb 2006 10:11:48 +0000
changeset 1361 19418e4422cb
parent 1336 3692456e7b0f
child 1367 e440d5c488c1
permissions -rw-r--r--
New configure-based build system. Still work in progress, but much improved
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
     3
    Copyright (C) 1997-2006 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
    13
    Lesser General Public License for more details.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
    16
    License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    19
    Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 1
diff changeset
    20
    slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    21
*/
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    23
#ifndef _SDL_BWin_h
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    24
#define _SDL_BWin_h
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    25
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    26
#include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    27
#include <AppKit.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    28
#include <InterfaceKit.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    29
#include <be/game/DirectWindow.h>
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
    30
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    31
#include <be/opengl/GLView.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    32
#endif
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    33
#include <support/UTF8.h>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    34
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    35
#include "SDL_BeApp.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    36
#include "SDL_events.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    37
#include "SDL_BView.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    38
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    39
extern "C" {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
    40
#include "../../events/SDL_events_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    41
};
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    42
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    43
class SDL_BWin : public BDirectWindow
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    44
{
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    45
public:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    46
	SDL_BWin(BRect bounds) :
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    47
			BDirectWindow(bounds, "Untitled", B_TITLED_WINDOW, 0) {
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    48
		InitKeyboard();
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    49
		last_buttons = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    50
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    51
		the_view = NULL;
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
    52
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    53
		SDL_GLView = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    54
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    55
		SDL_View = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    56
		Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    57
		shown = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    58
		inhibit_resize = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    59
	}
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    60
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    61
	virtual ~SDL_BWin() {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    62
		Lock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    63
		if ( the_view ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
    64
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    65
			if ( the_view == SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    66
				SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    67
			}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    68
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    69
			RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    70
			the_view = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    71
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    72
		Unlock();
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
    73
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    74
		if ( SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    75
			delete SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    76
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    77
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    78
		if ( SDL_View ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    79
			delete SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    80
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    81
	}
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    82
	
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    83
	virtual void InitKeyboard(void) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    84
		for ( uint i=0; i<SDL_TABLESIZE(keymap); ++i )
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    85
			keymap[i] = SDLK_UNKNOWN;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    86
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    87
		keymap[0x01]		= SDLK_ESCAPE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    88
		keymap[B_F1_KEY]	= SDLK_F1;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    89
		keymap[B_F2_KEY]	= SDLK_F2;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    90
		keymap[B_F3_KEY]	= SDLK_F3;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    91
		keymap[B_F4_KEY]	= SDLK_F4;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    92
		keymap[B_F5_KEY]	= SDLK_F5;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    93
		keymap[B_F6_KEY]	= SDLK_F6;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    94
		keymap[B_F7_KEY]	= SDLK_F7;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    95
		keymap[B_F8_KEY]	= SDLK_F8;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    96
		keymap[B_F9_KEY]	= SDLK_F9;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    97
		keymap[B_F10_KEY]	= SDLK_F10;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    98
		keymap[B_F11_KEY]	= SDLK_F11;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
    99
		keymap[B_F12_KEY]	= SDLK_F12;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   100
		keymap[B_PRINT_KEY]	= SDLK_PRINT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   101
		keymap[B_SCROLL_KEY]	= SDLK_SCROLLOCK;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   102
		keymap[B_PAUSE_KEY]	= SDLK_PAUSE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   103
		keymap[0x11]		= SDLK_BACKQUOTE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   104
		keymap[0x12]		= SDLK_1;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   105
		keymap[0x13]		= SDLK_2;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   106
		keymap[0x14]		= SDLK_3;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   107
		keymap[0x15]		= SDLK_4;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   108
		keymap[0x16]		= SDLK_5;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   109
		keymap[0x17]		= SDLK_6;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   110
		keymap[0x18]		= SDLK_7;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   111
		keymap[0x19]		= SDLK_8;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   112
		keymap[0x1a]		= SDLK_9;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   113
		keymap[0x1b]		= SDLK_0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   114
		keymap[0x1c]		= SDLK_MINUS;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   115
		keymap[0x1d]		= SDLK_EQUALS;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   116
		keymap[0x1e]		= SDLK_BACKSPACE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   117
		keymap[0x1f]		= SDLK_INSERT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   118
		keymap[0x20]		= SDLK_HOME;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   119
		keymap[0x21]		= SDLK_PAGEUP;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   120
		keymap[0x22]		= SDLK_NUMLOCK;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   121
		keymap[0x23]		= SDLK_KP_DIVIDE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   122
		keymap[0x24]		= SDLK_KP_MULTIPLY;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   123
		keymap[0x25]		= SDLK_KP_MINUS;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   124
		keymap[0x26]		= SDLK_TAB;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   125
		keymap[0x27]		= SDLK_q;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   126
		keymap[0x28]		= SDLK_w;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   127
		keymap[0x29]		= SDLK_e;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   128
		keymap[0x2a]		= SDLK_r;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   129
		keymap[0x2b]		= SDLK_t;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   130
		keymap[0x2c]		= SDLK_y;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   131
		keymap[0x2d]		= SDLK_u;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   132
		keymap[0x2e]		= SDLK_i;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   133
		keymap[0x2f]		= SDLK_o;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   134
		keymap[0x30]		= SDLK_p;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   135
		keymap[0x31]		= SDLK_LEFTBRACKET;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   136
		keymap[0x32]		= SDLK_RIGHTBRACKET;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   137
		keymap[0x33]		= SDLK_BACKSLASH;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   138
		keymap[0x34]		= SDLK_DELETE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   139
		keymap[0x35]		= SDLK_END;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   140
		keymap[0x36]		= SDLK_PAGEDOWN;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   141
		keymap[0x37]		= SDLK_KP7;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   142
		keymap[0x38]		= SDLK_KP8;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   143
		keymap[0x39]		= SDLK_KP9;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   144
		keymap[0x3a]		= SDLK_KP_PLUS;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   145
		keymap[0x3b]		= SDLK_CAPSLOCK;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   146
		keymap[0x3c]		= SDLK_a;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   147
		keymap[0x3d]		= SDLK_s;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   148
		keymap[0x3e]		= SDLK_d;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   149
		keymap[0x3f]		= SDLK_f;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   150
		keymap[0x40]		= SDLK_g;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   151
		keymap[0x41]		= SDLK_h;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   152
		keymap[0x42]		= SDLK_j;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   153
		keymap[0x43]		= SDLK_k;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   154
		keymap[0x44]		= SDLK_l;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   155
		keymap[0x45]		= SDLK_SEMICOLON;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   156
		keymap[0x46]		= SDLK_QUOTE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   157
		keymap[0x47]		= SDLK_RETURN;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   158
		keymap[0x48]		= SDLK_KP4;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   159
		keymap[0x49]		= SDLK_KP5;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   160
		keymap[0x4a]		= SDLK_KP6;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   161
		keymap[0x4b]		= SDLK_LSHIFT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   162
		keymap[0x4c]		= SDLK_z;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   163
		keymap[0x4d]		= SDLK_x;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   164
		keymap[0x4e]		= SDLK_c;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   165
		keymap[0x4f]		= SDLK_v;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   166
		keymap[0x50]		= SDLK_b;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   167
		keymap[0x51]		= SDLK_n;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   168
		keymap[0x52]		= SDLK_m;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   169
		keymap[0x53]		= SDLK_COMMA;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   170
		keymap[0x54]		= SDLK_PERIOD;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   171
		keymap[0x55]		= SDLK_SLASH;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   172
		keymap[0x56]		= SDLK_RSHIFT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   173
		keymap[0x57]		= SDLK_UP;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   174
		keymap[0x58]		= SDLK_KP1;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   175
		keymap[0x59]		= SDLK_KP2;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   176
		keymap[0x5a]		= SDLK_KP3;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   177
		keymap[0x5b]		= SDLK_KP_ENTER;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   178
		keymap[0x5c]		= SDLK_LCTRL;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   179
		keymap[0x5d]		= SDLK_LALT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   180
		keymap[0x5e]		= SDLK_SPACE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   181
		keymap[0x5f]		= SDLK_RALT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   182
		keymap[0x60]		= SDLK_RCTRL;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   183
		keymap[0x61]		= SDLK_LEFT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   184
		keymap[0x62]		= SDLK_DOWN;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   185
		keymap[0x63]		= SDLK_RIGHT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   186
		keymap[0x64]		= SDLK_KP0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   187
		keymap[0x65]		= SDLK_KP_PERIOD;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   188
		keymap[0x66]		= SDLK_LMETA;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   189
		keymap[0x67]		= SDLK_RMETA;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   190
		keymap[0x68]		= SDLK_MENU;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   191
		keymap[0x69]		= SDLK_EURO;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   192
		keymap[0x6a]		= SDLK_KP_EQUALS;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   193
		keymap[0x6b]		= SDLK_POWER;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   194
	}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   195
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   196
	/* Override the Show() method so we can tell when we've been shown */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   197
	virtual void Show(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   198
		BWindow::Show();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   199
		shown = true;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   200
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   201
	virtual bool Shown(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   202
		return (shown);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   203
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   204
	/* If called, the next resize event will not be forwarded to SDL. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   205
	virtual void InhibitResize(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   206
		inhibit_resize=true;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   207
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   208
	/* Handle resizing of the window */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   209
	virtual void FrameResized(float width, float height) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   210
		if(inhibit_resize)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   211
			inhibit_resize = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   212
		else 
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   213
			SDL_PrivateResize((int)width, (int)height);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   214
	}
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   215
	virtual int CreateView(Uint32 flags, Uint32 gl_flags) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   216
		int retval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   217
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   218
		retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   219
		Lock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   220
		if ( flags & SDL_OPENGL ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
   221
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   222
			if ( SDL_GLView == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   223
				SDL_GLView = new BGLView(Bounds(), "SDL GLView",
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   224
					 	B_FOLLOW_ALL_SIDES, (B_WILL_DRAW|B_FRAME_EVENTS),
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   225
					 	gl_flags);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   226
			}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   227
			if ( the_view != SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   228
				if ( the_view ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   229
					RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   230
				}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   231
				AddChild(SDL_GLView);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   232
				SDL_GLView->LockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   233
				the_view = SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   234
			}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   235
#else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   236
			SDL_SetError("OpenGL support not enabled");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   237
			retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   238
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   239
		} else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   240
			if ( SDL_View == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   241
				SDL_View = new SDL_BView(Bounds());
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   242
			}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   243
			if ( the_view != SDL_View ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   244
				if ( the_view ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
   245
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   246
					if ( the_view == SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   247
						SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   248
					}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   249
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   250
					RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   251
				}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   252
				AddChild(SDL_View);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   253
				the_view = SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   254
			}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   255
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   256
		Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   257
		return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   258
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   259
	virtual void SetBitmap(BBitmap *bitmap) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   260
		SDL_View->SetBitmap(bitmap);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   261
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   262
	virtual void SetXYOffset(int x, int y) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
   263
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   264
		if ( the_view == SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   265
			return;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   266
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   267
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   268
		SDL_View->SetXYOffset(x, y);		
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   269
	}
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   270
	virtual void GetXYOffset(int &x, int &y) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
   271
#if SDL_VIDEO_OPENGL
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   272
		if ( the_view == SDL_GLView ) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   273
			x = 0;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   274
			y = 0;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   275
			return;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   276
		}
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   277
#endif
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   278
		SDL_View->GetXYOffset(x, y);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
   279
	}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   280
	virtual bool BeginDraw(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   281
		return(Lock());
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   282
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   283
	virtual void DrawAsync(BRect updateRect) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   284
		SDL_View->DrawAsync(updateRect);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   285
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   286
	virtual void EndDraw(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   287
		SDL_View->Sync();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   288
		Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   289
	}
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
   290
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   291
	virtual void SwapBuffers(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   292
		SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   293
		SDL_GLView->LockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   294
		SDL_GLView->SwapBuffers();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   295
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   296
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   297
	virtual BView *View(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   298
		return(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   299
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   300
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   301
	/* Hook functions -- overridden */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   302
	virtual void Minimize(bool minimize) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   303
		/* This is only called when mimimized, not when restored */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   304
		//SDL_PrivateAppActive(minimize, SDL_APPACTIVE);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   305
		BWindow::Minimize(minimize);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   306
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   307
	virtual void WindowActivated(bool active) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   308
		SDL_PrivateAppActive(active, SDL_APPINPUTFOCUS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   309
	}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   310
	virtual bool QuitRequested(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   311
		if ( SDL_BeAppActive > 0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   312
			SDL_PrivateQuit();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   313
			/* We don't ever actually close the window here because
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   314
			   the application should respond to the quit request,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   315
			   or ignore it as desired.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   316
			 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   317
			return(false);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   318
		}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   319
		return(true);	/* Close the app window */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   320
	}
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   321
	virtual void Quit() {
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   322
		if (!IsLocked())
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   323
			Lock();
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   324
		BDirectWindow::Quit();
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   325
	}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   326
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   327
	virtual int16 Translate2Unicode(const char *buf) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   328
		int32 state, srclen, dstlen;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   329
		unsigned char destbuf[2];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   330
		Uint16 unicode = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   331
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   332
		if ((uchar)buf[0] > 127) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   333
			state = 0;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
   334
			srclen = SDL_strlen(buf);
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   335
			dstlen = sizeof(destbuf);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   336
			convert_from_utf8(B_UNICODE_CONVERSION, buf, &srclen, (char *)destbuf, &dstlen, &state);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   337
			unicode = destbuf[0];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   338
			unicode <<= 8;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   339
			unicode |= destbuf[1];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   340
		} else
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   341
			unicode = buf[0];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   342
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   343
		/* For some reason function keys map to control characters */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   344
# define CTRL(X)	((X)-'@')
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   345
		switch (unicode) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   346
		    case CTRL('A'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   347
		    case CTRL('B'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   348
		    case CTRL('C'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   349
		    case CTRL('D'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   350
		    case CTRL('E'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   351
		    case CTRL('K'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   352
		    case CTRL('L'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   353
		    case CTRL('P'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   354
			if ( ! (SDL_GetModState() & KMOD_CTRL) )
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   355
				unicode = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   356
			break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   357
			/* Keyboard input maps newline to carriage return */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   358
			case '\n':
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   359
				unicode = '\r';
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   360
			break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   361
		    default:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   362
			break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   363
		}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   364
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   365
		return unicode;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   366
	}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   367
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   368
	virtual void DispatchMessage(BMessage *msg, BHandler *target) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   369
		switch (msg->what) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   370
			case B_MOUSE_MOVED:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   371
			{
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   372
				BPoint where;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   373
				int32 transit;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   374
				if (msg->FindPoint("where", &where) == B_OK && msg->FindInt32("be:transit", &transit) == B_OK) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   375
					if (transit == B_EXITED_VIEW) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   376
						if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   377
							SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   378
							be_app->SetCursor(B_HAND_CURSOR);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   379
						}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   380
					} else {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   381
						int x, y;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   382
						if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   383
							SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   384
							SDL_SetCursor(NULL);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   385
						}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   386
						GetXYOffset(x, y);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   387
						x = (int)where.x - x;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   388
						y = (int)where.y - y;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   389
						SDL_PrivateMouseMotion(0, 0, x, y);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   390
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   391
				}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   392
				break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   393
			}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   394
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   395
			case B_MOUSE_DOWN:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   396
			{
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   397
				/*	it looks like mouse down is send only for first clicked
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   398
					button, each next is not send while last one is holded */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   399
				int32 buttons;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   400
				int sdl_buttons = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   401
				if (msg->FindInt32("buttons", &buttons) == B_OK) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   402
					/* Add any mouse button events */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   403
					if (buttons & B_PRIMARY_MOUSE_BUTTON) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   404
						sdl_buttons |= SDL_BUTTON_LEFT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   405
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   406
					if (buttons & B_SECONDARY_MOUSE_BUTTON) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   407
						sdl_buttons |= SDL_BUTTON_RIGHT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   408
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   409
					if (buttons & B_TERTIARY_MOUSE_BUTTON) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   410
						sdl_buttons |= SDL_BUTTON_MIDDLE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   411
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   412
					SDL_PrivateMouseButton(SDL_PRESSED, sdl_buttons, 0, 0);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   413
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   414
					last_buttons = buttons;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   415
				}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   416
				break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   417
			}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   418
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   419
			case B_MOUSE_UP:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   420
			{
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   421
				/*	mouse up doesn't give which button was released,
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   422
					only state of buttons (after release, so it's always = 0),
1013
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   423
					which is not what we need ;]
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   424
					So we need to store button in mouse down, and restore
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   425
					in mouse up :(
1013
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   426
					mouse up is (similarly to mouse down) send only for
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   427
					first button down (ie. it's no send if we click another button
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   428
					without releasing previous one first) - but that's probably
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   429
					because of how drivers are written?, not BeOS itself. */
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   430
				int32 buttons;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   431
				int sdl_buttons = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   432
				if (msg->FindInt32("buttons", &buttons) == B_OK) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   433
					/* Add any mouse button events */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   434
					if ((buttons ^ B_PRIMARY_MOUSE_BUTTON) & last_buttons) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   435
						sdl_buttons |= SDL_BUTTON_LEFT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   436
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   437
					if ((buttons ^ B_SECONDARY_MOUSE_BUTTON) & last_buttons) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   438
						sdl_buttons |= SDL_BUTTON_RIGHT;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   439
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   440
					if ((buttons ^ B_TERTIARY_MOUSE_BUTTON) & last_buttons) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   441
						sdl_buttons |= SDL_BUTTON_MIDDLE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   442
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   443
					SDL_PrivateMouseButton(SDL_RELEASED, sdl_buttons, 0, 0);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   444
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   445
					last_buttons = buttons;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   446
				}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   447
				break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   448
			}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   449
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   450
			case B_MOUSE_WHEEL_CHANGED:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   451
			{
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   452
				float x, y;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   453
				x = y = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   454
				if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   455
					if (x < 0 || y < 0) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   456
						SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   457
						SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   458
					} else if (x > 0 || y > 0) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   459
						SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   460
						SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   461
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   462
				}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   463
				break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   464
			}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   465
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   466
			case B_KEY_DOWN:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   467
			case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   468
			{
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   469
				int32 key;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   470
				int32 modifiers;
1013
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   471
				int32 key_repeat;
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   472
				/* Workaround for SDL message queue being filled too fast because of BeOS own key-repeat mechanism */
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   473
				if (msg->FindInt32("be:key_repeat", &key_repeat) == B_OK && key_repeat > 0)
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   474
					break;
a649064a3215 Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 907
diff changeset
   475
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   476
				if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   477
					SDL_keysym keysym;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   478
					keysym.scancode = key;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   479
					if (key < 128) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   480
						keysym.sym = keymap[key];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   481
					} else {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   482
						keysym.sym = SDLK_UNKNOWN;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   483
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   484
					/*	FIX THIS?
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   485
						it seems SDL_PrivateKeyboard() changes mod value
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   486
						anyway, and doesn't care about what we setup here */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   487
					keysym.mod = KMOD_NONE;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   488
					keysym.unicode = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   489
					if (SDL_TranslateUNICODE) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   490
						const char *bytes;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   491
						if (msg->FindString("bytes", &bytes) == B_OK) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   492
							/*	FIX THIS?
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   493
								this cares only about first "letter",
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   494
								so if someone maps some key to print
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   495
								"BeOS rulez!" only "B" will be used. */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   496
							keysym.unicode = Translate2Unicode(bytes);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   497
						}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   498
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   499
					SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   500
				}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   501
				break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   502
			}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   503
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   504
			case B_KEY_UP:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   505
			case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   506
			{
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   507
				int32 key;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   508
				int32 modifiers;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   509
				if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   510
					SDL_keysym keysym;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   511
					keysym.scancode = key;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   512
					if (key < 128) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   513
						keysym.sym = keymap[key];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   514
					} else {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   515
						keysym.sym = SDLK_UNKNOWN;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   516
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   517
					keysym.mod = KMOD_NONE; /* FIX THIS? */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   518
					keysym.unicode = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   519
					if (SDL_TranslateUNICODE) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   520
						const char *bytes;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   521
						if (msg->FindString("bytes", &bytes) == B_OK) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   522
							keysym.unicode = Translate2Unicode(bytes);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   523
						}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   524
					}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   525
					SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   526
				}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   527
				break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   528
			}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   529
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   530
			default:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   531
				/* move it after switch{} so it's always handled
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   532
					that way we keep BeOS feautures like:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   533
					- CTRL+Q to close window (and other shortcuts)
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   534
					- PrintScreen to make screenshot into /boot/home
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   535
					- etc.. */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   536
				//BDirectWindow::DispatchMessage(msg, target);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   537
				break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   538
		}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   539
		BDirectWindow::DispatchMessage(msg, target);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   540
	}
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   541
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   542
private:
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
   543
#if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   544
	BGLView *SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   545
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   546
	SDL_BView *SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   547
	BView *the_view;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   548
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   549
	bool shown;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   550
	bool inhibit_resize;
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   551
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   552
	int32 last_buttons;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
   553
	SDLKey keymap[128];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   554
};
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   555
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   556
#endif /* _SDL_BWin_h */