From 6039eb05ba6d82ef56f2868c96654c552d117bf9 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Wed, 7 Feb 2018 20:04:46 -0500 Subject: sdl: remove non-rockbox drivers We never use any of these other drivers, so having them around just takes up space. Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41 --- .../plugins/sdl/src/video/maccommon/SDL_lowvideo.h | 102 --- .../sdl/src/video/maccommon/SDL_macevents.c | 746 --------------------- .../sdl/src/video/maccommon/SDL_macevents_c.h | 32 - apps/plugins/sdl/src/video/maccommon/SDL_macgl.c | 197 ------ apps/plugins/sdl/src/video/maccommon/SDL_macgl_c.h | 47 -- apps/plugins/sdl/src/video/maccommon/SDL_mackeys.h | 140 ---- .../plugins/sdl/src/video/maccommon/SDL_macmouse.c | 129 ---- .../sdl/src/video/maccommon/SDL_macmouse_c.h | 34 - apps/plugins/sdl/src/video/maccommon/SDL_macwm.c | 442 ------------ apps/plugins/sdl/src/video/maccommon/SDL_macwm_c.h | 41 -- 10 files changed, 1910 deletions(-) delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_lowvideo.h delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_macevents.c delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_macevents_c.h delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_macgl.c delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_macgl_c.h delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_mackeys.h delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_macmouse.c delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_macmouse_c.h delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_macwm.c delete mode 100644 apps/plugins/sdl/src/video/maccommon/SDL_macwm_c.h (limited to 'apps/plugins/sdl/src/video/maccommon') diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_lowvideo.h b/apps/plugins/sdl/src/video/maccommon/SDL_lowvideo.h deleted file mode 100644 index f3dac29091..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_lowvideo.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_lowvideo_h -#define _SDL_lowvideo_h - -#if defined(__APPLE__) && defined(__MACH__) -#include -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) -#include -#else -#include -#include -#include -#include -#endif - -#if SDL_VIDEO_OPENGL -typedef struct __AGLContextRec *AGLContext; -#endif - -#include "SDL_video.h" -#include "../SDL_sysvideo.h" - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *this - -#if !TARGET_API_MAC_CARBON /* not available in OS X (or more accurately, Carbon) */ -/* Global QuickDraw data */ -extern QDGlobals *theQD; -#endif - -/* Private display data */ -struct SDL_PrivateVideoData { - GDevice **SDL_Display; - WindowRef SDL_Window; - SDL_Rect **SDL_modelist; - CTabHandle SDL_CTab; - PaletteHandle SDL_CPal; - -#if TARGET_API_MAC_CARBON - /* For entering and leaving fullscreen mode */ - Ptr fullscreen_ctx; -#endif - - /* The current window document style */ - int current_style; - - /* Information about the last cursor position */ - Point last_where; - - /* Information about the last keys down */ - EventModifiers last_mods; - KeyMap last_keys; - - /* A handle to the Apple Menu */ - MenuRef apple_menu; - - /* Information used by DrawSprocket driver */ - struct DSpInfo *dspinfo; - -#if SDL_VIDEO_OPENGL - AGLContext appleGLContext; - - void *libraryHandle; -#endif -}; -/* Old variable names */ -#define SDL_Display (this->hidden->SDL_Display) -#define SDL_Window (this->hidden->SDL_Window) -#define SDL_modelist (this->hidden->SDL_modelist) -#define SDL_CTab (this->hidden->SDL_CTab) -#define SDL_CPal (this->hidden->SDL_CPal) -#define fullscreen_ctx (this->hidden->fullscreen_ctx) -#define current_style (this->hidden->current_style) -#define last_where (this->hidden->last_where) -#define last_mods (this->hidden->last_mods) -#define last_keys (this->hidden->last_keys) -#define apple_menu (this->hidden->apple_menu) -#define glContext (this->hidden->appleGLContext) - -#endif /* _SDL_lowvideo_h */ diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_macevents.c b/apps/plugins/sdl/src/video/maccommon/SDL_macevents.c deleted file mode 100644 index 6e3fef2d60..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_macevents.c +++ /dev/null @@ -1,746 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include - -#if defined(__APPLE__) && defined(__MACH__) -#include -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) -#include -#else -#include -#include -#include -#include -#include -#endif - -#include "SDL_events.h" -#include "SDL_video.h" -#include "SDL_syswm.h" -#include "../../events/SDL_events_c.h" -#include "../../events/SDL_sysevents.h" -#include "../SDL_cursor_c.h" -#include "SDL_macevents_c.h" -#include "SDL_mackeys.h" -#include "SDL_macmouse_c.h" - -/* Define this to be able to collapse SDL windows. -#define USE_APPEARANCE_MANAGER - */ - -/* Macintosh resource constants */ -#define mApple 128 /* Apple menu resource */ -#define iAbout 1 /* About menu item */ - -/* Functions to handle the About menu */ -static void Mac_DoAppleMenu(_THIS, long item); - -/* The translation table from a macintosh key scancode to a SDL keysym */ -static SDLKey MAC_keymap[256]; -static SDL_keysym *TranslateKey(int scancode, int modifiers, - SDL_keysym *keysym, int pressed); - -/* Handle activation and deactivation -- returns whether an event was posted */ -static int Mac_HandleActivate(int activate) -{ - if ( activate ) { - /* Show the current SDL application cursor */ - SDL_SetCursor(NULL); - - /* put our mask back case it changed during context switch */ - SetEventMask(everyEvent & ~autoKeyMask); - } else { -#if TARGET_API_MAC_CARBON - { Cursor cursor; - SetCursor(GetQDGlobalsArrow(&cursor)); - } -#else - SetCursor(&theQD->arrow); -#endif - if ( ! Mac_cursor_showing ) { - ShowCursor(); - Mac_cursor_showing = 1; - } - } - return(SDL_PrivateAppActive(activate, SDL_APPINPUTFOCUS)); -} - -static void myGlobalToLocal(_THIS, Point *pt) -{ - if ( SDL_VideoSurface && !(SDL_VideoSurface->flags&SDL_FULLSCREEN) ) { - GrafPtr saveport; - GetPort(&saveport); -#if TARGET_API_MAC_CARBON - SetPort(GetWindowPort(SDL_Window)); -#else - SetPort(SDL_Window); -#endif - GlobalToLocal(pt); - SetPort(saveport); - } -} - -/* The main MacOS event handler */ -static int Mac_HandleEvents(_THIS, int wait4it) -{ - static int mouse_button = 1; - int i; - EventRecord event; - -#if TARGET_API_MAC_CARBON - /* There's no GetOSEvent() in the Carbon API. *sigh* */ -#define cooperative_multitasking 1 -#else - int cooperative_multitasking; - /* If we're running fullscreen, we can hog the MacOS events, - otherwise we had better play nicely with the other apps. - */ - if ( this->screen && (this->screen->flags & SDL_FULLSCREEN) ) { - cooperative_multitasking = 0; - } else { - cooperative_multitasking = 1; - } -#endif - - /* If we call WaitNextEvent(), MacOS will check other processes - * and allow them to run, and perform other high-level processing. - */ - if ( cooperative_multitasking || wait4it ) { - UInt32 wait_time; - - /* Are we polling or not? */ - if ( wait4it ) { - wait_time = 2147483647; - } else { - wait_time = 0; - } - WaitNextEvent(everyEvent, &event, wait_time, nil); - } else { -#if ! TARGET_API_MAC_CARBON - GetOSEvent(everyEvent, &event); -#endif - } - -#if TARGET_API_MAC_CARBON - /* for some reason, event.where isn't set ? */ - GetGlobalMouse ( &event.where ); -#endif - - /* Check for mouse motion */ - if ( (event.where.h != last_where.h) || - (event.where.v != last_where.v) ) { - Point pt; - pt = last_where = event.where; - myGlobalToLocal(this, &pt); - SDL_PrivateMouseMotion(0, 0, pt.h, pt.v); - } - - /* Check the current state of the keyboard */ - if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { - KeyMap keys; - const Uint32 *keysptr = (Uint32 *) &keys; - const Uint32 *last_keysptr = (Uint32 *) &last_keys; - - /* Check for special non-event keys */ - if ( event.modifiers != last_mods ) { - static struct { - EventModifiers mask; - SDLKey key; - } mods[] = { - { alphaLock, SDLK_CAPSLOCK }, -#if 0 /* These are handled below in the GetKeys() code */ - { cmdKey, SDLK_LMETA }, - { shiftKey, SDLK_LSHIFT }, - { rightShiftKey, SDLK_RSHIFT }, - { optionKey, SDLK_LALT }, - { rightOptionKey, SDLK_RALT }, - { controlKey, SDLK_LCTRL }, - { rightControlKey, SDLK_RCTRL }, -#endif /* 0 */ - { 0, 0 } - }; - SDL_keysym keysym; - Uint8 mode; - EventModifiers mod, mask; - - - /* Set up the keyboard event */ - keysym.scancode = 0; - keysym.sym = SDLK_UNKNOWN; - keysym.mod = KMOD_NONE; - keysym.unicode = 0; - - /* See what has changed, and generate events */ - mod = event.modifiers; - for ( i=0; mods[i].mask; ++i ) { - mask = mods[i].mask; - if ( (mod&mask) != (last_mods&mask) ) { - keysym.sym = mods[i].key; - if ( (mod&mask) || - (mods[i].key == SDLK_CAPSLOCK) ) { - mode = SDL_PRESSED; - } else { - mode = SDL_RELEASED; - } - SDL_PrivateKeyboard(mode, &keysym); - } - } - - /* Save state for next time */ - last_mods = mod; - } - - /* Check for normal event keys, but we have to scan the - actual keyboard state because on Mac OS X a keydown event - is immediately followed by a keyup event. - */ - GetKeys(keys); - if ( (keysptr[0] != last_keysptr[0]) || - (keysptr[1] != last_keysptr[1]) || - (keysptr[2] != last_keysptr[2]) || - (keysptr[3] != last_keysptr[3]) ) { - SDL_keysym keysym; - int old_bit, new_bit; - -#ifdef DEBUG_KEYBOARD - fprintf(sterr, "New keys: 0x%x 0x%x 0x%x 0x%x\n", - new_keys[0], new_keys[1], - new_keys[2], new_keys[3]); -#endif - for ( i=0; i<128; ++i ) { - old_bit = (((Uint8 *)last_keys)[i/8]>>(i%8)) & 0x01; - new_bit = (((Uint8 *)keys)[i/8]>>(i%8)) & 0x01; - if ( old_bit != new_bit ) { - /* Post the keyboard event */ -#ifdef DEBUG_KEYBOARD - fprintf(stderr,"Scancode: 0x%2.2X\n",i); -#endif - SDL_PrivateKeyboard(new_bit, - TranslateKey(i, event.modifiers, - &keysym, new_bit)); - } - } - - /* Save state for next time */ - last_keys[0] = keys[0]; - last_keys[1] = keys[1]; - last_keys[2] = keys[2]; - last_keys[3] = keys[3]; - } - } - - /* Handle normal events */ - switch (event.what) { - case mouseDown: { - WindowRef win; - short area; - - area = FindWindow(event.where, &win); - /* Support switching between the SIOUX console - and SDL_Window by clicking in the window. - */ - if ( win && (win != FrontWindow()) ) { - SelectWindow(win); - } - switch (area) { - case inMenuBar: /* Only the apple menu exists */ - Mac_DoAppleMenu(this, MenuSelect(event.where)); - HiliteMenu(0); - break; - case inDrag: -#if TARGET_API_MAC_CARBON - DragWindow(win, event.where, NULL); -#else - DragWindow(win, event.where, &theQD->screenBits.bounds); -#endif - break; - case inGoAway: - if ( TrackGoAway(win, event.where) ) { - SDL_PrivateQuit(); - } - break; - case inContent: - myGlobalToLocal(this, &event.where); - /* Treat command-click as right mouse button */ - if ( event.modifiers & optionKey ) { - mouse_button = 2; - } else if ( event.modifiers & cmdKey ) { - mouse_button = 3; - } else { - mouse_button = 1; - } - SDL_PrivateMouseButton(SDL_PRESSED, - mouse_button, event.where.h, event.where.v); - break; - case inGrow: { - int newSize; - - /* Don't allow resize if video mode isn't resizable */ - if ( ! SDL_PublicSurface || - ! (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { - break; - } -#if TARGET_API_MAC_CARBON - newSize = GrowWindow(win, event.where, NULL); -#else - newSize = GrowWindow(win, event.where, &theQD->screenBits.bounds); -#endif - if ( newSize ) { -#if !TARGET_API_MAC_CARBON - EraseRect ( &theQD->screenBits.bounds ); -#endif - SizeWindow ( win, LoWord (newSize), HiWord (newSize), 1 ); - SDL_PrivateResize ( LoWord (newSize), HiWord (newSize) ); - } - } break; - case inZoomIn: - case inZoomOut: - if ( TrackBox (win, event.where, area )) { - Rect rect; -#if !TARGET_API_MAC_CARBON - EraseRect ( &theQD->screenBits.bounds ); -#endif - ZoomWindow ( win, area, 0); - if ( area == inZoomIn ) { - GetWindowUserState(SDL_Window, &rect); - } else { - GetWindowStandardState(SDL_Window, &rect); - } - SDL_PrivateResize (rect.right-rect.left, - rect.bottom-rect.top); - } - break; -#if TARGET_API_MAC_CARBON - case inCollapseBox: - if ( TrackBox (win, event.where, area )) { - if ( IsWindowCollapsable(win) ) { - CollapseWindow (win, !IsWindowCollapsed(win)); - /* There should be something done like in inGrow case, but... */ - } - } - break; -#endif /* TARGET_API_MAC_CARBON */ - case inSysWindow: -#if TARGET_API_MAC_CARBON - /* Never happens in Carbon? */ -#else - SystemClick(&event, win); -#endif - break; - default: - break; - } - } - break; - case mouseUp: { - myGlobalToLocal(this, &event.where); - /* Release the mouse button we simulated in the last press. - The drawback of this methos is we cannot press more than - one button. However, this doesn't matter, since there is - only a single logical mouse button, even if you have a - multi-button mouse, this doesn't matter at all. - */ - SDL_PrivateMouseButton(SDL_RELEASED, - mouse_button, event.where.h, event.where.v); - } - break; -#if 0 /* Handled above the switch statement */ - case keyDown: { - SDL_keysym keysym; - - SDL_PrivateKeyboard(SDL_PRESSED, - TranslateKey((event.message&keyCodeMask)>>8 - event.modifiers, &keysym, 1)); - } - break; - case keyUp: { - SDL_keysym keysym; - - SDL_PrivateKeyboard(SDL_RELEASED, - TranslateKey((event.message&keyCodeMask)>>8 - event.modifiers, &keysym, 0)); - } - break; -#endif - case updateEvt: { - BeginUpdate(SDL_Window); - #if SDL_VIDEO_OPENGL - if (SDL_VideoSurface->flags & SDL_OPENGL) - SDL_GL_SwapBuffers(); - else - #endif - if ( (SDL_VideoSurface->flags & SDL_HWSURFACE) == - SDL_SWSURFACE ) { - SDL_UpdateRect(SDL_VideoSurface, 0, 0, 0, 0); - } - EndUpdate(SDL_Window); - } - /* If this was an update event for the SIOUX console, we return 0 - in order to stop an endless series of updates being triggered. - */ - if ( (WindowRef) event.message != SDL_Window ) { - return 0; - } - break; - case activateEvt: { - Mac_HandleActivate(!!(event.modifiers & activeFlag)); - } - break; - case diskEvt: { -#if TARGET_API_MAC_CARBON - /* What are we supposed to do? */; -#else - if ( ((event.message>>16)&0xFFFF) != noErr ) { - Point spot; - SetPt(&spot, 0x0070, 0x0050); - DIBadMount(spot, event.message); - } -#endif - } - break; - case osEvt: { - switch ((event.message>>24) & 0xFF) { -#if 0 /* Handled above the switch statement */ - case mouseMovedMessage: { - myGlobalToLocal(this, &event.where); - SDL_PrivateMouseMotion(0, 0, - event.where.h, event.where.v); - } - break; -#endif /* 0 */ - case suspendResumeMessage: { - Mac_HandleActivate(!!(event.message & resumeFlag)); - } - break; - } - } - break; - default: { - ; - } - break; - } - return (event.what != nullEvent); -} - - -void Mac_PumpEvents(_THIS) -{ - /* Process pending MacOS events */ - while ( Mac_HandleEvents(this, 0) ) { - /* Loop and check again */; - } -} - -void Mac_InitOSKeymap(_THIS) -{ - const void *KCHRPtr; - UInt32 state; - UInt32 value; - int i; - int world = SDLK_WORLD_0; - - /* Map the MAC keysyms */ - for ( i=0; ikeysym map. However, it will not - * work very well on international keyboard. Hence we now query MacOS - * for its own keymap to adjust our own mapping table. However, this is - * bascially only useful for ascii char keys. This is also the reason - * 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; - - /* Now translate the key code to a key value */ - value = KeyTranslate(KCHRPtr, i, &state) & 0xff; - - /* 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_* */ - MAC_keymap[i] = world++; - else if (value >= 32) /* non-control ASCII char */ - MAC_keymap[i] = value; - } - } - - /* The keypad codes are re-setup here, because the loop above cannot - * distinguish between a key on the keypad and a regular key. We maybe - * could get around this problem in another fashion: NSEvent's flags - * include a "NSNumericPadKeyMask" bit; we could check that and modify - * the symbol we return on the fly. However, this flag seems to exhibit - * some weird behaviour related to the num lock key - */ - MAC_keymap[MK_KP0] = SDLK_KP0; - MAC_keymap[MK_KP1] = SDLK_KP1; - MAC_keymap[MK_KP2] = SDLK_KP2; - MAC_keymap[MK_KP3] = SDLK_KP3; - MAC_keymap[MK_KP4] = SDLK_KP4; - MAC_keymap[MK_KP5] = SDLK_KP5; - MAC_keymap[MK_KP6] = SDLK_KP6; - MAC_keymap[MK_KP7] = SDLK_KP7; - MAC_keymap[MK_KP8] = SDLK_KP8; - MAC_keymap[MK_KP9] = SDLK_KP9; - MAC_keymap[MK_KP_MINUS] = SDLK_KP_MINUS; - MAC_keymap[MK_KP_PLUS] = SDLK_KP_PLUS; - MAC_keymap[MK_KP_PERIOD] = SDLK_KP_PERIOD; - MAC_keymap[MK_KP_EQUALS] = SDLK_KP_EQUALS; - MAC_keymap[MK_KP_DIVIDE] = SDLK_KP_DIVIDE; - MAC_keymap[MK_KP_MULTIPLY] = SDLK_KP_MULTIPLY; - MAC_keymap[MK_KP_ENTER] = SDLK_KP_ENTER; -} - -static SDL_keysym *TranslateKey(int scancode, int modifiers, - SDL_keysym *keysym, int pressed) -{ - /* Set the keysym information */ - keysym->scancode = scancode; - keysym->sym = MAC_keymap[keysym->scancode]; - keysym->mod = KMOD_NONE; - keysym->unicode = 0; - if ( pressed && SDL_TranslateUNICODE ) { - static unsigned long state = 0; - static Ptr keymap = nil; - Ptr new_keymap; - - /* Get the current keyboard map resource */ - new_keymap = (Ptr)GetScriptManagerVariable(smKCHRCache); - if ( new_keymap != keymap ) { - keymap = new_keymap; - state = 0; - } - keysym->unicode = KeyTranslate(keymap, - keysym->scancode|modifiers, &state) & 0xFFFF; - } - return(keysym); -} - -void Mac_InitEvents(_THIS) -{ - /* Create apple menu bar */ - apple_menu = GetMenu(mApple); - if ( apple_menu != nil ) { - AppendResMenu(apple_menu, 'DRVR'); - InsertMenu(apple_menu, 0); - } - DrawMenuBar(); - - /* Get rid of spurious events at startup */ - FlushEvents(everyEvent, 0); - - /* Allow every event but keyrepeat */ - SetEventMask(everyEvent & ~autoKeyMask); -} - -void Mac_QuitEvents(_THIS) -{ - ClearMenuBar(); - if ( apple_menu != nil ) { - ReleaseResource((char **)apple_menu); - } - - /* Clean up pending events */ - FlushEvents(everyEvent, 0); -} - -static void Mac_DoAppleMenu(_THIS, long choice) -{ -#if !TARGET_API_MAC_CARBON /* No Apple menu in OS X */ - short menu, item; - - item = (choice&0xFFFF); - choice >>= 16; - menu = (choice&0xFFFF); - - switch (menu) { - case mApple: { - switch (item) { - case iAbout: { - /* Run the about box */; - } - break; - default: { - Str255 name; - - GetMenuItemText(apple_menu, item, name); - OpenDeskAcc(name); - } - break; - } - } - break; - default: { - /* Ignore other menus */; - } - } -#endif /* !TARGET_API_MAC_CARBON */ -} - -#if !TARGET_API_MAC_CARBON -/* Since we don't initialize QuickDraw, we need to get a pointer to qd */ -struct QDGlobals *theQD = NULL; -#endif - -/* Exported to the macmain code */ -void SDL_InitQuickDraw(struct QDGlobals *the_qd) -{ -#if !TARGET_API_MAC_CARBON - theQD = the_qd; -#endif -} diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_macevents_c.h b/apps/plugins/sdl/src/video/maccommon/SDL_macevents_c.h deleted file mode 100644 index f9a983bde1..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_macevents_c.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "../macrom/SDL_romvideo.h" - -/* Functions exported by SDL_macevents.c for the video subsystem -*/ -extern void Mac_InitEvents(_THIS); -extern void Mac_QuitEvents(_THIS); - -extern void Mac_InitOSKeymap(_THIS); -extern void Mac_PumpEvents(_THIS); diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_macgl.c b/apps/plugins/sdl/src/video/maccommon/SDL_macgl.c deleted file mode 100644 index b7ded9bc5a..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_macgl.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* AGL implementation of SDL OpenGL support */ - -#include "SDL_lowvideo.h" -#include "SDL_macgl_c.h" -#include "SDL_loadso.h" - - -/* krat: adding OpenGL support */ -int Mac_GL_Init(_THIS) -{ -#if SDL_VIDEO_OPENGL - AGLPixelFormat format; - int i = 0; - GLint attributes [ 26 ]; /* 26 is max possible in this setup */ - GLboolean noerr; - - /* load the gl driver from a default path */ - if ( ! this->gl_config.driver_loaded ) { - /* no driver has been loaded, use default (ourselves) */ - if ( Mac_GL_LoadLibrary(this, NULL) < 0 ) { - return(-1); - } - } - - attributes[i++] = AGL_RGBA; - if ( this->gl_config.red_size != 0 && - this->gl_config.blue_size != 0 && - this->gl_config.green_size != 0 ) { - attributes[i++] = AGL_RED_SIZE; - attributes[i++] = this->gl_config.red_size; - attributes[i++] = AGL_GREEN_SIZE; - attributes[i++] = this->gl_config.green_size; - attributes[i++] = AGL_BLUE_SIZE; - attributes[i++] = this->gl_config.blue_size; - attributes[i++] = AGL_ALPHA_SIZE; - attributes[i++] = this->gl_config.alpha_size; - } - if ( this->gl_config.double_buffer ) { - attributes[i++] = AGL_DOUBLEBUFFER; - } - if ( this->gl_config.depth_size != 0 ) { - attributes[i++] = AGL_DEPTH_SIZE; - attributes[i++] = this->gl_config.depth_size; - } - if ( this->gl_config.stencil_size != 0 ) { - attributes[i++] = AGL_STENCIL_SIZE; - attributes[i++] = this->gl_config.stencil_size; - } - if ( this->gl_config.accum_red_size != 0 && - this->gl_config.accum_blue_size != 0 && - this->gl_config.accum_green_size != 0 ) { - - attributes[i++] = AGL_ACCUM_RED_SIZE; - attributes[i++] = this->gl_config.accum_red_size; - attributes[i++] = AGL_ACCUM_GREEN_SIZE; - attributes[i++] = this->gl_config.accum_green_size; - attributes[i++] = AGL_ACCUM_BLUE_SIZE; - attributes[i++] = this->gl_config.accum_blue_size; - attributes[i++] = AGL_ACCUM_ALPHA_SIZE; - attributes[i++] = this->gl_config.accum_alpha_size; - } - if ( this->gl_config.stereo ) { - attributes[i++] = AGL_STEREO; - } -#if defined(AGL_SAMPLE_BUFFERS_ARB) && defined(AGL_SAMPLES_ARB) - if ( this->gl_config.multisamplebuffers != 0 ) { - attributes[i++] = AGL_SAMPLE_BUFFERS_ARB; - attributes[i++] = this->gl_config.multisamplebuffers; - } - if ( this->gl_config.multisamplesamples != 0 ) { - attributes[i++] = AGL_SAMPLES_ARB; - attributes[i++] = this->gl_config.multisamplesamples; - } -#endif - if ( this->gl_config.accelerated > 0 ) { - attributes[i++] = AGL_ACCELERATED; - attributes[i++] = AGL_NO_RECOVERY; - } - - attributes[i++] = AGL_ALL_RENDERERS; - attributes[i] = AGL_NONE; - - format = aglChoosePixelFormat(NULL, 0, attributes); - if ( format == NULL ) { - SDL_SetError("Couldn't match OpenGL desired format"); - return(-1); - } - - glContext = aglCreateContext(format, NULL); - if ( glContext == NULL ) { - SDL_SetError("Couldn't create OpenGL context"); - return(-1); - } - aglDestroyPixelFormat(format); - - #if TARGET_API_MAC_CARBON - noerr = aglSetDrawable(glContext, GetWindowPort(SDL_Window)); - #else - noerr = aglSetDrawable(glContext, (AGLDrawable)SDL_Window); - #endif - - if(!noerr) { - SDL_SetError("Unable to bind GL context to window"); - return(-1); - } - return(0); -#else - SDL_SetError("OpenGL support not configured"); - return(-1); -#endif -} - -void Mac_GL_Quit(_THIS) -{ -#if SDL_VIDEO_OPENGL - if ( glContext != NULL ) { - aglSetCurrentContext(NULL); - aglSetDrawable(glContext, NULL); - aglDestroyContext(glContext); - glContext = NULL; - } -#endif -} - -#if SDL_VIDEO_OPENGL - -/* Make the current context active */ -int Mac_GL_MakeCurrent(_THIS) -{ - int retval; - - retval = 0; - if( ! aglSetCurrentContext(glContext) ) { - SDL_SetError("Unable to make GL context current"); - retval = -1; - } - return(retval); -} - -void Mac_GL_SwapBuffers(_THIS) -{ - aglSwapBuffers(glContext); -} - -int Mac_GL_LoadLibrary(_THIS, const char *location) -{ - if (location == NULL) -#if __MACH__ - location = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; -#else - location = "OpenGLLibrary"; -#endif - - this->hidden->libraryHandle = SDL_LoadObject(location); - - this->gl_config.driver_loaded = 1; - return (this->hidden->libraryHandle != NULL) ? 0 : -1; -} - -void Mac_GL_UnloadLibrary(_THIS) -{ - SDL_UnloadObject(this->hidden->libraryHandle); - - this->hidden->libraryHandle = NULL; - this->gl_config.driver_loaded = 0; -} - -void* Mac_GL_GetProcAddress(_THIS, const char *proc) -{ - return SDL_LoadFunction( this->hidden->libraryHandle, proc ); -} - -#endif /* SDL_VIDEO_OPENGL */ - diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_macgl_c.h b/apps/plugins/sdl/src/video/maccommon/SDL_macgl_c.h deleted file mode 100644 index 42cd70fbd2..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_macgl_c.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* AGL implementation of SDL OpenGL support */ - -#include "SDL_config.h" - -#if SDL_VIDEO_OPENGL -#include "SDL_opengl.h" -#if __MACOSX__ -#include /* AGL.framework */ -#else -#include -#endif -#endif /* SDL_VIDEO_OPENGL */ - -/* OpenGL functions */ -extern int Mac_GL_Init(_THIS); -extern void Mac_GL_Quit(_THIS); -#if SDL_VIDEO_OPENGL -extern int Mac_GL_MakeCurrent(_THIS); -extern int Mac_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); -extern void Mac_GL_SwapBuffers(_THIS); -extern int Mac_GL_LoadLibrary(_THIS, const char *location); -extern void Mac_GL_UnloadLibrary(_THIS); -extern void* Mac_GL_GetProcAddress(_THIS, const char *proc); -#endif - diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_mackeys.h b/apps/plugins/sdl/src/video/maccommon/SDL_mackeys.h deleted file mode 100644 index dfed30da23..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_mackeys.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* These are the Macintosh key scancode constants -- from Inside Macintosh */ - -#define MK_ESCAPE 0x35 -#define MK_F1 0x7A -#define MK_F2 0x78 -#define MK_F3 0x63 -#define MK_F4 0x76 -#define MK_F5 0x60 -#define MK_F6 0x61 -#define MK_F7 0x62 -#define MK_F8 0x64 -#define MK_F9 0x65 -#define MK_F10 0x6D -#define MK_F11 0x67 -#define MK_F12 0x6F -#define MK_PRINT 0x69 -#define MK_SCROLLOCK 0x6B -#define MK_PAUSE 0x71 -#define MK_POWER 0x7F -#define MK_BACKQUOTE 0x32 -#define MK_1 0x12 -#define MK_2 0x13 -#define MK_3 0x14 -#define MK_4 0x15 -#define MK_5 0x17 -#define MK_6 0x16 -#define MK_7 0x1A -#define MK_8 0x1C -#define MK_9 0x19 -#define MK_0 0x1D -#define MK_MINUS 0x1B -#define MK_EQUALS 0x18 -#define MK_BACKSPACE 0x33 -#define MK_INSERT 0x72 -#define MK_HOME 0x73 -#define MK_PAGEUP 0x74 -#define MK_NUMLOCK 0x47 -#define MK_KP_EQUALS 0x51 -#define MK_KP_DIVIDE 0x4B -#define MK_KP_MULTIPLY 0x43 -#define MK_TAB 0x30 -#define MK_q 0x0C -#define MK_w 0x0D -#define MK_e 0x0E -#define MK_r 0x0F -#define MK_t 0x11 -#define MK_y 0x10 -#define MK_u 0x20 -#define MK_i 0x22 -#define MK_o 0x1F -#define MK_p 0x23 -#define MK_LEFTBRACKET 0x21 -#define MK_RIGHTBRACKET 0x1E -#define MK_BACKSLASH 0x2A -#define MK_DELETE 0x75 -#define MK_END 0x77 -#define MK_PAGEDOWN 0x79 -#define MK_KP7 0x59 -#define MK_KP8 0x5B -#define MK_KP9 0x5C -#define MK_KP_MINUS 0x4E -#define MK_CAPSLOCK 0x39 -#define MK_a 0x00 -#define MK_s 0x01 -#define MK_d 0x02 -#define MK_f 0x03 -#define MK_g 0x05 -#define MK_h 0x04 -#define MK_j 0x26 -#define MK_k 0x28 -#define MK_l 0x25 -#define MK_SEMICOLON 0x29 -#define MK_QUOTE 0x27 -#define MK_RETURN 0x24 -#define MK_KP4 0x56 -#define MK_KP5 0x57 -#define MK_KP6 0x58 -#define MK_KP_PLUS 0x45 -#define MK_LSHIFT 0x38 -#define MK_z 0x06 -#define MK_x 0x07 -#define MK_c 0x08 -#define MK_v 0x09 -#define MK_b 0x0B -#define MK_n 0x2D -#define MK_m 0x2E -#define MK_COMMA 0x2B -#define MK_PERIOD 0x2F -#define MK_SLASH 0x2C -#if 0 /* These are the same as the left versions - use left by default */ -#define MK_RSHIFT 0x38 -#endif -#define MK_UP 0x7E -#define MK_KP1 0x53 -#define MK_KP2 0x54 -#define MK_KP3 0x55 -#define MK_KP_ENTER 0x4C -#define MK_LCTRL 0x3B -#define MK_LALT 0x3A -#define MK_LMETA 0x37 -#define MK_SPACE 0x31 -#if 0 /* These are the same as the left versions - use left by default */ -#define MK_RMETA 0x37 -#define MK_RALT 0x3A -#define MK_RCTRL 0x3B -#endif -#define MK_LEFT 0x7B -#define MK_DOWN 0x7D -#define MK_RIGHT 0x7C -#define MK_KP0 0x52 -#define MK_KP_PERIOD 0x41 - -/* Wierd, these keys are on my iBook under Mac OS X */ -#define MK_IBOOK_ENTER 0x34 -#define MK_IBOOK_LEFT 0x3B -#define MK_IBOOK_RIGHT 0x3C -#define MK_IBOOK_DOWN 0x3D -#define MK_IBOOK_UP 0x3E diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_macmouse.c b/apps/plugins/sdl/src/video/maccommon/SDL_macmouse.c deleted file mode 100644 index f19ad1b966..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_macmouse.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#if defined(__APPLE__) && defined(__MACH__) -#include -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) -#include -#else -#include -#endif - -/* Routines that are not supported by the Carbon API... */ -#if !TARGET_API_MAC_CARBON -#include -#endif - -#include "SDL_mouse.h" -#include "SDL_macmouse_c.h" - - -/* The implementation dependent data for the window manager cursor */ -struct WMcursor { - Cursor curs; -}; - - -void Mac_FreeWMCursor(_THIS, WMcursor *cursor) -{ - SDL_free(cursor); -} - -WMcursor *Mac_CreateWMCursor(_THIS, - Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) -{ - WMcursor *cursor; - int row, bytes; - - /* Allocate the cursor memory */ - cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); - if ( cursor == NULL ) { - SDL_OutOfMemory(); - return(NULL); - } - SDL_memset(cursor, 0, sizeof(*cursor)); - - if (w > 16) - w = 16; - - if (h > 16) - h = 16; - - bytes = (w+7)/8; - - for ( row=0; rowcurs.data[row], data, bytes); - data += bytes; - } - for ( row=0; rowcurs.mask[row], mask, bytes); - mask += bytes; - } - cursor->curs.hotSpot.h = hot_x; - cursor->curs.hotSpot.v = hot_y; - - /* That was easy. :) */ - return(cursor); -} - -int Mac_cursor_showing = 1; - -int Mac_ShowWMCursor(_THIS, WMcursor *cursor) -{ - if ( cursor == NULL ) { - if ( Mac_cursor_showing ) { - HideCursor(); - Mac_cursor_showing = 0; - } - } else { - SetCursor(&cursor->curs); - if ( ! Mac_cursor_showing ) { - ShowCursor(); - Mac_cursor_showing = 1; - } - } - return(1); -} - -void Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y) -{ -#if !TARGET_API_MAC_CARBON - CursorDevice *cursordevice; - - cursordevice = nil; - CursorDeviceNextDevice(&cursordevice); - if ( cursordevice != nil ) { - WindowPtr saveport; - Point where; - - GetPort(&saveport); - SetPort(SDL_Window); - where.h = x; - where.v = y; - LocalToGlobal(&where); - SetPort(saveport); - CursorDeviceMoveTo(cursordevice, where.h, where.v); - } -#endif /* !TARGET_API_MAC_CARBON */ -} - diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_macmouse_c.h b/apps/plugins/sdl/src/video/maccommon/SDL_macmouse_c.h deleted file mode 100644 index 18fb438b16..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_macmouse_c.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "../macrom/SDL_romvideo.h" - -/* Functions to be exported */ -extern void Mac_FreeWMCursor(_THIS, WMcursor *cursor); -extern WMcursor *Mac_CreateWMCursor(_THIS, - Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); -extern int Mac_ShowWMCursor(_THIS, WMcursor *cursor); -extern void Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y); - -/* Data to be exported */ -extern int Mac_cursor_showing; diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_macwm.c b/apps/plugins/sdl/src/video/maccommon/SDL_macwm.c deleted file mode 100644 index 6f485a3fa9..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_macwm.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#if defined(__APPLE__) && defined(__MACH__) -#include -#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) -#include -#else -#include -#include -#endif - -#if SDL_MACCLASSIC_GAMMA_SUPPORT -#include -#include -#include -#include -#include -#include -#endif - -#include "SDL_stdinc.h" -#include "SDL_macwm_c.h" - -void Mac_SetCaption(_THIS, const char *title, const char *icon) -{ - /* Don't convert C to P string in place, because it may be read-only */ - Str255 ptitle; /* MJS */ - ptitle[0] = strlen (title); - SDL_memcpy(ptitle+1, title, ptitle[0]); /* MJS */ - if (SDL_Window) - SetWTitle(SDL_Window, ptitle); /* MJS */ -} - -#if SDL_MACCLASSIC_GAMMA_SUPPORT -/* - * ADC Gamma Ramp support... - * - * Mac Gamma Ramp code was originally from sample code provided by - * Apple Developer Connection, and not written specifically for SDL: - * "Contains: Functions to enable Mac OS device gamma adjustments using 3 channel 256 element 8 bit gamma ramps - * Written by: Geoff Stahl (ggs) - * Copyright: Copyright (c) 1999 Apple Computer, Inc., All Rights Reserved - * Disclaimer: You may incorporate this sample code into your applications without - * restriction, though the sample code has been provided "AS IS" and the - * responsibility for its operation is 100% yours. However, what you are - * not permitted to do is to redistribute the source as "DSC Sample Code" - * after having made changes. If you're going to re-distribute the source, - * we require that you make it clear in the source that the code was - * descended from Apple Sample Code, but that you've made changes." - * (The sample code has been integrated into this file, and thus is modified from the original Apple sources.) - */ - -typedef struct recDeviceGamma /* storage for device handle and gamma table */ -{ - GDHandle hGD; /* handle to device */ - GammaTblPtr pDeviceGamma; /* pointer to device gamma table */ -} recDeviceGamma; -typedef recDeviceGamma * precDeviceGamma; - -typedef struct recSystemGamma /* storage for system devices and gamma tables */ -{ - short numDevices; /* number of devices */ - precDeviceGamma * devGamma; /* array of pointers to device gamma records */ -} recSystemGamma; -typedef recSystemGamma * precSystemGamma; - -static Ptr CopyGammaTable (GammaTblPtr pTableGammaIn) -{ - GammaTblPtr pTableGammaOut = NULL; - short tableSize, dataWidth; - - if (pTableGammaIn) /* if there is a table to copy */ - { - dataWidth = (pTableGammaIn->gDataWidth + 7) / 8; /* number of bytes per entry */ - tableSize = sizeof (GammaTbl) + pTableGammaIn->gFormulaSize + - (pTableGammaIn->gChanCnt * pTableGammaIn->gDataCnt * dataWidth); - pTableGammaOut = (GammaTblPtr) NewPtr (tableSize); /* allocate new table */ - if (pTableGammaOut) - BlockMove( (Ptr)pTableGammaIn, (Ptr)pTableGammaOut, tableSize); /* move everything */ - } - return (Ptr)pTableGammaOut; /* return whatever we allocated, could be NULL */ -} - -static OSErr GetGammaTable (GDHandle hGD, GammaTblPtr * ppTableGammaOut) -{ - VDGammaRecord DeviceGammaRec; - CntrlParam cParam; - OSErr err; - - cParam.ioCompletion = NULL; /* set up control params */ - cParam.ioNamePtr = NULL; - cParam.ioVRefNum = 0; - cParam.ioCRefNum = (**hGD).gdRefNum; - cParam.csCode = cscGetGamma; /* Get Gamma commnd to device */ - *(Ptr *)cParam.csParam = (Ptr) &DeviceGammaRec; /* record for gamma */ - - err = PBStatusSync( (ParmBlkPtr)&cParam ); /* get gamma */ - - *ppTableGammaOut = (GammaTblPtr)(DeviceGammaRec.csGTable); /* pull table out of record */ - - return err; -} - -static Ptr GetDeviceGamma (GDHandle hGD) -{ - GammaTblPtr pTableGammaDevice = NULL; - GammaTblPtr pTableGammaReturn = NULL; - OSErr err; - - err = GetGammaTable (hGD, &pTableGammaDevice); /* get a pointer to the devices table */ - if ((noErr == err) && pTableGammaDevice) /* if succesful */ - pTableGammaReturn = (GammaTblPtr) CopyGammaTable (pTableGammaDevice); /* copy to global */ - - return (Ptr) pTableGammaReturn; -} - -static void DisposeGammaTable (Ptr pGamma) -{ - if (pGamma) - DisposePtr((Ptr) pGamma); /* get rid of it */ -} - -static void DisposeSystemGammas (Ptr* ppSystemGammas) -{ - precSystemGamma pSysGammaIn; - if (ppSystemGammas) - { - pSysGammaIn = (precSystemGamma) *ppSystemGammas; - if (pSysGammaIn) - { - short i; - for (i = 0; i < pSysGammaIn->numDevices; i++) /* for all devices */ - if (pSysGammaIn->devGamma [i]) /* if pointer is valid */ - { - DisposeGammaTable ((Ptr) pSysGammaIn->devGamma [i]->pDeviceGamma); /* dump gamma table */ - DisposePtr ((Ptr) pSysGammaIn->devGamma [i]); /* dump device info */ - } - DisposePtr ((Ptr) pSysGammaIn->devGamma); /* dump device pointer array */ - DisposePtr ((Ptr) pSysGammaIn); /* dump system structure */ - *ppSystemGammas = NULL; - } - } -} - -static Boolean GetDeviceGammaRampGD (GDHandle hGD, Ptr pRamp) -{ - GammaTblPtr pTableGammaTemp = NULL; - long indexChan, indexEntry; - OSErr err; - - if (pRamp) /* ensure pRamp is allocated */ - { - err = GetGammaTable (hGD, &pTableGammaTemp); /* get a pointer to the current gamma */ - if ((noErr == err) && pTableGammaTemp) /* if successful */ - { - /* fill ramp */ - unsigned char * pEntry = (unsigned char *) &pTableGammaTemp->gFormulaData + pTableGammaTemp->gFormulaSize; /* base of table */ - short bytesPerEntry = (pTableGammaTemp->gDataWidth + 7) / 8; /* size, in bytes, of the device table entries */ - short shiftRightValue = pTableGammaTemp->gDataWidth - 8; /* number of right shifts device -> ramp */ - short channels = pTableGammaTemp->gChanCnt; - short entries = pTableGammaTemp->gDataCnt; - if (3 == channels) /* RGB format */ - { /* note, this will create runs of entries if dest. is bigger (not linear interpolate) */ - for (indexChan = 0; indexChan < channels; indexChan++) - for (indexEntry = 0; indexEntry < 256; indexEntry++) - *((unsigned char *) pRamp + (indexChan * 256) + indexEntry) = - *(pEntry + indexChan * entries * bytesPerEntry + indexEntry * entries * bytesPerEntry / 256) >> shiftRightValue; - } - else /* single channel format */ - { - for (indexChan = 0; indexChan < 768; indexChan += 256) /* repeat for all 3 channels (step by ramp size) */ - for (indexEntry = 0; indexEntry < 256; indexEntry++) /* for all entries set vramp value */ - *((unsigned char *) pRamp + indexChan + indexEntry) = - *(pEntry + indexEntry * entries * bytesPerEntry / 256) >> shiftRightValue; - } - return true; - } - } - return false; -} - -static Ptr GetSystemGammas (void) -{ - precSystemGamma pSysGammaOut; /* return pointer to system device gamma info */ - short devCount = 0; /* number of devices attached */ - Boolean fail = false; - GDHandle hGDevice; - - pSysGammaOut = (precSystemGamma) NewPtr (sizeof (recSystemGamma)); /* allocate for structure */ - - hGDevice = GetDeviceList (); /* top of device list */ - do /* iterate */ - { - devCount++; /* count devices */ - hGDevice = GetNextDevice (hGDevice); /* next device */ - } while (hGDevice); - - pSysGammaOut->devGamma = (precDeviceGamma *) NewPtr (sizeof (precDeviceGamma) * devCount); /* allocate for array of pointers to device records */ - if (pSysGammaOut) - { - pSysGammaOut->numDevices = devCount; /* stuff count */ - - devCount = 0; /* reset iteration */ - hGDevice = GetDeviceList (); - do - { - pSysGammaOut->devGamma [devCount] = (precDeviceGamma) NewPtr (sizeof (recDeviceGamma)); /* new device record */ - if (pSysGammaOut->devGamma [devCount]) /* if we actually allocated memory */ - { - pSysGammaOut->devGamma [devCount]->hGD = hGDevice; /* stuff handle */ - pSysGammaOut->devGamma [devCount]->pDeviceGamma = (GammaTblPtr)GetDeviceGamma (hGDevice); /* copy gamma table */ - } - else /* otherwise dump record on exit */ - fail = true; - devCount++; /* next device */ - hGDevice = GetNextDevice (hGDevice); - } while (hGDevice); - } - if (!fail) /* if we did not fail */ - return (Ptr) pSysGammaOut; /* return pointer to structure */ - else - { - DisposeSystemGammas ((Ptr *) &pSysGammaOut); /* otherwise dump the current structures (dispose does error checking) */ - return NULL; /* could not complete */ - } -} - -static void RestoreDeviceGamma (GDHandle hGD, Ptr pGammaTable) -{ - VDSetEntryRecord setEntriesRec; - VDGammaRecord gameRecRestore; - CTabHandle hCTabDeviceColors; - Ptr csPtr; - OSErr err = noErr; - - if (pGammaTable) /* if we have a table to restore */ - { - gameRecRestore.csGTable = pGammaTable; /* setup restore record */ - csPtr = (Ptr) &gameRecRestore; - err = Control((**hGD).gdRefNum, cscSetGamma, (Ptr) &csPtr); /* restore gamma */ - - if ((noErr == err) && (8 == (**(**hGD).gdPMap).pixelSize)) /* if successful and on an 8 bit device */ - { - hCTabDeviceColors = (**(**hGD).gdPMap).pmTable; /* do SetEntries to force CLUT update */ - setEntriesRec.csTable = (ColorSpec *) &(**hCTabDeviceColors).ctTable; - setEntriesRec.csStart = 0; - setEntriesRec.csCount = (**hCTabDeviceColors).ctSize; - csPtr = (Ptr) &setEntriesRec; - - err = Control((**hGD).gdRefNum, cscSetEntries, (Ptr) &csPtr); /* SetEntries in CLUT */ - } - } -} - -static void RestoreSystemGammas (Ptr pSystemGammas) -{ - short i; - precSystemGamma pSysGammaIn = (precSystemGamma) pSystemGammas; - if (pSysGammaIn) - for (i = 0; i < pSysGammaIn->numDevices; i++) /* for all devices */ - RestoreDeviceGamma (pSysGammaIn->devGamma [i]->hGD, (Ptr) pSysGammaIn->devGamma [i]->pDeviceGamma); /* restore gamma */ -} - -static Ptr CreateEmptyGammaTable (short channels, short entries, short bits) -{ - GammaTblPtr pTableGammaOut = NULL; - short tableSize, dataWidth; - - dataWidth = (bits + 7) / 8; /* number of bytes per entry */ - tableSize = sizeof (GammaTbl) + (channels * entries * dataWidth); - pTableGammaOut = (GammaTblPtr) NewPtrClear (tableSize); /* allocate new tabel */ - - if (pTableGammaOut) /* if we successfully allocated */ - { - pTableGammaOut->gVersion = 0; /* set parameters based on input */ - pTableGammaOut->gType = 0; - pTableGammaOut->gFormulaSize = 0; - pTableGammaOut->gChanCnt = channels; - pTableGammaOut->gDataCnt = entries; - pTableGammaOut->gDataWidth = bits; - } - return (Ptr)pTableGammaOut; /* return whatever we allocated */ -} - -static Boolean SetDeviceGammaRampGD (GDHandle hGD, Ptr pRamp) -{ - VDSetEntryRecord setEntriesRec; - VDGammaRecord gameRecRestore; - GammaTblPtr pTableGammaNew; - GammaTblPtr pTableGammaCurrent = NULL; - CTabHandle hCTabDeviceColors; - Ptr csPtr; - OSErr err; - short dataBits, entries, channels = 3; /* force three channels in the gamma table */ - - if (pRamp) /* ensure pRamp is allocated */ - { - err= GetGammaTable (hGD, &pTableGammaCurrent); /* get pointer to current table */ - if ((noErr == err) && pTableGammaCurrent) - { - dataBits = pTableGammaCurrent->gDataWidth; /* table must have same data width */ - entries = pTableGammaCurrent->gDataCnt; /* table must be same size */ - pTableGammaNew = (GammaTblPtr) CreateEmptyGammaTable (channels, entries, dataBits); /* our new table */ - if (pTableGammaNew) /* if successful fill table */ - { - unsigned char * pGammaBase = (unsigned char *) &pTableGammaNew->gFormulaData + pTableGammaNew->gFormulaSize; /* base of table */ - if ((256 == entries) && (8 == dataBits)) /* simple case: direct mapping */ - BlockMove ((Ptr)pRamp, (Ptr)pGammaBase, channels * entries); /* move everything */ - else /* tough case handle entry, channel and data size disparities */ - { - short indexChan, indexEntry; - short bytesPerEntry = (dataBits + 7) / 8; /* size, in bytes, of the device table entries */ - short shiftRightValue = 8 - dataBits; /* number of right shifts ramp -> device */ - shiftRightValue += ((bytesPerEntry - 1) * 8); /* multibyte entries and the need to map a byte at a time most sig. to least sig. */ - for (indexChan = 0; indexChan < channels; indexChan++) /* for all the channels */ - for (indexEntry = 0; indexEntry < entries; indexEntry++) /* for all the entries */ - { - short currentShift = shiftRightValue; /* reset current bit shift */ - long temp = *((unsigned char *)pRamp + (indexChan << 8) + (indexEntry << 8) / entries); /* get data from ramp */ - short indexByte; - for (indexByte = 0; indexByte < bytesPerEntry; indexByte++) /* for all bytes */ - { - if (currentShift < 0) /* shift data correctly for current byte */ - *(pGammaBase++) = temp << -currentShift; - else - *(pGammaBase++) = temp >> currentShift; - currentShift -= 8; /* increment shift to align to next less sig. byte */ - } - } - } - - /* set gamma */ - gameRecRestore.csGTable = (Ptr) pTableGammaNew; /* setup restore record */ - csPtr = (Ptr) &gameRecRestore; - err = Control((**hGD).gdRefNum, cscSetGamma, (Ptr) &csPtr); /* restore gamma (note, display drivers may delay returning from this until VBL) */ - - if ((8 == (**(**hGD).gdPMap).pixelSize) && (noErr == err)) /* if successful and on an 8 bit device */ - { - hCTabDeviceColors = (**(**hGD).gdPMap).pmTable; /* do SetEntries to force CLUT update */ - setEntriesRec.csTable = (ColorSpec *) &(**hCTabDeviceColors).ctTable; - setEntriesRec.csStart = 0; - setEntriesRec.csCount = (**hCTabDeviceColors).ctSize; - csPtr = (Ptr) &setEntriesRec; - err = Control((**hGD).gdRefNum, cscSetEntries, (Ptr) &csPtr); /* SetEntries in CLUT */ - } - DisposeGammaTable ((Ptr) pTableGammaNew); /* dump table */ - if (noErr == err) - return true; - } - } - } - else /* set NULL gamma -> results in linear map */ - { - gameRecRestore.csGTable = (Ptr) NULL; /* setup restore record */ - csPtr = (Ptr) &gameRecRestore; - err = Control((**hGD).gdRefNum, cscSetGamma, (Ptr) &csPtr); /* restore gamma */ - - if ((8 == (**(**hGD).gdPMap).pixelSize) && (noErr == err)) /* if successful and on an 8 bit device */ - { - hCTabDeviceColors = (**(**hGD).gdPMap).pmTable; /* do SetEntries to force CLUT update */ - setEntriesRec.csTable = (ColorSpec *) &(**hCTabDeviceColors).ctTable; - setEntriesRec.csStart = 0; - setEntriesRec.csCount = (**hCTabDeviceColors).ctSize; - csPtr = (Ptr) &setEntriesRec; - err = Control((**hGD).gdRefNum, cscSetEntries, (Ptr) &csPtr); /* SetEntries in CLUT */ - } - if (noErr == err) - return true; - } - return false; /* memory allocation or device control failed if we get here */ -} - -/* end of ADC Gamma Ramp support code... */ - -static Ptr systemGammaPtr; - -void Mac_QuitGamma(_THIS) -{ - if (systemGammaPtr) - { - RestoreSystemGammas(systemGammaPtr); - DisposeSystemGammas(&systemGammaPtr); - } -} - -static unsigned char shiftedRamp[3 * 256]; - -int Mac_SetGammaRamp(_THIS, Uint16 *ramp) -{ - int i; - if (!systemGammaPtr) - systemGammaPtr = GetSystemGammas(); - for (i = 0; i < 3 * 256; i++) - { - shiftedRamp[i] = ramp[i] >> 8; - } - - if (SetDeviceGammaRampGD(GetMainDevice(), (Ptr) shiftedRamp)) - return 0; - else - return -1; -} - -int Mac_GetGammaRamp(_THIS, Uint16 *ramp) -{ - if (GetDeviceGammaRampGD(GetMainDevice(), (Ptr) shiftedRamp)) - { - int i; - for (i = 0; i < 3 * 256; i++) - { - ramp[i] = shiftedRamp[i] << 8; - } - return 0; - } - else - return -1; -} - -#endif /* SDL_MACCLASSIC_GAMMA_SUPPORT */ - - diff --git a/apps/plugins/sdl/src/video/maccommon/SDL_macwm_c.h b/apps/plugins/sdl/src/video/maccommon/SDL_macwm_c.h deleted file mode 100644 index a0554d16dc..0000000000 --- a/apps/plugins/sdl/src/video/maccommon/SDL_macwm_c.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "../macrom/SDL_romvideo.h" - -/* Functions to be exported */ -extern void Mac_SetCaption(_THIS, const char *title, const char *icon); - -/* - * There's no Carbonized gamma support in Mac OS X, since PBStatusSync() and - * Control() aren't supported in OS X's Carbonlib. Use the Quartz driver - * instead. - */ -#define SDL_MACCLASSIC_GAMMA_SUPPORT ((defined(__APPLE__) && defined(__MACH__)) == 0) - -#if SDL_MACCLASSIC_GAMMA_SUPPORT -extern void Mac_QuitGamma(_THIS); -extern int Mac_SetGammaRamp(_THIS, Uint16 *ramp); -extern int Mac_GetGammaRamp(_THIS, Uint16 *ramp); -#endif - -- cgit v1.2.3