Use 10.5 compatible API's to get list of display resolutions on OS X.

Patch from user gamepromcompany on the MacOSX_Build wiki page.

Add support for the Mac command key as a hotkey modifier in 
WXKeyToString but present it as Control. WXKeyToString is used for     
both hotkeys and menu accelerators, the latter only supporting
Shift/Alt/Control with wxWidgets.

wxSpinCtrl on wx 2.9 has a very small default size, so give the 
window size ones a reasonable size.

Use wxFULLSCREEN_ALL when switching to fullscreen, which gets rid
of window decorations like the title bar. Note that to actually
be rid of it with wx 2.9 on OS X, you'll need this patch:
http://trac.wxwidgets.org/ticket/11701

Also remove a couple of files I had accidentally duplicated.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5642 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2010-06-09 20:03:37 +00:00
parent 9016c90d47
commit c05c9fa1f4
7 changed files with 47 additions and 209 deletions

View File

@ -439,10 +439,10 @@ void CConfigMain::CreateGUIControls()
wxStaticText* FullscreenResolutionText = new wxStaticText(DisplayPage, wxID_ANY, wxT("Fullscreen Display Resolution:"), wxDefaultPosition, wxDefaultSize, 0); wxStaticText* FullscreenResolutionText = new wxStaticText(DisplayPage, wxID_ANY, wxT("Fullscreen Display Resolution:"), wxDefaultPosition, wxDefaultSize, 0);
FullscreenResolution = new wxChoice(DisplayPage, ID_DISPLAY_FULLSCREENRES, wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenResolution, 0, wxDefaultValidator, arrayStringFor_FullscreenResolution[0]); FullscreenResolution = new wxChoice(DisplayPage, ID_DISPLAY_FULLSCREENRES, wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenResolution, 0, wxDefaultValidator, arrayStringFor_FullscreenResolution[0]);
wxStaticText *WindowSizeText = new wxStaticText(DisplayPage, wxID_ANY, wxT("Window Size:"), wxDefaultPosition, wxDefaultSize, 0); wxStaticText *WindowSizeText = new wxStaticText(DisplayPage, wxID_ANY, wxT("Window Size:"), wxDefaultPosition, wxDefaultSize, 0);
WindowWidth = new wxSpinCtrl(DisplayPage, ID_DISPLAY_WINDOWWIDTH, wxEmptyString, wxDefaultPosition, wxDefaultSize); WindowWidth = new wxSpinCtrl(DisplayPage, ID_DISPLAY_WINDOWWIDTH, wxEmptyString, wxDefaultPosition, wxSize(70, -1));
WindowWidth->SetRange(0,3280); WindowWidth->SetRange(0,3280);
wxStaticText *WindowXText = new wxStaticText(DisplayPage, wxID_ANY, wxT("x"), wxDefaultPosition, wxDefaultSize, 0); wxStaticText *WindowXText = new wxStaticText(DisplayPage, wxID_ANY, wxT("x"), wxDefaultPosition, wxDefaultSize, 0);
WindowHeight = new wxSpinCtrl(DisplayPage, ID_DISPLAY_WINDOWHEIGHT, wxEmptyString, wxDefaultPosition, wxDefaultSize); WindowHeight = new wxSpinCtrl(DisplayPage, ID_DISPLAY_WINDOWHEIGHT, wxEmptyString, wxDefaultPosition, wxSize(70, -1));
WindowHeight->SetRange(0,2048); WindowHeight->SetRange(0,2048);
Fullscreen = new wxCheckBox(DisplayPage, ID_DISPLAY_FULLSCREEN, wxT("Start Renderer in Fullscreen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); Fullscreen = new wxCheckBox(DisplayPage, ID_DISPLAY_FULLSCREEN, wxT("Start Renderer in Fullscreen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
HideCursor = new wxCheckBox(DisplayPage, ID_DISPLAY_HIDECURSOR, wxT("Hide Mouse Cursor")); HideCursor = new wxCheckBox(DisplayPage, ID_DISPLAY_HIDECURSOR, wxT("Hide Mouse Cursor"));
@ -1227,7 +1227,6 @@ bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename)
void CConfigMain::AddResolutions() void CConfigMain::AddResolutions()
{ {
#ifdef _WIN32 #ifdef _WIN32
DWORD iModeNum = 0; DWORD iModeNum = 0;
DEVMODE dmi; DEVMODE dmi;
ZeroMemory(&dmi, sizeof(dmi)); ZeroMemory(&dmi, sizeof(dmi));
@ -1247,40 +1246,46 @@ void CConfigMain::AddResolutions()
} }
ZeroMemory(&dmi, sizeof(dmi)); ZeroMemory(&dmi, sizeof(dmi));
} }
#elif defined(HAVE_XRANDR) && HAVE_XRANDR #elif defined(HAVE_XRANDR) && HAVE_XRANDR
main_frame->m_XRRConfig->AddResolutions(arrayStringFor_FullscreenResolution); main_frame->m_XRRConfig->AddResolutions(arrayStringFor_FullscreenResolution);
#elif defined(__APPLE__) #elif defined(__APPLE__)
CFDictionaryRef mode;
CGDisplayModeRef mode;
CFArrayRef array; CFArrayRef array;
CFIndex n, i; CFIndex n, i;
int w, h; int w, h;
std::vector<std::string> resos; std::vector<std::string> resos;
array = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL); array = CGDisplayAvailableModes(CGMainDisplayID());
n = CFArrayGetCount(array); n = CFArrayGetCount(array);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(array, i); mode = (CFDictionaryRef)CFArrayGetValueAtIndex(array, i);
w = CGDisplayModeGetWidth(mode);
h = CGDisplayModeGetHeight(mode); CFNumberRef anWidth = (CFNumberRef)CFDictionaryGetValue(mode,
kCGDisplayWidth);
if (NULL == anWidth ||
!CFNumberGetValue(anWidth, kCFNumberIntType, &w))
continue;
CFNumberRef anHeight =
(CFNumberRef)CFDictionaryGetValue(mode,
kCGDisplayHeight);
if (NULL == anHeight ||
!CFNumberGetValue(anHeight, kCFNumberIntType, &h))
continue;
char res[32]; char res[32];
sprintf(res,"%dx%d", w, h); sprintf(res,"%dx%d", w, h);
std::string strRes(res); std::string strRes(res);
// Only add unique resolutions // Only add unique resolutions
if (std::find(resos.begin(), resos.end(), strRes) == resos.end()) if (std::find(resos.begin(), resos.end(), strRes) ==
resos.end())
{ {
resos.push_back(strRes); resos.push_back(strRes);
arrayStringFor_FullscreenResolution.Add(wxString::FromAscii(res)); arrayStringFor_FullscreenResolution.Add(strRes);
} }
} }
CFRelease(array);
#endif #endif
} }

View File

@ -949,7 +949,7 @@ void CFrame::DoFullscreen(bool bF)
{ {
ToggleDisplayMode(bF); ToggleDisplayMode(bF);
m_RenderFrame->ShowFullScreen(bF); m_RenderFrame->ShowFullScreen(bF, wxFULLSCREEN_ALL);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{ {
if (bF) if (bF)

View File

@ -93,7 +93,8 @@ void HotkeyConfigDialog::OnKeyDown(wxKeyEvent& event)
g_Modkey = event.GetModifiers(); g_Modkey = event.GetModifiers();
// Don't allow modifier keys // Don't allow modifier keys
if (g_Pressed == WXK_CONTROL || g_Pressed == WXK_ALT || g_Pressed == WXK_SHIFT) if (g_Pressed == WXK_CONTROL || g_Pressed == WXK_ALT ||
g_Pressed == WXK_SHIFT || g_Pressed == WXK_COMMAND)
return; return;
// Use the space key to set a blank key // Use the space key to set a blank key

View File

@ -8,7 +8,6 @@ wxenv = env.Clone()
files = [ files = [
'BootManager.cpp', 'BootManager.cpp',
'cmdline.c',
] ]
libs = [ libs = [
@ -49,6 +48,10 @@ if wxenv['HAVE_WX']:
], ],
libs = [ 'debwx', 'debugger_ui_util'] + libs libs = [ 'debwx', 'debugger_ui_util'] + libs
else:
files+= [
'cmdline.c',
]
if sys.platform == 'darwin': if sys.platform == 'darwin':
files += [ 'cocoaApp.m', ] files += [ 'cocoaApp.m', ]

View File

@ -31,6 +31,10 @@ const wxString WXKeyToString(int keycode)
case WXK_SPACE: return wxT("Space"); case WXK_SPACE: return wxT("Space");
case WXK_DELETE: return wxT("Delete"); case WXK_DELETE: return wxT("Delete");
// Undocumented wx keycodes
case 167: return wxT("Paragraph");
case 177: return wxT("Plus-Minus");
case WXK_START: return wxT("Start"); case WXK_START: return wxT("Start");
case WXK_LBUTTON: return wxT("L Button"); case WXK_LBUTTON: return wxT("L Button");
case WXK_RBUTTON: return wxT("R Button"); case WXK_RBUTTON: return wxT("R Button");
@ -142,9 +146,12 @@ const wxString WXKeymodToString(int modifier)
switch (modifier) switch (modifier)
{ {
case wxMOD_ALT: return wxT("Alt"); case wxMOD_ALT: return wxT("Alt");
case wxMOD_CMD: return wxT("Ctrl"); case wxMOD_CONTROL: return wxT("Ctrl");
case wxMOD_ALTGR: return wxT("Ctrl+Alt"); case wxMOD_ALTGR: return wxT("Ctrl+Alt");
case wxMOD_SHIFT: return wxT("Shift"); case wxMOD_SHIFT: return wxT("Shift");
// wxWidgets can only use Alt/Ctrl/Shift as menu accelerators,
// so Meta (Command on OS X) is simply made equivalent to Ctrl.
case wxMOD_META: return wxT("Ctrl");
default: return wxT(""); default: return wxT("");
} }
} }

View File

@ -1,29 +0,0 @@
#import <Cocoa/Cocoa.h>
#import <OpenGL/CGLRenderers.h>
#ifdef __cplusplus
extern "C"
{
#endif
void cocoaGLCreateApp();
NSWindow *cocoaGLCreateWindow(int w,int h);
void cocoaGLSetTitle(NSWindow *win, const char *title);
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win);
NSOpenGLContext* cocoaGLInit(int mode);
void cocoaGLDelete(NSOpenGLContext *ctx);
void cocoaGLDeleteWindow(NSWindow *window);
void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window);
#ifdef __cplusplus
}
#endif

View File

@ -1,149 +0,0 @@
#import "cocoaGL.h"
NSWindow *cocoaGLCreateWindow(int w,int h)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *window;
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h)
styleMask:NSTitledWindowMask | NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:FALSE];
[window setReleasedWhenClosed: YES];
[window setTitle:@"Dolphin on OSX"];
//[window makeKeyAndOrderFront: nil];
[pool release];
return window;
}
void cocoaGLSetTitle(NSWindow *win, const char *title)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[win setTitle: [[[NSString alloc] initWithCString: title encoding: NSASCIIStringEncoding] autorelease]];
[pool release];
}
void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win)
{
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
int value = 0;
[ctx setValues:&value forParameter:NSOpenGLCPSwapInterval];
if (ctx) {
[ctx setView:[win contentView]];
[ctx update];
[ctx makeCurrentContext];
}
else
[NSOpenGLContext clearCurrentContext];
[pool release];
}
NSOpenGLContext* cocoaGLInit(int mode)
{
NSAutoreleasePool *pool;
NSOpenGLPixelFormatAttribute attr[32];
NSOpenGLPixelFormat *fmt;
NSOpenGLContext *context;
int i = 0;
pool = [[NSAutoreleasePool alloc] init];
attr[i++] = NSOpenGLPFADepthSize;
attr[i++] = 24;
attr[i++] = NSOpenGLPFADoubleBuffer;
attr[i++] = NSOpenGLPFASampleBuffers;
attr[i++] = mode;
attr[i++] = NSOpenGLPFASamples;
attr[i++] = 1;
attr[i++] = NSOpenGLPFANoRecovery;
#ifdef GL_VERSION_1_3
#else
#ifdef GL_VERSION_1_2
#warning "your card only supports ogl 1.2, dolphin will use software renderer"
//if opengl < 1.3 uncomment this twoo lines to use software renderer
attr[i++] = NSOpenGLPFARendererID;
attr[i++] = kCGLRendererGenericFloatID;
#endif
#endif
attr[i++] = NSOpenGLPFAScreenMask;
attr[i++] = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID());
attr[i] = 0;
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if (fmt == nil) {
printf("failed to create pixel format\n");
[pool release];
return NULL;
}
context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
[fmt release];
if (context == nil) {
printf("failed to create context\n");
[pool release];
return NULL;
}
[pool release];
return context;
}
void cocoaGLDelete(NSOpenGLContext *ctx)
{
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
[ctx clearDrawable];
[ctx release];
[pool release];
}
void cocoaGLDeleteWindow(NSWindow *window)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[window close];
[pool release];
return;
}
void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window)
{
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
[window makeKeyAndOrderFront: nil];
ctx = [NSOpenGLContext currentContext];
if (ctx != nil)
[ctx flushBuffer];
else
printf("bad cocoa gl ctx\n");
[pool release];
}