From fbbcc07ff457b497a1e6c8d8327a5ce40bf31fb5 Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Sat, 28 Jan 2012 18:10:31 -0600 Subject: [PATCH] gbuildify apple_remote --- RepositoryExternal.mk | 7 + apple_remote/Library_AppleRemote.mk | 58 +++++ apple_remote/Makefile | 7 + apple_remote/Module_apple_remote.mk | 39 +++ apple_remote/Package_inc.mk | 33 +++ .../inc/{ => apple_remote}/RemoteControl.h | 0 .../{ => apple_remote}/RemoteMainController.h | 0 apple_remote/makefile.mk | 82 ------- apple_remote/prj/build.lst | 3 +- apple_remote/prj/d.lst | 4 - apple_remote/prj/makefile.mk | 1 + apple_remote/{inc => source}/AppleRemote.h | 0 apple_remote/{ => source}/AppleRemote.m | 0 .../{inc => source}/GlobalKeyboardDevice.h | 2 +- .../{ => source}/GlobalKeyboardDevice.m | 88 +++---- .../{inc => source}/HIDRemoteControlDevice.h | 2 +- .../{ => source}/HIDRemoteControlDevice.m | 225 +++++++++--------- .../{inc => source}/KeyspanFrontRowControl.h | 0 .../{ => source}/KeyspanFrontRowControl.m | 0 .../MultiClickRemoteBehavior.h | 2 +- .../{ => source}/MultiClickRemoteBehavior.m | 0 apple_remote/{ => source}/RemoteControl.m | 45 ++-- .../{inc => source}/RemoteControlContainer.h | 2 +- .../{ => source}/RemoteControlContainer.m | 104 ++++---- .../{ => source}/RemoteMainController.m | 29 +-- 25 files changed, 407 insertions(+), 326 deletions(-) create mode 100644 apple_remote/Library_AppleRemote.mk create mode 100644 apple_remote/Makefile create mode 100644 apple_remote/Module_apple_remote.mk create mode 100644 apple_remote/Package_inc.mk rename apple_remote/inc/{ => apple_remote}/RemoteControl.h (100%) rename apple_remote/inc/{ => apple_remote}/RemoteMainController.h (100%) delete mode 100644 apple_remote/makefile.mk create mode 100644 apple_remote/prj/makefile.mk rename apple_remote/{inc => source}/AppleRemote.h (100%) rename apple_remote/{ => source}/AppleRemote.m (100%) rename apple_remote/{inc => source}/GlobalKeyboardDevice.h (98%) rename apple_remote/{ => source}/GlobalKeyboardDevice.m (94%) rename apple_remote/{inc => source}/HIDRemoteControlDevice.h (98%) rename apple_remote/{ => source}/HIDRemoteControlDevice.m (90%) rename apple_remote/{inc => source}/KeyspanFrontRowControl.h (100%) rename apple_remote/{ => source}/KeyspanFrontRowControl.m (100%) rename apple_remote/{inc => source}/MultiClickRemoteBehavior.h (99%) rename apple_remote/{ => source}/MultiClickRemoteBehavior.m (100%) rename apple_remote/{ => source}/RemoteControl.m (85%) rename apple_remote/{inc => source}/RemoteControlContainer.h (97%) rename apple_remote/{ => source}/RemoteControlContainer.m (61%) rename apple_remote/{ => source}/RemoteMainController.m (95%) diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 91ff7a38c24f..b607ac8700b6 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -1023,6 +1023,13 @@ $(call gb_LinkTarget_add_libs,$(1), \ endef +define gb_LinkTarget__use_iokit +$(call gb_LinkTarget_add_libs,$(1), \ + -framework IOKit \ +) + +endef + define gb_LinkTarget__use_qtkit $(call gb_LinkTarget_add_libs,$(1), \ -framework QTKit \ diff --git a/apple_remote/Library_AppleRemote.mk b/apple_remote/Library_AppleRemote.mk new file mode 100644 index 000000000000..308725c32683 --- /dev/null +++ b/apple_remote/Library_AppleRemote.mk @@ -0,0 +1,58 @@ + +# -*- Mode: makefile; tab-width: 4; indent-tabs-mode: t -*- +# +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Initial Developer of the Original Code is +# Norbert Thiebaud +# Portions created by the Initial Developer are Copyright (C) 2012 the +# Initial Developer. All Rights Reserved. +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. +# + +$(eval $(call gb_Library_Library,AppleRemote)) + +$(eval $(call gb_Library_set_include,AppleRemote,\ + -I$(SRCDIR)/apple_remote/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_Library_use_externals,AppleRemote,\ + cocoa \ + carbon \ + iokit \ +)) + +$(eval $(call gb_Library_add_libs,AppleRemote,\ + -framework Cocoa \ + -framework Carbon \ + -framework IOKit \ +)) + +$(eval $(call gb_Library_add_objcobjects,AppleRemote,\ + apple_remote/source/KeyspanFrontRowControl \ + apple_remote/source/AppleRemote \ + apple_remote/source/RemoteControl \ + apple_remote/source/RemoteControlContainer \ + apple_remote/source/GlobalKeyboardDevice \ + apple_remote/source/HIDRemoteControlDevice \ + apple_remote/source/MultiClickRemoteBehavior \ + apple_remote/source/RemoteMainController \ +)) diff --git a/apple_remote/Makefile b/apple_remote/Makefile new file mode 100644 index 000000000000..ccb1c85a04da --- /dev/null +++ b/apple_remote/Makefile @@ -0,0 +1,7 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +include $(module_directory)/../solenv/gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/apple_remote/Module_apple_remote.mk b/apple_remote/Module_apple_remote.mk new file mode 100644 index 000000000000..4b0a691f6754 --- /dev/null +++ b/apple_remote/Module_apple_remote.mk @@ -0,0 +1,39 @@ +# -*- Mode: makefile; tab-width: 4; indent-tabs-mode: t -*- +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Initial Developer of the Original Code is +# Norbert Thiebaud +# Portions created by the Initial Developer are Copyright (C) 2012 the +# Initial Developer. All Rights Reserved. +# +# Major Contributor(s): +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. + +$(eval $(call gb_Module_Module,apple_remote)) + +ifeq ($(GUIBASE),aqua) +$(eval $(call gb_Module_add_targets,apple_remote,\ + Library_AppleRemote \ + Package_inc \ +)) +endif + + +# vim: set noet sw=4 ts=4: diff --git a/apple_remote/Package_inc.mk b/apple_remote/Package_inc.mk new file mode 100644 index 000000000000..f6e61efb8e2d --- /dev/null +++ b/apple_remote/Package_inc.mk @@ -0,0 +1,33 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Initial Developer of the Original Code is +# Norbert Thiebaud +# Portions created by the Initial Developer are Copyright (C) 2012 the +# Initial Developer. All Rights Reserved. +# +# Major Contributor(s): +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. + +$(eval $(call gb_Package_Package,apple_remote_inc,$(SRCDIR)/apple_remote/inc)) + +$(eval $(call gb_Package_add_file,apple_remote_inc,inc/apple_remote/RemoteControl.h,apple_remote/RemoteControl.h)) +$(eval $(call gb_Package_add_file,apple_remote_inc,inc/apple_remote/RemoteMainController.h,apple_remote/RemoteMainController.h)) + diff --git a/apple_remote/inc/RemoteControl.h b/apple_remote/inc/apple_remote/RemoteControl.h similarity index 100% rename from apple_remote/inc/RemoteControl.h rename to apple_remote/inc/apple_remote/RemoteControl.h diff --git a/apple_remote/inc/RemoteMainController.h b/apple_remote/inc/apple_remote/RemoteMainController.h similarity index 100% rename from apple_remote/inc/RemoteMainController.h rename to apple_remote/inc/apple_remote/RemoteMainController.h diff --git a/apple_remote/makefile.mk b/apple_remote/makefile.mk deleted file mode 100644 index 7a5f28d3efff..000000000000 --- a/apple_remote/makefile.mk +++ /dev/null @@ -1,82 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=. - -PRJNAME=external -TARGET=AppleRemote - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -.IF "$(GUIBASE)"!="aqua" - -dummy: -# nothing - -.ELSE # "$(GUIBASE)"!="aqua" - -SHL1STDLIBS+= \ - -framework Cocoa -framework Carbon -framework IOKit - -LIB1FILES+= \ - $(SLB)$/AppleRemote.lib - -SLOFILES= \ - $(SLO)$/KeyspanFrontRowControl.obj \ - $(SLO)$/AppleRemote.obj \ - $(SLO)$/RemoteControl.obj \ - $(SLO)$/RemoteControlContainer.obj \ - $(SLO)$/GlobalKeyboardDevice.obj \ - $(SLO)$/HIDRemoteControlDevice.obj \ - $(SLO)$/MultiClickRemoteBehavior.obj \ - $(SLO)$/RemoteMainController.obj - -SHL1TARGET= $(TARGET)$(DLLPOSTFIX) -SHL1OBJS= $(SLOFILES) - -OUT2INC = \ - $(BUILDDIR)$/KeyspaFrontRowControl.h \ - $(BUILDDIR)$/AppleRemote.h \ - $(BUILDDIR)$/RemoteControl.h \ - $(BUILDDIR)$/RemoteControlContainer.h \ - $(BUILDDIR)$/GlobalKeyboardDevice.h \ - $(BUILDDIR)$/HIDRemoteControlDevice.h \ - $(BUILDDIR)$/MultiClickRemoteBehavior.h \ - $(BUILDDIR)$/RemoteMainController.h - - -.ENDIF # "$(GUIBASE)"!="aqua" - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/apple_remote/prj/build.lst b/apple_remote/prj/build.lst index ff4ee577408a..29a33558d7df 100644 --- a/apple_remote/prj/build.lst +++ b/apple_remote/prj/build.lst @@ -1,2 +1,3 @@ apr apple_remote : solenv soltools NULL -apr apple_remote nmake - u apr_aprem NULL +apr apple_remote\prj nmake - u apr_aprem NULL + diff --git a/apple_remote/prj/d.lst b/apple_remote/prj/d.lst index 8d05687ba9f1..8b137891791f 100644 --- a/apple_remote/prj/d.lst +++ b/apple_remote/prj/d.lst @@ -1,5 +1 @@ -mkdir: %_DEST%\inc\apple_remote -..\inc\*.h %_DEST%\inc\apple_remote\* - -..\%__SRC%\lib\*.dylib %_DEST%\lib\*.dylib diff --git a/apple_remote/prj/makefile.mk b/apple_remote/prj/makefile.mk new file mode 100644 index 000000000000..0997622e00f6 --- /dev/null +++ b/apple_remote/prj/makefile.mk @@ -0,0 +1 @@ +.INCLUDE : gbuildbridge.mk diff --git a/apple_remote/inc/AppleRemote.h b/apple_remote/source/AppleRemote.h similarity index 100% rename from apple_remote/inc/AppleRemote.h rename to apple_remote/source/AppleRemote.h diff --git a/apple_remote/AppleRemote.m b/apple_remote/source/AppleRemote.m similarity index 100% rename from apple_remote/AppleRemote.m rename to apple_remote/source/AppleRemote.m diff --git a/apple_remote/inc/GlobalKeyboardDevice.h b/apple_remote/source/GlobalKeyboardDevice.h similarity index 98% rename from apple_remote/inc/GlobalKeyboardDevice.h rename to apple_remote/source/GlobalKeyboardDevice.h index ad9c4f3f57a5..6a8a052e7ae5 100644 --- a/apple_remote/inc/GlobalKeyboardDevice.h +++ b/apple_remote/source/GlobalKeyboardDevice.h @@ -28,7 +28,7 @@ * *****************************************************************************/ -#import "RemoteControl.h" +#import #import diff --git a/apple_remote/GlobalKeyboardDevice.m b/apple_remote/source/GlobalKeyboardDevice.m similarity index 94% rename from apple_remote/GlobalKeyboardDevice.m rename to apple_remote/source/GlobalKeyboardDevice.m index 14bf558a0511..2fd6156c23f6 100644 --- a/apple_remote/GlobalKeyboardDevice.m +++ b/apple_remote/source/GlobalKeyboardDevice.m @@ -2,13 +2,13 @@ * GlobalKeyboardDevice.m * RemoteControlWrapper * - * Created by Martin Kahr on 11.03.06 under a MIT-style license. + * Created by Martin Kahr on 11.03.06 under a MIT-style license. * Copyright (c) 2006 martinkahr.com. All rights reserved. * - * Code modified and adapted to OpenOffice.org + * Code modified and adapted to OpenOffice.org * by Eric Bachard on 11.08.2008 under the same license * - * Permission is hereby granted, free of charge, to any person obtaining a + * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, @@ -20,7 +20,7 @@ * * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN @@ -41,7 +41,7 @@ /* the following default keys are read and shall be used to change the keyboard mapping - + mac.remotecontrols.GlobalKeyboardDevice.plus_modifiers mac.remotecontrols.GlobalKeyboardDevice.plus_keycode mac.remotecontrols.GlobalKeyboardDevice.minus_modifiers @@ -62,19 +62,19 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*); @implementation GlobalKeyboardDevice -- (id) initWithDelegate: (id) _remoteControlDelegate { +- (id) initWithDelegate: (id) _remoteControlDelegate { if ( (self = [super initWithDelegate: _remoteControlDelegate]) ) { hotKeyRemoteEventMapping = [[NSMutableDictionary alloc] init]; - + unsigned int modifiers = cmdKey + shiftKey /*+ optionKey*/ + controlKey; - + [self mapRemoteButton:kRemoteButtonPlus defaultKeycode:F1 defaultModifiers:modifiers]; [self mapRemoteButton:kRemoteButtonMinus defaultKeycode:F2 defaultModifiers:modifiers]; [self mapRemoteButton:kRemoteButtonPlay defaultKeycode:F3 defaultModifiers:modifiers]; [self mapRemoteButton:kRemoteButtonLeft defaultKeycode:F4 defaultModifiers:modifiers]; [self mapRemoteButton:kRemoteButtonRight defaultKeycode:F5 defaultModifiers:modifiers]; [self mapRemoteButton:kRemoteButtonMenu defaultKeycode:F6 defaultModifiers:modifiers]; - [self mapRemoteButton:kRemoteButtonPlay_Hold defaultKeycode:F7 defaultModifiers:modifiers]; + [self mapRemoteButton:kRemoteButtonPlay_Hold defaultKeycode:F7 defaultModifiers:modifiers]; } return self; } @@ -85,48 +85,48 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*); } - (void) mapRemoteButton: (RemoteControlEventIdentifier) remoteButtonIdentifier defaultKeycode: (unsigned int) defaultKeycode defaultModifiers: (unsigned int) defaultModifiers { - NSString* defaultsKey = NULL; - + NSString* defaultsKey = NULL; + switch(remoteButtonIdentifier) { case kRemoteButtonPlus: defaultsKey = @"plus"; break; case kRemoteButtonMinus: defaultsKey = @"minus"; - break; + break; case kRemoteButtonMenu: defaultsKey = @"menu"; - break; + break; case kRemoteButtonPlay: defaultsKey = @"play"; break; case kRemoteButtonRight: defaultsKey = @"right"; - break; - case kRemoteButtonLeft: + break; + case kRemoteButtonLeft: defaultsKey = @"left"; break; case kRemoteButtonPlay_Hold: defaultsKey = @"playhold"; - break; - default: + break; + default: #ifdef DEBUG NSLog(@"Unknown global keyboard defaults key for remote button identifier %d", remoteButtonIdentifier); #endif break; } - + NSNumber* modifiersCfg = [[NSUserDefaults standardUserDefaults] objectForKey: [NSString stringWithFormat: @"mac.remotecontrols.GlobalKeyboardDevice.%@_modifiers", defaultsKey]]; NSNumber* keycodeCfg = [[NSUserDefaults standardUserDefaults] objectForKey: [NSString stringWithFormat: @"mac.remotecontrols.GlobalKeyboardDevice.%@_keycode", defaultsKey]]; - + unsigned int modifiers = defaultModifiers; if (modifiersCfg) modifiers = [modifiersCfg unsignedIntValue]; - + unsigned int keycode = defaultKeycode; if (keycodeCfg) keycode = [keycodeCfg unsignedIntValue]; - + [self registerHotKeyCode: keycode modifiers: modifiers remoteEventIdentifier: remoteButtonIdentifier]; -} +} - (void) setListeningToRemote: (BOOL) value { if (value == [self isListeningToRemote]) return; @@ -136,26 +136,29 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*); [self stopListening: self]; } } -- (BOOL) isListeningToRemote { +- (BOOL) isListeningToRemote { return (eventHandlerRef!=NULL); } - (void) startListening: (id) sender { - + if (eventHandlerRef) return; - + EventTypeSpec eventSpec[2] = { { kEventClassKeyboard, kEventHotKeyPressed }, { kEventClassKeyboard, kEventHotKeyReleased } - }; - + }; + InstallEventHandler( GetEventDispatcherTarget(), - (EventHandlerProcPtr)hotKeyEventHandler, - 2, eventSpec, self, &eventHandlerRef); + (EventHandlerProcPtr)hotKeyEventHandler, + 2, eventSpec, self, &eventHandlerRef); + (void)sender; } + - (void) stopListening: (id) sender { RemoveEventHandler(eventHandlerRef); eventHandlerRef = NULL; + (void)sender; } - (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier { @@ -171,21 +174,21 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*); return "Keyboard"; } -- (BOOL)registerHotKeyCode: (unsigned int) keycode modifiers: (unsigned int) modifiers remoteEventIdentifier: (RemoteControlEventIdentifier) identifier { +- (BOOL)registerHotKeyCode: (unsigned int) keycode modifiers: (unsigned int) modifiers remoteEventIdentifier: (RemoteControlEventIdentifier) identifier { OSStatus err; EventHotKeyID hotKeyID; EventHotKeyRef carbonHotKey; hotKeyID.signature = 'PTHk'; hotKeyID.id = (long)keycode; - + err = RegisterEventHotKey(keycode, modifiers, hotKeyID, GetEventDispatcherTarget(), 0, &carbonHotKey ); - + if( err ) return NO; - + [hotKeyRemoteEventMapping setObject: [NSNumber numberWithInt:identifier] forKey: [NSNumber numberWithUnsignedInt: hotKeyID.id]]; - + return YES; } /* @@ -194,21 +197,21 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*); OSStatus err; EventHotKeyRef carbonHotKey; NSValue* key; - + if( [[self allHotKeys] containsObject: hotKey] == NO ) return; - + carbonHotKey = [self _carbonHotKeyForHotKey: hotKey]; NSAssert( carbonHotKey != nil, @"" ); - + err = UnregisterEventHotKey( carbonHotKey ); //Watch as we ignore 'err': - + key = [NSValue valueWithPointer: carbonHotKey]; [mHotKeys removeObjectForKey: key]; - + [self _updateEventHandler]; - + //See that? Completely ignored } */ @@ -227,13 +230,14 @@ static RemoteControlEventIdentifier lastEvent; static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void* userData ) { + (void)inHandlerRef; GlobalKeyboardDevice* keyboardDevice = (GlobalKeyboardDevice*) userData; EventHotKeyID hkCom; GetEventParameter(inEvent,kEventParamDirectObject,typeEventHotKeyID,NULL,sizeof(hkCom),NULL,&hkCom); RemoteControlEventIdentifier identifier = [keyboardDevice remoteControlEventIdentifierForID:hkCom.id]; if (identifier == 0) return noErr; - + BOOL pressedDown = YES; if (identifier != lastEvent) { lastEvent = identifier; @@ -242,7 +246,7 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef in pressedDown = NO; } [keyboardDevice sendRemoteButtonEvent: identifier pressedDown: pressedDown]; - + return noErr; } diff --git a/apple_remote/inc/HIDRemoteControlDevice.h b/apple_remote/source/HIDRemoteControlDevice.h similarity index 98% rename from apple_remote/inc/HIDRemoteControlDevice.h rename to apple_remote/source/HIDRemoteControlDevice.h index 44e4d17fc65d..d193472de5f5 100644 --- a/apple_remote/inc/HIDRemoteControlDevice.h +++ b/apple_remote/source/HIDRemoteControlDevice.h @@ -28,7 +28,7 @@ * *****************************************************************************/ -#import "RemoteControl.h" +#import #import diff --git a/apple_remote/HIDRemoteControlDevice.m b/apple_remote/source/HIDRemoteControlDevice.m similarity index 90% rename from apple_remote/HIDRemoteControlDevice.m rename to apple_remote/source/HIDRemoteControlDevice.m index 2cd7506e60d3..a42a91419754 100644 --- a/apple_remote/HIDRemoteControlDevice.m +++ b/apple_remote/source/HIDRemoteControlDevice.m @@ -2,13 +2,13 @@ * HIDRemoteControlDevice.m * RemoteControlWrapper * - * Created by Martin Kahr on 11.03.06 under a MIT-style license. + * Created by Martin Kahr on 11.03.06 under a MIT-style license. * Copyright (c) 2006 martinkahr.com. All rights reserved. * - * Code modified and adapted to OpenOffice.org + * Code modified and adapted to OpenOffice.org * by Eric Bachard on 11.08.2008 under the same license * - * Permission is hereby granted, free of charge, to any person obtaining a + * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, @@ -20,7 +20,7 @@ * * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN @@ -37,17 +37,17 @@ #import #import -@interface HIDRemoteControlDevice (PrivateMethods) +@interface HIDRemoteControlDevice (PrivateMethods) - (NSDictionary*) cookieToButtonMapping; // Creates the dictionary using the magics, depending on the remote - (IOHIDQueueInterface**) queue; - (IOHIDDeviceInterface**) hidDeviceInterface; -- (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues: (SInt32) sumOfValues; +- (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues: (SInt32) sumOfValues; - (void) removeNotifcationObserver; - (void) remoteControlAvailable:(NSNotification *)notification; @end -@interface HIDRemoteControlDevice (IOKitMethods) +@interface HIDRemoteControlDevice (IOKitMethods) + (io_object_t) findRemoteDevice; - (IOHIDDeviceInterface**) createInterfaceForDevice: (io_object_t) hidDevice; - (BOOL) initializeCookies; @@ -60,25 +60,25 @@ return ""; } -+ (BOOL) isRemoteAvailable { ++ (BOOL) isRemoteAvailable { io_object_t hidDevice = [self findRemoteDevice]; if (hidDevice != 0) { IOObjectRelease(hidDevice); return YES; } else { - return NO; + return NO; } } -- (id) initWithDelegate: (id) _remoteControlDelegate { +- (id) initWithDelegate: (id) _remoteControlDelegate { if ([[self class] isRemoteAvailable] == NO) return nil; - + if ( (self = [super initWithDelegate: _remoteControlDelegate]) ) { openInExclusiveMode = YES; queue = NULL; hidDeviceInterface = NULL; cookieToButtonMapping = [[NSMutableDictionary alloc] init]; - + [self setCookieMappingInDictionary: cookieToButtonMapping]; NSEnumerator* enumerator = [cookieToButtonMapping objectEnumerator]; @@ -87,10 +87,10 @@ while( (identifier = [enumerator nextObject]) ) { supportedButtonEvents |= [identifier intValue]; } - + fixSecureEventInputBug = [[NSUserDefaults standardUserDefaults] boolForKey: @"remoteControlWrapperFixSecureEventInputBug"]; } - + return self; } @@ -105,8 +105,10 @@ [delegate sendRemoteButtonEvent: event pressedDown: pressedDown remoteControl:self]; } -- (void) setCookieMappingInDictionary: (NSMutableDictionary*) cookieToButtonMapping { +- (void) setCookieMappingInDictionary: (NSMutableDictionary*) cookieToButtonMap { + (void)cookieToButtonMap; } + - (int) remoteIdSwitchCookie { return 0; } @@ -114,9 +116,9 @@ - (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier { return (supportedButtonEvents & identifier) == identifier; } - + - (BOOL) isListeningToRemote { - return (hidDeviceInterface != NULL && allCookies != NULL && queue != NULL); + return (hidDeviceInterface != NULL && allCookies != NULL && queue != NULL); } - (void) setListeningToRemote: (BOOL) value { @@ -141,38 +143,39 @@ processesBacklog = value; } -- (void) startListening: (id) sender { +- (void) startListening: (id) sender { + (void)sender; if ([self isListeningToRemote]) return; - + // 4th July 2007 - // + // // A security update in february of 2007 introduced an odd behavior. // Whenever SecureEventInput is activated or deactivated the exclusive access // to the remote control device is lost. This leads to very strange behavior where // a press on the Menu button activates FrontRow while your app still gets the event. - // A great number of people have complained about this. - // + // A great number of people have complained about this. + // // Enabling the SecureEventInput and keeping it enabled does the trick. // // I'm pretty sure this is a kind of bug at Apple and I'm in contact with the responsible - // Apple Engineer. This solution is not a perfect one - I know. + // Apple Engineer. This solution is not a perfect one - I know. // One of the side effects is that applications that listen for special global keyboard shortcuts (like Quicksilver) // may get into problems as they no longer get the events. // As there is no official Apple Remote API from Apple I also failed to open a technical incident on this. - // + // // Note that there is a corresponding DisableSecureEventInput in the stopListening method below. - // - if ([self isOpenInExclusiveMode] && fixSecureEventInputBug) EnableSecureEventInput(); - + // + if ([self isOpenInExclusiveMode] && fixSecureEventInputBug) EnableSecureEventInput(); + [self removeNotifcationObserver]; - + io_object_t hidDevice = [[self class] findRemoteDevice]; if (hidDevice == 0) return; - + if ([self createInterfaceForDevice:hidDevice] == NULL) { goto error; } - + if ([self initializeCookies]==NO) { goto error; } @@ -184,67 +187,68 @@ [self willChangeValueForKey:@"listeningToRemote"]; [self didChangeValueForKey:@"listeningToRemote"]; goto cleanup; - + error: [self stopListening:self]; DisableSecureEventInput(); - -cleanup: - IOObjectRelease(hidDevice); + +cleanup: + IOObjectRelease(hidDevice); } - (void) stopListening: (id) sender { + (void)sender; if ([self isListeningToRemote]==NO) return; - + BOOL sendNotification = NO; - + if (eventSource != NULL) { CFRunLoopRemoveSource(CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode); CFRelease(eventSource); eventSource = NULL; } if (queue != NULL) { - (*queue)->stop(queue); - + (*queue)->stop(queue); + //dispose of queue - (*queue)->dispose(queue); - + (*queue)->dispose(queue); + //release the queue we allocated - (*queue)->Release(queue); - + (*queue)->Release(queue); + queue = NULL; - + sendNotification = YES; } - + if (allCookies != nil) { [allCookies autorelease]; allCookies = nil; } - + if (hidDeviceInterface != NULL) { //close the device (*hidDeviceInterface)->close(hidDeviceInterface); - - //release the interface + + //release the interface (*hidDeviceInterface)->Release(hidDeviceInterface); - + hidDeviceInterface = NULL; } - + if ([self isOpenInExclusiveMode] && fixSecureEventInputBug) DisableSecureEventInput(); - + if ([self isOpenInExclusiveMode] && sendNotification) { - [[self class] sendFinishedNotifcationForAppIdentifier: nil]; + [[self class] sendFinishedNotifcationForAppIdentifier: nil]; } // be KVO friendly [self willChangeValueForKey:@"listeningToRemote"]; - [self didChangeValueForKey:@"listeningToRemote"]; + [self didChangeValueForKey:@"listeningToRemote"]; } @end -@implementation HIDRemoteControlDevice (PrivateMethods) +@implementation HIDRemoteControlDevice (PrivateMethods) - (IOHIDQueueInterface**) queue { return queue; @@ -265,7 +269,7 @@ cleanup: NSString* key; while( (key = [keyEnum nextObject]) ) { NSRange range = [cookieString rangeOfString:key]; - if (range.location == 0) return key; + if (range.location == 0) return key; } return nil; } @@ -275,10 +279,10 @@ cleanup: if (previousRemainingCookieString) { cookieString = [previousRemainingCookieString stringByAppendingString: cookieString]; NSLog(@"New cookie string is %@", cookieString); - [previousRemainingCookieString release], previousRemainingCookieString=nil; + [previousRemainingCookieString release], previousRemainingCookieString=nil; }*/ if (cookieString == nil || [cookieString length] == 0) return; - + NSNumber* buttonId = [[self cookieToButtonMapping] objectForKey: cookieString]; if (buttonId != nil) { switch ( (int)buttonId ) @@ -304,14 +308,14 @@ cleanup: } if (processesBacklog == NO && lastSubCookieString != nil) { // process the last event of the backlog and assume that the button is not pressed down any longer. - // The events in the backlog do not seem to be in order and therefore (in rare cases) the last event might be - // a button pressed down event while in reality the user has released it. + // The events in the backlog do not seem to be in order and therefore (in rare cases) the last event might be + // a button pressed down event while in reality the user has released it. // NSLog(@"processing last event of backlog"); [self handleEventWithCookieString: lastSubCookieString sumOfValues:0]; } if ([cookieString length] > 0) { NSLog(@"Unknown button for cookiestring %@", cookieString); - } + } } } @@ -320,6 +324,7 @@ cleanup: } - (void) remoteControlAvailable:(NSNotification *)notification { + (void)notification; [self removeNotifcationObserver]; [self startListening: self]; } @@ -329,33 +334,35 @@ cleanup: /* Callback method for the device queue Will be called for any event of any type (cookie) to which we subscribe */ -static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, void* sender) { - if (target < 0) { +static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, void* sender) { + (void)refcon; + (void)sender; + if ((intptr_t)target < 0) { NSLog(@"QueueCallbackFunction called with invalid target!"); return; } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - HIDRemoteControlDevice* remote = (HIDRemoteControlDevice*)target; - IOHIDEventStruct event; + + HIDRemoteControlDevice* remote = (HIDRemoteControlDevice*)target; + IOHIDEventStruct event; AbsoluteTime zeroTime = {0,0}; NSMutableString* cookieString = [NSMutableString string]; SInt32 sumOfValues = 0; while (result == kIOReturnSuccess) { - result = (*[remote queue])->getNextEvent([remote queue], &event, zeroTime, 0); + result = (*[remote queue])->getNextEvent([remote queue], &event, zeroTime, 0); if ( result != kIOReturnSuccess ) continue; - - //printf("%d %d %d\n", event.elementCookie, event.value, event.longValue); - + + //printf("%d %d %d\n", event.elementCookie, event.value, event.longValue); + if (((int)event.elementCookie)!=5) { sumOfValues+=event.value; [cookieString appendString:[NSString stringWithFormat:@"%d_", event.elementCookie]]; } } [remote handleEventWithCookieString: cookieString sumOfValues: sumOfValues]; - + [pool release]; } @@ -367,16 +374,16 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, HRESULT plugInResult = S_OK; SInt32 score = 0; IOReturn ioReturnValue = kIOReturnSuccess; - + hidDeviceInterface = NULL; - + ioReturnValue = IOObjectGetClass(hidDevice, className); - + if (ioReturnValue != kIOReturnSuccess) { NSLog(@"Error: Failed to get class name."); return NULL; } - + ioReturnValue = IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, @@ -386,7 +393,7 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, { //Call a method of the intermediate plug-in to create the device interface plugInResult = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID) &hidDeviceInterface); - + if (plugInResult != S_OK) { NSLog(@"Error: Couldn't create HID class device interface"); } @@ -405,41 +412,41 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, NSArray* elements = nil; NSDictionary* element; IOReturn success; - + if (!handle || !(*handle)) return NO; - + // Copy all elements, since we're grabbing most of the elements // for this device anyway, and thus, it's faster to iterate them // ourselves. When grabbing only one or two elements, a matching // dictionary should be passed in here instead of NULL. success = (*handle)->copyMatchingElements(handle, NULL, (CFArrayRef*)&elements); - + if (success == kIOReturnSuccess) { - - [elements autorelease]; + + [elements autorelease]; /* - cookies = calloc(NUMBER_OF_APPLE_REMOTE_ACTIONS, sizeof(IOHIDElementCookie)); + cookies = calloc(NUMBER_OF_APPLE_REMOTE_ACTIONS, sizeof(IOHIDElementCookie)); memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS); */ allCookies = [[NSMutableArray alloc] init]; - + NSEnumerator *elementsEnumerator = [elements objectEnumerator]; - - while ( (element = [elementsEnumerator nextObject]) ) { + + while ( (element = [elementsEnumerator nextObject]) ) { //Get cookie object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementCookieKey) ]; if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) continue; cookie = (IOHIDElementCookie) [object longValue]; - + //Get usage object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementUsageKey) ]; - if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; + if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; usage = [object longValue]; - + //Get usage page object = [element valueForKey: (NSString*)CFSTR(kIOHIDElementUsagePageKey) ]; - if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; + if (object == nil || ![object isKindOfClass:[NSNumber class]]) continue; usagePage = [object longValue]; [allCookies addObject: [NSNumber numberWithInt:(int)cookie]]; @@ -447,38 +454,38 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, } else { return NO; } - + return YES; } - (BOOL) openDevice { HRESULT result; - + IOHIDOptionsType openMode = kIOHIDOptionsTypeNone; - if ([self isOpenInExclusiveMode]) openMode = kIOHIDOptionsTypeSeizeDevice; - IOReturn ioReturnValue = (*hidDeviceInterface)->open(hidDeviceInterface, openMode); - - if (ioReturnValue == KERN_SUCCESS) { + if ([self isOpenInExclusiveMode]) openMode = kIOHIDOptionsTypeSeizeDevice; + IOReturn ioReturnValue = (*hidDeviceInterface)->open(hidDeviceInterface, openMode); + + if (ioReturnValue == KERN_SUCCESS) { queue = (*hidDeviceInterface)->allocQueue(hidDeviceInterface); if (queue) { result = (*queue)->create(queue, 0, 12); //depth: maximum number of elements in queue before oldest elements in queue begin to be lost. IOHIDElementCookie cookie; NSEnumerator *allCookiesEnumerator = [allCookies objectEnumerator]; - + while ( (cookie = (IOHIDElementCookie)[[allCookiesEnumerator nextObject] intValue]) ) { (*queue)->addElement(queue, cookie, 0); } - - // add callback for async events - ioReturnValue = (*queue)->createAsyncEventSource(queue, &eventSource); + + // add callback for async events + ioReturnValue = (*queue)->createAsyncEventSource(queue, &eventSource); if (ioReturnValue == KERN_SUCCESS) { ioReturnValue = (*queue)->setEventCallout(queue,QueueCallbackFunction, self, NULL); if (ioReturnValue == KERN_SUCCESS) { CFRunLoopAddSource(CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode); - + //start data delivery to queue - (*queue)->start(queue); + (*queue)->start(queue); return YES; } else { NSLog(@"Error when setting event callback"); @@ -491,36 +498,36 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, } } else if (ioReturnValue == kIOReturnExclusiveAccess) { // the device is used exclusive by another application - + // 1. we register for the FINISHED_USING_REMOTE_CONTROL_NOTIFICATION notification [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(remoteControlAvailable:) name:FINISHED_USING_REMOTE_CONTROL_NOTIFICATION object:nil]; - - // 2. send a distributed notification that we wanted to use the remote control + + // 2. send a distributed notification that we wanted to use the remote control [[self class] sendRequestForRemoteControlNotification]; } - return NO; + return NO; } + (io_object_t) findRemoteDevice { CFMutableDictionaryRef hidMatchDictionary = NULL; - IOReturn ioReturnValue = kIOReturnSuccess; + IOReturn ioReturnValue = kIOReturnSuccess; io_iterator_t hidObjectIterator = 0; io_object_t hidDevice = 0; - + // Set up a matching dictionary to search the I/O Registry by class // name for all HID class devices hidMatchDictionary = IOServiceMatching([self remoteControlDeviceName]); - + // Now search I/O Registry for matching devices. ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, hidMatchDictionary, &hidObjectIterator); - + if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0)) { hidDevice = IOIteratorNext(hidObjectIterator); } - + // release the iterator IOObjectRelease(hidObjectIterator); - + return hidDevice; } diff --git a/apple_remote/inc/KeyspanFrontRowControl.h b/apple_remote/source/KeyspanFrontRowControl.h similarity index 100% rename from apple_remote/inc/KeyspanFrontRowControl.h rename to apple_remote/source/KeyspanFrontRowControl.h diff --git a/apple_remote/KeyspanFrontRowControl.m b/apple_remote/source/KeyspanFrontRowControl.m similarity index 100% rename from apple_remote/KeyspanFrontRowControl.m rename to apple_remote/source/KeyspanFrontRowControl.m diff --git a/apple_remote/inc/MultiClickRemoteBehavior.h b/apple_remote/source/MultiClickRemoteBehavior.h similarity index 99% rename from apple_remote/inc/MultiClickRemoteBehavior.h rename to apple_remote/source/MultiClickRemoteBehavior.h index a704febaa4fb..9cf2e7f03e5c 100644 --- a/apple_remote/inc/MultiClickRemoteBehavior.h +++ b/apple_remote/source/MultiClickRemoteBehavior.h @@ -29,7 +29,7 @@ *****************************************************************************/ -#import "RemoteControl.h" +#import /** A behavior that adds multiclick and hold events on top of a device. diff --git a/apple_remote/MultiClickRemoteBehavior.m b/apple_remote/source/MultiClickRemoteBehavior.m similarity index 100% rename from apple_remote/MultiClickRemoteBehavior.m rename to apple_remote/source/MultiClickRemoteBehavior.m diff --git a/apple_remote/RemoteControl.m b/apple_remote/source/RemoteControl.m similarity index 85% rename from apple_remote/RemoteControl.m rename to apple_remote/source/RemoteControl.m index d0812d384b3e..f82a7e76e76b 100644 --- a/apple_remote/RemoteControl.m +++ b/apple_remote/source/RemoteControl.m @@ -2,13 +2,13 @@ * RemoteControl.m * RemoteControlWrapper * - * Created by Martin Kahr on 11.03.06 under a MIT-style license. + * Created by Martin Kahr on 11.03.06 under a MIT-style license. * Copyright (c) 2006 martinkahr.com. All rights reserved. * - * Code modified and adapted to OpenOffice.org + * Code modified and adapted to OpenOffice.org * by Eric Bachard on 11.08.2008 under the same License * - * Permission is hereby granted, free of charge, to any person obtaining a + * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, @@ -20,17 +20,17 @@ * * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * *****************************************************************************/ - -#import "RemoteControl.h" -// notifaction names that are being used to signal that an application wants to +#import + +// notifaction names that are being used to signal that an application wants to // have access to the remote control device or if the application has finished // using the remote control device NSString* REQUEST_FOR_REMOTE_CONTROL_NOTIFCATION = @"mac.remotecontrols.RequestForRemoteControl"; @@ -47,14 +47,14 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier"; @implementation RemoteControl // returns nil if the remote control device is not available -- (id) initWithDelegate: (id) _remoteControlDelegate { +- (id) initWithDelegate: (id) _remoteControlDelegate { if ( (self = [super init]) ) { - delegate = [_remoteControlDelegate retain]; + delegate = [_remoteControlDelegate retain]; #ifdef DEBUG NSLog(@"RemoteControl initWithDelegate ok"); #endif } - return self; + return self; } - (void) dealloc { @@ -66,33 +66,38 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier"; #ifdef DEBUG NSLog(@"setListeningToRemote ok"); #endif + (void)value; } - (BOOL) isListeningToRemote { - return NO; + return NO; } - (void) startListening: (id) sender { #ifdef DEBUG NSLog(@"startListening ok"); #endif + (void)sender; } - (void) stopListening: (id) sender { #ifdef DEBUG NSLog(@"stopListening ok"); #endif + (void)sender; } - (BOOL) isOpenInExclusiveMode { - return YES; + return YES; } - (void) setOpenInExclusiveMode: (BOOL) value { + (void)value; } - (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier { #ifdef DEBUG - NSLog(@"sending event for button identifier \n"); + NSLog(@"sending event for button identifier \n"); #endif - return YES; + (void)identifier; + return YES; } + (void) sendDistributedNotification: (NSString*) notificationName targetBundleIdentifier: (NSString*) targetIdentifier @@ -106,7 +111,7 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier"; kTargetApplicationIdentifier /*targetBundleIdentifier -> does not appear, since the peer is nil*/, nil]; #ifdef DEBUG - // Debug purpose: returns all the existing dictionary keys. + // Debug purpose: returns all the existing dictionary keys. NSString *s; NSEnumerator *e = [userInfo keyEnumerator]; while ( (s = [e nextObject]) ) { @@ -119,10 +124,10 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier"; NSLog(@"sendDistributedNotification ..."); #endif - [[NSDistributedNotificationCenter defaultCenter] postNotificationName:notificationName - object:nil - userInfo:userInfo - deliverImmediately:YES]; + [[NSDistributedNotificationCenter defaultCenter] postNotificationName:notificationName + object:nil + userInfo:userInfo + deliverImmediately:YES]; } } @@ -140,7 +145,7 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier"; } + (const char*) remoteControlDeviceName { - return NULL; + return NULL; } @end diff --git a/apple_remote/inc/RemoteControlContainer.h b/apple_remote/source/RemoteControlContainer.h similarity index 97% rename from apple_remote/inc/RemoteControlContainer.h rename to apple_remote/source/RemoteControlContainer.h index e82fa6b88deb..db70ee64a916 100644 --- a/apple_remote/inc/RemoteControlContainer.h +++ b/apple_remote/source/RemoteControlContainer.h @@ -28,7 +28,7 @@ * *****************************************************************************/ -#import "RemoteControl.h" +#import @interface RemoteControlContainer : RemoteControl { NSMutableArray* remoteControls; diff --git a/apple_remote/RemoteControlContainer.m b/apple_remote/source/RemoteControlContainer.m similarity index 61% rename from apple_remote/RemoteControlContainer.m rename to apple_remote/source/RemoteControlContainer.m index 40a222f2d829..04a4c6c1cfe1 100644 --- a/apple_remote/RemoteControlContainer.m +++ b/apple_remote/source/RemoteControlContainer.m @@ -2,13 +2,13 @@ * RemoteControlContainer.m * RemoteControlWrapper * - * Created by Martin Kahr on 11.03.06 under a MIT-style license. + * Created by Martin Kahr on 11.03.06 under a MIT-style license. * Copyright (c) 2006 martinkahr.com. All rights reserved. * - * Code modified and adapted to OpenOffice.org + * Code modified and adapted to OpenOffice.org * by Eric Bachard on 11.08.2008 under the same License * - * Permission is hereby granted, free of charge, to any person obtaining a + * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, @@ -20,7 +20,7 @@ * * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN @@ -33,23 +33,23 @@ @implementation RemoteControlContainer - (id) initWithDelegate: (id) _remoteControlDelegate { - if ( (self = [super initWithDelegate:_remoteControlDelegate]) ) { - remoteControls = [[NSMutableArray alloc] init]; + if ( (self = [super initWithDelegate:_remoteControlDelegate]) ) { + remoteControls = [[NSMutableArray alloc] init]; #ifdef DEBUG NSLog(@"RemoteControlContainer initWithDelegate ok"); - } + } else { NSLog(@"RemoteControlContainer initWithDelegate failed"); #endif } - return self; + return self; } - (void) dealloc { - [self stopListening: self]; - [remoteControls release]; - [super dealloc]; + [self stopListening: self]; + [remoteControls release]; + [super dealloc]; } - (BOOL) instantiateAndAddRemoteControlDeviceWithClass: (Class) clazz { @@ -58,83 +58,87 @@ if (remoteControl) { [remoteControls addObject: remoteControl]; [remoteControl addObserver: self forKeyPath:@"listeningToRemote" options:NSKeyValueObservingOptionNew context:nil]; - toReturn = YES; + toReturn = YES; } #ifdef DEBUG else { NSLog(@"RemoteControlContainer instantiateAndAddRemoteControlDeviceWithClass failed"); - toReturn = NO; + toReturn = NO; } #endif return toReturn; } - (unsigned int) count { - return [remoteControls count]; + return [remoteControls count]; } - (void) reset { - [self willChangeValueForKey:@"listeningToRemote"]; - [self didChangeValueForKey:@"listeningToRemote"]; + [self willChangeValueForKey:@"listeningToRemote"]; + [self didChangeValueForKey:@"listeningToRemote"]; #ifdef DEBUG - // debug purpose + // debug purpose NSLog(@"reset... (after listening to remote)"); #endif } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - [self reset]; + [self reset]; + (void)keyPath; + (void)object; + (void)change; + (void)context; } - (void) setListeningToRemote: (BOOL) value { - int i; - for(i=0; i < [remoteControls count]; i++) { - [[remoteControls objectAtIndex: i] setListeningToRemote: value]; - } - if (value && value != [self isListeningToRemote]) [self performSelector:@selector(reset) withObject:nil afterDelay:0.01]; + unsigned int i; + for(i=0; i < [remoteControls count]; i++) { + [[remoteControls objectAtIndex: i] setListeningToRemote: value]; + } + if (value && value != [self isListeningToRemote]) [self performSelector:@selector(reset) withObject:nil afterDelay:0.01]; } - (BOOL) isListeningToRemote { - int i; - for(i=0; i < [remoteControls count]; i++) { - if ([[remoteControls objectAtIndex: i] isListeningToRemote]) { - return YES; - } - } - return NO; + unsigned int i; + for(i=0; i < [remoteControls count]; i++) { + if ([[remoteControls objectAtIndex: i] isListeningToRemote]) { + return YES; + } + } + return NO; } - (void) startListening: (id) sender { #ifdef DEBUG - NSLog(@"startListening to events... "); + NSLog(@"startListening to events... "); #endif - int i; - for(i=0; i < [remoteControls count]; i++) { - [[remoteControls objectAtIndex: i] startListening: sender]; - } + unsigned int i; + for(i=0; i < [remoteControls count]; i++) { + [[remoteControls objectAtIndex: i] startListening: sender]; + } } - (void) stopListening: (id) sender { #ifdef DEBUG - NSLog(@"stopListening to events... "); + NSLog(@"stopListening to events... "); #endif - int i; - for(i=0; i < [remoteControls count]; i++) { - [[remoteControls objectAtIndex: i] stopListening: sender]; - } + unsigned int i; + for(i=0; i < [remoteControls count]; i++) { + [[remoteControls objectAtIndex: i] stopListening: sender]; + } } - (BOOL) isOpenInExclusiveMode { - BOOL mode = YES; - int i; - for(i=0; i < [remoteControls count]; i++) { - mode = mode && ([[remoteControls objectAtIndex: i] isOpenInExclusiveMode]); - } - return mode; + BOOL mode = YES; + unsigned int i; + for(i=0; i < [remoteControls count]; i++) { + mode = mode && ([[remoteControls objectAtIndex: i] isOpenInExclusiveMode]); + } + return mode; } - (void) setOpenInExclusiveMode: (BOOL) value { - int i; - for(i=0; i < [remoteControls count]; i++) { - [[remoteControls objectAtIndex: i] setOpenInExclusiveMode:value]; - } + unsigned int i; + for(i=0; i < [remoteControls count]; i++) { + [[remoteControls objectAtIndex: i] setOpenInExclusiveMode:value]; + } } @end diff --git a/apple_remote/RemoteMainController.m b/apple_remote/source/RemoteMainController.m similarity index 95% rename from apple_remote/RemoteMainController.m rename to apple_remote/source/RemoteMainController.m index c3da7bbf313d..b7ed2110eb81 100644 --- a/apple_remote/RemoteMainController.m +++ b/apple_remote/source/RemoteMainController.m @@ -1,13 +1,13 @@ /***************************************************************************** * RemoteMainController.m * - * Created by Martin Kahr on 11.03.06 under a MIT-style license. + * Created by Martin Kahr on 11.03.06 under a MIT-style license. * Copyright (c) 2006 martinkahr.com. All rights reserved. * - * Code modified and adapted to OpenOffice.org + * Code modified and adapted to OpenOffice.org * by Eric Bachard on 11.08.2008 under the same License * - * Permission is hereby granted, free of charge, to any person obtaining a + * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, @@ -19,7 +19,7 @@ * * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN @@ -27,7 +27,7 @@ * *****************************************************************************/ -#import "RemoteMainController.h" +#import #import "AppleRemote.h" #import "KeyspanFrontRowControl.h" #import "GlobalKeyboardDevice.h" @@ -41,15 +41,15 @@ @implementation MainController - (id) init { - self = [super init]; // because we redefined our own init instead of use the fu..nny awakeFromNib + self = [super init]; // because we redefined our own init instead of use the fu..nny awakeFromNib if (self != nil) { // 1. instantiate the desired behavior for the remote control device - remoteControlBehavior = [[MultiClickRemoteBehavior alloc] init]; + remoteControlBehavior = [[MultiClickRemoteBehavior alloc] init]; // 2. configure the behavior [remoteControlBehavior setDelegate: self]; - + // 3. a Remote Control Container manages a number of devices and conforms to the RemoteControl interface // Therefore you can enable or disable all the devices of the container with a single "startListening:" call. RemoteControlContainer* container = [[RemoteControlContainer alloc] initWithDelegate: remoteControlBehavior]; @@ -70,21 +70,21 @@ else { NSLog(@"[container instantiateAndAddRemoteControlDeviceWithClass: [GlobalKeyboardDevice class]] failed"); #endif - } + } // to give the binding mechanism a chance to see the change of the attribute - [self setValue: container forKey: @"remoteControl"]; + [self setValue: container forKey: @"remoteControl"]; #ifdef DEBUG NSLog(@"MainController init done"); #endif } - else + else NSLog(@"MainController init failed"); return self; } - (void) postTheEvent: (short int)buttonIdentifier modifierFlags:(int)modifierFlags { - [NSApp postEvent: + [NSApp postEvent: [NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint modifierFlags:modifierFlags @@ -92,7 +92,7 @@ windowNumber:[[NSApp keyWindow] windowNumber] context:nil subtype:AppleRemoteControlEvent - data1: buttonIdentifier + data1: buttonIdentifier data2: 0] atStart: NO]; } @@ -100,6 +100,7 @@ - (void) remoteButton: (RemoteControlEventIdentifier)buttonIdentifier pressedDown: (BOOL) pressedDown clickCount: (unsigned int)clickCount { + (void)clickCount; NSString* pressed = @""; #ifdef DEBUG NSString* buttonName = nil; @@ -109,7 +110,7 @@ pressed = @"(pressed)"; #ifdef DEBUG - switch(buttonIdentifier) + switch(buttonIdentifier) { case kRemoteButtonPlus: buttonName = @"Volume up"; break; // MEDIA_COMMAND_VOLUME_UP ( see vcl/inc/vcl/cmdevt.hxx ) case kRemoteButtonMinus: buttonName = @"Volume down"; break; // MEDIA_COMMAND_VOLUME_DOWN