Porting Mac keypress detection from GIPS repository.

Mac keypress detection was added specifically for GTalk.
Review URL: http://webrtc-codereview.appspot.com/124001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@453 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
zakkhoyt@google.com 2011-08-25 20:30:25 +00:00
parent ba9bd692ea
commit 59af6f1434
2 changed files with 25 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/*
c/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
@ -13,6 +13,10 @@
#if defined(_WIN32)
#include <windows.h>
#include "event_windows.h"
#elif defined(WEBRTC_MAC_INTEL)
#include <ApplicationServices/ApplicationServices.h>
#include <pthread.h>
#include "event_posix.h"
#else
#include <pthread.h>
#include "event_posix.h"
@ -45,6 +49,21 @@ int EventWrapper::KeyPressed()
{
return 0;
}
#elif defined(WEBRTC_MAC_INTEL)
bool keyDown = false;
// loop through all Mac virtual key constant values
for(int keyIndex = 0; keyIndex <= 0x5C; keyIndex++)
{
keyDown |= CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, keyIndex);
}
if(keyDown)
{
return 1;
}
else
{
return 0;
}
#else
return -1;
#endif

View File

@ -97,6 +97,11 @@
'sources': [
'cpu_mac.cc',
],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework',
],
},
}],
['OS=="win"', {
'sources': [