src/video/cocoa/event.mm
author egladil
Sun, 23 Dec 2007 18:08:39 +0000
changeset 8623 652df321c912
parent 8461 385ca6f76feb
child 8768 a45175c17e5b
permissions -rw-r--r--
(svn r11688) -Fix [FS#1581]: Compilation was broken on OS X again.
2743
b3a6f4ddfdb8 (svn r3288) Set svn properties on cocoa related files, and add Id tag.
peter1138
parents: 2741
diff changeset
     1
/* $Id$ */
b3a6f4ddfdb8 (svn r3288) Set svn properties on cocoa related files, and add Id tag.
peter1138
parents: 2741
diff changeset
     2
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
     3
/******************************************************************************
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
     4
 *                             Cocoa video driver                             *
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
     5
 * Known things left to do:                                                   *
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
     6
 *  Nothing at the moment.                                                    *
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
     7
 ******************************************************************************/
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
     8
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
     9
#ifdef WITH_COCOA
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    10
8461
385ca6f76feb (svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents: 8460
diff changeset
    11
#define MAC_OS_X_VERSION_MIN_REQUIRED    MAC_OS_X_VERSION_10_3
385ca6f76feb (svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents: 8460
diff changeset
    12
#include <AvailabilityMacros.h>
385ca6f76feb (svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents: 8460
diff changeset
    13
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    14
#import <Cocoa/Cocoa.h>
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    15
#import <sys/time.h> /* gettimeofday */
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    16
#import <sys/param.h> /* for MAXPATHLEN */
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    17
#import <unistd.h>
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    18
6192
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    19
/**
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    20
 * Important notice regarding all modifications!!!!!!!
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    21
 * There are certain limitations because the file is objective C++.
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    22
 * gdb has limitations.
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    23
 * C++ and objective C code can't be joined in all cases (classes stuff).
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    24
 * Read http://developer.apple.com/releasenotes/Cocoa/Objective-C++.html for more information.
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    25
 */
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    26
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
    27
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    28
/* Defined in stdbool.h */
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    29
#ifndef __cplusplus
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    30
# ifndef __BEOS__
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    31
#  undef bool
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    32
#  undef false
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    33
#  undef true
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    34
# endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    35
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    36
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5832
diff changeset
    37
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    38
#include "../../stdafx.h"
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    39
#include "../../openttd.h"
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    40
#include "../../debug.h"
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    41
#include "../../os/macosx/splash.h"
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    42
#include "../../variables.h"
8623
652df321c912 (svn r11688) -Fix [FS#1581]: Compilation was broken on OS X again.
egladil
parents: 8461
diff changeset
    43
#include "../../core/geometry_type.hpp"
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    44
#include "cocoa_v.h"
3035
57f039f65023 (svn r3615) Remove the Quartz key codes from the public cocoa video driver interface
tron
parents: 3016
diff changeset
    45
#include "cocoa_keys.h"
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    46
#include "../../blitter/factory.hpp"
8623
652df321c912 (svn r11688) -Fix [FS#1581]: Compilation was broken on OS X again.
egladil
parents: 8461
diff changeset
    47
#include "../../gfx_func.h"
652df321c912 (svn r11688) -Fix [FS#1581]: Compilation was broken on OS X again.
egladil
parents: 8461
diff changeset
    48
#include "../../network/network.h"
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    49
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    50
7981
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
    51
/* Right Mouse Button Emulation enum */
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
    52
enum {
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
    53
	RMBE_COMMAND,
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
    54
	RMBE_CONTROL,
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
    55
	RMBE_OFF,
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
    56
};
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
    57
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
    58
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    59
static bool _show_mouse = true;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    60
static unsigned int _current_mods;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    61
static bool _tab_is_down;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    62
static bool _emulating_right_button;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    63
#ifdef _DEBUG
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    64
static uint32 _tEvent;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    65
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    66
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    67
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6562
diff changeset
    68
static uint32 GetTick()
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    69
{
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    70
	struct timeval tim;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    71
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    72
	gettimeofday(&tim, NULL);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    73
	return tim.tv_usec / 1000 + tim.tv_sec * 1000;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    74
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    75
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    76
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    77
void QZ_ShowMouse()
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    78
{
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    79
	if (!_show_mouse) {
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    80
		[ NSCursor unhide ];
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    81
		_show_mouse = true;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    82
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    83
		// Hide the openttd cursor when leaving the window
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    84
		if (_cocoa_subdriver != NULL)
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    85
			UndrawMouseCursor();
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    86
		_cursor.in_window = false;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    87
	}
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    88
}
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    89
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    90
void QZ_HideMouse()
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    91
{
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    92
	if (_show_mouse) {
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    93
		/*
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    94
		 * Don't hide the cursor when compiling in debug mode.
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    95
		 * Note: Not hiding the cursor will cause artefacts around it in 8bpp fullscreen mode.
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    96
		 */
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    97
#ifndef _DEBUG
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    98
		[ NSCursor hide ];
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
    99
#endif
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   100
		_show_mouse = false;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   101
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   102
		// Show the openttd cursor again
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   103
		_cursor.in_window = true;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   104
	}
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   105
}
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   106
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   107
static void QZ_WarpCursor(int x, int y)
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   108
{
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   109
	NSPoint p;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   110
	CGPoint cgp;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   111
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   112
	assert(_cocoa_subdriver);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   113
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   114
	/* Only allow warping when in foreground */
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   115
	if (![ NSApp isActive ]) return;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   116
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   117
	p = NSMakePoint(x, y);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   118
	cgp = _cocoa_subdriver->PrivateLocalToCG(&p);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   119
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   120
	/* this is the magic call that fixes cursor "freezing" after warp */
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   121
	CGSetLocalEventsSuppressionInterval(0.0);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   122
	/* Do the actual warp */
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   123
	CGWarpMouseCursorPosition(cgp);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   124
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   125
	/* Generate the mouse moved event */
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   126
}
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   127
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   128
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6562
diff changeset
   129
static void QZ_CheckPaletteAnim()
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   130
{
7456
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   131
	if (_pal_count_dirty != 0) {
7457
b380079242fa (svn r10217) -Fix r10216: forgot to declare 'blitter' in win32 and cocoa driver (tnx glx)
truelight
parents: 7456
diff changeset
   132
		Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
b380079242fa (svn r10217) -Fix r10216: forgot to declare 'blitter' in win32 and cocoa driver (tnx glx)
truelight
parents: 7456
diff changeset
   133
7456
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   134
		switch (blitter->UsePaletteAnimation()) {
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   135
			case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   136
				_cocoa_subdriver->UpdatePalette(_pal_first_dirty, _pal_count_dirty);
7456
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   137
				break;
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   138
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   139
			case Blitter::PALETTE_ANIMATION_BLITTER:
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   140
				blitter->PaletteAnimate(_pal_first_dirty, _pal_count_dirty);
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   141
				break;
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   142
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   143
			case Blitter::PALETTE_ANIMATION_NONE:
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   144
				break;
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   145
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   146
			default:
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   147
				NOT_REACHED();
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   148
		}
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7435
diff changeset
   149
		_pal_count_dirty = 0;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   150
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   151
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   152
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   153
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   154
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   155
struct VkMapping {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   156
	unsigned short vk_from;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   157
	byte map_to;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   158
};
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   159
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   160
#define AS(x, z) {x, z}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   161
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   162
static const VkMapping _vk_mapping[] = {
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   163
	AS(QZ_BACKQUOTE,  WKC_BACKQUOTE), // key left of '1'
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   164
	AS(QZ_BACKQUOTE2, WKC_BACKQUOTE), // some keyboards have it on another scancode
2845
258ea64174da (svn r3393) -Fix: [OSX] some keyboards had a different scancode for opening the console (egladil)
bjarni
parents: 2827
diff changeset
   165
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   166
	/* Pageup stuff + up/down */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   167
	AS(QZ_PAGEUP,   WKC_PAGEUP),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   168
	AS(QZ_PAGEDOWN, WKC_PAGEDOWN),
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   169
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   170
	AS(QZ_UP,    WKC_UP),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   171
	AS(QZ_DOWN,  WKC_DOWN),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   172
	AS(QZ_LEFT,  WKC_LEFT),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   173
	AS(QZ_RIGHT, WKC_RIGHT),
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   174
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   175
	AS(QZ_HOME, WKC_HOME),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   176
	AS(QZ_END,  WKC_END),
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   177
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   178
	AS(QZ_INSERT, WKC_INSERT),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   179
	AS(QZ_DELETE, WKC_DELETE),
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   180
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   181
	/* Letters. QZ_[a-z] is not in numerical order so we can't use AM(...) */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   182
	AS(QZ_a, 'A'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   183
	AS(QZ_b, 'B'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   184
	AS(QZ_c, 'C'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   185
	AS(QZ_d, 'D'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   186
	AS(QZ_e, 'E'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   187
	AS(QZ_f, 'F'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   188
	AS(QZ_g, 'G'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   189
	AS(QZ_h, 'H'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   190
	AS(QZ_i, 'I'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   191
	AS(QZ_j, 'J'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   192
	AS(QZ_k, 'K'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   193
	AS(QZ_l, 'L'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   194
	AS(QZ_m, 'M'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   195
	AS(QZ_n, 'N'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   196
	AS(QZ_o, 'O'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   197
	AS(QZ_p, 'P'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   198
	AS(QZ_q, 'Q'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   199
	AS(QZ_r, 'R'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   200
	AS(QZ_s, 'S'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   201
	AS(QZ_t, 'T'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   202
	AS(QZ_u, 'U'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   203
	AS(QZ_v, 'V'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   204
	AS(QZ_w, 'W'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   205
	AS(QZ_x, 'X'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   206
	AS(QZ_y, 'Y'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   207
	AS(QZ_z, 'Z'),
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   208
	/* Same thing for digits */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   209
	AS(QZ_0, '0'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   210
	AS(QZ_1, '1'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   211
	AS(QZ_2, '2'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   212
	AS(QZ_3, '3'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   213
	AS(QZ_4, '4'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   214
	AS(QZ_5, '5'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   215
	AS(QZ_6, '6'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   216
	AS(QZ_7, '7'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   217
	AS(QZ_8, '8'),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   218
	AS(QZ_9, '9'),
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   219
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   220
	AS(QZ_ESCAPE,    WKC_ESC),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   221
	AS(QZ_PAUSE,     WKC_PAUSE),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   222
	AS(QZ_BACKSPACE, WKC_BACKSPACE),
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   223
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   224
	AS(QZ_SPACE,  WKC_SPACE),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   225
	AS(QZ_RETURN, WKC_RETURN),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   226
	AS(QZ_TAB,    WKC_TAB),
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   227
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   228
	/* Function keys */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   229
	AS(QZ_F1,  WKC_F1),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   230
	AS(QZ_F2,  WKC_F2),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   231
	AS(QZ_F3,  WKC_F3),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   232
	AS(QZ_F4,  WKC_F4),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   233
	AS(QZ_F5,  WKC_F5),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   234
	AS(QZ_F6,  WKC_F6),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   235
	AS(QZ_F7,  WKC_F7),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   236
	AS(QZ_F8,  WKC_F8),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   237
	AS(QZ_F9,  WKC_F9),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   238
	AS(QZ_F10, WKC_F10),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   239
	AS(QZ_F11, WKC_F11),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   240
	AS(QZ_F12, WKC_F12),
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   241
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   242
	/* Numeric part */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   243
	AS(QZ_KP0,         WKC_NUM_0),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   244
	AS(QZ_KP1,         WKC_NUM_1),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   245
	AS(QZ_KP2,         WKC_NUM_2),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   246
	AS(QZ_KP3,         WKC_NUM_3),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   247
	AS(QZ_KP4,         WKC_NUM_4),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   248
	AS(QZ_KP5,         WKC_NUM_5),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   249
	AS(QZ_KP6,         WKC_NUM_6),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   250
	AS(QZ_KP7,         WKC_NUM_7),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   251
	AS(QZ_KP8,         WKC_NUM_8),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   252
	AS(QZ_KP9,         WKC_NUM_9),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   253
	AS(QZ_KP_DIVIDE,   WKC_NUM_DIV),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   254
	AS(QZ_KP_MULTIPLY, WKC_NUM_MUL),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   255
	AS(QZ_KP_MINUS,    WKC_NUM_MINUS),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   256
	AS(QZ_KP_PLUS,     WKC_NUM_PLUS),
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   257
	AS(QZ_KP_ENTER,    WKC_NUM_ENTER),
7806
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   258
	AS(QZ_KP_PERIOD,   WKC_NUM_DECIMAL),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   259
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   260
	/* Other non-letter keys */
7806
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   261
	AS(QZ_SLASH,        WKC_SLASH),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   262
	AS(QZ_SEMICOLON,    WKC_SEMICOLON),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   263
	AS(QZ_EQUALS,       WKC_EQUALS),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   264
	AS(QZ_LEFTBRACKET,  WKC_L_BRACKET),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   265
	AS(QZ_BACKSLASH,    WKC_BACKSLASH),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   266
	AS(QZ_RIGHTBRACKET, WKC_R_BRACKET),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   267
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   268
	AS(QZ_QUOTE,   WKC_SINGLEQUOTE),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   269
	AS(QZ_COMMA,   WKC_COMMA),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   270
	AS(QZ_MINUS,   WKC_MINUS),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7672
diff changeset
   271
	AS(QZ_PERIOD,  WKC_PERIOD)
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   272
};
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   273
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   274
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   275
static uint32 QZ_MapKey(unsigned short sym)
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   276
{
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   277
	const VkMapping *map;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   278
	uint32 key = 0;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   279
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   280
	for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   281
		if (sym == map->vk_from) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   282
			key = map->map_to;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   283
			break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   284
		}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   285
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   286
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   287
	if (_current_mods & NSShiftKeyMask)     key |= WKC_SHIFT;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   288
	if (_current_mods & NSControlKeyMask)   key |= (_patches.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_CTRL : WKC_META);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   289
	if (_current_mods & NSAlternateKeyMask) key |= WKC_ALT;
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   290
	if (_current_mods & NSCommandKeyMask)   key |= (_patches.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_META : WKC_CTRL);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   291
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   292
	return key << 16;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   293
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   294
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   295
static void QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL down)
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   296
{
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   297
	switch (keycode) {
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   298
		case QZ_UP:    SB(_dirkeys, 1, 1, down); break;
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   299
		case QZ_DOWN:  SB(_dirkeys, 3, 1, down); break;
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   300
		case QZ_LEFT:  SB(_dirkeys, 0, 1, down); break;
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   301
		case QZ_RIGHT: SB(_dirkeys, 2, 1, down); break;
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   302
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   303
		case QZ_TAB: _tab_is_down = down; break;
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   304
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   305
		case QZ_RETURN:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   306
		case QZ_f:
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   307
			if (down && (_current_mods & NSCommandKeyMask)) {
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7632
diff changeset
   308
				_video_driver->ToggleFullscreen(!_fullscreen);
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   309
			}
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   310
			break;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   311
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   312
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   313
	if (down) {
5086
99e0b202b9fb (svn r7153) -Fix [FS#279]: Some keyboard events possibly lost under high CPU load, handle
Darkvater
parents: 4550
diff changeset
   314
		uint32 pressed_key = QZ_MapKey(keycode) | unicode;
99e0b202b9fb (svn r7153) -Fix [FS#279]: Some keyboard events possibly lost under high CPU load, handle
Darkvater
parents: 4550
diff changeset
   315
		HandleKeypress(pressed_key);
5571
2d8adccea2fd (svn r7569) -Fix (r7565): cocoa files were (somehow) forgotten.
rubidium
parents: 5090
diff changeset
   316
		DEBUG(driver, 2, "cocoa_v: QZ_KeyEvent: %x (%x), down, mapping: %x", keycode, unicode, pressed_key);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   317
	} else {
5571
2d8adccea2fd (svn r7569) -Fix (r7565): cocoa files were (somehow) forgotten.
rubidium
parents: 5090
diff changeset
   318
		DEBUG(driver, 2, "cocoa_v: QZ_KeyEvent: %x (%x), up", keycode, unicode);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   319
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   320
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   321
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   322
static void QZ_DoUnsidedModifiers(unsigned int newMods)
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   323
{
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   324
	const int mapping[] = { QZ_CAPSLOCK, QZ_LSHIFT, QZ_LCTRL, QZ_LALT, QZ_LMETA };
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   325
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   326
	int i;
6192
c6adfc929c6b (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5993
diff changeset
   327
	unsigned int bit;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   328
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   329
	if (_current_mods == newMods) return;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   330
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   331
	/* Iterate through the bits, testing each against the current modifiers */
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   332
	for (i = 0, bit = NSAlphaShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   333
		unsigned int currentMask, newMask;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   334
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   335
		currentMask = _current_mods & bit;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   336
		newMask     = newMods & bit;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   337
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   338
		if (currentMask && currentMask != newMask) { /* modifier up event */
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   339
			/* If this was Caps Lock, we need some additional voodoo to make SDL happy (is this needed in ottd?) */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   340
			if (bit == NSAlphaShiftKeyMask) QZ_KeyEvent(mapping[i], 0, YES);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   341
			QZ_KeyEvent(mapping[i], 0, NO);
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   342
		} else if (newMask && currentMask != newMask) { /* modifier down event */
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   343
			QZ_KeyEvent(mapping[i], 0, YES);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   344
			/* If this was Caps Lock, we need some additional voodoo to make SDL happy (is this needed in ottd?) */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   345
			if (bit == NSAlphaShiftKeyMask) QZ_KeyEvent(mapping[i], 0, NO);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   346
		}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   347
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   348
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   349
	_current_mods = newMods;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   350
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   351
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   352
static void QZ_MouseMovedEvent(int x, int y)
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   353
{
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   354
	if (_cursor.fix_at) {
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   355
		int dx = x - _cursor.pos.x;
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   356
		int dy = y - _cursor.pos.y;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   357
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   358
		if (dx != 0 || dy != 0) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   359
			_cursor.delta.x += dx;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   360
			_cursor.delta.y += dy;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   361
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   362
			QZ_WarpCursor(_cursor.pos.x, _cursor.pos.y);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   363
		}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   364
	} else {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   365
		_cursor.delta.x = x - _cursor.pos.x;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   366
		_cursor.delta.y = y - _cursor.pos.y;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   367
		_cursor.pos.x = x;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   368
		_cursor.pos.y = y;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   369
		_cursor.dirty = true;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   370
	}
5090
8907f67c2c15 (svn r7157) -Fix [FS#221, SF1168820]: Some mouse events possibly lost under high CPU load, handle
Darkvater
parents: 5086
diff changeset
   371
	HandleMouseEvents();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   372
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   373
4509
ad99f5ff4e8d (svn r6294) -Cleanup: Add static
tron
parents: 4475
diff changeset
   374
ad99f5ff4e8d (svn r6294) -Cleanup: Add static
tron
parents: 4475
diff changeset
   375
static void QZ_MouseButtonEvent(int button, BOOL down)
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   376
{
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   377
	switch (button) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   378
		case 0:
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   379
			if (down) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   380
				_left_button_down = true;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   381
			} else {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   382
				_left_button_down = false;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   383
				_left_button_clicked = false;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   384
			}
5090
8907f67c2c15 (svn r7157) -Fix [FS#221, SF1168820]: Some mouse events possibly lost under high CPU load, handle
Darkvater
parents: 5086
diff changeset
   385
			HandleMouseEvents();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   386
			break;
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   387
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   388
		case 1:
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   389
			if (down) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   390
				_right_button_down = true;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   391
				_right_button_clicked = true;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   392
			} else {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   393
				_right_button_down = false;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   394
			}
5090
8907f67c2c15 (svn r7157) -Fix [FS#221, SF1168820]: Some mouse events possibly lost under high CPU load, handle
Darkvater
parents: 5086
diff changeset
   395
			HandleMouseEvents();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   396
			break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   397
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   398
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   399
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   400
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   401
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   402
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6562
diff changeset
   403
static bool QZ_PollEvent()
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   404
{
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   405
	NSEvent *event;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   406
	NSPoint pt;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   407
	NSString *chars;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   408
#ifdef _DEBUG
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   409
	uint32 et0, et;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   410
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   411
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   412
	assert(_cocoa_subdriver != NULL);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   413
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   414
#ifdef _DEBUG
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   415
	et0 = GetTick();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   416
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   417
	event = [ NSApp nextEventMatchingMask:NSAnyEventMask
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   418
			untilDate: [ NSDate distantPast ]
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   419
			inMode: NSDefaultRunLoopMode dequeue:YES ];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   420
#ifdef _DEBUG
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   421
	et = GetTick();
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   422
	_tEvent+= et - et0;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   423
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   424
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   425
	if (event == nil) return false;
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   426
	if (!_cocoa_subdriver->IsActive()) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   427
		QZ_ShowMouse();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   428
		[NSApp sendEvent:event];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   429
		return true;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   430
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   431
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   432
	QZ_DoUnsidedModifiers( [ event modifierFlags ] );
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   433
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   434
	switch ([event type]) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   435
		case NSMouseMoved:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   436
		case NSOtherMouseDragged:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   437
		case NSLeftMouseDragged:
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   438
			pt = _cocoa_subdriver->GetMouseLocation(event);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   439
			if (!_cocoa_subdriver->MouseIsInsideView(&pt) &&
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   440
					!_emulating_right_button) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   441
				QZ_ShowMouse();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   442
				[NSApp sendEvent:event];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   443
				break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   444
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   445
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   446
			QZ_HideMouse();
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   447
			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   448
			break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   449
8460
8a773ea36eb6 (svn r11520) -Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling. Thanks ln- for pointing this out and providing a fix.
egladil
parents: 8448
diff changeset
   450
		case NSRightMouseDragged:
8a773ea36eb6 (svn r11520) -Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling. Thanks ln- for pointing this out and providing a fix.
egladil
parents: 8448
diff changeset
   451
			pt = _cocoa_subdriver->GetMouseLocation(event);
8a773ea36eb6 (svn r11520) -Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling. Thanks ln- for pointing this out and providing a fix.
egladil
parents: 8448
diff changeset
   452
			QZ_HideMouse();
8a773ea36eb6 (svn r11520) -Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling. Thanks ln- for pointing this out and providing a fix.
egladil
parents: 8448
diff changeset
   453
			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
8a773ea36eb6 (svn r11520) -Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling. Thanks ln- for pointing this out and providing a fix.
egladil
parents: 8448
diff changeset
   454
			break;
8a773ea36eb6 (svn r11520) -Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling. Thanks ln- for pointing this out and providing a fix.
egladil
parents: 8448
diff changeset
   455
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   456
		case NSLeftMouseDown:
7981
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   457
		{
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   458
			uint32 keymask = 0;
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   459
			if (_patches.right_mouse_btn_emulation == RMBE_COMMAND) keymask |= NSCommandKeyMask;
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   460
			if (_patches.right_mouse_btn_emulation == RMBE_CONTROL) keymask |= NSControlKeyMask;
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   461
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   462
			pt = _cocoa_subdriver->GetMouseLocation(event);
7981
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   463
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   464
			if (!([ event modifierFlags ] & keymask) ||
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   465
					!_cocoa_subdriver->MouseIsInsideView(&pt)) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   466
				[NSApp sendEvent:event];
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   467
			}
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   468
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   469
			if (!_cocoa_subdriver->MouseIsInsideView(&pt)) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   470
				QZ_ShowMouse();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   471
				break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   472
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   473
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   474
			QZ_HideMouse();
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   475
			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   476
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   477
			/* Right mouse button emulation */
7981
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   478
			if ([ event modifierFlags ] & keymask) {
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   479
				_emulating_right_button = true;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   480
				QZ_MouseButtonEvent(1, YES);
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   481
			} else {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   482
				QZ_MouseButtonEvent(0, YES);
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   483
			}
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   484
			break;
7981
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7952
diff changeset
   485
		}
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   486
		case NSLeftMouseUp:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   487
			[NSApp sendEvent:event];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   488
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   489
			pt = _cocoa_subdriver->GetMouseLocation(event);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   490
			if (!_cocoa_subdriver->MouseIsInsideView(&pt)) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   491
				QZ_ShowMouse();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   492
				break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   493
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   494
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   495
			QZ_HideMouse();
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   496
			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   497
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   498
			/* Right mouse button emulation */
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   499
			if (_emulating_right_button) {
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   500
				_emulating_right_button = false;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   501
				QZ_MouseButtonEvent(1, NO);
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   502
			} else {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   503
				QZ_MouseButtonEvent(0, NO);
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   504
			}
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   505
			break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   506
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   507
		case NSRightMouseDown:
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   508
			pt = _cocoa_subdriver->GetMouseLocation(event);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   509
			if (!_cocoa_subdriver->MouseIsInsideView(&pt)) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   510
				QZ_ShowMouse();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   511
				[NSApp sendEvent:event];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   512
				break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   513
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   514
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   515
			QZ_HideMouse();
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   516
			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   517
			QZ_MouseButtonEvent(1, YES);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   518
			break;
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   519
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   520
		case NSRightMouseUp:
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   521
			pt = _cocoa_subdriver->GetMouseLocation(event);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   522
			if (!_cocoa_subdriver->MouseIsInsideView(&pt)) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   523
				QZ_ShowMouse();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   524
				[NSApp sendEvent:event];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   525
				break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   526
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   527
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   528
			QZ_HideMouse();
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   529
			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   530
			QZ_MouseButtonEvent(1, NO);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   531
			break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   532
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   533
#if 0
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   534
		/* This is not needed since openttd currently only use two buttons */
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   535
		case NSOtherMouseDown:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   536
			pt = QZ_GetMouseLocation(event);
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   537
			if (!QZ_MouseIsInsideView(&pt)) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   538
				QZ_ShowMouse();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   539
				[NSApp sendEvent:event];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   540
				break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   541
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   542
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   543
			QZ_HideMouse();
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   544
			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   545
			QZ_MouseButtonEvent([ event buttonNumber ], YES);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   546
			break;
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   547
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   548
		case NSOtherMouseUp:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   549
			pt = QZ_GetMouseLocation(event);
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   550
			if (!QZ_MouseIsInsideView(&pt)) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   551
				QZ_ShowMouse();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   552
				[NSApp sendEvent:event];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   553
				break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   554
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   555
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   556
			QZ_HideMouse();
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   557
			QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   558
			QZ_MouseButtonEvent([ event buttonNumber ], NO);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   559
			break;
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   560
#endif
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   561
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   562
		case NSKeyDown:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   563
			/* Quit, hide and minimize */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   564
			switch ([event keyCode]) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   565
				case QZ_q:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   566
				case QZ_h:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   567
				case QZ_m:
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   568
					if ([ event modifierFlags ] & NSCommandKeyMask) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   569
						[NSApp sendEvent:event];
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   570
					}
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   571
					break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   572
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   573
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   574
			chars = [ event characters ];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   575
			QZ_KeyEvent([event keyCode], [ chars length ] ? [ chars characterAtIndex:0 ] : 0, YES);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   576
			break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   577
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   578
		case NSKeyUp:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   579
			/* Quit, hide and minimize */
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   580
			switch ([event keyCode]) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   581
				case QZ_q:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   582
				case QZ_h:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   583
				case QZ_m:
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   584
					if ([ event modifierFlags ] & NSCommandKeyMask) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   585
						[NSApp sendEvent:event];
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   586
					}
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   587
					break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   588
			}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   589
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   590
			chars = [ event characters ];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   591
			QZ_KeyEvent([event keyCode], [ chars length ] ? [ chars characterAtIndex:0 ] : 0, NO);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   592
			break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   593
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   594
		case NSScrollWheel:
4116
a8406022f8bc (svn r5460) -Feature: [OSX] macs with touchpads that support two finger scrolling can now use this "scrollwheel" to scroll up/down (ln-)
bjarni
parents: 4000
diff changeset
   595
			if ([ event deltaY ] > 0.0) { /* Scroll up */
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   596
				_cursor.wheel--;
4116
a8406022f8bc (svn r5460) -Feature: [OSX] macs with touchpads that support two finger scrolling can now use this "scrollwheel" to scroll up/down (ln-)
bjarni
parents: 4000
diff changeset
   597
			} else if ([ event deltaY ] < 0.0) { /* Scroll down */
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   598
				_cursor.wheel++;
4116
a8406022f8bc (svn r5460) -Feature: [OSX] macs with touchpads that support two finger scrolling can now use this "scrollwheel" to scroll up/down (ln-)
bjarni
parents: 4000
diff changeset
   599
			} /* else: deltaY was 0.0 and we don't want to do anything */
6615
96d30d65ed35 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6574
diff changeset
   600
96d30d65ed35 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6574
diff changeset
   601
			/* Set the scroll count for scrollwheel scrolling */
96d30d65ed35 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6574
diff changeset
   602
			_cursor.h_wheel -= (int)([ event deltaX ]* 5 * _patches.scrollwheel_multiplier);
96d30d65ed35 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6574
diff changeset
   603
			_cursor.v_wheel -= (int)([ event deltaY ]* 5 * _patches.scrollwheel_multiplier);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   604
			break;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   605
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   606
		default:
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   607
			[NSApp sendEvent:event];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   608
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   609
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   610
	return true;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   611
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   612
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   613
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   614
void QZ_GameLoop()
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   615
{
5832
28aa8ad3bb04 (svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient.
rubidium
parents: 5794
diff changeset
   616
	uint32 cur_ticks = GetTick();
7514
98a024616010 (svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight
parents: 7495
diff changeset
   617
	uint32 last_cur_ticks = cur_ticks;
5832
28aa8ad3bb04 (svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient.
rubidium
parents: 5794
diff changeset
   618
	uint32 next_tick = cur_ticks + 30;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   619
	uint32 pal_tick = 0;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   620
#ifdef _DEBUG
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   621
	uint32 et0, et, st0, st;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   622
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   623
	int i;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   624
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   625
#ifdef _DEBUG
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   626
	et0 = GetTick();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   627
	st = 0;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   628
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   629
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   630
	_screen.dst_ptr = _cocoa_subdriver->GetPixelBuffer();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   631
	DisplaySplashImage();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   632
	QZ_CheckPaletteAnim();
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   633
	_cocoa_subdriver->Draw();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   634
	CSleep(1);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   635
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   636
	for (i = 0; i < 2; i++) GameLoop();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   637
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   638
	_screen.dst_ptr = _cocoa_subdriver->GetPixelBuffer();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   639
	UpdateWindows();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   640
	QZ_CheckPaletteAnim();
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   641
	_cocoa_subdriver->Draw();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   642
	CSleep(1);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   643
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   644
	for (;;) {
5843
39deb3484971 (svn r8043) -Fix (8028): forgot setting a variable.
rubidium
parents: 5838
diff changeset
   645
		uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   646
		InteractiveRandom(); // randomness
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   647
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   648
		while (QZ_PollEvent()) {}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   649
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   650
		if (_exit_game) break;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   651
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   652
#if defined(_DEBUG)
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   653
		if (_current_mods & NSShiftKeyMask)
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   654
#else
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   655
		if (_tab_is_down)
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   656
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   657
		{
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   658
			if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2;
4536
f13408cba18f (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4509
diff changeset
   659
		} else if (_fast_forward & 2) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   660
			_fast_forward = 0;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   661
		}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   662
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   663
		cur_ticks = GetTick();
6562
ffdb1169edce (svn r9039) -Fix r9034: missed the _pause in cocoa_v.mm
bjarni
parents: 6514
diff changeset
   664
		if (cur_ticks >= next_tick || (_fast_forward && !_pause_game) || cur_ticks < prev_cur_ticks) {
7515
46295cf47928 (svn r10278) -Fix r10276: make the _realtime_tick less demanding on the CPU
truelight
parents: 7514
diff changeset
   665
			_realtime_tick += cur_ticks - last_cur_ticks;
46295cf47928 (svn r10278) -Fix r10276: make the _realtime_tick less demanding on the CPU
truelight
parents: 7514
diff changeset
   666
			last_cur_ticks = cur_ticks;
5832
28aa8ad3bb04 (svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient.
rubidium
parents: 5794
diff changeset
   667
			next_tick = cur_ticks + 30;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   668
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   669
			_ctrl_pressed = !!(_current_mods & ( _patches.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask));
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   670
			_shift_pressed = !!(_current_mods & NSShiftKeyMask);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   671
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   672
			GameLoop();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   673
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   674
			_screen.dst_ptr = _cocoa_subdriver->GetPixelBuffer();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   675
			UpdateWindows();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   676
			if (++pal_tick > 4) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   677
				QZ_CheckPaletteAnim();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   678
				pal_tick = 1;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   679
			}
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   680
			_cocoa_subdriver->Draw();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   681
		} else {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   682
#ifdef _DEBUG
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   683
			st0 = GetTick();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   684
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   685
			CSleep(1);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   686
#ifdef _DEBUG
3036
d6670ee6981f (svn r3616) Style sweep
tron
parents: 3035
diff changeset
   687
			st += GetTick() - st0;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   688
#endif
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   689
			_screen.dst_ptr = _cocoa_subdriver->GetPixelBuffer();
7952
5ed8694bb77e (svn r10946) -Fix (r10932): forgot one occurence
glx
parents: 7930
diff changeset
   690
			DrawChatMessage();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   691
			DrawMouseCursor();
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   692
			_cocoa_subdriver->Draw();
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   693
		}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   694
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   695
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   696
#ifdef _DEBUG
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   697
	et = GetTick();
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   698
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   699
	DEBUG(driver, 1, "cocoa_v: nextEventMatchingMask took %i ms total", _tEvent);
5571
2d8adccea2fd (svn r7569) -Fix (r7565): cocoa files were (somehow) forgotten.
rubidium
parents: 5090
diff changeset
   700
	DEBUG(driver, 1, "cocoa_v: game loop took %i ms total (%i ms without sleep)", et - et0, et - et0 - st);
8435
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   701
	DEBUG(driver, 1, "cocoa_v: (nextEventMatchingMask total)/(game loop total) is %f%%", (double)_tEvent / (double)(et - et0) * 100);
38a1ab65d6e4 (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier).
egladil
parents: 8423
diff changeset
   702
	DEBUG(driver, 1, "cocoa_v: (nextEventMatchingMask total)/(game loop without sleep total) is %f%%", (double)_tEvent / (double)(et - et0 - st) * 100);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   703
#endif
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   704
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   705
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   706
#endif /* WITH_COCOA */