2007-10-03 22:26:39 +00:00
|
|
|
//
|
|
|
|
// MediaKeysApplication.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 10/3/07.
|
|
|
|
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MediaKeysApplication.h"
|
|
|
|
#import "AppController.h"
|
|
|
|
|
|
|
|
@implementation MediaKeysApplication
|
|
|
|
|
|
|
|
- (void)mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat
|
|
|
|
{
|
|
|
|
switch( key )
|
|
|
|
{
|
|
|
|
case NX_KEYTYPE_PLAY:
|
|
|
|
if( state == 0 )
|
2013-10-03 08:00:58 +00:00
|
|
|
[(AppController *)[self delegate] clickPlay]; //Play pressed and released
|
2007-10-03 22:26:39 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-02 19:20:08 +00:00
|
|
|
case NX_KEYTYPE_NEXT:
|
2007-10-03 22:26:39 +00:00
|
|
|
case NX_KEYTYPE_FAST:
|
|
|
|
if( state == 0 )
|
2013-10-03 08:00:58 +00:00
|
|
|
[(AppController *)[self delegate] clickNext]; //Next pressed and released
|
2007-10-03 22:26:39 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-02 19:20:08 +00:00
|
|
|
case NX_KEYTYPE_PREVIOUS:
|
2007-10-03 22:26:39 +00:00
|
|
|
case NX_KEYTYPE_REWIND:
|
|
|
|
if( state == 0 )
|
2013-10-03 08:00:58 +00:00
|
|
|
[(AppController *)[self delegate] clickPrev]; //Previous pressed and released
|
2007-10-03 22:26:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sendEvent: (NSEvent*)event
|
|
|
|
{
|
|
|
|
if( [event type] == NSSystemDefined && [event subtype] == 8 )
|
|
|
|
{
|
|
|
|
int keyCode = (([event data1] & 0xFFFF0000) >> 16);
|
|
|
|
int keyFlags = ([event data1] & 0x0000FFFF);
|
|
|
|
int keyState = (((keyFlags & 0xFF00) >> 8)) ==0xA;
|
|
|
|
int keyRepeat = (keyFlags & 0x1);
|
|
|
|
|
|
|
|
[self mediaKeyEvent: keyCode state: keyState repeat: keyRepeat];
|
|
|
|
}
|
|
|
|
|
|
|
|
[super sendEvent: event];
|
|
|
|
}
|
|
|
|
@end
|