Created
January 21, 2014 03:53
-
-
Save kode54/8534201 to your computer and use it in GitHub Desktop.
Patch against higan v094 which does the following:
1) Adds the executable base path to the dlopen search path, to facilitate loading libananke.dylib from the app bundle.
2) Imports endian.h from the correct path.
3) Fixes noinline macro clash with Cocoa/Carbon headers.
4) Updates Ruby Carbon input implementation poll() function and removes an ex…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -urN higan_v094-source/nall/dl.hpp higan/nall/dl.hpp | |
--- higan_v094-source/nall/dl.hpp 2014-01-20 17:30:18.000000000 -0800 | |
+++ higan/nall/dl.hpp 2014-01-20 18:17:41.000000000 -0800 | |
@@ -60,9 +60,15 @@ | |
handle = 0; | |
} | |
#elif defined(PLATFORM_MACOSX) | |
+static void junk_function() {} | |
inline bool library::open(const string& name, const string& path) { | |
if(handle) close(); | |
handle = (uintptr_t)dlopen(string(path, !path.empty() && !path.endsWith("/") ? "/" : "", "lib", name, ".dylib"), RTLD_LAZY); | |
+ if(!handle) { | |
+ Dl_info info; | |
+ dladdr((void*)&junk_function, &info); | |
+ handle = (uintptr_t)dlopen(string(parentdir(info.dli_fname), "lib", name, ".dylib"), RTLD_LAZY); | |
+ } | |
if(!handle) handle = (uintptr_t)dlopen(string("/usr/local/lib/lib", name, ".dylib"), RTLD_LAZY); | |
return handle; | |
} | |
diff -urN higan_v094-source/nall/platform.hpp higan/nall/platform.hpp | |
--- higan_v094-source/nall/platform.hpp 2014-01-20 17:30:18.000000000 -0800 | |
+++ higan/nall/platform.hpp 2014-01-20 17:51:45.000000000 -0800 | |
@@ -41,7 +41,11 @@ | |
#undef interface | |
#define dllexport __declspec(dllexport) | |
#else | |
- #include <endian.h> | |
+ #ifdef __APPLE__ | |
+ #include <machine/endian.h> | |
+ #else | |
+ #include <endian.h> | |
+ #endif | |
#include <unistd.h> | |
#include <pwd.h> | |
#define dllexport | |
diff -urN higan_v094-source/ruby/implementation.cpp higan/ruby/implementation.cpp | |
--- higan_v094-source/ruby/implementation.cpp 2014-01-20 17:30:18.000000000 -0800 | |
+++ higan/ruby/implementation.cpp 2014-01-20 18:41:36.000000000 -0800 | |
@@ -6,8 +6,11 @@ | |
#include <X11/Xatom.h> | |
#elif defined(PLATFORM_MACOSX) | |
#define decimal CocoaDecimal | |
+ #pragma push_macro("noinline") | |
+ #undef noinline | |
#include <Cocoa/Cocoa.h> | |
#include <Carbon/Carbon.h> | |
+ #pragma pop_macro("noinline") | |
#undef decimal | |
#elif defined(PLATFORM_WINDOWS) | |
#define _WIN32_WINNT 0x0501 | |
diff -urN higan_v094-source/ruby/input/carbon.cpp higan/ruby/input/carbon.cpp | |
--- higan_v094-source/ruby/input/carbon.cpp 2014-01-20 17:30:18.000000000 -0800 | |
+++ higan/ruby/input/carbon.cpp 2014-01-20 17:56:28.000000000 -0800 | |
@@ -35,18 +35,21 @@ | |
group.input[inputID].value = value; | |
} | |
- void poll(vector<HID::Device*>& devices) { | |
+ vector<HID::Device*> poll() { | |
+ vector<HID::Device*> devices; | |
KeyMap keymap; | |
GetKeys(keymap); | |
uint8_t* buffer = (uint8_t*)keymap; | |
unsigned inputID = 0; | |
for(auto& key : keys) { | |
- bool value = buffer[key.id >> 3] & (1 << (key.id & 7))); | |
+ bool value = buffer[key.id >> 3] & (1 << (key.id & 7)); | |
assign(kb.hid, HID::Keyboard::GroupID::Button, inputID++, value); | |
} | |
devices.append(&kb.hid); | |
+ | |
+ return devices; | |
} | |
bool rumble(uint64_t id, bool enable) { | |
diff -urN higan_v094-source/ruby/video/cgl.cpp higan/ruby/video/cgl.cpp | |
--- higan_v094-source/ruby/video/cgl.cpp 2014-01-20 17:30:18.000000000 -0800 | |
+++ higan/ruby/video/cgl.cpp 2014-01-20 19:44:22.000000000 -0800 | |
@@ -16,6 +16,7 @@ | |
struct pVideoCGL : OpenGL { | |
RubyVideoCGL* view; | |
+ bool initialized; | |
struct { | |
NSView* handle; | |
@@ -144,21 +145,25 @@ | |
} | |
clear(); | |
- return true; | |
+ return initialized = true; | |
} | |
void term() { | |
- OpenGL::term(); | |
+ if (initialized) { | |
+ OpenGL::term(); | |
- @autoreleasepool { | |
- [view removeFromSuperview]; | |
- [view release]; | |
- view = nil; | |
+ @autoreleasepool { | |
+ [view removeFromSuperview]; | |
+ [view release]; | |
+ view = nil; | |
+ } | |
} | |
+ initialized = false; | |
} | |
pVideoCGL() { | |
view = nil; | |
+ initialized = false; | |
settings.handle = nil; | |
settings.synchronize = false; |
nice one cheers. would be nice if the whole repo was in github :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!