mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-10 21:44:28 +00:00
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;
|
const int DefaultModifier;
|
||||||
} g_HKData[] = {
|
} g_HKData[] = {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
{ "ToggleFullscreen", 70 /* 'F' */, 0x08 /* wxMOD_CMD */ },
|
|
||||||
{ "PlayPause", 80 /* 'P' */, 0x08 /* wxMOD_CMD */ },
|
{ "PlayPause", 80 /* 'P' */, 0x08 /* wxMOD_CMD */ },
|
||||||
{ "Stop", 87 /* 'W' */, 0x08 /* wxMOD_CMD */ },
|
{ "Stop", 87 /* 'W' */, 0x08 /* wxMOD_CMD */ },
|
||||||
{ "Screenshot", 83 /* 'S' */, 0x08 /* wxMOD_CMD */ },
|
{ "Screenshot", 83 /* 'S' */, 0x08 /* wxMOD_CMD */ },
|
||||||
|
{ "ToggleFullscreen", 70 /* 'F' */, 0x08 /* wxMOD_CMD */ },
|
||||||
{ "Wiimote1Connect", 49 /* '1' */, 0x08 /* wxMOD_CMD */ },
|
{ "Wiimote1Connect", 49 /* '1' */, 0x08 /* wxMOD_CMD */ },
|
||||||
{ "Wiimote2Connect", 50 /* '2' */, 0x08 /* wxMOD_CMD */ },
|
{ "Wiimote2Connect", 50 /* '2' */, 0x08 /* wxMOD_CMD */ },
|
||||||
{ "Wiimote3Connect", 51 /* '3' */, 0x08 /* wxMOD_CMD */ },
|
{ "Wiimote3Connect", 51 /* '3' */, 0x08 /* wxMOD_CMD */ },
|
||||||
{ "Wiimote4Connect", 52 /* '4' */, 0x08 /* wxMOD_CMD */ },
|
{ "Wiimote4Connect", 52 /* '4' */, 0x08 /* wxMOD_CMD */ },
|
||||||
#else
|
#else
|
||||||
{ "ToggleFullscreen", 13 /* WXK_RETURN */, 0x01 /* wxMOD_ALT */ },
|
|
||||||
{ "PlayPause", 349 /* WXK_F10 */, 0x00 /* wxMOD_NONE*/ },
|
{ "PlayPause", 349 /* WXK_F10 */, 0x00 /* wxMOD_NONE*/ },
|
||||||
{ "Stop", 27 /* WXK_ESCAPE */, 0x00 /* wxMOD_NONE*/ },
|
{ "Stop", 27 /* WXK_ESCAPE */, 0x00 /* wxMOD_NONE*/ },
|
||||||
{ "Screenshot", 348 /* WXK_F9 */, 0x00 /* wxMOD_NONE*/ },
|
{ "Screenshot", 348 /* WXK_F9 */, 0x00 /* wxMOD_NONE*/ },
|
||||||
|
{ "ToggleFullscreen", 13 /* WXK_RETURN */, 0x01 /* wxMOD_ALT */ },
|
||||||
{ "Wiimote1Connect", 344 /* WXK_F5 */, 0x01 /* wxMOD_ALT */ },
|
{ "Wiimote1Connect", 344 /* WXK_F5 */, 0x01 /* wxMOD_ALT */ },
|
||||||
{ "Wiimote2Connect", 345 /* WXK_F6 */, 0x01 /* wxMOD_ALT */ },
|
{ "Wiimote2Connect", 345 /* WXK_F6 */, 0x01 /* wxMOD_ALT */ },
|
||||||
{ "Wiimote3Connect", 346 /* WXK_F7 */, 0x01 /* wxMOD_ALT */ },
|
{ "Wiimote3Connect", 346 /* WXK_F7 */, 0x01 /* wxMOD_ALT */ },
|
||||||
|
@ -308,7 +308,12 @@ void CFrame::CreateMenu()
|
|||||||
|
|
||||||
wxString CFrame::GetMenuLabel(int Id)
|
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)
|
switch (Id)
|
||||||
{
|
{
|
||||||
case HK_FULLSCREEN:
|
case HK_FULLSCREEN:
|
||||||
@ -335,14 +340,20 @@ wxString CFrame::GetMenuLabel(int Id)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Modifier = InputCommon::WXKeymodToString
|
// wxWidgets only accepts Ctrl/Alt/Shift as menu accelerator
|
||||||
(SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[Id]);
|
// modifiers. On OS X, "Ctrl+" is mapped to the Command key.
|
||||||
wxString Hotkey = InputCommon::WXKeyToString
|
#ifdef __APPLE__
|
||||||
(SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[Id]);
|
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)
|
if (Modifier.Len() + Hotkey.Len() > 0)
|
||||||
Label += '\t';
|
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
|
// Update the textbox for the buttons
|
||||||
void HotkeyConfigDialog::SetButtonText(int id, const wxString &keystr, const wxString &modkeystr)
|
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)
|
void HotkeyConfigDialog::DoGetButtons(int _GetId)
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "CommonPaths.h"
|
#include "CommonPaths.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
@ -1129,6 +1133,12 @@ void CISOProperties::OnEditConfig(wxCommandEvent& WXUNUSED (event))
|
|||||||
{
|
{
|
||||||
SaveGameConfig();
|
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"));
|
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("ini"));
|
||||||
if(filetype == NULL) // From extension failed, trying with MIME type now
|
if(filetype == NULL) // From extension failed, trying with MIME type now
|
||||||
{
|
{
|
||||||
@ -1146,6 +1156,7 @@ void CISOProperties::OnEditConfig(wxCommandEvent& WXUNUSED (event))
|
|||||||
else
|
else
|
||||||
if(wxExecute(OpenCommand, wxEXEC_SYNC) == -1)
|
if(wxExecute(OpenCommand, wxEXEC_SYNC) == -1)
|
||||||
PanicAlertT("wxExecute returned -1 on application run!");
|
PanicAlertT("wxExecute returned -1 on application run!");
|
||||||
|
#endif
|
||||||
|
|
||||||
GameIni.Load(GameIniFile.c_str());
|
GameIni.Load(GameIniFile.c_str());
|
||||||
LoadGameConfig();
|
LoadGameConfig();
|
||||||
|
@ -259,11 +259,6 @@ void X11_MainLoop()
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
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;
|
int ch, help = 0;
|
||||||
struct option longopts[] = {
|
struct option longopts[] = {
|
||||||
{ "exec", no_argument, NULL, 'e' },
|
{ "exec", no_argument, NULL, 'e' },
|
||||||
@ -307,36 +302,32 @@ int main(int argc, char* argv[])
|
|||||||
if (BootManager::BootCore(argv[optind]))
|
if (BootManager::BootCore(argv[optind]))
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
GetCurrentProcess(&psn);
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
NSEvent *event = [[NSEvent alloc] init];
|
||||||
SetFrontProcess(&psn);
|
|
||||||
|
|
||||||
if (NSApp == nil) {
|
|
||||||
[NSApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
//TODO : Create menu
|
[NSApp activateIgnoringOtherApps: YES];
|
||||||
[NSApp finishLaunching];
|
[NSApp finishLaunching];
|
||||||
}
|
|
||||||
|
|
||||||
while (running)
|
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')
|
|
||||||
{
|
{
|
||||||
Core::Stop();
|
event = [NSApp nextEventMatchingMask: NSAnyEventMask
|
||||||
break;
|
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)
|
[event release];
|
||||||
[NSApp sendEvent: event];
|
[pool release];
|
||||||
}
|
|
||||||
|
|
||||||
[event release];
|
|
||||||
[pool release];
|
|
||||||
#elif defined HAVE_X11 && HAVE_X11
|
#elif defined HAVE_X11 && HAVE_X11
|
||||||
XInitThreads();
|
XInitThreads();
|
||||||
X11_MainLoop();
|
X11_MainLoop();
|
||||||
|
@ -138,22 +138,29 @@ const wxString WXKeyToString(int keycode)
|
|||||||
return wxString((wxChar)keycode, 1);
|
return wxString((wxChar)keycode, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _T("");
|
return wxT("");
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxString WXKeymodToString(int modifier)
|
const wxString WXKeymodToString(int modifier)
|
||||||
{
|
{
|
||||||
switch (modifier)
|
wxString mods;
|
||||||
{
|
|
||||||
case wxMOD_ALT: return wxT("Alt");
|
if (modifier & wxMOD_META)
|
||||||
case wxMOD_CONTROL: return wxT("Ctrl");
|
#ifdef __APPLE__
|
||||||
case wxMOD_ALTGR: return wxT("Ctrl+Alt");
|
mods += wxT("Cmd+");
|
||||||
case wxMOD_SHIFT: return wxT("Shift");
|
#elif defined _WIN32
|
||||||
// wxWidgets can only use Alt/Ctrl/Shift as menu accelerators,
|
mods += wxT("Win+");
|
||||||
// so Meta (Command on OS X) is simply made equivalent to Ctrl.
|
#else
|
||||||
case wxMOD_META: return wxT("Ctrl");
|
mods += wxT("Meta+");
|
||||||
default: return wxT("");
|
#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
|
#if defined(USE_WX) && USE_WX
|
||||||
// Handled by Host_UpdateTitle()
|
// Handled by Host_UpdateTitle()
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
[GLWin.cocoaWin setTitle: [[[NSString alloc]
|
[GLWin.cocoaWin setTitle: [NSString stringWithUTF8String: text]];
|
||||||
initWithCString: text] autorelease]];
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
// TODO convert text to unicode and change SetWindowTextA to SetWindowText
|
// TODO convert text to unicode and change SetWindowTextA to SetWindowText
|
||||||
SetWindowTextA(EmuWindow::GetWnd(), text);
|
SetWindowTextA(EmuWindow::GetWnd(), text);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user