blob: 01286d868e8a31c6ab3ad2113b8477fa74edc9fb [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "event_wrapper.h"
12
13#if defined(_WIN32)
14 #include <windows.h>
15 #include "event_windows.h"
16#else
17 #include <pthread.h>
ajm@google.comb5c49ff2011-08-01 17:04:04 +000018 #include "event_posix.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019#endif
20
21namespace webrtc {
22EventWrapper* EventWrapper::Create()
23{
24#if defined(_WIN32)
25 return new EventWindows();
26#else
ajm@google.comb5c49ff2011-08-01 17:04:04 +000027 return EventPosix::Create();
niklase@google.com470e71d2011-07-07 08:21:25 +000028#endif
29}
30
31int EventWrapper::KeyPressed()
32{
33#if defined(_WIN32)
34 int keyDown = 0;
35 for(int key = 0x20; key < 0x90; key++)
36 {
37 short res = GetAsyncKeyState(key);
38 keyDown |= res%2; // Get the LSB
39 }
40 if(keyDown)
41 {
42 return 1;
43 }
44 else
45 {
46 return 0;
47 }
48#else
49 return -1;
50#endif
51}
52} // namespace webrtc