 +#include <math.h>
 +
 +static EventQueue event_queue;
-+
-+struct SDL_NACL_Event {
-+  PP_InputEvent_Type type;
-+  Uint8 button;
-+  SDL_keysym keysym;
-+  int32_t x, y;
-+  int32_t wheel_clicks_x;
-+  int32_t wheel_clicks_y;
-+};
 +
 +static Uint8 translateButton(int32_t button) {
 +  switch (button) {

 	/* Allow ourselves to be asynchronously cancelled */
diff -urN SDL-1.2.14/src/video/nacl/eventqueue.h SDL-1.2.14-nacl/src/video/nacl/eventqueue.h
--- SDL-1.2.14/src/video/nacl/eventqueue.h	1970-01-01 03:00:00.000000000 +0300
+++ SDL-1.2.14-nacl/src/video/nacl/eventqueue.h	2012-01-16 12:16:39.470269368 +0400
@@ -0,0 +1,43 @@
+#ifndef _SDL_nacl_eventqueue_h
+#define _SDL_nacl_eventqueue_h
+
+#include "SDL_mutex.h"
+
+#include <queue>
+#include <ppapi/c/pp_input_event.h>
+
+struct SDL_NACL_Event;
+
+class EventQueue {
+public:

+        keysym.sym = translateKey(keysym.scancode);
+      }
+    } else {  // event->type == PP_INPUTEVENT_TYPE_KEYUP
+      event.type = SDL_KEYUP;
+      last_scancode = 0;
+    }
+    keysym.mod = KMOD_NONE;
+    event.key.keysym = keysym;
+    event_queue.PushEvent(copyEvent(&event));
+  } else if (type == PP_INPUTEVENT_TYPE_MOUSEENTER ||
+             type == PP_INPUTEVENT_TYPE_MOUSELEAVE) {
+    event.type = SDL_ACTIVEEVENT;
+    event.active.gain = (type == PP_INPUTEVENT_TYPE_MOUSEENTER) ? 1 : 0;
+    event.active.state = SDL_APPMOUSEFOCUS;
+    event_queue.PushEvent(copyEvent(&event));
+  }
+}
+
+void SDL_NACL_SetHasFocus(bool has_focus) {
+  SDL_Event event;
+  event.type = SDL_ACTIVEEVENT;
+  event.active.gain = has_focus ? 1 : 0;
+  event.active.state = SDL_APPINPUTFOCUS;
+  event_queue.PushEvent(copyEvent(&event));
+}
+
+void SDL_NACL_SetPageVisible(bool is_visible) {
+  SDL_Event event;
+  event.type = SDL_ACTIVEEVENT;
+  event.active.gain = is_visible ? 1 : 0;
+  event.active.state = SDL_APPACTIVE;
+  event_queue.PushEvent(copyEvent(&event));
+}
+
+void NACL_PumpEvents(_THIS) {
+  SDL_Event* event;
+  while (event = event_queue.PopEvent()) {
+    if (event->type == SDL_MOUSEBUTTONDOWN) {
+      SDL_PrivateMouseButton(SDL_PRESSED, event->button.button,
+                             event->button.x, event->button.y);
+    } else if (event->type == SDL_MOUSEBUTTONUP) {
+      SDL_PrivateMouseButton(SDL_RELEASED, event->button.button,
+                             event->button.x, event->button.y);
+    } else if (event->type == SDL_MOUSEMOTION) {
+      SDL_PrivateMouseMotion(0, 0, event->motion.x, event->motion.y);
+    } else if (event->type == SDL_KEYDOWN) {
+      SDL_PrivateKeyboard(SDL_PRESSED, &event->key.keysym);
+    } else if (event->type == SDL_KEYUP) {
+      SDL_PrivateKeyboard(SDL_RELEASED, &event->key.keysym);
+    } else if (event->type == SDL_ACTIVEEVENT) {
+      SDL_PrivateAppActive(event->active.gain, event->active.state);
+    }
+    free(event);
+  }
