Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
02fb8b4b
Commit
02fb8b4b
authored
Aug 24, 2012
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macosx/AppleRemote: simplify setters and getters
parent
d94d377a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
76 deletions
+31
-76
modules/gui/macosx/AppleRemote.h
modules/gui/macosx/AppleRemote.h
+17
-29
modules/gui/macosx/AppleRemote.m
modules/gui/macosx/AppleRemote.m
+14
-47
No files found.
modules/gui/macosx/AppleRemote.h
View file @
02fb8b4b
...
...
@@ -93,9 +93,9 @@ The class is not thread safe
NSMutableDictionary
*
cookieToButtonMapping
;
CFRunLoopSourceRef
eventSource
;
BOOL
openInExclusiveMode
;
BOOL
simulatePlusMinusHold
;
BOOL
processesBacklog
;
BOOL
_
openInExclusiveMode
;
BOOL
_
simulatePlusMinusHold
;
BOOL
_
processesBacklog
;
/* state for simulating plus/minus hold */
BOOL
lastEventSimulatedHold
;
...
...
@@ -103,25 +103,20 @@ The class is not thread safe
NSTimeInterval
lastPlusMinusEventTime
;
int
remoteId
;
unsigned
int
clickCountEnabledButtons
;
NSTimeInterval
maxClickTimeDifference
;
unsigned
int
_
clickCountEnabledButtons
;
NSTimeInterval
_
maxClickTimeDifference
;
NSTimeInterval
lastClickCountEventTime
;
AppleRemoteEventIdentifier
lastClickCountEvent
;
unsigned
int
eventClickCount
;
IBOutlet
id
delegate
;
id
delegate
;
}
+
(
AppleRemote
*
)
sharedInstance
;
-
(
int
)
remoteId
;
-
(
BOOL
)
isRemoteAvailable
;
-
(
BOOL
)
isListeningToRemote
;
-
(
void
)
setListeningToRemote
:
(
BOOL
)
value
;
-
(
BOOL
)
isOpenInExclusiveMode
;
-
(
void
)
setOpenInExclusiveMode
:
(
BOOL
)
value
;
@property
(
readonly
)
int
remoteId
;
@property
(
readonly
)
BOOL
remoteAvailable
;
@property
(
readwrite
)
BOOL
listeningToRemote
;
@property
(
readwrite
)
BOOL
openInExclusiveMode
;
/* click counting makes it possible to recognize if the user has pressed a button repeatedly
* click counting does delay each event as it has to wait if there is another event (second click)
...
...
@@ -129,38 +124,31 @@ The class is not thread safe
* of the user and the call of your delegate method
* click counting can be enabled individually for specific buttons. Use the property clickCountEnableButtons
* to set the buttons for which click counting shall be enabled */
-
(
BOOL
)
clickCountingEnabled
;
-
(
void
)
setClickCountingEnabled
:
(
BOOL
)
value
;
@property
(
readwrite
)
BOOL
clickCountingEnabled
;
-
(
unsigned
int
)
clickCountEnabledButtons
;
-
(
void
)
setClickCountEnabledButtons
:
(
unsigned
int
)
value
;
@property
(
readwrite
)
unsigned
int
clickCountEnabledButtons
;
/* the maximum time difference till which clicks are recognized as multi clicks */
-
(
NSTimeInterval
)
maximumClickCountTimeDifference
;
-
(
void
)
setMaximumClickCountTimeDifference
:
(
NSTimeInterval
)
timeDiff
;
@property
(
readwrite
)
NSTimeInterval
maximumClickCountTimeDifference
;
/* When your application needs to much time on the main thread when processing an event other events
* may already be received which are put on a backlog. As soon as your main thread
* has some spare time this backlog is processed and may flood your delegate with calls.
* Backlog processing is turned off by default. */
-
(
BOOL
)
processesBacklog
;
-
(
void
)
setProcessesBacklog
:
(
BOOL
)
value
;
@property
(
readwrite
)
BOOL
processesBacklog
;
/* Sets an NSApplication delegate which starts listening when application is becoming active
* and stops listening when application resigns being active.
* If an NSApplication delegate has been already set all method calls will be forwarded to this delegate, too. */
-
(
BOOL
)
listeningOnAppActivate
;
-
(
void
)
setListeningOnAppActivate
:
(
BOOL
)
value
;
@property
(
readwrite
)
BOOL
listeningOnAppActivate
;
/* Simulating plus/minus hold does deactivate sending of individual requests for plus/minus pressed down/released.
* Instead special hold events are being triggered when the user is pressing and holding plus/minus for a small period.
* With simulating enabled the plus/minus buttons do behave as the left/right buttons */
-
(
BOOL
)
simulatesPlusMinusHold
;
-
(
void
)
setSimulatesPlusMinusHold
:
(
BOOL
)
value
;
@property
(
readwrite
)
BOOL
simulatesPlusMinusHold
;
/* Delegates are not retained */
-
(
void
)
setDelegate
:
(
id
)
delegate
;
-
(
id
)
delegate
;
@property
(
readwrite
,
assign
)
id
delegate
;
-
(
IBAction
)
startListening
:
(
id
)
sender
;
-
(
IBAction
)
stopListening
:
(
id
)
sender
;
...
...
modules/gui/macosx/AppleRemote.m
View file @
02fb8b4b
...
...
@@ -64,6 +64,8 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
@implementation
AppleRemote
@synthesize
openInExclusiveMode
=
_openInExclusiveMode
,
clickCountEnabledButtons
=
_clickCountEnabledButtons
,
maximumClickCountTimeDifference
=
_maxClickTimeDifference
,
processesBacklog
=
_processesBacklog
,
simulatesPlusMinusHold
=
_simulatePlusMinusHold
;
#pragma public interface
static
AppleRemote
*
_o_sharedInstance
=
nil
;
...
...
@@ -79,7 +81,7 @@ static AppleRemote *_o_sharedInstance = nil;
[
self
dealloc
];
}
else
{
_o_sharedInstance
=
[
super
init
];
openInExclusiveMode
=
YES
;
_
openInExclusiveMode
=
YES
;
queue
=
NULL
;
hidDeviceInterface
=
NULL
;
cookieToButtonMapping
=
[[
NSMutableDictionary
alloc
]
init
];
...
...
@@ -139,7 +141,7 @@ static AppleRemote *_o_sharedInstance = nil;
/* defaults */
[
self
setSimulatesPlusMinusHold
:
YES
];
maxClickTimeDifference
=
DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE
;
_
maxClickTimeDifference
=
DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE
;
}
return
_o_sharedInstance
;
...
...
@@ -155,7 +157,7 @@ static AppleRemote *_o_sharedInstance = nil;
return
remoteId
;
}
-
(
BOOL
)
isR
emoteAvailable
{
-
(
BOOL
)
r
emoteAvailable
{
io_object_t
hidDevice
=
[
self
findAppleRemoteDevice
];
if
(
hidDevice
!=
0
)
{
IOObjectRelease
(
hidDevice
);
...
...
@@ -165,7 +167,7 @@ static AppleRemote *_o_sharedInstance = nil;
}
}
-
(
BOOL
)
isL
isteningToRemote
{
-
(
BOOL
)
l
isteningToRemote
{
return
(
hidDeviceInterface
!=
NULL
&&
allCookies
!=
NULL
&&
queue
!=
NULL
);
}
...
...
@@ -191,15 +193,8 @@ static AppleRemote *_o_sharedInstance = nil;
return
delegate
;
}
-
(
BOOL
)
isOpenInExclusiveMode
{
return
openInExclusiveMode
;
}
-
(
void
)
setOpenInExclusiveMode
:
(
BOOL
)
value
{
openInExclusiveMode
=
value
;
}
-
(
BOOL
)
clickCountingEnabled
{
return
clickCountEnabledButtons
!=
0
;
return
self
.
clickCountEnabledButtons
!=
0
;
}
-
(
void
)
setClickCountingEnabled
:
(
BOOL
)
value
{
if
(
value
)
{
...
...
@@ -209,27 +204,6 @@ static AppleRemote *_o_sharedInstance = nil;
}
}
-
(
unsigned
int
)
clickCountEnabledButtons
{
return
clickCountEnabledButtons
;
}
-
(
void
)
setClickCountEnabledButtons
:
(
unsigned
int
)
value
{
clickCountEnabledButtons
=
value
;
}
-
(
NSTimeInterval
)
maximumClickCountTimeDifference
{
return
maxClickTimeDifference
;
}
-
(
void
)
setMaximumClickCountTimeDifference
:
(
NSTimeInterval
)
timeDiff
{
maxClickTimeDifference
=
timeDiff
;
}
-
(
BOOL
)
processesBacklog
{
return
processesBacklog
;
}
-
(
void
)
setProcessesBacklog
:
(
BOOL
)
value
{
processesBacklog
=
value
;
}
-
(
BOOL
)
listeningOnAppActivate
{
id
appDelegate
=
[
NSApp
delegate
];
return
(
appDelegate
!=
nil
&&
[
appDelegate
isKindOfClass
:
[
AppleRemoteApplicationDelegate
class
]]);
...
...
@@ -249,15 +223,8 @@ static AppleRemote *_o_sharedInstance = nil;
}
}
-
(
BOOL
)
simulatesPlusMinusHold
{
return
simulatePlusMinusHold
;
}
-
(
void
)
setSimulatesPlusMinusHold
:
(
BOOL
)
value
{
simulatePlusMinusHold
=
value
;
}
-
(
IBAction
)
startListening
:
(
id
)
sender
{
if
([
self
isL
isteningToRemote
])
return
;
if
([
self
l
isteningToRemote
])
return
;
io_object_t
hidDevice
=
[
self
findAppleRemoteDevice
];
if
(
hidDevice
==
0
)
return
;
...
...
@@ -401,7 +368,7 @@ static AppleRemote* sharedInstance=nil;
-
(
void
)
sendRemoteButtonEvent
:
(
AppleRemoteEventIdentifier
)
event
pressedDown
:
(
BOOL
)
pressedDown
{
if
(
delegate
)
{
if
(
s
imulate
PlusMinusHold
)
{
if
(
s
elf
.
simulates
PlusMinusHold
)
{
if
(
event
==
kRemoteButtonVolume_Plus
||
event
==
kRemoteButtonVolume_Minus
)
{
if
(
pressedDown
)
{
lastPlusMinusEvent
=
event
;
...
...
@@ -425,7 +392,7 @@ static AppleRemote* sharedInstance=nil;
}
}
if
((
[
self
clickCountEnabledButtons
]
&
event
)
==
event
)
{
if
((
self
.
clickCountEnabledButtons
&
event
)
==
event
)
{
if
(
pressedDown
==
NO
&&
(
event
==
kRemoteButtonVolume_Minus
||
event
==
kRemoteButtonVolume_Plus
))
{
return
;
// this one is triggered automatically by the handler
}
...
...
@@ -444,7 +411,7 @@ static AppleRemote* sharedInstance=nil;
}
[
self
performSelector
:
@selector
(
executeClickCountEvent
:)
withObject:
[
NSArray
arrayWithObjects
:
eventNumber
,
timeNumber
,
nil
]
afterDelay:
maxClickTimeDifference
];
afterDelay:
_
maxClickTimeDifference
];
}
else
{
[
delegate
appleRemoteButton
:
event
pressedDown
:
pressedDown
clickCount
:
1
];
}
...
...
@@ -493,9 +460,9 @@ static AppleRemote* sharedInstance=nil;
while
((
subCookieString
=
[
self
validCookieSubstring
:
cookieString
]))
{
cookieString
=
[
cookieString
substringFromIndex
:
[
subCookieString
length
]];
lastSubCookieString
=
subCookieString
;
if
(
processesBacklog
)
[
self
handleEventWithCookieString
:
subCookieString
sumOfValues
:
sumOfValues
];
if
(
self
.
processesBacklog
)
[
self
handleEventWithCookieString
:
subCookieString
sumOfValues
:
sumOfValues
];
}
if
(
processesBacklog
==
NO
&&
lastSubCookieString
!=
nil
)
{
if
(
self
.
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.
...
...
@@ -661,7 +628,7 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
HRESULT
result
;
IOHIDOptionsType
openMode
=
kIOHIDOptionsTypeNone
;
if
([
self
isO
penInExclusiveMode
])
openMode
=
kIOHIDOptionsTypeSeizeDevice
;
if
([
self
o
penInExclusiveMode
])
openMode
=
kIOHIDOptionsTypeSeizeDevice
;
IOReturn
ioReturnValue
=
(
*
hidDeviceInterface
)
->
open
(
hidDeviceInterface
,
openMode
);
if
(
ioReturnValue
==
KERN_SUCCESS
)
{
...
...
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