mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
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:
parent
9016c90d47
commit
c05c9fa1f4
@ -439,10 +439,10 @@ void CConfigMain::CreateGUIControls()
|
||||
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]);
|
||||
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);
|
||||
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);
|
||||
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"));
|
||||
@ -1227,7 +1227,6 @@ bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename)
|
||||
void CConfigMain::AddResolutions()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
DWORD iModeNum = 0;
|
||||
DEVMODE dmi;
|
||||
ZeroMemory(&dmi, sizeof(dmi));
|
||||
@ -1247,40 +1246,46 @@ void CConfigMain::AddResolutions()
|
||||
}
|
||||
ZeroMemory(&dmi, sizeof(dmi));
|
||||
}
|
||||
|
||||
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||
|
||||
main_frame->m_XRRConfig->AddResolutions(arrayStringFor_FullscreenResolution);
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
CGDisplayModeRef mode;
|
||||
CFDictionaryRef mode;
|
||||
CFArrayRef array;
|
||||
CFIndex n, i;
|
||||
int w, h;
|
||||
std::vector<std::string> resos;
|
||||
|
||||
array = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
|
||||
array = CGDisplayAvailableModes(CGMainDisplayID());
|
||||
n = CFArrayGetCount(array);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(array, i);
|
||||
w = CGDisplayModeGetWidth(mode);
|
||||
h = CGDisplayModeGetHeight(mode);
|
||||
mode = (CFDictionaryRef)CFArrayGetValueAtIndex(array, i);
|
||||
|
||||
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];
|
||||
sprintf(res,"%dx%d", w, h);
|
||||
std::string strRes(res);
|
||||
|
||||
// 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);
|
||||
arrayStringFor_FullscreenResolution.Add(wxString::FromAscii(res));
|
||||
arrayStringFor_FullscreenResolution.Add(strRes);
|
||||
}
|
||||
}
|
||||
CFRelease(array);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -949,7 +949,7 @@ void CFrame::DoFullscreen(bool bF)
|
||||
{
|
||||
ToggleDisplayMode(bF);
|
||||
|
||||
m_RenderFrame->ShowFullScreen(bF);
|
||||
m_RenderFrame->ShowFullScreen(bF, wxFULLSCREEN_ALL);
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
|
||||
{
|
||||
if (bF)
|
||||
|
@ -93,7 +93,8 @@ void HotkeyConfigDialog::OnKeyDown(wxKeyEvent& event)
|
||||
g_Modkey = event.GetModifiers();
|
||||
|
||||
// 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;
|
||||
|
||||
// Use the space key to set a blank key
|
||||
|
@ -8,7 +8,6 @@ wxenv = env.Clone()
|
||||
|
||||
files = [
|
||||
'BootManager.cpp',
|
||||
'cmdline.c',
|
||||
]
|
||||
|
||||
libs = [
|
||||
@ -49,6 +48,10 @@ if wxenv['HAVE_WX']:
|
||||
],
|
||||
|
||||
libs = [ 'debwx', 'debugger_ui_util'] + libs
|
||||
else:
|
||||
files+= [
|
||||
'cmdline.c',
|
||||
]
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
files += [ 'cocoaApp.m', ]
|
||||
|
@ -31,6 +31,10 @@ const wxString WXKeyToString(int keycode)
|
||||
case WXK_SPACE: return wxT("Space");
|
||||
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_LBUTTON: return wxT("L Button");
|
||||
case WXK_RBUTTON: return wxT("R Button");
|
||||
@ -142,9 +146,12 @@ const wxString WXKeymodToString(int modifier)
|
||||
switch (modifier)
|
||||
{
|
||||
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_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("");
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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];
|
||||
}
|
Loading…
Reference in New Issue
Block a user