From 2d586139bc0abec2718c41047edbc2bb2ab3638b Mon Sep 17 00:00:00 2001 From: tmator Date: Tue, 13 Jan 2009 00:34:36 +0000 Subject: [PATCH] cocoa event wip, i'm tired i'll continue tomorrow git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1860 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/cocoaApp.m | 2 +- .../Plugin_PadSimple/Src/GUI/ConfigDlg.cpp | 4 +- .../Plugin_PadSimple/Src/GUI/ConfigDlg.h | 2 +- .../Plugin_PadSimple/Src/PadSimple.cpp | 70 ++++++++++++++++++- .../Plugins/Plugin_PadSimple/Src/SConscript | 10 ++- .../Plugin_PadSimple/Src/XInputBase.cpp | 1 + 6 files changed, 83 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinWX/Src/cocoaApp.m b/Source/Core/DolphinWX/Src/cocoaApp.m index 7d5a579ba0..5021769a17 100644 --- a/Source/Core/DolphinWX/Src/cocoaApp.m +++ b/Source/Core/DolphinWX/Src/cocoaApp.m @@ -56,7 +56,7 @@ void cocoaKeyCode(NSEvent *event) [connec setRootObject: event]; if ([connec registerName: @"DolphinCocoaEvent"] == NO) { - printf("error creating nsconnection\n"); + //printf("error creating nsconnection\n"); } [pool release]; diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp index 95882a560f..fd55019652 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp @@ -84,7 +84,7 @@ inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer, wxALIGN_CENTER_VERTICAL|wxALL); #ifdef _WIN32 DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr); -#else +#elif defined(HAVE_X11) && HAVE_X11 XKeyToString(pad[controller].keyForControl[ctl], keyStr); #endif @@ -269,7 +269,7 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event) break; } } -#else +#elif defined(HAVE_X11) && HAVE_X11 pad[page].keyForControl[clickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode()); clickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode())); #endif diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h index 4161d06e5f..34d12ee34f 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h @@ -29,7 +29,7 @@ #include #include -#ifndef _WIN32 +#if defined(HAVE_X11) && HAVE_X11 #include "../XInputBase.h" #endif diff --git a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp index 1727f7a659..73a26393b8 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp +++ b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp @@ -23,6 +23,8 @@ #include "PadSimple.h" #include "IniFile.h" + + #if defined(HAVE_WX) && HAVE_WX #include "GUI/ConfigDlg.h" #endif @@ -44,6 +46,8 @@ DInput dinput; Display* GXdsp; bool KeyStatus[NUMCONTROLS]; +#elif defined(HAVE_COCOA) && HAVE_COCOA +#include #endif SPads pad[4]; @@ -174,6 +178,9 @@ void DllConfig(HWND _hParent) #elif defined(HAVE_WX) && HAVE_WX ConfigDialog frame(NULL); frame.ShowModal(); +#elif defined(HAVE_COCOA) && HAVE_COCOA + ConfigDialog frame(NULL); + frame.ShowModal(); #endif SaveConfig(); } @@ -192,6 +199,7 @@ void PAD_Initialize(SPADInitialize _PADInitialize) dinput.Init((HWND)g_PADInitialize.hWnd); #elif defined(HAVE_X11) && HAVE_X11 GXdsp = (Display*)g_PADInitialize.hWnd; +#elif defined(HAVE_COCOA) && HAVE_COCOA #endif LoadConfig(); @@ -476,7 +484,38 @@ void X11_Read(int _numPAD, SPADStatus* _pPADStatus) #endif +#if defined(HAVE_COCOA) && HAVE_COCOA +void cocoa_Read(int _numPAD, SPADStatus* _pPADStatus) +{ + // Do all the stuff we need to do once per frame here + if (_numPAD != 0) { + return; + } + //get event from main thread + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSConnection *conn; + NSDistantObject *proxy; + + conn = [NSConnection connectionWithRegisteredName:@"DolphinCocoaEvent" host:nil]; + if (!conn) { + //printf("error creating cnx event client\n"); + } + + proxy = [conn rootProxy]; + + if (!proxy) { + //printf("error prox client\n"); + } + + if ([proxy keyCode] != 0) + printf("evt recevied : %d\n",[proxy keyCode]); + + [pool release]; + +} + +#endif // Set buttons status from wxWidgets in the main application // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void PAD_Input(u8 _Key, u8 _UpDown) {} @@ -519,6 +558,9 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) #elif defined(HAVE_X11) && HAVE_X11 _pPADStatus->err = PAD_ERR_NONE; X11_Read(_numPAD, _pPADStatus); +#elif defined(HAVE_COCOA) && HAVE_COCOA + _pPADStatus->err = PAD_ERR_NONE; + cocoa_Read(_numPAD, _pPADStatus); #endif #ifdef RECORD_STORE @@ -606,7 +648,7 @@ void LoadConfig() DIK_H, DIK_LSHIFT }; -#else +#elif defined(HAVE_X11) && HAVE_X11 const int defaultKeyForControl[NUMCONTROLS] = { XK_x, //A @@ -632,6 +674,32 @@ void LoadConfig() XK_Shift_L, //halfpress XK_p }; +#elif defined(HAVE_COCOA) && HAVE_COCOA + const int defaultKeyForControl[NUMCONTROLS] = + { + 7, //A + 6, + 1, + 8, + 2, + 36, + 12, + 13, + 126, //mainstick + 125, + 123, + 124, + 34, //substick + 40, + 38, + 37, + 17, //dpad + 5, + 3, + 4, + 56, //halfpress + 35 + }; #endif IniFile file; file.Load(FULL_CONFIG_DIR "pad.ini"); diff --git a/Source/Plugins/Plugin_PadSimple/Src/SConscript b/Source/Plugins/Plugin_PadSimple/Src/SConscript index 884394256c..a7bcaabb3b 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/SConscript +++ b/Source/Plugins/Plugin_PadSimple/Src/SConscript @@ -30,9 +30,17 @@ if padenv['HAVE_COCOA']: if padenv['HAVE_WX']: files += [ "GUI/ConfigDlg.cpp", + ] + +if env['HAVE_X11']: + files += [ "XInputBase.cpp", ] -padenv.Append(LIBS = [ 'common' ]) +if padenv['HAVE_COCOA']: + padenv.Append( CXXFLAGS = compileFlags, + LIBS = [ 'common' ]) +else: + padenv.Append(LIBS = [ 'common' ]) padenv.SharedLibrary(env['plugin_dir']+name, files) diff --git a/Source/Plugins/Plugin_PadSimple/Src/XInputBase.cpp b/Source/Plugins/Plugin_PadSimple/Src/XInputBase.cpp index 3f89067194..bca40e64db 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/XInputBase.cpp +++ b/Source/Plugins/Plugin_PadSimple/Src/XInputBase.cpp @@ -1,3 +1,4 @@ + #include "XInputBase.h" // Taken from wxw source code