Skip to content

Commit

Permalink
Cleaned out all the deprecated stuff in Mac OS X 10.6 SDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 22, 2011
1 parent 1c072ec commit 991bbb9
Show file tree
Hide file tree
Showing 4 changed files with 303 additions and 114 deletions.
110 changes: 88 additions & 22 deletions src/video/quartz/SDL_QuartzEvents.m
Expand Up @@ -79,9 +79,10 @@

void QZ_InitOSKeymap (_THIS) {
const void *KCHRPtr;
BOOL saw_layout = NO;
UInt32 state;
UInt32 value;
int i;
Uint16 i;
int world = SDLK_WORLD_0;

for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
Expand Down Expand Up @@ -212,31 +213,96 @@ void QZ_InitOSKeymap (_THIS) {
why we keep the static table, too.
*/

/* Get a pointer to the systems cached KCHR */
KCHRPtr = (void *)GetScriptManagerVariable(smKCHRCache);
if (KCHRPtr)
{
/* Loop over all 127 possible scan codes */
for (i = 0; i < 0x7F; i++)
{
/* We pretend a clean start to begin with (i.e. no dead keys active */
state = 0;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1050)
if (TISCopyCurrentKeyboardLayoutInputSource != NULL) {
TISInputSourceRef src = TISCopyCurrentKeyboardLayoutInputSource();
if (src != NULL) {
CFDataRef data = (CFDataRef)
TISGetInputSourceProperty(src,
kTISPropertyUnicodeKeyLayoutData);
if (data != NULL) {
const UCKeyboardLayout *layout = (const UCKeyboardLayout *)
CFDataGetBytePtr(data);
if (layout != NULL) {
const UInt32 kbdtype = LMGetKbdType();
saw_layout = YES;

/* Loop over all 127 possible scan codes */
for (i = 0; i < 0x7F; i++) {
UniChar buf[16];
UniCharCount count = 0;

/* We pretend a clean start to begin with (i.e. no dead keys active */
state = 0;

if (UCKeyTranslate(layout, i, kUCKeyActionDown, 0, kbdtype,
0, &state, 16, &count, buf) != noErr) {
continue;
}

/* If the state become 0, it was a dead key. We need to
translate again, passing in the new state, to get
the actual key value */
if (state != 0) {
if (UCKeyTranslate(layout, i, kUCKeyActionDown, 0, kbdtype,
0, &state, 16, &count, buf) != noErr) {
continue;
}
}

if (count != 1) {
continue; /* no multi-char. Use SDL 1.3 instead. :) */
}

value = (UInt32) buf[0];
if (value >= 128) {
/* Some non-ASCII char, map it to SDLK_WORLD_* */
if (world < 0xFF) {
keymap[i] = world++;
}
} else if (value >= 32) { /* non-control ASCII char */
keymap[i] = value;
}
}
}
}
CFRelease(src);
}
}
#endif

/* Now translate the key code to a key value */
value = KeyTranslate(KCHRPtr, i, &state) & 0xff;
#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1050)
if (!saw_layout) {
/* Get a pointer to the systems cached KCHR */
KCHRPtr = (void *)GetScriptManagerVariable(smKCHRCache);
if (KCHRPtr)
{
/* Loop over all 127 possible scan codes */
for (i = 0; i < 0x7F; i++)
{
/* We pretend a clean start to begin with (i.e. no dead keys active */
state = 0;

/* If the state become 0, it was a dead key. We need to translate again,
passing in the new state, to get the actual key value */
if (state != 0)
/* Now translate the key code to a key value */
value = KeyTranslate(KCHRPtr, i, &state) & 0xff;

/* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */
if (value >= 128) /* Some non-ASCII char, map it to SDLK_WORLD_* */
keymap[i] = world++;
else if (value >= 32) /* non-control ASCII char */
keymap[i] = value;
/* If the state become 0, it was a dead key. We need to translate again,
passing in the new state, to get the actual key value */
if (state != 0)
value = KeyTranslate(KCHRPtr, i, &state) & 0xff;

/* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */
if (value >= 128) { /* Some non-ASCII char, map it to SDLK_WORLD_* */
if (world < 0xFF) {
keymap[i] = world++;
}
} else if (value >= 32) { /* non-control ASCII char */
keymap[i] = value;
}
}
}
}
#endif

/*
The keypad codes are re-setup here, because the loop above cannot
Expand Down Expand Up @@ -730,7 +796,7 @@ static int QZ_OtherMouseButtonToSDL(int button)

void QZ_PumpEvents (_THIS)
{
CGMouseDelta dx, dy;
int32_t dx, dy;

NSDate *distantPast;
NSEvent *event;
Expand Down Expand Up @@ -853,7 +919,7 @@ void QZ_PumpEvents (_THIS)
so we have to call the lowlevel window server
function. This is less accurate but works OK.
*/
CGMouseDelta dx1, dy1;
int32_t dx1, dy1;
CGGetLastMouseDelta (&dx1, &dy1);
dx += dx1;
dy += dy1;
Expand Down
12 changes: 4 additions & 8 deletions src/video/quartz/SDL_QuartzVideo.h
Expand Up @@ -40,7 +40,6 @@
- Check accuracy of QZ_SetGamma()
Problems:
- OGL not working in full screen with software renderer
- SetColors sets palette correctly but clears framebuffer
- Crash in CG after several mode switches (I think this has been fixed)
- Retained windows don't draw their title bar quite right (OS Bug) (not using retained windows)
- Cursor in 8 bit modes is screwy (might just be Radeon PCI bug) (update: not just Radeon)
Expand Down Expand Up @@ -86,13 +85,11 @@ CGLContextObj QZ_GetCGLContextObj(NSOpenGLContext *nsctx);

/* Main driver structure to store required state information */
typedef struct SDL_PrivateVideoData {

BOOL snow_leopard_or_later;
BOOL allow_screensaver; /* 0 == disable screensaver */
CGDirectDisplayID display; /* 0 == main display (only support single display) */
CFDictionaryRef mode; /* current mode of the display */
CFDictionaryRef save_mode; /* original mode of the display */
CFArrayRef mode_list; /* list of available fullscreen modes */
CGDirectPaletteRef palette; /* palette of an 8-bit display */
const void *mode; /* current mode of the display */
const void *save_mode; /* original mode of the display */
NSOpenGLContext *gl_context; /* OpenGL rendering context */
Uint32 width, height, bpp; /* frequently used data about the display */
Uint32 flags; /* flags for current mode, for teardown purposes */
Expand Down Expand Up @@ -129,9 +126,8 @@ typedef struct SDL_PrivateVideoData {
#define display_id (this->hidden->display)
#define mode (this->hidden->mode)
#define save_mode (this->hidden->save_mode)
#define snow_leopard_or_later (this->hidden->snow_leopard_or_later)
#define allow_screensaver (this->hidden->allow_screensaver)
#define mode_list (this->hidden->mode_list)
#define palette (this->hidden->palette)
#define gl_context (this->hidden->gl_context)
#define device_width (this->hidden->width)
#define device_height (this->hidden->height)
Expand Down

0 comments on commit 991bbb9

Please sign in to comment.