Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2009-04-28 02:15:05 +0400
committerMikkel Krautz <mikkel@krautz.dk>2009-04-28 02:41:31 +0400
commit91a9f16acf6ff863d87133c31376c7df6280ea3e (patch)
tree07950428ce7e67942050e7414e524f6f679303a1 /g15helper
parent3727bf980c487666cbac15ce9b37b70cc347878f (diff)
Add (untested) G15 LCD support for Mac OS X.
Diffstat (limited to 'g15helper')
-rw-r--r--g15helper/g15helper.c8
-rw-r--r--g15helper/g15helper.h4
-rw-r--r--g15helper/g15helper.plist20
-rw-r--r--g15helper/g15helper.pro22
-rw-r--r--g15helper/g15helper_macx.c174
5 files changed, 213 insertions, 15 deletions
diff --git a/g15helper/g15helper.c b/g15helper/g15helper.c
index b8055b868..97115c609 100644
--- a/g15helper/g15helper.c
+++ b/g15helper/g15helper.c
@@ -85,11 +85,11 @@ int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
hStdin = GetStdHandle(STD_INPUT_HANDLE);
if (hStdin == INVALID_HANDLE_VALUE)
- die(G15_ERR_PIPESTATE, "Failed to get standard input");
+ die(G15_ERR_INIT, "Failed to get standard input");
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdout == INVALID_HANDLE_VALUE)
- die(G15_ERR_PIPESTATE, "Failed to get standard output");
+ die(G15_ERR_INIT, "Failed to get standard output");
/*
* Clear and set up initial structures.
@@ -187,10 +187,6 @@ int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
if (dwErr != ERROR_SUCCESS)
die(G15_ERR_DEINIT, "Unable to deinitialize LCD library. (Error: %i)", dwErr);
- /*
- * Close pipe handle.
- */
-
warn("Terminated successfully.");
return 0;
diff --git a/g15helper/g15helper.h b/g15helper/g15helper.h
index 4a18a9843..40d6ad638 100644
--- a/g15helper/g15helper.h
+++ b/g15helper/g15helper.h
@@ -37,13 +37,9 @@
#define G15_MAX_BPP 1
#define G15_MAX_FBMEM (G15_MAX_WIDTH * G15_MAX_HEIGHT * G15_MAX_BPP)
#define G15_MAX_FBMEM_BITS (G15_MAX_FBMEM / 8)
-#define G15_PIPE_NAME L"\\\\.\\pipe\\MumbleG15Pipe"
#define G15_WIDGET_NAME L"Mumble G15 Display"
enum {
- G15_ERR_WAITPIPE = 50,
- G15_ERR_CREATEFILE,
- G15_ERR_PIPESTATE,
G15_ERR_INIT,
G15_ERR_CONNECT,
G15_ERR_ENUMERATE,
diff --git a/g15helper/g15helper.plist b/g15helper/g15helper.plist
new file mode 100644
index 000000000..fc1e9c663
--- /dev/null
+++ b/g15helper/g15helper.plist
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleExecutable</key>
+ <string>mumble-g15-helper</string>
+ <key>CFBundleGetInfoString</key>
+ <string>Mumble helper daemon for interfacing with G15 and compatible keyboards.</string>
+ <key>CFBundleIdentifier</key>
+ <string>net.sourceforge.mumble.g15helper</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>G15H</string>
+ <key>CFBundleVersion</key>
+ <string>1.2.0</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright (c) 2009 Mikkel Krautz &lt;mikkel@krautz.dk&gt;</string>
+</dict>
+</plist>
diff --git a/g15helper/g15helper.pro b/g15helper/g15helper.pro
index 8a8e13da6..e5452629b 100644
--- a/g15helper/g15helper.pro
+++ b/g15helper/g15helper.pro
@@ -7,12 +7,24 @@ CONFIG -= qt
CONFIG *= debug_and_release warn_on
TARGET = mumble-g15-helper
-SOURCES = g15helper.c
HEADERS = g15helper.h
-RC_FILE = g15helper.rc
-LIBS *= -llgLcd -ladvapi32 -lshell32 -luser32
-LIBPATH *= /dev/G15SDK/SDK/Libs/x86
-INCLUDEPATH *= /dev/G15SDK/SDK/Src
+
+win32 {
+ SOURCES = g15helper.c
+ RC_FILE = g15helper.rc
+ LIBS *= -llgLcd -ladvapi32 -lshell32 -luser32
+ LIBPATH *= /dev/G15SDK/SDK/Libs/x86
+ INCLUDEPATH *= /dev/G15SDK/SDK/Src
+}
+
+macx {
+ CONFIG -= app_bundle
+ SOURCES = g15helper_macx.c
+ LIBS *= -llgLcd
+ LIBPATH *= /opt/mumble/g15sdk/SDK/lib/
+ INCLUDEPATH *= /opt/mumble/g15sdk/SDK/Src/
+ QMAKE_LFLAGS *= -framework CoreFoundation -sectcreate __TEXT __info_plist g15helper.plist
+}
CONFIG(release, debug|release) {
DESTDIR = ../release
diff --git a/g15helper/g15helper_macx.c b/g15helper/g15helper_macx.c
new file mode 100644
index 000000000..cf4f893f5
--- /dev/null
+++ b/g15helper/g15helper_macx.c
@@ -0,0 +1,174 @@
+/* Copyright (C) 2008-2009, 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.
+*/
+
+/*
+ * G15 Helper Daemon for Mac OS X.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+#include "g15helper.h"
+#include "lglcd.h"
+
+#define ERROR_SUCCESS 0
+#define BOOL unsigned char
+#define BYTE unsigned char
+#define TRUE 1
+#define FALSE 0
+
+static void ods(const char *fmt, va_list args) {
+ vfprintf(stderr, fmt, args);
+}
+
+static void __cdecl warn(const char *fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ ods(fmt, args);
+ va_end(args);
+}
+
+static void __cdecl die(int err, const char *fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ ods(fmt, args);
+ va_end(args);
+ exit(err);
+}
+
+int main(int argc, char *argv[]) {
+ int dwErr;
+ BOOL bDetect = FALSE;
+ int i;
+ lgLcdConnectContextEx conn;
+ lgLcdOpenByTypeContext ctx;
+ lgLcdBitmap160x43x1 bitmap;
+
+ if (argc > 1 && (strcmp(argv[1], "/detect") == 0)) {
+ warn("Detect mode!");
+ bDetect = TRUE;
+ } else if (!(argc > 1) || (strcmp(argv[1], "/mumble") != 0)) {
+ CFUserNotificationDisplayAlert(0, 0, NULL, NULL, NULL, CFSTR("Nothing to see here"), CFSTR("This program is run by Mumble, and should not be started separately."), CFSTR("OK"), NULL, NULL, NULL);
+ return 0;
+ }
+
+ /*
+ * Clear and set up initial structures.
+ */
+ memset(&conn, 0, sizeof(conn));
+ memset(&ctx, 0, sizeof(ctx));
+ memset(&bitmap, 0, sizeof(bitmap));
+
+ conn.appFriendlyName = CFSTR(G15_WIDGET_NAME);
+ conn.isAutostartable = FALSE;
+ conn.isPersistent = FALSE;
+ conn.dwAppletCapabilitiesSupported =LGLCD_APPLET_CAP_BASIC | LGLCD_APPLET_CAP_BW;
+ conn.connection = LGLCD_INVALID_CONNECTION;
+
+ /*
+ * Initialize and connect.
+ */
+ dwErr = lgLcdInit();
+ if (dwErr != ERROR_SUCCESS)
+ die(G15_ERR_INIT, "Unable to initialize Logitech LCD library. (Error: %i)", dwErr);
+
+ dwErr = lgLcdConnectEx(&conn);
+ if (dwErr != ERROR_SUCCESS)
+ die(G15_ERR_CONNECT, "Unable to connect to Logitech LCD manager. (Error: %i)", dwErr);
+
+ ctx.connection = conn.connection;
+ ctx.device = LGLCD_INVALID_DEVICE;
+ ctx.deviceType =LGLCD_DEVICE_BW;
+
+ dwErr = lgLcdOpenByType(&ctx);
+
+ warn("That returned %d %d", dwErr, ERROR_SUCCESS);
+
+ if (bDetect)
+ return (dwErr != ERROR_SUCCESS);
+ else if (dwErr != ERROR_SUCCESS)
+ die(G15_ERR_OPEN, "Unable to open device. (Error: %i)", dwErr);
+
+ /*
+ * Diplay buffer format.
+ */
+ bitmap.hdr.Format = LGLCD_BMP_FORMAT_160x43x1;
+
+ /*
+ * Main drawing loop.
+ */
+ while (1) {
+ int ret;
+ int remain = 0;
+ BYTE bPriority;
+
+ ret = read(0, &bPriority, 1);
+ if (ret == -1 || ret != 1)
+ die(G15_ERR_READFILE, "Error while reading priority.");
+
+ do {
+ ret = read(0, bitmap.pixels + remain, G15_MAX_FBMEM - remain);
+ if (ret < 1)
+ die(G15_ERR_READFILE, "Error while reading framebuffer. %d (%s)", ret, strerror(errno));
+ remain += ret;
+ } while (remain < G15_MAX_FBMEM);
+
+ dwErr = lgLcdUpdateBitmap(ctx.device, (const lgLcdBitmapHeader *) &bitmap, bPriority ? LGLCD_SYNC_UPDATE(LGLCD_PRIORITY_ALERT) : LGLCD_SYNC_UPDATE(LGLCD_PRIORITY_NORMAL));
+ if (dwErr != ERROR_SUCCESS)
+ warn("Unable to update bitmap for device #%i successfully. (Error: %i)", i, dwErr);
+ }
+
+ /*
+ * Close device connections.
+ */
+ dwErr = lgLcdClose(ctx.device);
+ if (dwErr != ERROR_SUCCESS)
+ die(G15_ERR_CLOSE, "Unable to close LCD device. (Error: %i)", dwErr);
+
+ /*
+ * Disconnect from LCD monitor.
+ */
+ dwErr = lgLcdDisconnect(conn.connection);
+ if (dwErr != ERROR_SUCCESS)
+ die(G15_ERR_DISCONNECT, "Unable to disconnect from LCD manager. (Error: %i)", dwErr);
+
+ /*
+ * Deinitialize G15 library.
+ */
+ dwErr = lgLcdDeInit();
+ if (dwErr != ERROR_SUCCESS)
+ die(G15_ERR_DEINIT, "Unable to deinitialize LCD library. (Error: %i)", dwErr);
+
+ warn("Terminated successfully.");
+
+ return 0;
+}