diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2010-02-20 18:44:35 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2010-02-20 19:01:46 +0300 |
commit | 8934d917d598377e95d1effb4293318803d77c53 (patch) | |
tree | 794fdadb990e7cc152a64e755259485f414b820e /macx | |
parent | 157695703981da297e33352baf3718388ae74abe (diff) |
Add automatic overlay injection for OSX (Snow Leopard only, for now).
Diffstat (limited to 'macx')
-rw-r--r-- | macx/macx.pro | 2 | ||||
-rw-r--r-- | macx/osax/MumbleOverlay.sdef | 7 | ||||
-rw-r--r-- | macx/osax/osax.m | 90 | ||||
-rw-r--r-- | macx/osax/osax.plist | 39 | ||||
-rw-r--r-- | macx/osax/osax.pro | 34 | ||||
-rw-r--r-- | macx/overlay/overlay.m | 37 | ||||
-rw-r--r-- | macx/overlay/overlay.pro | 3 |
7 files changed, 185 insertions, 27 deletions
diff --git a/macx/macx.pro b/macx/macx.pro index d877df1b8..37397f5cd 100644 --- a/macx/macx.pro +++ b/macx/macx.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs CONFIG += debug_and_release -SUBDIRS = overlay launcher compat +SUBDIRS = overlay launcher compat osax diff --git a/macx/osax/MumbleOverlay.sdef b/macx/osax/MumbleOverlay.sdef new file mode 100644 index 000000000..987597dfb --- /dev/null +++ b/macx/osax/MumbleOverlay.sdef @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd"> +<dictionary> + <suite name="MumbleOverlaySuite" code="MUOL" description="Mumble In-Game Overlay"> + <command name="load Mumble Overlay" code="OLAYload" description="Load the Mumble Overlay into process"/> + </suite> +</dictionary> diff --git a/macx/osax/osax.m b/macx/osax/osax.m new file mode 100644 index 000000000..c694c09f2 --- /dev/null +++ b/macx/osax/osax.m @@ -0,0 +1,90 @@ +/* Copyright (C) 2010, Mikkel Krautz <mikkel@krautz.dk> + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + - Neither the name of the Mumble Developers nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#import <Cocoa/Cocoa.h> +#include <dlfcn.h> + +__attribute__ ((visibility("default"))) +OSErr MumbleOverlayEventHandler(const AppleEvent *ae, AppleEvent *reply, long refcon) { + + /* Is the overlay already loaded into the process? */ + if (dlsym(RTLD_DEFAULT, "MumbleOverlayEntryPoint")) { + fprintf(stderr, "MumbleOverlayLoader: Overlay already loaded.\n"); + return; + } + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + /* Get a hold of our Mumble process, to find our overlay library. */ + NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; + NSString *mumblePath = nil; + + for (NSDictionary *dict in apps) { + if ([[dict objectForKey:@"NSApplicationBundleIdentifier"] isEqualToString:@"net.sourceforge.mumble.Mumble"]) { + mumblePath = [dict objectForKey:@"NSApplicationPath"]; + break; + } + if ([[dict objectForKey:@"NSApplicationBundleIdentifier"] isEqualToString:@"net.sourceforge.mumble.Mumble11x"]) { + mumblePath = [dict objectForKey:@"NSApplicationPath"]; + break; + } + } + + if (! mumblePath) { + fprintf(stderr, "MumbleOverlayLoader: Cannot find open Mumble instance. Bailing.\n"); + goto out; + } + + NSBundle *appBundle = [NSBundle bundleWithPath: mumblePath]; + if (! appBundle) { + fprintf(stderr, "MumbleOverlayLoader: Cannot open Mumble app bundle.\n"); + goto out; + } + + NSString *overlayInBundle = [appBundle objectForInfoDictionaryKey:@"MumbleOverlayLibrary"]; + if (! overlayInBundle) { + fprintf(stderr, "MumbleOverlayLoader: No key 'MumbleOverlayLibrary' specified in Mumble's property list. Cannot find overlay library.\n"); + goto out; + } + + NSString *overlayPath = [NSString stringWithFormat:@"%@/%@", mumblePath, overlayInBundle]; + + if (! [[NSFileManager defaultManager] fileExistsAtPath:overlayPath]) { + fprintf(stderr, "MumbleOverlayLoader: Overlay library non-existant at MumbleOverlayLibrary-specified path.\n"); + goto out; + } + + /* Load the overlay library. */ + dlopen([overlayPath UTF8String ], RTLD_LAZY); + +out: + [pool release]; + return noErr; +} diff --git a/macx/osax/osax.plist b/macx/osax/osax.plist new file mode 100644 index 000000000..52fe7801f --- /dev/null +++ b/macx/osax/osax.plist @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>MumbleOverlay</string> + <key>CFBundleIdentifier</key> + <string>net.sourceforge.mumble.OverlayScriptingAddition</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>osax</string> + <key>CFbundleVersion</key> + <string>1.2.3</string> + <key>CFBundleSignature</key> + <string>MUOL</string> + <key>CSResourcesFileMapped</key> + <true/> + <key>OSAScriptingDefinition</key> + <string>MumbleOverlay.sdef</string> + <key>OSAXHandlers</key> + <dict> + <key>Events</key> + <dict> + <key>MUOLload</key> + <dict> + <key>Handler</key> + <string>MumbleOverlayEventHandler</string> + <key>Context</key> + <string>Process</string> + <key>ThreadSafe</key> + <false/> + </dict> + </dict> + </dict> +</dict> +</plist> diff --git a/macx/osax/osax.pro b/macx/osax/osax.pro new file mode 100644 index 000000000..2bde6c9d3 --- /dev/null +++ b/macx/osax/osax.pro @@ -0,0 +1,34 @@ +# Mumble Overlay scripting addition +# (for injection into running processes) + +include(../../compiler.pri) + +CONFIG += x86_64 x86 ppc debug_and_release + +TEMPLATE = lib +CONFIG += plugin plugin_bundle +CONFIG -= gui qt + +TARGET = MumbleOverlay +QMAKE_INFO_PLIST = osax.plist + +QMAKE_LFLAGS = -framework Foundation -framework Cocoa +QMAKE_BUNDLE_EXTENSION = .osax +QMAKE_LFLAGS_PLUGIN = -bundle + +SDEF.files = MumbleOverlay.sdef +SDEF.path = Contents/Resources +QMAKE_BUNDLE_DATA += SDEF + +SOURCES = osax.m +DIST = osax.plist MumbleOverlay.sdef + +CONFIG(debug, debug|release) { + DESTDIR = ../../debug +} + +CONFIG(release, debug|release) { + DESTDIR = ../../release +} + +include(../../symbols.pri) diff --git a/macx/overlay/overlay.m b/macx/overlay/overlay.m index 216979def..17607c7b3 100644 --- a/macx/overlay/overlay.m +++ b/macx/overlay/overlay.m @@ -1,5 +1,5 @@ /* Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com> - Copyright (C) 2008-2009, Mikkel Krautz <mikkel@krautz.dk> + Copyright (C) 2008-2010, Mikkel Krautz <mikkel@krautz.dk> All rights reserved. @@ -57,7 +57,6 @@ #include "../../overlay/overlay.h" static bool bDebug = false; -static bool vendorIntel = false; typedef struct _Context { struct _Context *next; @@ -131,11 +130,6 @@ static void newContext(Context * ctx) { ods("OpenGL Version %s, Vendor %s, Renderer %s, Shader %s", glGetString(GL_VERSION), glGetString(GL_VENDOR), glGetString(GL_RENDERER), glGetString(GL_SHADING_LANGUAGE_VERSION)); - if (!strcmp(glGetString(GL_VENDOR), "Intel Inc.")) { - ods("Enabling Intel specific hacks"); - vendorIntel = true; - } - const char *vsource = vshader; const char *fsource = fshader; char buffer[8192]; @@ -379,22 +373,16 @@ static void drawOverlay(Context *ctx, unsigned int width, unsigned int height) { right, bottom}; GLfloat tex[] = {xm, ymx, xm, ym, xmx, ym, xmx, ymx}; - if (! vendorIntel) { - glVertexPointer(2, GL_FLOAT, 0, vertex); - glTexCoordPointer(2, GL_FLOAT, 0, tex); - glDrawArrays(GL_QUADS, 0, 4); - } else { - glBegin(GL_QUADS); - glTexCoord2f(tex[0], tex[1]); - glVertex2f(vertex[0], vertex[1]); - glTexCoord2f(tex[2], tex[3]); - glVertex2f(vertex[2], vertex[3]); - glTexCoord2f(tex[4], tex[5]); - glVertex2f(vertex[4], vertex[5]); - glTexCoord2f(tex[6], tex[7]); - glVertex2f(vertex[6], vertex[7]); - glEnd(); - } + glBegin(GL_QUADS); + glTexCoord2f(tex[0], tex[1]); + glVertex2f(vertex[0], vertex[1]); + glTexCoord2f(tex[2], tex[3]); + glVertex2f(vertex[2], vertex[3]); + glTexCoord2f(tex[4], tex[5]); + glVertex2f(vertex[4], vertex[5]); + glTexCoord2f(tex[6], tex[7]); + glVertex2f(vertex[6], vertex[7]); + glEnd(); glPopMatrix(); } @@ -565,8 +553,9 @@ void CGLFlushDrawableOverride(CGLContextObj ctx) { } +__attribute__ ((visibility("default"))) __attribute__((constructor)) -static void entryPoint() { +void MumbleOverlayEntryPoint() { if (getenv("MUMBLE_OVERLAY_DEBUG")) bDebug = true; else diff --git a/macx/overlay/overlay.pro b/macx/overlay/overlay.pro index 246df1b3d..3c2c30bdc 100644 --- a/macx/overlay/overlay.pro +++ b/macx/overlay/overlay.pro @@ -2,10 +2,9 @@ include(../../compiler.pri) -CONFIG += x86_64 x86 ppc +CONFIG += x86_64 x86 ppc debug_and_release plugin TEMPLATE = lib -CONFIG += plugin CONFIG -= gui qt TARGET = mumbleoverlay |