Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
fbbcc07f
Kaydet (Commit)
fbbcc07f
authored
Ock 29, 2012
tarafından
Norbert Thiebaud
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
gbuildify apple_remote
üst
e48d33bc
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
407 additions
and
326 deletions
+407
-326
RepositoryExternal.mk
RepositoryExternal.mk
+7
-0
Library_AppleRemote.mk
apple_remote/Library_AppleRemote.mk
+58
-0
Makefile
apple_remote/Makefile
+7
-0
Module_apple_remote.mk
apple_remote/Module_apple_remote.mk
+39
-0
Package_inc.mk
apple_remote/Package_inc.mk
+33
-0
RemoteControl.h
apple_remote/inc/apple_remote/RemoteControl.h
+0
-0
RemoteMainController.h
apple_remote/inc/apple_remote/RemoteMainController.h
+0
-0
makefile.mk
apple_remote/makefile.mk
+0
-82
build.lst
apple_remote/prj/build.lst
+2
-1
d.lst
apple_remote/prj/d.lst
+0
-4
makefile.mk
apple_remote/prj/makefile.mk
+1
-0
AppleRemote.h
apple_remote/source/AppleRemote.h
+0
-0
AppleRemote.m
apple_remote/source/AppleRemote.m
+0
-0
GlobalKeyboardDevice.h
apple_remote/source/GlobalKeyboardDevice.h
+1
-1
GlobalKeyboardDevice.m
apple_remote/source/GlobalKeyboardDevice.m
+46
-42
HIDRemoteControlDevice.h
apple_remote/source/HIDRemoteControlDevice.h
+1
-1
HIDRemoteControlDevice.m
apple_remote/source/HIDRemoteControlDevice.m
+116
-109
KeyspanFrontRowControl.h
apple_remote/source/KeyspanFrontRowControl.h
+0
-0
KeyspanFrontRowControl.m
apple_remote/source/KeyspanFrontRowControl.m
+0
-0
MultiClickRemoteBehavior.h
apple_remote/source/MultiClickRemoteBehavior.h
+1
-1
MultiClickRemoteBehavior.m
apple_remote/source/MultiClickRemoteBehavior.m
+0
-0
RemoteControl.m
apple_remote/source/RemoteControl.m
+25
-20
RemoteControlContainer.h
apple_remote/source/RemoteControlContainer.h
+1
-1
RemoteControlContainer.m
apple_remote/source/RemoteControlContainer.m
+54
-50
RemoteMainController.m
apple_remote/source/RemoteMainController.m
+15
-14
No files found.
RepositoryExternal.mk
Dosyayı görüntüle @
fbbcc07f
...
@@ -1023,6 +1023,13 @@ $(call gb_LinkTarget_add_libs,$(1), \
...
@@ -1023,6 +1023,13 @@ $(call gb_LinkTarget_add_libs,$(1), \
endef
endef
define gb_LinkTarget__use_iokit
$(call gb_LinkTarget_add_libs,$(1), \
-framework IOKit \
)
endef
define gb_LinkTarget__use_qtkit
define gb_LinkTarget__use_qtkit
$(call gb_LinkTarget_add_libs,$(1), \
$(call gb_LinkTarget_add_libs,$(1), \
-framework QTKit \
-framework QTKit \
...
...
apple_remote/Library_AppleRemote.mk
0 → 100644
Dosyayı görüntüle @
fbbcc07f
# -*- 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 <nthiebaud@gmail.com>
# 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
\
))
apple_remote/Makefile
0 → 100644
Dosyayı görüntüle @
fbbcc07f
# -*- 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:
apple_remote/Module_apple_remote.mk
0 → 100644
Dosyayı görüntüle @
fbbcc07f
# -*- 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 <nthiebaud@gmail.com>
# 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:
apple_remote/Package_inc.mk
0 → 100644
Dosyayı görüntüle @
fbbcc07f
# -*- 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 <nthiebaud@gmail.com>
# 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))
apple_remote/inc/RemoteControl.h
→
apple_remote/inc/
apple_remote/
RemoteControl.h
Dosyayı görüntüle @
fbbcc07f
File moved
apple_remote/inc/RemoteMainController.h
→
apple_remote/inc/
apple_remote/
RemoteMainController.h
Dosyayı görüntüle @
fbbcc07f
File moved
apple_remote/makefile.mk
deleted
100644 → 0
Dosyayı görüntüle @
e48d33bc
#*************************************************************************
#
# 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
# <http://www.openoffice.org/license.html>
# 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
apple_remote/prj/build.lst
Dosyayı görüntüle @
fbbcc07f
apr apple_remote : solenv soltools NULL
apr apple_remote : solenv soltools NULL
apr apple_remote nmake - u apr_aprem NULL
apr apple_remote\prj nmake - u apr_aprem NULL
apple_remote/prj/d.lst
Dosyayı görüntüle @
fbbcc07f
mkdir: %_DEST%\inc\apple_remote
..\inc\*.h %_DEST%\inc\apple_remote\*
..\%__SRC%\lib\*.dylib %_DEST%\lib\*.dylib
apple_remote/prj/makefile.mk
0 → 100644
Dosyayı görüntüle @
fbbcc07f
.INCLUDE
:
gbuildbridge.mk
apple_remote/
inc
/AppleRemote.h
→
apple_remote/
source
/AppleRemote.h
Dosyayı görüntüle @
fbbcc07f
File moved
apple_remote/AppleRemote.m
→
apple_remote/
source/
AppleRemote.m
Dosyayı görüntüle @
fbbcc07f
File moved
apple_remote/
inc
/GlobalKeyboardDevice.h
→
apple_remote/
source
/GlobalKeyboardDevice.h
Dosyayı görüntüle @
fbbcc07f
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
*
*
*****************************************************************************/
*****************************************************************************/
#import
"RemoteControl.h"
#import
<apple_remote/RemoteControl.h>
#import <Carbon/Carbon.h>
#import <Carbon/Carbon.h>
...
...
apple_remote/GlobalKeyboardDevice.m
→
apple_remote/
source/
GlobalKeyboardDevice.m
Dosyayı görüntüle @
fbbcc07f
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
* GlobalKeyboardDevice.m
* GlobalKeyboardDevice.m
* RemoteControlWrapper
* 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.
* 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
* 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"),
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
*
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* 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
* 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,
* 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
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
/*
/*
the following default keys are read and shall be used to change the keyboard mapping
the following default keys are read and shall be used to change the keyboard mapping
mac.remotecontrols.GlobalKeyboardDevice.plus_modifiers
mac.remotecontrols.GlobalKeyboardDevice.plus_modifiers
mac.remotecontrols.GlobalKeyboardDevice.plus_keycode
mac.remotecontrols.GlobalKeyboardDevice.plus_keycode
mac.remotecontrols.GlobalKeyboardDevice.minus_modifiers
mac.remotecontrols.GlobalKeyboardDevice.minus_modifiers
...
@@ -62,19 +62,19 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
...
@@ -62,19 +62,19 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
@implementation
GlobalKeyboardDevice
@implementation
GlobalKeyboardDevice
-
(
id
)
initWithDelegate
:
(
id
)
_remoteControlDelegate
{
-
(
id
)
initWithDelegate
:
(
id
)
_remoteControlDelegate
{
if
(
(
self
=
[
super
initWithDelegate
:
_remoteControlDelegate
])
)
{
if
(
(
self
=
[
super
initWithDelegate
:
_remoteControlDelegate
])
)
{
hotKeyRemoteEventMapping
=
[[
NSMutableDictionary
alloc
]
init
];
hotKeyRemoteEventMapping
=
[[
NSMutableDictionary
alloc
]
init
];
unsigned
int
modifiers
=
cmdKey
+
shiftKey
/*+ optionKey*/
+
controlKey
;
unsigned
int
modifiers
=
cmdKey
+
shiftKey
/*+ optionKey*/
+
controlKey
;
[
self
mapRemoteButton
:
kRemoteButtonPlus
defaultKeycode
:
F1
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonPlus
defaultKeycode
:
F1
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonMinus
defaultKeycode
:
F2
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonMinus
defaultKeycode
:
F2
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonPlay
defaultKeycode
:
F3
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonPlay
defaultKeycode
:
F3
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonLeft
defaultKeycode
:
F4
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonLeft
defaultKeycode
:
F4
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonRight
defaultKeycode
:
F5
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonRight
defaultKeycode
:
F5
defaultModifiers
:
modifiers
];
[
self
mapRemoteButton
:
kRemoteButtonMenu
defaultKeycode
:
F6
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
;
return
self
;
}
}
...
@@ -85,48 +85,48 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
...
@@ -85,48 +85,48 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
}
}
-
(
void
)
mapRemoteButton
:
(
RemoteControlEventIdentifier
)
remoteButtonIdentifier
defaultKeycode
:
(
unsigned
int
)
defaultKeycode
defaultModifiers
:
(
unsigned
int
)
defaultModifiers
{
-
(
void
)
mapRemoteButton
:
(
RemoteControlEventIdentifier
)
remoteButtonIdentifier
defaultKeycode
:
(
unsigned
int
)
defaultKeycode
defaultModifiers
:
(
unsigned
int
)
defaultModifiers
{
NSString
*
defaultsKey
=
NULL
;
NSString
*
defaultsKey
=
NULL
;
switch
(
remoteButtonIdentifier
)
{
switch
(
remoteButtonIdentifier
)
{
case
kRemoteButtonPlus
:
case
kRemoteButtonPlus
:
defaultsKey
=
@"plus"
;
defaultsKey
=
@"plus"
;
break
;
break
;
case
kRemoteButtonMinus
:
case
kRemoteButtonMinus
:
defaultsKey
=
@"minus"
;
defaultsKey
=
@"minus"
;
break
;
break
;
case
kRemoteButtonMenu
:
case
kRemoteButtonMenu
:
defaultsKey
=
@"menu"
;
defaultsKey
=
@"menu"
;
break
;
break
;
case
kRemoteButtonPlay
:
case
kRemoteButtonPlay
:
defaultsKey
=
@"play"
;
defaultsKey
=
@"play"
;
break
;
break
;
case
kRemoteButtonRight
:
case
kRemoteButtonRight
:
defaultsKey
=
@"right"
;
defaultsKey
=
@"right"
;
break
;
break
;
case
kRemoteButtonLeft
:
case
kRemoteButtonLeft
:
defaultsKey
=
@"left"
;
defaultsKey
=
@"left"
;
break
;
break
;
case
kRemoteButtonPlay_Hold
:
case
kRemoteButtonPlay_Hold
:
defaultsKey
=
@"playhold"
;
defaultsKey
=
@"playhold"
;
break
;
break
;
default
:
default
:
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"Unknown global keyboard defaults key for remote button identifier %d"
,
remoteButtonIdentifier
);
NSLog
(
@"Unknown global keyboard defaults key for remote button identifier %d"
,
remoteButtonIdentifier
);
#endif
#endif
break
;
break
;
}
}
NSNumber
*
modifiersCfg
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
[
NSString
stringWithFormat
:
@"mac.remotecontrols.GlobalKeyboardDevice.%@_modifiers"
,
defaultsKey
]];
NSNumber
*
modifiersCfg
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
[
NSString
stringWithFormat
:
@"mac.remotecontrols.GlobalKeyboardDevice.%@_modifiers"
,
defaultsKey
]];
NSNumber
*
keycodeCfg
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
[
NSString
stringWithFormat
:
@"mac.remotecontrols.GlobalKeyboardDevice.%@_keycode"
,
defaultsKey
]];
NSNumber
*
keycodeCfg
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
[
NSString
stringWithFormat
:
@"mac.remotecontrols.GlobalKeyboardDevice.%@_keycode"
,
defaultsKey
]];
unsigned
int
modifiers
=
defaultModifiers
;
unsigned
int
modifiers
=
defaultModifiers
;
if
(
modifiersCfg
)
modifiers
=
[
modifiersCfg
unsignedIntValue
];
if
(
modifiersCfg
)
modifiers
=
[
modifiersCfg
unsignedIntValue
];
unsigned
int
keycode
=
defaultKeycode
;
unsigned
int
keycode
=
defaultKeycode
;
if
(
keycodeCfg
)
keycode
=
[
keycodeCfg
unsignedIntValue
];
if
(
keycodeCfg
)
keycode
=
[
keycodeCfg
unsignedIntValue
];
[
self
registerHotKeyCode
:
keycode
modifiers
:
modifiers
remoteEventIdentifier
:
remoteButtonIdentifier
];
[
self
registerHotKeyCode
:
keycode
modifiers
:
modifiers
remoteEventIdentifier
:
remoteButtonIdentifier
];
}
}
-
(
void
)
setListeningToRemote
:
(
BOOL
)
value
{
-
(
void
)
setListeningToRemote
:
(
BOOL
)
value
{
if
(
value
==
[
self
isListeningToRemote
])
return
;
if
(
value
==
[
self
isListeningToRemote
])
return
;
...
@@ -136,26 +136,29 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
...
@@ -136,26 +136,29 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
[
self
stopListening
:
self
];
[
self
stopListening
:
self
];
}
}
}
}
-
(
BOOL
)
isListeningToRemote
{
-
(
BOOL
)
isListeningToRemote
{
return
(
eventHandlerRef
!=
NULL
);
return
(
eventHandlerRef
!=
NULL
);
}
}
-
(
void
)
startListening
:
(
id
)
sender
{
-
(
void
)
startListening
:
(
id
)
sender
{
if
(
eventHandlerRef
)
return
;
if
(
eventHandlerRef
)
return
;
EventTypeSpec
eventSpec
[
2
]
=
{
EventTypeSpec
eventSpec
[
2
]
=
{
{
kEventClassKeyboard
,
kEventHotKeyPressed
},
{
kEventClassKeyboard
,
kEventHotKeyPressed
},
{
kEventClassKeyboard
,
kEventHotKeyReleased
}
{
kEventClassKeyboard
,
kEventHotKeyReleased
}
};
};
InstallEventHandler
(
GetEventDispatcherTarget
(),
InstallEventHandler
(
GetEventDispatcherTarget
(),
(
EventHandlerProcPtr
)
hotKeyEventHandler
,
(
EventHandlerProcPtr
)
hotKeyEventHandler
,
2
,
eventSpec
,
self
,
&
eventHandlerRef
);
2
,
eventSpec
,
self
,
&
eventHandlerRef
);
(
void
)
sender
;
}
}
-
(
void
)
stopListening
:
(
id
)
sender
{
-
(
void
)
stopListening
:
(
id
)
sender
{
RemoveEventHandler
(
eventHandlerRef
);
RemoveEventHandler
(
eventHandlerRef
);
eventHandlerRef
=
NULL
;
eventHandlerRef
=
NULL
;
(
void
)
sender
;
}
}
-
(
BOOL
)
sendsEventForButtonIdentifier
:
(
RemoteControlEventIdentifier
)
identifier
{
-
(
BOOL
)
sendsEventForButtonIdentifier
:
(
RemoteControlEventIdentifier
)
identifier
{
...
@@ -171,21 +174,21 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
...
@@ -171,21 +174,21 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
return
"Keyboard"
;
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
;
OSStatus
err
;
EventHotKeyID
hotKeyID
;
EventHotKeyID
hotKeyID
;
EventHotKeyRef
carbonHotKey
;
EventHotKeyRef
carbonHotKey
;
hotKeyID
.
signature
=
'
PTHk
'
;
hotKeyID
.
signature
=
'
PTHk
'
;
hotKeyID
.
id
=
(
long
)
keycode
;
hotKeyID
.
id
=
(
long
)
keycode
;
err
=
RegisterEventHotKey
(
keycode
,
modifiers
,
hotKeyID
,
GetEventDispatcherTarget
(),
0
,
&
carbonHotKey
);
err
=
RegisterEventHotKey
(
keycode
,
modifiers
,
hotKeyID
,
GetEventDispatcherTarget
(),
0
,
&
carbonHotKey
);
if
(
err
)
if
(
err
)
return
NO
;
return
NO
;
[
hotKeyRemoteEventMapping
setObject
:
[
NSNumber
numberWithInt
:
identifier
]
forKey
:
[
NSNumber
numberWithUnsignedInt
:
hotKeyID
.
id
]];
[
hotKeyRemoteEventMapping
setObject
:
[
NSNumber
numberWithInt
:
identifier
]
forKey
:
[
NSNumber
numberWithUnsignedInt
:
hotKeyID
.
id
]];
return
YES
;
return
YES
;
}
}
/*
/*
...
@@ -194,21 +197,21 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
...
@@ -194,21 +197,21 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef, EventRef, void*);
OSStatus err;
OSStatus err;
EventHotKeyRef carbonHotKey;
EventHotKeyRef carbonHotKey;
NSValue* key;
NSValue* key;
if( [[self allHotKeys] containsObject: hotKey] == NO )
if( [[self allHotKeys] containsObject: hotKey] == NO )
return;
return;
carbonHotKey = [self _carbonHotKeyForHotKey: hotKey];
carbonHotKey = [self _carbonHotKeyForHotKey: hotKey];
NSAssert( carbonHotKey != nil, @"" );
NSAssert( carbonHotKey != nil, @"" );
err = UnregisterEventHotKey( carbonHotKey );
err = UnregisterEventHotKey( carbonHotKey );
//Watch as we ignore 'err':
//Watch as we ignore 'err':
key = [NSValue valueWithPointer: carbonHotKey];
key = [NSValue valueWithPointer: carbonHotKey];
[mHotKeys removeObjectForKey: key];
[mHotKeys removeObjectForKey: key];
[self _updateEventHandler];
[self _updateEventHandler];
//See that? Completely ignored
//See that? Completely ignored
}
}
*/
*/
...
@@ -227,13 +230,14 @@ static RemoteControlEventIdentifier lastEvent;
...
@@ -227,13 +230,14 @@ static RemoteControlEventIdentifier lastEvent;
static
OSStatus
hotKeyEventHandler
(
EventHandlerCallRef
inHandlerRef
,
EventRef
inEvent
,
void
*
userData
)
static
OSStatus
hotKeyEventHandler
(
EventHandlerCallRef
inHandlerRef
,
EventRef
inEvent
,
void
*
userData
)
{
{
(
void
)
inHandlerRef
;
GlobalKeyboardDevice
*
keyboardDevice
=
(
GlobalKeyboardDevice
*
)
userData
;
GlobalKeyboardDevice
*
keyboardDevice
=
(
GlobalKeyboardDevice
*
)
userData
;
EventHotKeyID
hkCom
;
EventHotKeyID
hkCom
;
GetEventParameter
(
inEvent
,
kEventParamDirectObject
,
typeEventHotKeyID
,
NULL
,
sizeof
(
hkCom
),
NULL
,
&
hkCom
);
GetEventParameter
(
inEvent
,
kEventParamDirectObject
,
typeEventHotKeyID
,
NULL
,
sizeof
(
hkCom
),
NULL
,
&
hkCom
);
RemoteControlEventIdentifier
identifier
=
[
keyboardDevice
remoteControlEventIdentifierForID
:
hkCom
.
id
];
RemoteControlEventIdentifier
identifier
=
[
keyboardDevice
remoteControlEventIdentifierForID
:
hkCom
.
id
];
if
(
identifier
==
0
)
return
noErr
;
if
(
identifier
==
0
)
return
noErr
;
BOOL
pressedDown
=
YES
;
BOOL
pressedDown
=
YES
;
if
(
identifier
!=
lastEvent
)
{
if
(
identifier
!=
lastEvent
)
{
lastEvent
=
identifier
;
lastEvent
=
identifier
;
...
@@ -242,7 +246,7 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef in
...
@@ -242,7 +246,7 @@ static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef in
pressedDown
=
NO
;
pressedDown
=
NO
;
}
}
[
keyboardDevice
sendRemoteButtonEvent
:
identifier
pressedDown
:
pressedDown
];
[
keyboardDevice
sendRemoteButtonEvent
:
identifier
pressedDown
:
pressedDown
];
return
noErr
;
return
noErr
;
}
}
...
...
apple_remote/
inc
/HIDRemoteControlDevice.h
→
apple_remote/
source
/HIDRemoteControlDevice.h
Dosyayı görüntüle @
fbbcc07f
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
*
*
*****************************************************************************/
*****************************************************************************/
#import
"RemoteControl.h"
#import
<apple_remote/RemoteControl.h>
#import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDLib.h>
...
...
apple_remote/HIDRemoteControlDevice.m
→
apple_remote/
source/
HIDRemoteControlDevice.m
Dosyayı görüntüle @
fbbcc07f
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
* HIDRemoteControlDevice.m
* HIDRemoteControlDevice.m
* RemoteControlWrapper
* 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.
* 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
* 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"),
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
*
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* 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
* 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,
* 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
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
...
@@ -37,17 +37,17 @@
...
@@ -37,17 +37,17 @@
#import <IOKit/hid/IOHIDKeys.h>
#import <IOKit/hid/IOHIDKeys.h>
#import <Carbon/Carbon.h>
#import <Carbon/Carbon.h>
@interface
HIDRemoteControlDevice
(
PrivateMethods
)
@interface
HIDRemoteControlDevice
(
PrivateMethods
)
-
(
NSDictionary
*
)
cookieToButtonMapping
;
// Creates the dictionary using the magics, depending on the remote
-
(
NSDictionary
*
)
cookieToButtonMapping
;
// Creates the dictionary using the magics, depending on the remote
-
(
IOHIDQueueInterface
**
)
queue
;
-
(
IOHIDQueueInterface
**
)
queue
;
-
(
IOHIDDeviceInterface
**
)
hidDeviceInterface
;
-
(
IOHIDDeviceInterface
**
)
hidDeviceInterface
;
-
(
void
)
handleEventWithCookieString
:
(
NSString
*
)
cookieString
sumOfValues
:
(
SInt32
)
sumOfValues
;
-
(
void
)
handleEventWithCookieString
:
(
NSString
*
)
cookieString
sumOfValues
:
(
SInt32
)
sumOfValues
;
-
(
void
)
removeNotifcationObserver
;
-
(
void
)
removeNotifcationObserver
;
-
(
void
)
remoteControlAvailable
:(
NSNotification
*
)
notification
;
-
(
void
)
remoteControlAvailable
:(
NSNotification
*
)
notification
;
@end
@end
@interface
HIDRemoteControlDevice
(
IOKitMethods
)
@interface
HIDRemoteControlDevice
(
IOKitMethods
)
+
(
io_object_t
)
findRemoteDevice
;
+
(
io_object_t
)
findRemoteDevice
;
-
(
IOHIDDeviceInterface
**
)
createInterfaceForDevice
:
(
io_object_t
)
hidDevice
;
-
(
IOHIDDeviceInterface
**
)
createInterfaceForDevice
:
(
io_object_t
)
hidDevice
;
-
(
BOOL
)
initializeCookies
;
-
(
BOOL
)
initializeCookies
;
...
@@ -60,25 +60,25 @@
...
@@ -60,25 +60,25 @@
return
""
;
return
""
;
}
}
+
(
BOOL
)
isRemoteAvailable
{
+
(
BOOL
)
isRemoteAvailable
{
io_object_t
hidDevice
=
[
self
findRemoteDevice
];
io_object_t
hidDevice
=
[
self
findRemoteDevice
];
if
(
hidDevice
!=
0
)
{
if
(
hidDevice
!=
0
)
{
IOObjectRelease
(
hidDevice
);
IOObjectRelease
(
hidDevice
);
return
YES
;
return
YES
;
}
else
{
}
else
{
return
NO
;
return
NO
;
}
}
}
}
-
(
id
)
initWithDelegate
:
(
id
)
_remoteControlDelegate
{
-
(
id
)
initWithDelegate
:
(
id
)
_remoteControlDelegate
{
if
([[
self
class
]
isRemoteAvailable
]
==
NO
)
return
nil
;
if
([[
self
class
]
isRemoteAvailable
]
==
NO
)
return
nil
;
if
(
(
self
=
[
super
initWithDelegate
:
_remoteControlDelegate
])
)
{
if
(
(
self
=
[
super
initWithDelegate
:
_remoteControlDelegate
])
)
{
openInExclusiveMode
=
YES
;
openInExclusiveMode
=
YES
;
queue
=
NULL
;
queue
=
NULL
;
hidDeviceInterface
=
NULL
;
hidDeviceInterface
=
NULL
;
cookieToButtonMapping
=
[[
NSMutableDictionary
alloc
]
init
];
cookieToButtonMapping
=
[[
NSMutableDictionary
alloc
]
init
];
[
self
setCookieMappingInDictionary
:
cookieToButtonMapping
];
[
self
setCookieMappingInDictionary
:
cookieToButtonMapping
];
NSEnumerator
*
enumerator
=
[
cookieToButtonMapping
objectEnumerator
];
NSEnumerator
*
enumerator
=
[
cookieToButtonMapping
objectEnumerator
];
...
@@ -87,10 +87,10 @@
...
@@ -87,10 +87,10 @@
while
(
(
identifier
=
[
enumerator
nextObject
])
)
{
while
(
(
identifier
=
[
enumerator
nextObject
])
)
{
supportedButtonEvents
|=
[
identifier
intValue
];
supportedButtonEvents
|=
[
identifier
intValue
];
}
}
fixSecureEventInputBug
=
[[
NSUserDefaults
standardUserDefaults
]
boolForKey
:
@"remoteControlWrapperFixSecureEventInputBug"
];
fixSecureEventInputBug
=
[[
NSUserDefaults
standardUserDefaults
]
boolForKey
:
@"remoteControlWrapperFixSecureEventInputBug"
];
}
}
return
self
;
return
self
;
}
}
...
@@ -105,8 +105,10 @@
...
@@ -105,8 +105,10 @@
[
delegate
sendRemoteButtonEvent
:
event
pressedDown
:
pressedDown
remoteControl
:
self
];
[
delegate
sendRemoteButtonEvent
:
event
pressedDown
:
pressedDown
remoteControl
:
self
];
}
}
-
(
void
)
setCookieMappingInDictionary
:
(
NSMutableDictionary
*
)
cookieToButtonMapping
{
-
(
void
)
setCookieMappingInDictionary
:
(
NSMutableDictionary
*
)
cookieToButtonMap
{
(
void
)
cookieToButtonMap
;
}
}
-
(
int
)
remoteIdSwitchCookie
{
-
(
int
)
remoteIdSwitchCookie
{
return
0
;
return
0
;
}
}
...
@@ -114,9 +116,9 @@
...
@@ -114,9 +116,9 @@
-
(
BOOL
)
sendsEventForButtonIdentifier
:
(
RemoteControlEventIdentifier
)
identifier
{
-
(
BOOL
)
sendsEventForButtonIdentifier
:
(
RemoteControlEventIdentifier
)
identifier
{
return
(
supportedButtonEvents
&
identifier
)
==
identifier
;
return
(
supportedButtonEvents
&
identifier
)
==
identifier
;
}
}
-
(
BOOL
)
isListeningToRemote
{
-
(
BOOL
)
isListeningToRemote
{
return
(
hidDeviceInterface
!=
NULL
&&
allCookies
!=
NULL
&&
queue
!=
NULL
);
return
(
hidDeviceInterface
!=
NULL
&&
allCookies
!=
NULL
&&
queue
!=
NULL
);
}
}
-
(
void
)
setListeningToRemote
:
(
BOOL
)
value
{
-
(
void
)
setListeningToRemote
:
(
BOOL
)
value
{
...
@@ -141,38 +143,39 @@
...
@@ -141,38 +143,39 @@
processesBacklog
=
value
;
processesBacklog
=
value
;
}
}
-
(
void
)
startListening
:
(
id
)
sender
{
-
(
void
)
startListening
:
(
id
)
sender
{
(
void
)
sender
;
if
([
self
isListeningToRemote
])
return
;
if
([
self
isListeningToRemote
])
return
;
// 4th July 2007
// 4th July 2007
//
//
// A security update in february of 2007 introduced an odd behavior.
// A security update in february of 2007 introduced an odd behavior.
// Whenever SecureEventInput is activated or deactivated the exclusive access
// Whenever SecureEventInput is activated or deactivated the exclusive access
// to the remote control device is lost. This leads to very strange behavior where
// 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 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.
// 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
// 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)
// 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.
// 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.
// 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.
// Note that there is a corresponding DisableSecureEventInput in the stopListening method below.
//
//
if
([
self
isOpenInExclusiveMode
]
&&
fixSecureEventInputBug
)
EnableSecureEventInput
();
if
([
self
isOpenInExclusiveMode
]
&&
fixSecureEventInputBug
)
EnableSecureEventInput
();
[
self
removeNotifcationObserver
];
[
self
removeNotifcationObserver
];
io_object_t
hidDevice
=
[[
self
class
]
findRemoteDevice
];
io_object_t
hidDevice
=
[[
self
class
]
findRemoteDevice
];
if
(
hidDevice
==
0
)
return
;
if
(
hidDevice
==
0
)
return
;
if
([
self
createInterfaceForDevice
:
hidDevice
]
==
NULL
)
{
if
([
self
createInterfaceForDevice
:
hidDevice
]
==
NULL
)
{
goto
error
;
goto
error
;
}
}
if
([
self
initializeCookies
]
==
NO
)
{
if
([
self
initializeCookies
]
==
NO
)
{
goto
error
;
goto
error
;
}
}
...
@@ -184,67 +187,68 @@
...
@@ -184,67 +187,68 @@
[
self
willChangeValueForKey
:
@"listeningToRemote"
];
[
self
willChangeValueForKey
:
@"listeningToRemote"
];
[
self
didChangeValueForKey
:
@"listeningToRemote"
];
[
self
didChangeValueForKey
:
@"listeningToRemote"
];
goto
cleanup
;
goto
cleanup
;
error
:
error
:
[
self
stopListening
:
self
];
[
self
stopListening
:
self
];
DisableSecureEventInput
();
DisableSecureEventInput
();
cleanup
:
cleanup
:
IOObjectRelease
(
hidDevice
);
IOObjectRelease
(
hidDevice
);
}
}
-
(
void
)
stopListening
:
(
id
)
sender
{
-
(
void
)
stopListening
:
(
id
)
sender
{
(
void
)
sender
;
if
([
self
isListeningToRemote
]
==
NO
)
return
;
if
([
self
isListeningToRemote
]
==
NO
)
return
;
BOOL
sendNotification
=
NO
;
BOOL
sendNotification
=
NO
;
if
(
eventSource
!=
NULL
)
{
if
(
eventSource
!=
NULL
)
{
CFRunLoopRemoveSource
(
CFRunLoopGetCurrent
(),
eventSource
,
kCFRunLoopDefaultMode
);
CFRunLoopRemoveSource
(
CFRunLoopGetCurrent
(),
eventSource
,
kCFRunLoopDefaultMode
);
CFRelease
(
eventSource
);
CFRelease
(
eventSource
);
eventSource
=
NULL
;
eventSource
=
NULL
;
}
}
if
(
queue
!=
NULL
)
{
if
(
queue
!=
NULL
)
{
(
*
queue
)
->
stop
(
queue
);
(
*
queue
)
->
stop
(
queue
);
//dispose of queue
//dispose of queue
(
*
queue
)
->
dispose
(
queue
);
(
*
queue
)
->
dispose
(
queue
);
//release the queue we allocated
//release the queue we allocated
(
*
queue
)
->
Release
(
queue
);
(
*
queue
)
->
Release
(
queue
);
queue
=
NULL
;
queue
=
NULL
;
sendNotification
=
YES
;
sendNotification
=
YES
;
}
}
if
(
allCookies
!=
nil
)
{
if
(
allCookies
!=
nil
)
{
[
allCookies
autorelease
];
[
allCookies
autorelease
];
allCookies
=
nil
;
allCookies
=
nil
;
}
}
if
(
hidDeviceInterface
!=
NULL
)
{
if
(
hidDeviceInterface
!=
NULL
)
{
//close the device
//close the device
(
*
hidDeviceInterface
)
->
close
(
hidDeviceInterface
);
(
*
hidDeviceInterface
)
->
close
(
hidDeviceInterface
);
//release the interface
//release the interface
(
*
hidDeviceInterface
)
->
Release
(
hidDeviceInterface
);
(
*
hidDeviceInterface
)
->
Release
(
hidDeviceInterface
);
hidDeviceInterface
=
NULL
;
hidDeviceInterface
=
NULL
;
}
}
if
([
self
isOpenInExclusiveMode
]
&&
fixSecureEventInputBug
)
DisableSecureEventInput
();
if
([
self
isOpenInExclusiveMode
]
&&
fixSecureEventInputBug
)
DisableSecureEventInput
();
if
([
self
isOpenInExclusiveMode
]
&&
sendNotification
)
{
if
([
self
isOpenInExclusiveMode
]
&&
sendNotification
)
{
[[
self
class
]
sendFinishedNotifcationForAppIdentifier
:
nil
];
[[
self
class
]
sendFinishedNotifcationForAppIdentifier
:
nil
];
}
}
// be KVO friendly
// be KVO friendly
[
self
willChangeValueForKey
:
@"listeningToRemote"
];
[
self
willChangeValueForKey
:
@"listeningToRemote"
];
[
self
didChangeValueForKey
:
@"listeningToRemote"
];
[
self
didChangeValueForKey
:
@"listeningToRemote"
];
}
}
@end
@end
@implementation
HIDRemoteControlDevice
(
PrivateMethods
)
@implementation
HIDRemoteControlDevice
(
PrivateMethods
)
-
(
IOHIDQueueInterface
**
)
queue
{
-
(
IOHIDQueueInterface
**
)
queue
{
return
queue
;
return
queue
;
...
@@ -265,7 +269,7 @@ cleanup:
...
@@ -265,7 +269,7 @@ cleanup:
NSString
*
key
;
NSString
*
key
;
while
(
(
key
=
[
keyEnum
nextObject
])
)
{
while
(
(
key
=
[
keyEnum
nextObject
])
)
{
NSRange
range
=
[
cookieString
rangeOfString
:
key
];
NSRange
range
=
[
cookieString
rangeOfString
:
key
];
if
(
range
.
location
==
0
)
return
key
;
if
(
range
.
location
==
0
)
return
key
;
}
}
return
nil
;
return
nil
;
}
}
...
@@ -275,10 +279,10 @@ cleanup:
...
@@ -275,10 +279,10 @@ cleanup:
if (previousRemainingCookieString) {
if (previousRemainingCookieString) {
cookieString = [previousRemainingCookieString stringByAppendingString: cookieString];
cookieString = [previousRemainingCookieString stringByAppendingString: cookieString];
NSLog(@"New cookie string is %@", cookieString);
NSLog(@"New cookie string is %@", cookieString);
[previousRemainingCookieString release], previousRemainingCookieString=nil;
[previousRemainingCookieString release], previousRemainingCookieString=nil;
}*/
}*/
if
(
cookieString
==
nil
||
[
cookieString
length
]
==
0
)
return
;
if
(
cookieString
==
nil
||
[
cookieString
length
]
==
0
)
return
;
NSNumber
*
buttonId
=
[[
self
cookieToButtonMapping
]
objectForKey
:
cookieString
];
NSNumber
*
buttonId
=
[[
self
cookieToButtonMapping
]
objectForKey
:
cookieString
];
if
(
buttonId
!=
nil
)
{
if
(
buttonId
!=
nil
)
{
switch
(
(
int
)
buttonId
)
switch
(
(
int
)
buttonId
)
...
@@ -304,14 +308,14 @@ cleanup:
...
@@ -304,14 +308,14 @@ cleanup:
}
}
if
(
processesBacklog
==
NO
&&
lastSubCookieString
!=
nil
)
{
if
(
processesBacklog
==
NO
&&
lastSubCookieString
!=
nil
)
{
// process the last event of the backlog and assume that the button is not pressed down any longer.
// 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
// 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.
// a button pressed down event while in reality the user has released it.
// NSLog(@"processing last event of backlog");
// NSLog(@"processing last event of backlog");
[
self
handleEventWithCookieString
:
lastSubCookieString
sumOfValues
:
0
];
[
self
handleEventWithCookieString
:
lastSubCookieString
sumOfValues
:
0
];
}
}
if
([
cookieString
length
]
>
0
)
{
if
([
cookieString
length
]
>
0
)
{
NSLog
(
@"Unknown button for cookiestring %@"
,
cookieString
);
NSLog
(
@"Unknown button for cookiestring %@"
,
cookieString
);
}
}
}
}
}
}
...
@@ -320,6 +324,7 @@ cleanup:
...
@@ -320,6 +324,7 @@ cleanup:
}
}
-
(
void
)
remoteControlAvailable
:
(
NSNotification
*
)
notification
{
-
(
void
)
remoteControlAvailable
:
(
NSNotification
*
)
notification
{
(
void
)
notification
;
[
self
removeNotifcationObserver
];
[
self
removeNotifcationObserver
];
[
self
startListening
:
self
];
[
self
startListening
:
self
];
}
}
...
@@ -329,33 +334,35 @@ cleanup:
...
@@ -329,33 +334,35 @@ cleanup:
/* Callback method for the device queue
/* Callback method for the device queue
Will be called for any event of any type (cookie) to which we subscribe
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
)
{
static
void
QueueCallbackFunction
(
void
*
target
,
IOReturn
result
,
void
*
refcon
,
void
*
sender
)
{
if
(
target
<
0
)
{
(
void
)
refcon
;
(
void
)
sender
;
if
((
intptr_t
)
target
<
0
)
{
NSLog
(
@"QueueCallbackFunction called with invalid target!"
);
NSLog
(
@"QueueCallbackFunction called with invalid target!"
);
return
;
return
;
}
}
NSAutoreleasePool
*
pool
=
[[
NSAutoreleasePool
alloc
]
init
];
NSAutoreleasePool
*
pool
=
[[
NSAutoreleasePool
alloc
]
init
];
HIDRemoteControlDevice
*
remote
=
(
HIDRemoteControlDevice
*
)
target
;
HIDRemoteControlDevice
*
remote
=
(
HIDRemoteControlDevice
*
)
target
;
IOHIDEventStruct
event
;
IOHIDEventStruct
event
;
AbsoluteTime
zeroTime
=
{
0
,
0
};
AbsoluteTime
zeroTime
=
{
0
,
0
};
NSMutableString
*
cookieString
=
[
NSMutableString
string
];
NSMutableString
*
cookieString
=
[
NSMutableString
string
];
SInt32
sumOfValues
=
0
;
SInt32
sumOfValues
=
0
;
while
(
result
==
kIOReturnSuccess
)
while
(
result
==
kIOReturnSuccess
)
{
{
result
=
(
*
[
remote
queue
])
->
getNextEvent
([
remote
queue
],
&
event
,
zeroTime
,
0
);
result
=
(
*
[
remote
queue
])
->
getNextEvent
([
remote
queue
],
&
event
,
zeroTime
,
0
);
if
(
result
!=
kIOReturnSuccess
)
if
(
result
!=
kIOReturnSuccess
)
continue
;
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
)
{
if
(((
int
)
event
.
elementCookie
)
!=
5
)
{
sumOfValues
+=
event
.
value
;
sumOfValues
+=
event
.
value
;
[
cookieString
appendString
:[
NSString
stringWithFormat
:
@"%d_"
,
event
.
elementCookie
]];
[
cookieString
appendString
:[
NSString
stringWithFormat
:
@"%d_"
,
event
.
elementCookie
]];
}
}
}
}
[
remote
handleEventWithCookieString
:
cookieString
sumOfValues
:
sumOfValues
];
[
remote
handleEventWithCookieString
:
cookieString
sumOfValues
:
sumOfValues
];
[
pool
release
];
[
pool
release
];
}
}
...
@@ -367,16 +374,16 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
...
@@ -367,16 +374,16 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
HRESULT
plugInResult
=
S_OK
;
HRESULT
plugInResult
=
S_OK
;
SInt32
score
=
0
;
SInt32
score
=
0
;
IOReturn
ioReturnValue
=
kIOReturnSuccess
;
IOReturn
ioReturnValue
=
kIOReturnSuccess
;
hidDeviceInterface
=
NULL
;
hidDeviceInterface
=
NULL
;
ioReturnValue
=
IOObjectGetClass
(
hidDevice
,
className
);
ioReturnValue
=
IOObjectGetClass
(
hidDevice
,
className
);
if
(
ioReturnValue
!=
kIOReturnSuccess
)
{
if
(
ioReturnValue
!=
kIOReturnSuccess
)
{
NSLog
(
@"Error: Failed to get class name."
);
NSLog
(
@"Error: Failed to get class name."
);
return
NULL
;
return
NULL
;
}
}
ioReturnValue
=
IOCreatePlugInInterfaceForService
(
hidDevice
,
ioReturnValue
=
IOCreatePlugInInterfaceForService
(
hidDevice
,
kIOHIDDeviceUserClientTypeID
,
kIOHIDDeviceUserClientTypeID
,
kIOCFPlugInInterfaceID
,
kIOCFPlugInInterfaceID
,
...
@@ -386,7 +393,7 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
...
@@ -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
//Call a method of the intermediate plug-in to create the device interface
plugInResult
=
(
*
plugInInterface
)
->
QueryInterface
(
plugInInterface
,
CFUUIDGetUUIDBytes
(
kIOHIDDeviceInterfaceID
),
(
LPVOID
)
&
hidDeviceInterface
);
plugInResult
=
(
*
plugInInterface
)
->
QueryInterface
(
plugInInterface
,
CFUUIDGetUUIDBytes
(
kIOHIDDeviceInterfaceID
),
(
LPVOID
)
&
hidDeviceInterface
);
if
(
plugInResult
!=
S_OK
)
{
if
(
plugInResult
!=
S_OK
)
{
NSLog
(
@"Error: Couldn't create HID class device interface"
);
NSLog
(
@"Error: Couldn't create HID class device interface"
);
}
}
...
@@ -405,41 +412,41 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
...
@@ -405,41 +412,41 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
NSArray
*
elements
=
nil
;
NSArray
*
elements
=
nil
;
NSDictionary
*
element
;
NSDictionary
*
element
;
IOReturn
success
;
IOReturn
success
;
if
(
!
handle
||
!
(
*
handle
))
return
NO
;
if
(
!
handle
||
!
(
*
handle
))
return
NO
;
// Copy all elements, since we're grabbing most of the elements
// Copy all elements, since we're grabbing most of the elements
// for this device anyway, and thus, it's faster to iterate them
// for this device anyway, and thus, it's faster to iterate them
// ourselves. When grabbing only one or two elements, a matching
// ourselves. When grabbing only one or two elements, a matching
// dictionary should be passed in here instead of NULL.
// dictionary should be passed in here instead of NULL.
success
=
(
*
handle
)
->
copyMatchingElements
(
handle
,
NULL
,
(
CFArrayRef
*
)
&
elements
);
success
=
(
*
handle
)
->
copyMatchingElements
(
handle
,
NULL
,
(
CFArrayRef
*
)
&
elements
);
if
(
success
==
kIOReturnSuccess
)
{
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);
memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS);
*/
*/
allCookies
=
[[
NSMutableArray
alloc
]
init
];
allCookies
=
[[
NSMutableArray
alloc
]
init
];
NSEnumerator
*
elementsEnumerator
=
[
elements
objectEnumerator
];
NSEnumerator
*
elementsEnumerator
=
[
elements
objectEnumerator
];
while
(
(
element
=
[
elementsEnumerator
nextObject
])
)
{
while
(
(
element
=
[
elementsEnumerator
nextObject
])
)
{
//Get cookie
//Get cookie
object
=
[
element
valueForKey
:
(
NSString
*
)
CFSTR
(
kIOHIDElementCookieKey
)
];
object
=
[
element
valueForKey
:
(
NSString
*
)
CFSTR
(
kIOHIDElementCookieKey
)
];
if
(
object
==
nil
||
!
[
object
isKindOfClass
:[
NSNumber
class
]])
continue
;
if
(
object
==
nil
||
!
[
object
isKindOfClass
:[
NSNumber
class
]])
continue
;
if
(
object
==
0
||
CFGetTypeID
(
object
)
!=
CFNumberGetTypeID
())
continue
;
if
(
object
==
0
||
CFGetTypeID
(
object
)
!=
CFNumberGetTypeID
())
continue
;
cookie
=
(
IOHIDElementCookie
)
[
object
longValue
];
cookie
=
(
IOHIDElementCookie
)
[
object
longValue
];
//Get usage
//Get usage
object
=
[
element
valueForKey
:
(
NSString
*
)
CFSTR
(
kIOHIDElementUsageKey
)
];
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
];
usage
=
[
object
longValue
];
//Get usage page
//Get usage page
object
=
[
element
valueForKey
:
(
NSString
*
)
CFSTR
(
kIOHIDElementUsagePageKey
)
];
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
];
usagePage
=
[
object
longValue
];
[
allCookies
addObject
:
[
NSNumber
numberWithInt
:(
int
)
cookie
]];
[
allCookies
addObject
:
[
NSNumber
numberWithInt
:(
int
)
cookie
]];
...
@@ -447,38 +454,38 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
...
@@ -447,38 +454,38 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
}
else
{
}
else
{
return
NO
;
return
NO
;
}
}
return
YES
;
return
YES
;
}
}
-
(
BOOL
)
openDevice
{
-
(
BOOL
)
openDevice
{
HRESULT
result
;
HRESULT
result
;
IOHIDOptionsType
openMode
=
kIOHIDOptionsTypeNone
;
IOHIDOptionsType
openMode
=
kIOHIDOptionsTypeNone
;
if
([
self
isOpenInExclusiveMode
])
openMode
=
kIOHIDOptionsTypeSeizeDevice
;
if
([
self
isOpenInExclusiveMode
])
openMode
=
kIOHIDOptionsTypeSeizeDevice
;
IOReturn
ioReturnValue
=
(
*
hidDeviceInterface
)
->
open
(
hidDeviceInterface
,
openMode
);
IOReturn
ioReturnValue
=
(
*
hidDeviceInterface
)
->
open
(
hidDeviceInterface
,
openMode
);
if
(
ioReturnValue
==
KERN_SUCCESS
)
{
if
(
ioReturnValue
==
KERN_SUCCESS
)
{
queue
=
(
*
hidDeviceInterface
)
->
allocQueue
(
hidDeviceInterface
);
queue
=
(
*
hidDeviceInterface
)
->
allocQueue
(
hidDeviceInterface
);
if
(
queue
)
{
if
(
queue
)
{
result
=
(
*
queue
)
->
create
(
queue
,
0
,
12
);
//depth: maximum number of elements in queue before oldest elements in queue begin to be lost.
result
=
(
*
queue
)
->
create
(
queue
,
0
,
12
);
//depth: maximum number of elements in queue before oldest elements in queue begin to be lost.
IOHIDElementCookie
cookie
;
IOHIDElementCookie
cookie
;
NSEnumerator
*
allCookiesEnumerator
=
[
allCookies
objectEnumerator
];
NSEnumerator
*
allCookiesEnumerator
=
[
allCookies
objectEnumerator
];
while
(
(
cookie
=
(
IOHIDElementCookie
)[[
allCookiesEnumerator
nextObject
]
intValue
])
)
{
while
(
(
cookie
=
(
IOHIDElementCookie
)[[
allCookiesEnumerator
nextObject
]
intValue
])
)
{
(
*
queue
)
->
addElement
(
queue
,
cookie
,
0
);
(
*
queue
)
->
addElement
(
queue
,
cookie
,
0
);
}
}
// add callback for async events
// add callback for async events
ioReturnValue
=
(
*
queue
)
->
createAsyncEventSource
(
queue
,
&
eventSource
);
ioReturnValue
=
(
*
queue
)
->
createAsyncEventSource
(
queue
,
&
eventSource
);
if
(
ioReturnValue
==
KERN_SUCCESS
)
{
if
(
ioReturnValue
==
KERN_SUCCESS
)
{
ioReturnValue
=
(
*
queue
)
->
setEventCallout
(
queue
,
QueueCallbackFunction
,
self
,
NULL
);
ioReturnValue
=
(
*
queue
)
->
setEventCallout
(
queue
,
QueueCallbackFunction
,
self
,
NULL
);
if
(
ioReturnValue
==
KERN_SUCCESS
)
{
if
(
ioReturnValue
==
KERN_SUCCESS
)
{
CFRunLoopAddSource
(
CFRunLoopGetCurrent
(),
eventSource
,
kCFRunLoopDefaultMode
);
CFRunLoopAddSource
(
CFRunLoopGetCurrent
(),
eventSource
,
kCFRunLoopDefaultMode
);
//start data delivery to queue
//start data delivery to queue
(
*
queue
)
->
start
(
queue
);
(
*
queue
)
->
start
(
queue
);
return
YES
;
return
YES
;
}
else
{
}
else
{
NSLog
(
@"Error when setting event callback"
);
NSLog
(
@"Error when setting event callback"
);
...
@@ -491,36 +498,36 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
...
@@ -491,36 +498,36 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
}
}
}
else
if
(
ioReturnValue
==
kIOReturnExclusiveAccess
)
{
}
else
if
(
ioReturnValue
==
kIOReturnExclusiveAccess
)
{
// the device is used exclusive by another application
// the device is used exclusive by another application
// 1. we register for the FINISHED_USING_REMOTE_CONTROL_NOTIFICATION notification
// 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
];
[[
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
];
[[
self
class
]
sendRequestForRemoteControlNotification
];
}
}
return
NO
;
return
NO
;
}
}
+
(
io_object_t
)
findRemoteDevice
{
+
(
io_object_t
)
findRemoteDevice
{
CFMutableDictionaryRef
hidMatchDictionary
=
NULL
;
CFMutableDictionaryRef
hidMatchDictionary
=
NULL
;
IOReturn
ioReturnValue
=
kIOReturnSuccess
;
IOReturn
ioReturnValue
=
kIOReturnSuccess
;
io_iterator_t
hidObjectIterator
=
0
;
io_iterator_t
hidObjectIterator
=
0
;
io_object_t
hidDevice
=
0
;
io_object_t
hidDevice
=
0
;
// Set up a matching dictionary to search the I/O Registry by class
// Set up a matching dictionary to search the I/O Registry by class
// name for all HID class devices
// name for all HID class devices
hidMatchDictionary
=
IOServiceMatching
([
self
remoteControlDeviceName
]);
hidMatchDictionary
=
IOServiceMatching
([
self
remoteControlDeviceName
]);
// Now search I/O Registry for matching devices.
// Now search I/O Registry for matching devices.
ioReturnValue
=
IOServiceGetMatchingServices
(
kIOMasterPortDefault
,
hidMatchDictionary
,
&
hidObjectIterator
);
ioReturnValue
=
IOServiceGetMatchingServices
(
kIOMasterPortDefault
,
hidMatchDictionary
,
&
hidObjectIterator
);
if
((
ioReturnValue
==
kIOReturnSuccess
)
&&
(
hidObjectIterator
!=
0
))
{
if
((
ioReturnValue
==
kIOReturnSuccess
)
&&
(
hidObjectIterator
!=
0
))
{
hidDevice
=
IOIteratorNext
(
hidObjectIterator
);
hidDevice
=
IOIteratorNext
(
hidObjectIterator
);
}
}
// release the iterator
// release the iterator
IOObjectRelease
(
hidObjectIterator
);
IOObjectRelease
(
hidObjectIterator
);
return
hidDevice
;
return
hidDevice
;
}
}
...
...
apple_remote/
inc
/KeyspanFrontRowControl.h
→
apple_remote/
source
/KeyspanFrontRowControl.h
Dosyayı görüntüle @
fbbcc07f
File moved
apple_remote/KeyspanFrontRowControl.m
→
apple_remote/
source/
KeyspanFrontRowControl.m
Dosyayı görüntüle @
fbbcc07f
File moved
apple_remote/
inc
/MultiClickRemoteBehavior.h
→
apple_remote/
source
/MultiClickRemoteBehavior.h
Dosyayı görüntüle @
fbbcc07f
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
*****************************************************************************/
*****************************************************************************/
#import
"RemoteControl.h"
#import
<apple_remote/RemoteControl.h>
/**
/**
A behavior that adds multiclick and hold events on top of a device.
A behavior that adds multiclick and hold events on top of a device.
...
...
apple_remote/MultiClickRemoteBehavior.m
→
apple_remote/
source/
MultiClickRemoteBehavior.m
Dosyayı görüntüle @
fbbcc07f
File moved
apple_remote/RemoteControl.m
→
apple_remote/
source/
RemoteControl.m
Dosyayı görüntüle @
fbbcc07f
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
* RemoteControl.m
* RemoteControl.m
* RemoteControlWrapper
* 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.
* 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
* 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"),
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
...
@@ -20,17 +20,17 @@
...
@@ -20,17 +20,17 @@
*
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* 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
* 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,
* 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
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* THE SOFTWARE.
*
*
*****************************************************************************/
*****************************************************************************/
#import "RemoteControl.h"
// notifaction names that are being used to signal that an application wants to
#import <apple_remote/RemoteControl.h>
// 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
// have access to the remote control device or if the application has finished
// using the remote control device
// using the remote control device
NSString
*
REQUEST_FOR_REMOTE_CONTROL_NOTIFCATION
=
@"mac.remotecontrols.RequestForRemoteControl"
;
NSString
*
REQUEST_FOR_REMOTE_CONTROL_NOTIFCATION
=
@"mac.remotecontrols.RequestForRemoteControl"
;
...
@@ -47,14 +47,14 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
...
@@ -47,14 +47,14 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
@implementation
RemoteControl
@implementation
RemoteControl
// returns nil if the remote control device is not available
// returns nil if the remote control device is not available
-
(
id
)
initWithDelegate
:
(
id
)
_remoteControlDelegate
{
-
(
id
)
initWithDelegate
:
(
id
)
_remoteControlDelegate
{
if
(
(
self
=
[
super
init
])
)
{
if
(
(
self
=
[
super
init
])
)
{
delegate
=
[
_remoteControlDelegate
retain
];
delegate
=
[
_remoteControlDelegate
retain
];
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"RemoteControl initWithDelegate ok"
);
NSLog
(
@"RemoteControl initWithDelegate ok"
);
#endif
#endif
}
}
return
self
;
return
self
;
}
}
-
(
void
)
dealloc
{
-
(
void
)
dealloc
{
...
@@ -66,33 +66,38 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
...
@@ -66,33 +66,38 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"setListeningToRemote ok"
);
NSLog
(
@"setListeningToRemote ok"
);
#endif
#endif
(
void
)
value
;
}
}
-
(
BOOL
)
isListeningToRemote
{
-
(
BOOL
)
isListeningToRemote
{
return
NO
;
return
NO
;
}
}
-
(
void
)
startListening
:
(
id
)
sender
{
-
(
void
)
startListening
:
(
id
)
sender
{
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"startListening ok"
);
NSLog
(
@"startListening ok"
);
#endif
#endif
(
void
)
sender
;
}
}
-
(
void
)
stopListening
:
(
id
)
sender
{
-
(
void
)
stopListening
:
(
id
)
sender
{
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"stopListening ok"
);
NSLog
(
@"stopListening ok"
);
#endif
#endif
(
void
)
sender
;
}
}
-
(
BOOL
)
isOpenInExclusiveMode
{
-
(
BOOL
)
isOpenInExclusiveMode
{
return
YES
;
return
YES
;
}
}
-
(
void
)
setOpenInExclusiveMode
:
(
BOOL
)
value
{
-
(
void
)
setOpenInExclusiveMode
:
(
BOOL
)
value
{
(
void
)
value
;
}
}
-
(
BOOL
)
sendsEventForButtonIdentifier
:
(
RemoteControlEventIdentifier
)
identifier
{
-
(
BOOL
)
sendsEventForButtonIdentifier
:
(
RemoteControlEventIdentifier
)
identifier
{
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"sending event for button identifier
\n
"
);
NSLog
(
@"sending event for button identifier
\n
"
);
#endif
#endif
return
YES
;
(
void
)
identifier
;
return
YES
;
}
}
+
(
void
)
sendDistributedNotification
:
(
NSString
*
)
notificationName
targetBundleIdentifier
:
(
NSString
*
)
targetIdentifier
+
(
void
)
sendDistributedNotification
:
(
NSString
*
)
notificationName
targetBundleIdentifier
:
(
NSString
*
)
targetIdentifier
...
@@ -106,7 +111,7 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
...
@@ -106,7 +111,7 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
kTargetApplicationIdentifier
/*targetBundleIdentifier -> does not appear, since the peer is nil*/
,
kTargetApplicationIdentifier
/*targetBundleIdentifier -> does not appear, since the peer is nil*/
,
nil
];
nil
];
#ifdef DEBUG
#ifdef DEBUG
// Debug purpose: returns all the existing dictionary keys.
// Debug purpose: returns all the existing dictionary keys.
NSString
*
s
;
NSString
*
s
;
NSEnumerator
*
e
=
[
userInfo
keyEnumerator
];
NSEnumerator
*
e
=
[
userInfo
keyEnumerator
];
while
(
(
s
=
[
e
nextObject
])
)
{
while
(
(
s
=
[
e
nextObject
])
)
{
...
@@ -119,10 +124,10 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
...
@@ -119,10 +124,10 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
NSLog
(
@"sendDistributedNotification ..."
);
NSLog
(
@"sendDistributedNotification ..."
);
#endif
#endif
[[
NSDistributedNotificationCenter
defaultCenter
]
postNotificationName
:
notificationName
[[
NSDistributedNotificationCenter
defaultCenter
]
postNotificationName
:
notificationName
object
:
nil
object
:
nil
userInfo
:
userInfo
userInfo
:
userInfo
deliverImmediately
:
YES
];
deliverImmediately
:
YES
];
}
}
}
}
...
@@ -140,7 +145,7 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
...
@@ -140,7 +145,7 @@ NSString* kTargetApplicationIdentifier = @"TargetBundleIdentifier";
}
}
+
(
const
char
*
)
remoteControlDeviceName
{
+
(
const
char
*
)
remoteControlDeviceName
{
return
NULL
;
return
NULL
;
}
}
@end
@end
apple_remote/
inc
/RemoteControlContainer.h
→
apple_remote/
source
/RemoteControlContainer.h
Dosyayı görüntüle @
fbbcc07f
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
*
*
*****************************************************************************/
*****************************************************************************/
#import
"RemoteControl.h"
#import
<apple_remote/RemoteControl.h>
@interface
RemoteControlContainer
:
RemoteControl
{
@interface
RemoteControlContainer
:
RemoteControl
{
NSMutableArray
*
remoteControls
;
NSMutableArray
*
remoteControls
;
...
...
apple_remote/RemoteControlContainer.m
→
apple_remote/
source/
RemoteControlContainer.m
Dosyayı görüntüle @
fbbcc07f
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
* RemoteControlContainer.m
* RemoteControlContainer.m
* RemoteControlWrapper
* 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.
* 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
* 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"),
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
*
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* 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
* 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,
* 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
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
...
@@ -33,23 +33,23 @@
...
@@ -33,23 +33,23 @@
@implementation
RemoteControlContainer
@implementation
RemoteControlContainer
-
(
id
)
initWithDelegate
:
(
id
)
_remoteControlDelegate
{
-
(
id
)
initWithDelegate
:
(
id
)
_remoteControlDelegate
{
if
(
(
self
=
[
super
initWithDelegate
:
_remoteControlDelegate
])
)
{
if
(
(
self
=
[
super
initWithDelegate
:
_remoteControlDelegate
])
)
{
remoteControls
=
[[
NSMutableArray
alloc
]
init
];
remoteControls
=
[[
NSMutableArray
alloc
]
init
];
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"RemoteControlContainer initWithDelegate ok"
);
NSLog
(
@"RemoteControlContainer initWithDelegate ok"
);
}
}
else
{
else
{
NSLog
(
@"RemoteControlContainer initWithDelegate failed"
);
NSLog
(
@"RemoteControlContainer initWithDelegate failed"
);
#endif
#endif
}
}
return
self
;
return
self
;
}
}
-
(
void
)
dealloc
{
-
(
void
)
dealloc
{
[
self
stopListening
:
self
];
[
self
stopListening
:
self
];
[
remoteControls
release
];
[
remoteControls
release
];
[
super
dealloc
];
[
super
dealloc
];
}
}
-
(
BOOL
)
instantiateAndAddRemoteControlDeviceWithClass
:
(
Class
)
clazz
{
-
(
BOOL
)
instantiateAndAddRemoteControlDeviceWithClass
:
(
Class
)
clazz
{
...
@@ -58,83 +58,87 @@
...
@@ -58,83 +58,87 @@
if
(
remoteControl
)
{
if
(
remoteControl
)
{
[
remoteControls
addObject
:
remoteControl
];
[
remoteControls
addObject
:
remoteControl
];
[
remoteControl
addObserver
:
self
forKeyPath
:
@"listeningToRemote"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
[
remoteControl
addObserver
:
self
forKeyPath
:
@"listeningToRemote"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
toReturn
=
YES
;
toReturn
=
YES
;
}
}
#ifdef DEBUG
#ifdef DEBUG
else
{
else
{
NSLog
(
@"RemoteControlContainer instantiateAndAddRemoteControlDeviceWithClass failed"
);
NSLog
(
@"RemoteControlContainer instantiateAndAddRemoteControlDeviceWithClass failed"
);
toReturn
=
NO
;
toReturn
=
NO
;
}
}
#endif
#endif
return
toReturn
;
return
toReturn
;
}
}
-
(
unsigned
int
)
count
{
-
(
unsigned
int
)
count
{
return
[
remoteControls
count
];
return
[
remoteControls
count
];
}
}
-
(
void
)
reset
{
-
(
void
)
reset
{
[
self
willChangeValueForKey
:
@"listeningToRemote"
];
[
self
willChangeValueForKey
:
@"listeningToRemote"
];
[
self
didChangeValueForKey
:
@"listeningToRemote"
];
[
self
didChangeValueForKey
:
@"listeningToRemote"
];
#ifdef DEBUG
#ifdef DEBUG
// debug purpose
// debug purpose
NSLog
(
@"reset... (after listening to remote)"
);
NSLog
(
@"reset... (after listening to remote)"
);
#endif
#endif
}
}
-
(
void
)
observeValueForKeyPath
:
(
NSString
*
)
keyPath
ofObject
:
(
id
)
object
change
:
(
NSDictionary
*
)
change
context
:
(
void
*
)
context
{
-
(
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
{
-
(
void
)
setListeningToRemote
:
(
BOOL
)
value
{
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
[[
remoteControls
objectAtIndex
:
i
]
setListeningToRemote
:
value
];
[[
remoteControls
objectAtIndex
:
i
]
setListeningToRemote
:
value
];
}
}
if
(
value
&&
value
!=
[
self
isListeningToRemote
])
[
self
performSelector
:
@selector
(
reset
)
withObject
:
nil
afterDelay
:
0
.
01
];
if
(
value
&&
value
!=
[
self
isListeningToRemote
])
[
self
performSelector
:
@selector
(
reset
)
withObject
:
nil
afterDelay
:
0
.
01
];
}
}
-
(
BOOL
)
isListeningToRemote
{
-
(
BOOL
)
isListeningToRemote
{
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
if
([[
remoteControls
objectAtIndex
:
i
]
isListeningToRemote
])
{
if
([[
remoteControls
objectAtIndex
:
i
]
isListeningToRemote
])
{
return
YES
;
return
YES
;
}
}
}
}
return
NO
;
return
NO
;
}
}
-
(
void
)
startListening
:
(
id
)
sender
{
-
(
void
)
startListening
:
(
id
)
sender
{
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"startListening to events... "
);
NSLog
(
@"startListening to events... "
);
#endif
#endif
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
[[
remoteControls
objectAtIndex
:
i
]
startListening
:
sender
];
[[
remoteControls
objectAtIndex
:
i
]
startListening
:
sender
];
}
}
}
}
-
(
void
)
stopListening
:
(
id
)
sender
{
-
(
void
)
stopListening
:
(
id
)
sender
{
#ifdef DEBUG
#ifdef DEBUG
NSLog
(
@"stopListening to events... "
);
NSLog
(
@"stopListening to events... "
);
#endif
#endif
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
[[
remoteControls
objectAtIndex
:
i
]
stopListening
:
sender
];
[[
remoteControls
objectAtIndex
:
i
]
stopListening
:
sender
];
}
}
}
}
-
(
BOOL
)
isOpenInExclusiveMode
{
-
(
BOOL
)
isOpenInExclusiveMode
{
BOOL
mode
=
YES
;
BOOL
mode
=
YES
;
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
mode
=
mode
&&
([[
remoteControls
objectAtIndex
:
i
]
isOpenInExclusiveMode
]);
mode
=
mode
&&
([[
remoteControls
objectAtIndex
:
i
]
isOpenInExclusiveMode
]);
}
}
return
mode
;
return
mode
;
}
}
-
(
void
)
setOpenInExclusiveMode
:
(
BOOL
)
value
{
-
(
void
)
setOpenInExclusiveMode
:
(
BOOL
)
value
{
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
for
(
i
=
0
;
i
<
[
remoteControls
count
];
i
++
)
{
[[
remoteControls
objectAtIndex
:
i
]
setOpenInExclusiveMode
:
value
];
[[
remoteControls
objectAtIndex
:
i
]
setOpenInExclusiveMode
:
value
];
}
}
}
}
@end
@end
apple_remote/RemoteMainController.m
→
apple_remote/
source/
RemoteMainController.m
Dosyayı görüntüle @
fbbcc07f
/*****************************************************************************
/*****************************************************************************
* RemoteMainController.m
* 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.
* 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
* 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"),
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
*
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* 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
* 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,
* 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
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
*
*
*****************************************************************************/
*****************************************************************************/
#import
"RemoteMainController.h"
#import
<apple_remote/RemoteMainController.h>
#import "AppleRemote.h"
#import "AppleRemote.h"
#import "KeyspanFrontRowControl.h"
#import "KeyspanFrontRowControl.h"
#import "GlobalKeyboardDevice.h"
#import "GlobalKeyboardDevice.h"
...
@@ -41,15 +41,15 @@
...
@@ -41,15 +41,15 @@
@implementation
MainController
@implementation
MainController
-
(
id
)
init
{
-
(
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
)
{
if
(
self
!=
nil
)
{
// 1. instantiate the desired behavior for the remote control device
// 1. instantiate the desired behavior for the remote control device
remoteControlBehavior
=
[[
MultiClickRemoteBehavior
alloc
]
init
];
remoteControlBehavior
=
[[
MultiClickRemoteBehavior
alloc
]
init
];
// 2. configure the behavior
// 2. configure the behavior
[
remoteControlBehavior
setDelegate
:
self
];
[
remoteControlBehavior
setDelegate
:
self
];
// 3. a Remote Control Container manages a number of devices and conforms to the RemoteControl interface
// 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.
// Therefore you can enable or disable all the devices of the container with a single "startListening:" call.
RemoteControlContainer
*
container
=
[[
RemoteControlContainer
alloc
]
initWithDelegate
:
remoteControlBehavior
];
RemoteControlContainer
*
container
=
[[
RemoteControlContainer
alloc
]
initWithDelegate
:
remoteControlBehavior
];
...
@@ -70,21 +70,21 @@
...
@@ -70,21 +70,21 @@
else
{
else
{
NSLog
(
@"[container instantiateAndAddRemoteControlDeviceWithClass: [GlobalKeyboardDevice class]] failed"
);
NSLog
(
@"[container instantiateAndAddRemoteControlDeviceWithClass: [GlobalKeyboardDevice class]] failed"
);
#endif
#endif
}
}
// to give the binding mechanism a chance to see the change of the attribute
// 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
#ifdef DEBUG
NSLog
(
@"MainController init done"
);
NSLog
(
@"MainController init done"
);
#endif
#endif
}
}
else
else
NSLog
(
@"MainController init failed"
);
NSLog
(
@"MainController init failed"
);
return
self
;
return
self
;
}
}
-
(
void
)
postTheEvent
:
(
short
int
)
buttonIdentifier
modifierFlags
:
(
int
)
modifierFlags
-
(
void
)
postTheEvent
:
(
short
int
)
buttonIdentifier
modifierFlags
:
(
int
)
modifierFlags
{
{
[
NSApp
postEvent
:
[
NSApp
postEvent
:
[
NSEvent
otherEventWithType
:
NSApplicationDefined
[
NSEvent
otherEventWithType
:
NSApplicationDefined
location
:
NSZeroPoint
location
:
NSZeroPoint
modifierFlags
:
modifierFlags
modifierFlags
:
modifierFlags
...
@@ -92,7 +92,7 @@
...
@@ -92,7 +92,7 @@
windowNumber
:
[[
NSApp
keyWindow
]
windowNumber
]
windowNumber
:
[[
NSApp
keyWindow
]
windowNumber
]
context
:
nil
context
:
nil
subtype
:
AppleRemoteControlEvent
subtype
:
AppleRemoteControlEvent
data1
:
buttonIdentifier
data1
:
buttonIdentifier
data2
:
0
]
data2
:
0
]
atStart
:
NO
];
atStart
:
NO
];
}
}
...
@@ -100,6 +100,7 @@
...
@@ -100,6 +100,7 @@
-
(
void
)
remoteButton
:
(
RemoteControlEventIdentifier
)
buttonIdentifier
pressedDown
:
(
BOOL
)
pressedDown
clickCount
:
(
unsigned
int
)
clickCount
-
(
void
)
remoteButton
:
(
RemoteControlEventIdentifier
)
buttonIdentifier
pressedDown
:
(
BOOL
)
pressedDown
clickCount
:
(
unsigned
int
)
clickCount
{
{
(
void
)
clickCount
;
NSString
*
pressed
=
@""
;
NSString
*
pressed
=
@""
;
#ifdef DEBUG
#ifdef DEBUG
NSString
*
buttonName
=
nil
;
NSString
*
buttonName
=
nil
;
...
@@ -109,7 +110,7 @@
...
@@ -109,7 +110,7 @@
pressed
=
@"(pressed)"
;
pressed
=
@"(pressed)"
;
#ifdef DEBUG
#ifdef DEBUG
switch
(
buttonIdentifier
)
switch
(
buttonIdentifier
)
{
{
case
kRemoteButtonPlus
:
buttonName
=
@"Volume up"
;
break
;
// MEDIA_COMMAND_VOLUME_UP ( see vcl/inc/vcl/cmdevt.hxx )
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
case
kRemoteButtonMinus
:
buttonName
=
@"Volume down"
;
break
;
// MEDIA_COMMAND_VOLUME_DOWN
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment