Reformatted event* classes.

TEST=Ran trybots.

Review URL: https://webrtc-codereview.appspot.com/972012

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3253 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
phoglund@webrtc.org
2012-12-10 10:44:37 +00:00
parent 3bb42ef0d6
commit 5bbe069f28
6 changed files with 390 additions and 451 deletions

View File

@ -8,64 +8,55 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "event_wrapper.h"
#include "webrtc/system_wrappers/interface/event_wrapper.h"
#if defined(_WIN32)
#include <windows.h>
#include "event_win.h"
#include <windows.h>
#include "webrtc/system_wrappers/source/event_win.h"
#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
#include <ApplicationServices/ApplicationServices.h>
#include <pthread.h>
#include "event_posix.h"
#include <ApplicationServices/ApplicationServices.h>
#include <pthread.h>
#include "webrtc/system_wrappers/source/event_posix.h"
#else
#include <pthread.h>
#include "event_posix.h"
#include <pthread.h>
#include "webrtc/system_wrappers/source/event_posix.h"
#endif
namespace webrtc {
EventWrapper* EventWrapper::Create()
{
EventWrapper* EventWrapper::Create() {
#if defined(_WIN32)
return new EventWindows();
return new EventWindows();
#else
return EventPosix::Create();
return EventPosix::Create();
#endif
}
int EventWrapper::KeyPressed()
{
int EventWrapper::KeyPressed() {
#if defined(_WIN32)
int keyDown = 0;
for(int key = 0x20; key < 0x90; key++)
{
short res = GetAsyncKeyState(key);
keyDown |= res%2; // Get the LSB
}
if(keyDown)
{
return 1;
}
else
{
return 0;
}
int key_down = 0;
for (int key = 0x20; key < 0x90; key++) {
short res = GetAsyncKeyState(key);
key_down |= res % 2; // Get the LSB
}
if (key_down) {
return 1;
} else {
return 0;
}
#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
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;
}
bool key_down = false;
// loop through all Mac virtual key constant values
for (int key_index = 0; key_index <= 0x5C; key_index++) {
key_down |= CGEventSourceKeyState(kCGEventSourceStateHIDSystemState,
key_index);
}
if (key_down) {
return 1;
} else {
return 0;
}
#else
return -1;
return -1;
#endif
}
} // namespace webrtc