Use o3tl::convert in Math
[LibreOffice.git] / apple_remote / source / AppleRemote.m
blobfe50af4cc1be07eb116dacc62fc15c28957dd088
1 /* -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*****************************************************************************
3  * RemoteControlWrapper.m
4  * RemoteControlWrapper
5  *
6  * Created by Martin Kahr on 11.03.06 under a MIT-style license.
7  * Copyright (c) 2006 martinkahr.com. All rights reserved.
8  *
9  * Code modified and adapted to OpenOffice.org
10  * by Eric Bachard on 11.08.2008 under the same license
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28  * THE SOFTWARE.
29  *
30  *****************************************************************************/
32 #import "AppleRemote.h"
34 #import <mach/mach.h>
35 #import <mach/mach_error.h>
36 #import <IOKit/IOKitLib.h>
37 #import <IOKit/IOCFPlugIn.h>
38 #import <IOKit/hid/IOHIDKeys.h>
40 static const char* AppleRemoteDeviceName = "AppleIRController";
42 @implementation AppleRemote
44 + (const char*) remoteControlDeviceName {
45         return AppleRemoteDeviceName;
48 - (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMapping    {
50     // TODO : avoid such magics
51 #ifdef DEBUG
52     NSLog( @"Apple Remote: setting 10.6 cookies" );
53 #endif
54     // 10.6.x Snow Leopard
55     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlus]                forKey:@"33_31_30_21_20_2_"];
56     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus]               forKey:@"33_32_30_21_20_2_"];
57     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu]                forKey:@"33_22_21_20_2_33_22_21_20_2_"];
58     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay]                forKey:@"33_23_21_20_2_33_23_21_20_2_"];
59     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight]               forKey:@"33_24_21_20_2_33_24_21_20_2_"];
60     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft]                forKey:@"33_25_21_20_2_33_25_21_20_2_"];
61     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight_Hold]  forKey:@"33_21_20_14_12_2_"];
62     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold]   forKey:@"33_21_20_13_12_2_"];
63     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold]   forKey:@"33_21_20_2_33_21_20_2_"];
64     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Hold]   forKey:@"37_33_21_20_2_37_33_21_20_2_"];
65     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched]  forKey:@"19_"];
66     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kMetallicRemote2009ButtonPlay]       forKey:@"33_21_20_8_2_33_21_20_8_2_"];
67     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kMetallicRemote2009ButtonMiddlePlay] forKey:@"33_21_20_3_2_33_21_20_3_2_"];
68     [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
71 - (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown {
72         if (pressedDown == NO && event == kRemoteButtonMenu_Hold) {
73                 // There is no separate event for pressed down on menu hold. We are simulating that event here
74                 [super sendRemoteButtonEvent:event pressedDown:YES];
75         }
77         [super sendRemoteButtonEvent:event pressedDown:pressedDown];
79         if (pressedDown && (event == kRemoteButtonRight || event == kRemoteButtonLeft || event == kRemoteButtonPlay || event == kRemoteButtonMenu || event == kRemoteButtonPlay_Hold)) {
80                 // There is no separate event when the button is being released. We are simulating that event here
81                 [super sendRemoteButtonEvent:event pressedDown:NO];
82         }
85 @end
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */