root/Spiral/trunk/SPAppleRemote.h
| Revision 5472, 4.3 kB (checked in by morris, 5 months ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /* $Id$ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 2007 Axel Andersson |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 25 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 | * POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | /***************************************************************************** |
| 30 | * RemoteControlWrapper |
| 31 | * |
| 32 | * Created by Martin Kahr on 11.03.06 under a MIT-style license. |
| 33 | * Copyright (c) 2006 martinkahr.com. All rights reserved. |
| 34 | * |
| 35 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 36 | * copy of this software and associated documentation files (the "Software"), |
| 37 | * to deal in the Software without restriction, including without limitation |
| 38 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 39 | * and/or sell copies of the Software, and to permit persons to whom the |
| 40 | * Software is furnished to do so, subject to the following conditions: |
| 41 | * |
| 42 | * The above copyright notice and this permission notice shall be included |
| 43 | * in all copies or substantial portions of the Software. |
| 44 | * |
| 45 | * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 46 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 47 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 48 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 49 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 50 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 51 | * THE SOFTWARE. |
| 52 | * |
| 53 | *****************************************************************************/ |
| 54 | |
| 55 | #import "SPRemote.h" |
| 56 | |
| 57 | enum _SPAppleRemoteButton { |
| 58 | SPAppleRemoteButtonVolumePlus = 1 << 1, |
| 59 | SPAppleRemoteButtonVolumeMinus = 1 << 2, |
| 60 | SPAppleRemoteButtonMenu = 1 << 3, |
| 61 | SPAppleRemoteButtonPlay = 1 << 4, |
| 62 | SPAppleRemoteButtonRight = 1 << 5, |
| 63 | SPAppleRemoteButtonLeft = 1 << 6, |
| 64 | SPAppleRemoteButtonRightHold = 1 << 7, |
| 65 | SPAppleRemoteButtonLeftHold = 1 << 8, |
| 66 | SPAppleRemoteButtonMenuHold = 1 << 9, |
| 67 | SPAppleRemoteButtonPlaySleep = 1 << 10, |
| 68 | SPAppleRemoteControlSwitched = 1 << 11 |
| 69 | }; |
| 70 | typedef enum _SPAppleRemoteButton SPAppleRemoteButton; |
| 71 | |
| 72 | |
| 73 | @protocol SPAppleRemoteDelegate; |
| 74 | |
| 75 | @interface SPAppleRemote : SPRemote { |
| 76 | IBOutlet id <SPAppleRemoteDelegate> delegate; |
| 77 | |
| 78 | BOOL _listening; |
| 79 | |
| 80 | IOHIDDeviceInterface **_deviceInterface; |
| 81 | IOHIDQueueInterface **_queue; |
| 82 | NSMutableDictionary *_buttonsByCookie; |
| 83 | NSMutableArray *_allCookies; |
| 84 | |
| 85 | SPAppleRemoteButton _lastHoldButton; |
| 86 | NSTimeInterval _lastHoldButtonTime; |
| 87 | BOOL _lastButtonSimulatedHold; |
| 88 | |
| 89 | BOOL _delegateAppleRemotePressedButton; |
| 90 | BOOL _delegateAppleRemoteHeldButton; |
| 91 | BOOL _delegateAppleRemoteReleasedButton; |
| 92 | } |
| 93 | |
| 94 | + (SPAppleRemote *)sharedRemote; |
| 95 | |
| 96 | - (void)setDelegate:(id <SPAppleRemoteDelegate>)delegate; |
| 97 | - (id <SPAppleRemoteDelegate>)delegate; |
| 98 | |
| 99 | - (void)startListening; |
| 100 | - (void)stopListening; |
| 101 | - (BOOL)isListening; |
| 102 | |
| 103 | - (SPRemoteAction)actionForButton:(SPAppleRemoteButton)button inContext:(SPRemoteContext)context; |
| 104 | |
| 105 | @end |
| 106 | |
| 107 | |
| 108 | @protocol SPAppleRemoteDelegate <NSObject> |
| 109 | |
| 110 | @optional |
| 111 | |
| 112 | - (void)appleRemotePressedButton:(SPAppleRemoteButton)button; |
| 113 | - (void)appleRemoteHeldButton:(SPAppleRemoteButton)button; |
| 114 | - (void)appleRemoteReleasedButton; |
| 115 | |
| 116 | @end |
Note: See TracBrowser for help on using the browser.
