Be more flexible about hotkey modifier permutations.
Open .ini files with TextEdit on OS X since wx has no binding. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6986 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
f41e5b3b85
commit
2622f86eb6
|
@ -32,19 +32,19 @@ static const struct {
|
|||
const int DefaultModifier;
|
||||
} g_HKData[] = {
|
||||
#ifdef __APPLE__
|
||||
{ "ToggleFullscreen", 70 /* 'F' */, 0x08 /* wxMOD_CMD */ },
|
||||
{ "PlayPause", 80 /* 'P' */, 0x08 /* wxMOD_CMD */ },
|
||||
{ "Stop", 87 /* 'W' */, 0x08 /* wxMOD_CMD */ },
|
||||
{ "Screenshot", 83 /* 'S' */, 0x08 /* wxMOD_CMD */ },
|
||||
{ "ToggleFullscreen", 70 /* 'F' */, 0x08 /* wxMOD_CMD */ },
|
||||
{ "Wiimote1Connect", 49 /* '1' */, 0x08 /* wxMOD_CMD */ },
|
||||
{ "Wiimote2Connect", 50 /* '2' */, 0x08 /* wxMOD_CMD */ },
|
||||
{ "Wiimote3Connect", 51 /* '3' */, 0x08 /* wxMOD_CMD */ },
|
||||
{ "Wiimote4Connect", 52 /* '4' */, 0x08 /* wxMOD_CMD */ },
|
||||
#else
|
||||
{ "ToggleFullscreen", 13 /* WXK_RETURN */, 0x01 /* wxMOD_ALT */ },
|
||||
{ "PlayPause", 349 /* WXK_F10 */, 0x00 /* wxMOD_NONE*/ },
|
||||
{ "Stop", 27 /* WXK_ESCAPE */, 0x00 /* wxMOD_NONE*/ },
|
||||
{ "Screenshot", 348 /* WXK_F9 */, 0x00 /* wxMOD_NONE*/ },
|
||||
{ "ToggleFullscreen", 13 /* WXK_RETURN */, 0x01 /* wxMOD_ALT */ },
|
||||
{ "Wiimote1Connect", 344 /* WXK_F5 */, 0x01 /* wxMOD_ALT */ },
|
||||
{ "Wiimote2Connect", 345 /* WXK_F6 */, 0x01 /* wxMOD_ALT */ },
|
||||
{ "Wiimote3Connect", 346 /* WXK_F7 */, 0x01 /* wxMOD_ALT */ },
|
||||
|
|
|
@ -308,7 +308,12 @@ void CFrame::CreateMenu()
|
|||
|
||||
wxString CFrame::GetMenuLabel(int Id)
|
||||
{
|
||||
wxString Label;
|
||||
int hotkey = SConfig::GetInstance().\
|
||||
m_LocalCoreStartupParameter.iHotkey[Id];
|
||||
int hotkeymodifier = SConfig::GetInstance().\
|
||||
m_LocalCoreStartupParameter.iHotkeyModifier[Id];
|
||||
wxString Hotkey, Label, Modifier;
|
||||
|
||||
switch (Id)
|
||||
{
|
||||
case HK_FULLSCREEN:
|
||||
|
@ -335,14 +340,20 @@ wxString CFrame::GetMenuLabel(int Id)
|
|||
break;
|
||||
}
|
||||
|
||||
wxString Modifier = InputCommon::WXKeymodToString
|
||||
(SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[Id]);
|
||||
wxString Hotkey = InputCommon::WXKeyToString
|
||||
(SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[Id]);
|
||||
// wxWidgets only accepts Ctrl/Alt/Shift as menu accelerator
|
||||
// modifiers. On OS X, "Ctrl+" is mapped to the Command key.
|
||||
#ifdef __APPLE__
|
||||
if (hotkeymodifier & wxMOD_CMD)
|
||||
hotkeymodifier |= wxMOD_CONTROL;
|
||||
#endif
|
||||
hotkeymodifier &= wxMOD_CONTROL | wxMOD_ALT | wxMOD_SHIFT;
|
||||
|
||||
Modifier = InputCommon::WXKeymodToString(hotkeymodifier);
|
||||
Hotkey = InputCommon::WXKeyToString(hotkey);
|
||||
if (Modifier.Len() + Hotkey.Len() > 0)
|
||||
Label += '\t';
|
||||
|
||||
return Label + Modifier + (Modifier.Len() ? _T("+") : _T("")) + Hotkey;
|
||||
return Label + Modifier + Hotkey;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ void HotkeyConfigDialog::OnKeyDown(wxKeyEvent& event)
|
|||
// Update the textbox for the buttons
|
||||
void HotkeyConfigDialog::SetButtonText(int id, const wxString &keystr, const wxString &modkeystr)
|
||||
{
|
||||
m_Button_Hotkeys[id]->SetLabel(modkeystr + (modkeystr.Len() ? _T("+") : _T("")) + keystr);
|
||||
m_Button_Hotkeys[id]->SetLabel(modkeystr + keystr);
|
||||
}
|
||||
|
||||
void HotkeyConfigDialog::DoGetButtons(int _GetId)
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifdef __APPLE__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
#include "Common.h"
|
||||
#include "CommonPaths.h"
|
||||
#include "Globals.h"
|
||||
|
@ -1129,6 +1133,12 @@ void CISOProperties::OnEditConfig(wxCommandEvent& WXUNUSED (event))
|
|||
{
|
||||
SaveGameConfig();
|
||||
|
||||
#ifdef __APPLE__
|
||||
// wxTheMimeTypesManager is not yet implemented for wxCocoa
|
||||
[[NSWorkspace sharedWorkspace] openFile:
|
||||
[NSString stringWithUTF8String: GameIniFile.c_str()]
|
||||
withApplication: @"TextEdit"];
|
||||
#else
|
||||
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("ini"));
|
||||
if(filetype == NULL) // From extension failed, trying with MIME type now
|
||||
{
|
||||
|
@ -1146,6 +1156,7 @@ void CISOProperties::OnEditConfig(wxCommandEvent& WXUNUSED (event))
|
|||
else
|
||||
if(wxExecute(OpenCommand, wxEXEC_SYNC) == -1)
|
||||
PanicAlertT("wxExecute returned -1 on application run!");
|
||||
#endif
|
||||
|
||||
GameIni.Load(GameIniFile.c_str());
|
||||
LoadGameConfig();
|
||||
|
|
|
@ -259,11 +259,6 @@ void X11_MainLoop()
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSEvent *event = [[NSEvent alloc] init];
|
||||
ProcessSerialNumber psn;
|
||||
#endif
|
||||
int ch, help = 0;
|
||||
struct option longopts[] = {
|
||||
{ "exec", no_argument, NULL, 'e' },
|
||||
|
@ -307,36 +302,32 @@ int main(int argc, char* argv[])
|
|||
if (BootManager::BootCore(argv[optind]))
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
GetCurrentProcess(&psn);
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
SetFrontProcess(&psn);
|
||||
|
||||
if (NSApp == nil) {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSEvent *event = [[NSEvent alloc] init];
|
||||
[NSApplication sharedApplication];
|
||||
//TODO : Create menu
|
||||
[NSApp activateIgnoringOtherApps: YES];
|
||||
[NSApp finishLaunching];
|
||||
}
|
||||
|
||||
while (running)
|
||||
{
|
||||
event = [NSApp nextEventMatchingMask: NSAnyEventMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSDefaultRunLoopMode dequeue: YES];
|
||||
|
||||
if ([event type] == NSKeyDown &&
|
||||
[event modifierFlags] & NSCommandKeyMask &&
|
||||
[[event characters] UTF8String][0] == 'q')
|
||||
while (running)
|
||||
{
|
||||
Core::Stop();
|
||||
break;
|
||||
}
|
||||
event = [NSApp nextEventMatchingMask: NSAnyEventMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSDefaultRunLoopMode dequeue: YES];
|
||||
|
||||
if ([event type] == NSKeyDown &&
|
||||
[event modifierFlags] & NSCommandKeyMask &&
|
||||
[[event characters] UTF8String][0] == 'q')
|
||||
{
|
||||
Core::Stop();
|
||||
break;
|
||||
}
|
||||
|
||||
if ([event type] != NSKeyDown)
|
||||
[NSApp sendEvent: event];
|
||||
}
|
||||
|
||||
if ([event type] != NSKeyDown)
|
||||
[NSApp sendEvent: event];
|
||||
}
|
||||
|
||||
[event release];
|
||||
[pool release];
|
||||
[event release];
|
||||
[pool release];
|
||||
#elif defined HAVE_X11 && HAVE_X11
|
||||
XInitThreads();
|
||||
X11_MainLoop();
|
||||
|
|
|
@ -138,22 +138,29 @@ const wxString WXKeyToString(int keycode)
|
|||
return wxString((wxChar)keycode, 1);
|
||||
}
|
||||
|
||||
return _T("");
|
||||
return wxT("");
|
||||
}
|
||||
|
||||
const wxString WXKeymodToString(int modifier)
|
||||
{
|
||||
switch (modifier)
|
||||
{
|
||||
case wxMOD_ALT: return wxT("Alt");
|
||||
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("");
|
||||
}
|
||||
wxString mods;
|
||||
|
||||
if (modifier & wxMOD_META)
|
||||
#ifdef __APPLE__
|
||||
mods += wxT("Cmd+");
|
||||
#elif defined _WIN32
|
||||
mods += wxT("Win+");
|
||||
#else
|
||||
mods += wxT("Meta+");
|
||||
#endif
|
||||
if (modifier & wxMOD_CONTROL)
|
||||
mods += wxT("Ctrl+");
|
||||
if (modifier & wxMOD_ALT)
|
||||
mods += wxT("Alt+");
|
||||
if (modifier & wxMOD_SHIFT)
|
||||
mods += wxT("Shift+");
|
||||
|
||||
return mods;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,8 +68,7 @@ void OpenGL_SetWindowText(const char *text)
|
|||
#if defined(USE_WX) && USE_WX
|
||||
// Handled by Host_UpdateTitle()
|
||||
#elif defined(__APPLE__)
|
||||
[GLWin.cocoaWin setTitle: [[[NSString alloc]
|
||||
initWithCString: text] autorelease]];
|
||||
[GLWin.cocoaWin setTitle: [NSString stringWithUTF8String: text]];
|
||||
#elif defined(_WIN32)
|
||||
// TODO convert text to unicode and change SetWindowTextA to SetWindowText
|
||||
SetWindowTextA(EmuWindow::GetWnd(), text);
|
||||
|
|
Loading…
Reference in New Issue