Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: libraries/SDL-1.2.14/nacl-SDL-1.2.14.patch

Issue 9860021: Support SDL_ActiveEvent (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 diff -urN SDL-1.2.14/build-scripts/config.sub SDL-1.2.14-nacl/build-scripts/conf ig.sub 1 diff -urN SDL-1.2.14/build-scripts/config.sub SDL-1.2.14-nacl/build-scripts/conf ig.sub
2 --- SDL-1.2.14/build-scripts/config.sub 2009-10-13 03:07:12.000000000 +0400 2 --- SDL-1.2.14/build-scripts/config.sub 2009-10-13 03:07:12.000000000 +0400
3 +++ SDL-1.2.14-nacl/build-scripts/config.sub 2012-01-16 12:16:39.460269192 +0 400 3 +++ SDL-1.2.14-nacl/build-scripts/config.sub 2012-01-16 12:16:39.460269192 +0 400
4 @@ -318,6 +318,14 @@ 4 @@ -318,6 +318,14 @@
5 i*86 | x86_64) 5 i*86 | x86_64)
6 basic_machine=$basic_machine-pc 6 basic_machine=$basic_machine-pc
7 ;; 7 ;;
8 + nacl64*) 8 + nacl64*)
9 + basic_machine=x86_64-pc 9 + basic_machine=x86_64-pc
10 + os=-nacl 10 + os=-nacl
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 @@ -265,6 +266,7 @@ 91 @@ -265,6 +266,7 @@
92 #undef SDL_VIDEO_DRIVER_GEM 92 #undef SDL_VIDEO_DRIVER_GEM
93 #undef SDL_VIDEO_DRIVER_GGI 93 #undef SDL_VIDEO_DRIVER_GGI
94 #undef SDL_VIDEO_DRIVER_IPOD 94 #undef SDL_VIDEO_DRIVER_IPOD
95 +#undef SDL_VIDEO_DRIVER_NACL 95 +#undef SDL_VIDEO_DRIVER_NACL
96 #undef SDL_VIDEO_DRIVER_NANOX 96 #undef SDL_VIDEO_DRIVER_NANOX
97 #undef SDL_VIDEO_DRIVER_OS2FS 97 #undef SDL_VIDEO_DRIVER_OS2FS
98 #undef SDL_VIDEO_DRIVER_PHOTON 98 #undef SDL_VIDEO_DRIVER_PHOTON
99 diff -urN SDL-1.2.14/include/SDL_nacl.h SDL-1.2.14-nacl/include/SDL_nacl.h 99 diff -urN SDL-1.2.14/include/SDL_nacl.h SDL-1.2.14-nacl/include/SDL_nacl.h
100 --- SDL-1.2.14/include/SDL_nacl.h 1970-01-01 03:00:00.000000000 +0300 100 --- SDL-1.2.14/include/SDL_nacl.h 1970-01-01 03:00:00.000000000 +0300
101 +++ SDL-1.2.14-nacl/include/SDL_nacl.h» 2012-01-16 12:16:39.460269192 +0400 101 +++ SDL-1.2.14-nacl/include/SDL_nacl.h» 2012-03-25 08:05:23.160195017 +0400
102 @@ -0,0 +1,22 @@ 102 @@ -0,0 +1,24 @@
103 +#ifndef _SDL_nacl_h 103 +#ifndef _SDL_nacl_h
104 +#define _SDL_nacl_h 104 +#define _SDL_nacl_h
105 + 105 +
106 +#include "begin_code.h" 106 +#include "begin_code.h"
107 +#include <ppapi/cpp/input_event.h> 107 +#include <ppapi/cpp/input_event.h>
108 + 108 +
109 +/* Set up for C function definitions, even when using C++ */ 109 +/* Set up for C function definitions, even when using C++ */
110 +#ifdef __cplusplus 110 +#ifdef __cplusplus
111 +extern "C" { 111 +extern "C" {
112 +#endif 112 +#endif
113 + 113 +
114 +#include <ppapi/c/ppp_instance.h> 114 +#include <ppapi/c/ppp_instance.h>
115 +void SDL_NACL_SetInstance(PP_Instance instance, int width, int height); 115 +void SDL_NACL_SetInstance(PP_Instance instance, int width, int height);
116 +void SDL_NACL_PushEvent(const pp::InputEvent& ppevent); 116 +void SDL_NACL_PushEvent(const pp::InputEvent& ppevent);
117 +void SDL_NACL_SetHasFocus(bool has_focus);
118 +void SDL_NACL_SetPageVisible(bool is_visible);
117 + 119 +
118 +/* Ends C function definitions when using C++ */ 120 +/* Ends C function definitions when using C++ */
119 +#ifdef __cplusplus 121 +#ifdef __cplusplus
120 +} 122 +}
121 +#endif 123 +#endif
122 +#include "close_code.h" 124 +#include "close_code.h"
123 + 125 +
124 +#endif /* _SDL_nacl_h */ 126 +#endif /* _SDL_nacl_h */
125 diff -urN SDL-1.2.14/include/SDL_platform.h SDL-1.2.14-nacl/include/SDL_platform .h 127 diff -urN SDL-1.2.14/include/SDL_platform.h SDL-1.2.14-nacl/include/SDL_platform .h
126 --- SDL-1.2.14/include/SDL_platform.h 2009-10-13 03:07:19.000000000 +0400 128 --- SDL-1.2.14/include/SDL_platform.h 2009-10-13 03:07:19.000000000 +0400
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 for ( i=0; sig_list[i]; ++i ) { 413 for ( i=0; sig_list[i]; ++i ) {
412 sigaddset(&mask, sig_list[i]); 414 sigaddset(&mask, sig_list[i]);
413 } 415 }
414 pthread_sigmask(SIG_BLOCK, &mask, 0); 416 pthread_sigmask(SIG_BLOCK, &mask, 0);
415 +#endif 417 +#endif
416 418
417 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS 419 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS
418 /* Allow ourselves to be asynchronously cancelled */ 420 /* Allow ourselves to be asynchronously cancelled */
419 diff -urN SDL-1.2.14/src/video/nacl/eventqueue.h SDL-1.2.14-nacl/src/video/nacl/ eventqueue.h 421 diff -urN SDL-1.2.14/src/video/nacl/eventqueue.h SDL-1.2.14-nacl/src/video/nacl/ eventqueue.h
420 --- SDL-1.2.14/src/video/nacl/eventqueue.h 1970-01-01 03:00:00.000000000 +0 300 422 --- SDL-1.2.14/src/video/nacl/eventqueue.h 1970-01-01 03:00:00.000000000 +0 300
421 +++ SDL-1.2.14-nacl/src/video/nacl/eventqueue.h»2012-01-16 12:16:39.470269368 +0 400 423 +++ SDL-1.2.14-nacl/src/video/nacl/eventqueue.h»2012-03-25 09:10:10.058485979 +0 400
422 @@ -0,0 +1,43 @@ 424 @@ -0,0 +1,40 @@
423 +#ifndef _SDL_nacl_eventqueue_h 425 +#ifndef _SDL_nacl_eventqueue_h
424 +#define _SDL_nacl_eventqueue_h 426 +#define _SDL_nacl_eventqueue_h
425 + 427 +
426 +#include "SDL_mutex.h" 428 +#include "SDL_mutex.h"
427 + 429 +
428 +#include <queue> 430 +#include <queue>
429 +#include <ppapi/c/pp_input_event.h>
430 +
431 +struct SDL_NACL_Event;
432 + 431 +
433 +class EventQueue { 432 +class EventQueue {
434 +public: 433 +public:
435 + EventQueue() { 434 + EventQueue() {
436 + mu_ = SDL_CreateMutex(); 435 + mu_ = SDL_CreateMutex();
437 + } 436 + }
438 + 437 +
439 + ~EventQueue() { 438 + ~EventQueue() {
440 + SDL_DestroyMutex(mu_); 439 + SDL_DestroyMutex(mu_);
441 + } 440 + }
442 + 441 +
443 + SDL_NACL_Event* PopEvent() { 442 + SDL_Event* PopEvent() {
444 + SDL_LockMutex(mu_); 443 + SDL_LockMutex(mu_);
445 + SDL_NACL_Event* event = NULL; 444 + SDL_Event* event = NULL;
446 + if (!queue_.empty()) { 445 + if (!queue_.empty()) {
447 + event = queue_.front(); 446 + event = queue_.front();
448 + queue_.pop(); 447 + queue_.pop();
449 + } 448 + }
450 + SDL_UnlockMutex(mu_); 449 + SDL_UnlockMutex(mu_);
451 + return event; 450 + return event;
452 + } 451 + }
453 + 452 +
454 + void PushEvent(SDL_NACL_Event* event) { 453 + void PushEvent(SDL_Event* event) {
455 + SDL_LockMutex(mu_); 454 + SDL_LockMutex(mu_);
456 + queue_.push(event); 455 + queue_.push(event);
457 + SDL_UnlockMutex(mu_); 456 + SDL_UnlockMutex(mu_);
458 + } 457 + }
459 + 458 +
460 +private: 459 +private:
461 + std::queue<SDL_NACL_Event*> queue_; 460 + std::queue<SDL_Event*> queue_;
462 + SDL_mutex* mu_; 461 + SDL_mutex* mu_;
463 +}; 462 +};
464 + 463 +
465 +#endif // _SDL_nacl_eventqueue_h 464 +#endif // _SDL_nacl_eventqueue_h
466 diff -urN SDL-1.2.14/src/video/nacl/MainThreadRunner.cc SDL-1.2.14-nacl/src/vide o/nacl/MainThreadRunner.cc 465 diff -urN SDL-1.2.14/src/video/nacl/MainThreadRunner.cc SDL-1.2.14-nacl/src/vide o/nacl/MainThreadRunner.cc
467 --- SDL-1.2.14/src/video/nacl/MainThreadRunner.cc 1970-01-01 03:00:00.0000 00000 +0300 466 --- SDL-1.2.14/src/video/nacl/MainThreadRunner.cc 1970-01-01 03:00:00.0000 00000 +0300
468 +++ SDL-1.2.14-nacl/src/video/nacl/MainThreadRunner.cc 2012-03-21 03:17:01.1504 49516 +0400 467 +++ SDL-1.2.14-nacl/src/video/nacl/MainThreadRunner.cc 2012-03-21 03:17:01.1504 49516 +0400
469 @@ -0,0 +1,227 @@ 468 @@ -0,0 +1,227 @@
470 +/* 469 +/*
471 + * Copyright (c) 2012 The Native Client Authors. All rights reserved. 470 + * Copyright (c) 2012 The Native Client Authors. All rights reserved.
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 + public: 794 + public:
796 + virtual ~MainThreadJob() {} 795 + virtual ~MainThreadJob() {}
797 + virtual void Run(MainThreadRunner::JobEntry *entry) = 0; 796 + virtual void Run(MainThreadRunner::JobEntry *entry) = 0;
798 +}; 797 +};
799 + 798 +
800 +// MainThreadRunner executes MainThreadJobs asynchronously 799 +// MainThreadRunner executes MainThreadJobs asynchronously
801 + 800 +
802 +#endif // LIBRARIES_NACL_MOUNTS_BASE_MAINTHREADRUNNER_H_ 801 +#endif // LIBRARIES_NACL_MOUNTS_BASE_MAINTHREADRUNNER_H_
803 diff -urN SDL-1.2.14/src/video/nacl/SDL_naclevents.cc SDL-1.2.14-nacl/src/video/ nacl/SDL_naclevents.cc 802 diff -urN SDL-1.2.14/src/video/nacl/SDL_naclevents.cc SDL-1.2.14-nacl/src/video/ nacl/SDL_naclevents.cc
804 --- SDL-1.2.14/src/video/nacl/SDL_naclevents.cc 1970-01-01 03:00:00.000000000 +0 300 803 --- SDL-1.2.14/src/video/nacl/SDL_naclevents.cc 1970-01-01 03:00:00.000000000 +0 300
805 +++ SDL-1.2.14-nacl/src/video/nacl/SDL_naclevents.cc» 2012-01-16 12:20:38.7944 63980 +0400 804 +++ SDL-1.2.14-nacl/src/video/nacl/SDL_naclevents.cc» 2012-03-27 05:28:18.5396 56031 +0400
806 @@ -0,0 +1,282 @@ 805 @@ -0,0 +1,307 @@
807 +#include "SDL_config.h" 806 +#include "SDL_config.h"
808 + 807 +
809 +#include "SDL_nacl.h" 808 +#include "SDL_nacl.h"
810 + 809 +
811 +extern "C" { 810 +extern "C" {
812 +#include "SDL.h" 811 +#include "SDL.h"
813 +#include "../../events/SDL_sysevents.h" 812 +#include "../../events/SDL_sysevents.h"
814 +#include "../../events/SDL_events_c.h" 813 +#include "../../events/SDL_events_c.h"
815 +} 814 +}
816 + 815 +
817 +#include "SDL_naclevents_c.h" 816 +#include "SDL_naclevents_c.h"
818 +#include "eventqueue.h" 817 +#include "eventqueue.h"
819 +#include <ppapi/cpp/input_event.h> 818 +#include <ppapi/cpp/input_event.h>
820 +#include <ppapi/cpp/point.h> 819 +#include <ppapi/cpp/point.h>
821 +#include <ppapi/cpp/var.h> 820 +#include <ppapi/cpp/var.h>
822 + 821 +
823 +#include <math.h> 822 +#include <math.h>
824 + 823 +
825 +static EventQueue event_queue; 824 +static EventQueue event_queue;
826 + 825 +
827 +struct SDL_NACL_Event {
828 + PP_InputEvent_Type type;
829 + Uint8 button;
830 + SDL_keysym keysym;
831 + int32_t x, y;
832 + int32_t wheel_clicks_x;
833 + int32_t wheel_clicks_y;
834 +};
835 +
836 +static Uint8 translateButton(int32_t button) { 826 +static Uint8 translateButton(int32_t button) {
837 + switch (button) { 827 + switch (button) {
838 + case PP_INPUTEVENT_MOUSEBUTTON_LEFT: 828 + case PP_INPUTEVENT_MOUSEBUTTON_LEFT:
839 + return SDL_BUTTON_LEFT; 829 + return SDL_BUTTON_LEFT;
840 + case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE: 830 + case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE:
841 + return SDL_BUTTON_MIDDLE; 831 + return SDL_BUTTON_MIDDLE;
842 + case PP_INPUTEVENT_MOUSEBUTTON_RIGHT: 832 + case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
843 + return SDL_BUTTON_RIGHT; 833 + return SDL_BUTTON_RIGHT;
844 + case PP_INPUTEVENT_MOUSEBUTTON_NONE: 834 + case PP_INPUTEVENT_MOUSEBUTTON_NONE:
845 + default: 835 + default:
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 + return SDLK_PERIOD; 959 + return SDLK_PERIOD;
970 + case 191: 960 + case 191:
971 + return SDLK_SLASH; 961 + return SDLK_SLASH;
972 + case 192: 962 + case 192:
973 + return SDLK_BACKQUOTE; 963 + return SDLK_BACKQUOTE;
974 + default: 964 + default:
975 + return SDLK_UNKNOWN; 965 + return SDLK_UNKNOWN;
976 + } 966 + }
977 +} 967 +}
978 + 968 +
969 +static SDL_Event *copyEvent(SDL_Event *event) {
970 + SDL_Event *event_copy = (SDL_Event*)malloc(sizeof(SDL_Event));
971 + *event_copy = *event;
972 + return event_copy;
973 +}
974 +
979 +void SDL_NACL_PushEvent(const pp::InputEvent& ppevent) { 975 +void SDL_NACL_PushEvent(const pp::InputEvent& ppevent) {
980 + static Uint8 last_scancode = 0; 976 + static Uint8 last_scancode = 0;
981 + SDL_keysym keysym; 977 + SDL_keysym keysym;
982 + struct SDL_NACL_Event* event =
983 + (struct SDL_NACL_Event*)malloc(sizeof(struct SDL_NACL_Event));
984 + static double wheel_clicks_x; 978 + static double wheel_clicks_x;
985 + static double wheel_clicks_y; 979 + static double wheel_clicks_y;
986 + event->type = ppevent.GetType(); 980 + SDL_Event event;
981 + PP_InputEvent_Type type = ppevent.GetType();
987 + 982 +
988 + pp::InputEvent *input_event = const_cast<pp::InputEvent*>(&ppevent); 983 + pp::InputEvent *input_event = const_cast<pp::InputEvent*>(&ppevent);
989 + 984 +
990 + if (event->type == PP_INPUTEVENT_TYPE_MOUSEDOWN || 985 + if (type == PP_INPUTEVENT_TYPE_MOUSEDOWN ||
991 + event->type == PP_INPUTEVENT_TYPE_MOUSEUP) { 986 + type == PP_INPUTEVENT_TYPE_MOUSEUP) {
992 + pp::MouseInputEvent *mouse_event = 987 + pp::MouseInputEvent *mouse_event =
993 + reinterpret_cast<pp::MouseInputEvent*>(input_event); 988 + reinterpret_cast<pp::MouseInputEvent*>(input_event);
994 + event->button = translateButton(mouse_event->GetButton()); 989 + event.type = (type == PP_INPUTEVENT_TYPE_MOUSEUP) ? SDL_MOUSEBUTTONUP : SDL _MOUSEBUTTONDOWN;
995 + } else if (event->type == PP_INPUTEVENT_TYPE_WHEEL) { 990 + event.button.button = translateButton(mouse_event->GetButton());
991 + event.button.x = mouse_event->GetPosition().x();
992 + event.button.y = mouse_event->GetPosition().y();
993 + event_queue.PushEvent(copyEvent(&event));
994 + } else if (type == PP_INPUTEVENT_TYPE_WHEEL) {
996 + pp::WheelInputEvent *wheel_event = 995 + pp::WheelInputEvent *wheel_event =
997 + reinterpret_cast<pp::WheelInputEvent*>(input_event); 996 + reinterpret_cast<pp::WheelInputEvent*>(input_event);
998 + wheel_clicks_x += wheel_event->GetTicks().x(); 997 + wheel_clicks_x += wheel_event->GetTicks().x();
999 + wheel_clicks_y += wheel_event->GetTicks().y(); 998 + wheel_clicks_y += wheel_event->GetTicks().y();
1000 + event->wheel_clicks_x = trunc(wheel_clicks_x); 999 + int sdl_wheel_clicks_x = trunc(wheel_clicks_x);
1001 + event->wheel_clicks_y = trunc(wheel_clicks_y); 1000 + int sdl_wheel_clicks_y = trunc(wheel_clicks_y);
1002 + if (event->wheel_clicks_x == 0 && event->wheel_clicks_y == 0) { 1001 + event.button.x = event.button.y = 0;
1003 + free(event); 1002 + event.button.button = (sdl_wheel_clicks_x > 0) ? SDL_BUTTON_X1 : SDL_BUTTON _X2;
1004 + return; 1003 + for (int i = 0; i < abs(sdl_wheel_clicks_x); i++) {
1004 + event.type = SDL_MOUSEBUTTONDOWN;
1005 + event_queue.PushEvent(copyEvent(&event));
1006 + event.type = SDL_MOUSEBUTTONUP;
1007 + event_queue.PushEvent(copyEvent(&event));
1005 + } 1008 + }
1006 + wheel_clicks_x -= event->wheel_clicks_x; 1009 + event.button.button = (sdl_wheel_clicks_y > 0) ? SDL_BUTTON_WHEELUP : SDL_B UTTON_WHEELDOWN;
1007 + wheel_clicks_y -= event->wheel_clicks_y; 1010 + for (int i = 0; i < abs(sdl_wheel_clicks_y); i++) {
1008 + } else if (event->type == PP_INPUTEVENT_TYPE_MOUSEMOVE) { 1011 + event.type = SDL_MOUSEBUTTONDOWN;
1012 + event_queue.PushEvent(copyEvent(&event));
1013 + event.type = SDL_MOUSEBUTTONUP;
1014 + event_queue.PushEvent(copyEvent(&event));
1015 + }
1016 + wheel_clicks_x -= sdl_wheel_clicks_x;
1017 + wheel_clicks_y -= sdl_wheel_clicks_y;
1018 + } else if (type == PP_INPUTEVENT_TYPE_MOUSEMOVE) {
1009 + pp::MouseInputEvent *mouse_event = 1019 + pp::MouseInputEvent *mouse_event =
1010 + reinterpret_cast<pp::MouseInputEvent*>(input_event); 1020 + reinterpret_cast<pp::MouseInputEvent*>(input_event);
1011 + event->x = mouse_event->GetPosition().x(); 1021 + event.type = SDL_MOUSEMOTION;
1012 + event->y = mouse_event->GetPosition().y(); 1022 + event.motion.x = mouse_event->GetPosition().x();
1013 + } else if (event->type == PP_INPUTEVENT_TYPE_KEYDOWN || 1023 + event.motion.y = mouse_event->GetPosition().y();
1014 + event->type == PP_INPUTEVENT_TYPE_KEYUP || 1024 + event_queue.PushEvent(copyEvent(&event));
1015 + event->type == PP_INPUTEVENT_TYPE_CHAR) { 1025 + } else if (type == PP_INPUTEVENT_TYPE_KEYDOWN ||
1026 + type == PP_INPUTEVENT_TYPE_KEYUP ||
1027 + type == PP_INPUTEVENT_TYPE_CHAR) {
1016 + // PPAPI sends us separate events for KEYDOWN and CHAR; the first one 1028 + // PPAPI sends us separate events for KEYDOWN and CHAR; the first one
1017 + // contains only the keycode, the second one - only the unicode text. 1029 + // contains only the keycode, the second one - only the unicode text.
1018 + // SDL wants both in SDL_PRESSED event :( 1030 + // SDL wants both in SDL_PRESSED event :(
1019 + // For now, ignore the keydown event for printable ascii (32-126) as we 1031 + // For now, ignore the keydown event for printable ascii (32-126) as we
1020 + // know we'll get a char event and can set sym directly. For everything 1032 + // know we'll get a char event and can set sym directly. For everything
1021 + // else, risk sending an extra SDL_PRESSED with unicode text and zero 1033 + // else, risk sending an extra SDL_PRESSED with unicode text and zero
1022 + // keycode for scancode / sym. 1034 + // keycode for scancode / sym.
1023 + // It seems that SDL 1.3 is better in this regard. 1035 + // It seems that SDL 1.3 is better in this regard.
1024 + pp::KeyboardInputEvent *keyboard_event = 1036 + pp::KeyboardInputEvent *keyboard_event =
1025 + reinterpret_cast<pp::KeyboardInputEvent*>(input_event); 1037 + reinterpret_cast<pp::KeyboardInputEvent*>(input_event);
1026 + keysym.scancode = keyboard_event->GetKeyCode(); 1038 + keysym.scancode = keyboard_event->GetKeyCode();
1027 + keysym.unicode = keyboard_event->GetCharacterText().AsString()[0]; 1039 + keysym.unicode = keyboard_event->GetCharacterText().AsString()[0];
1028 + keysym.sym = translateKey(keysym.scancode); 1040 + keysym.sym = translateKey(keysym.scancode);
1029 + if (event->type == PP_INPUTEVENT_TYPE_KEYDOWN) { 1041 + if (type == PP_INPUTEVENT_TYPE_KEYDOWN) {
1042 + event.type = SDL_KEYDOWN;
1030 + last_scancode = keysym.scancode; 1043 + last_scancode = keysym.scancode;
1031 + if (keysym.sym >= ' ' && keysym.sym <= 126) { 1044 + if (keysym.sym >= ' ' && keysym.sym <= 126) {
1032 + free(event);
1033 + return; 1045 + return;
1034 + } 1046 + }
1035 + } else if (event->type == PP_INPUTEVENT_TYPE_CHAR) { 1047 + } else if (type == PP_INPUTEVENT_TYPE_CHAR) {
1048 + event.type = SDL_KEYDOWN;
1036 + if (keysym.sym >= ' ' && keysym.sym <= 126) { 1049 + if (keysym.sym >= ' ' && keysym.sym <= 126) {
1037 + keysym.scancode = translateAscii(keysym.unicode); 1050 + keysym.scancode = translateAscii(keysym.unicode);
1038 + keysym.sym = translateKey(keysym.scancode); 1051 + keysym.sym = translateKey(keysym.scancode);
1039 + } else if (last_scancode) { 1052 + } else if (last_scancode) {
1040 + keysym.scancode = last_scancode; 1053 + keysym.scancode = last_scancode;
1041 + keysym.sym = translateKey(keysym.scancode); 1054 + keysym.sym = translateKey(keysym.scancode);
1042 + } 1055 + }
1043 + } else { // event->type == PP_INPUTEVENT_TYPE_KEYUP 1056 + } else { // event->type == PP_INPUTEVENT_TYPE_KEYUP
1057 + event.type = SDL_KEYUP;
1044 + last_scancode = 0; 1058 + last_scancode = 0;
1045 + } 1059 + }
1046 + keysym.mod = KMOD_NONE; 1060 + keysym.mod = KMOD_NONE;
1047 + event->keysym = keysym; 1061 + event.key.keysym = keysym;
1048 + } else { 1062 + event_queue.PushEvent(copyEvent(&event));
1049 + free(event); 1063 + } else if (type == PP_INPUTEVENT_TYPE_MOUSEENTER ||
1050 + return; 1064 + type == PP_INPUTEVENT_TYPE_MOUSELEAVE) {
1065 + event.type = SDL_ACTIVEEVENT;
1066 + event.active.gain = (type == PP_INPUTEVENT_TYPE_MOUSEENTER) ? 1 : 0;
1067 + event.active.state = SDL_APPMOUSEFOCUS;
1068 + event_queue.PushEvent(copyEvent(&event));
1051 + } 1069 + }
1052 + event_queue.PushEvent(event); 1070 +}
1071 +
1072 +void SDL_NACL_SetHasFocus(bool has_focus) {
1073 + SDL_Event event;
1074 + event.type = SDL_ACTIVEEVENT;
1075 + event.active.gain = has_focus ? 1 : 0;
1076 + event.active.state = SDL_APPINPUTFOCUS;
1077 + event_queue.PushEvent(copyEvent(&event));
1078 +}
1079 +
1080 +void SDL_NACL_SetPageVisible(bool is_visible) {
1081 + SDL_Event event;
1082 + event.type = SDL_ACTIVEEVENT;
1083 + event.active.gain = is_visible ? 1 : 0;
1084 + event.active.state = SDL_APPACTIVE;
1085 + event_queue.PushEvent(copyEvent(&event));
1053 +} 1086 +}
1054 + 1087 +
1055 +void NACL_PumpEvents(_THIS) { 1088 +void NACL_PumpEvents(_THIS) {
1056 + SDL_NACL_Event* event; 1089 + SDL_Event* event;
1057 + while (event = event_queue.PopEvent()) { 1090 + while (event = event_queue.PopEvent()) {
1058 + if (event->type == PP_INPUTEVENT_TYPE_MOUSEDOWN) { 1091 + if (event->type == SDL_MOUSEBUTTONDOWN) {
1059 + SDL_PrivateMouseButton(SDL_PRESSED, event->button, 0, 0); 1092 + SDL_PrivateMouseButton(SDL_PRESSED, event->button.button,
1060 + } else if (event->type == PP_INPUTEVENT_TYPE_MOUSEUP) { 1093 + event->button.x, event->button.y);
1061 + SDL_PrivateMouseButton(SDL_RELEASED, event->button, 0, 0); 1094 + } else if (event->type == SDL_MOUSEBUTTONUP) {
1062 + } else if (event->type == PP_INPUTEVENT_TYPE_WHEEL) { 1095 + SDL_PrivateMouseButton(SDL_RELEASED, event->button.button,
1063 + Uint8 button = event->wheel_clicks_x > 0 ? SDL_BUTTON_X1 : SDL_BUTTON_X2; 1096 + event->button.x, event->button.y);
1064 + int count = abs(event->wheel_clicks_x); 1097 + } else if (event->type == SDL_MOUSEMOTION) {
1065 + while (count--) { 1098 + SDL_PrivateMouseMotion(0, 0, event->motion.x, event->motion.y);
1066 + SDL_PrivateMouseButton(SDL_PRESSED, button, 0, 0); 1099 + } else if (event->type == SDL_KEYDOWN) {
1067 + SDL_PrivateMouseButton(SDL_RELEASED, button, 0, 0); 1100 + SDL_PrivateKeyboard(SDL_PRESSED, &event->key.keysym);
1068 + } 1101 + } else if (event->type == SDL_KEYUP) {
1069 + button = event->wheel_clicks_y > 0 ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEE LDOWN; 1102 + SDL_PrivateKeyboard(SDL_RELEASED, &event->key.keysym);
1070 + count = abs(event->wheel_clicks_y); 1103 + } else if (event->type == SDL_ACTIVEEVENT) {
1071 + while (count--) { 1104 + SDL_PrivateAppActive(event->active.gain, event->active.state);
1072 + SDL_PrivateMouseButton(SDL_PRESSED, button, 0, 0);
1073 + SDL_PrivateMouseButton(SDL_RELEASED, button, 0, 0);
1074 + }
1075 + } else if (event->type == PP_INPUTEVENT_TYPE_MOUSEMOVE) {
1076 + SDL_PrivateMouseMotion(0, 0, event->x, event->y);
1077 + } else if (event->type == PP_INPUTEVENT_TYPE_KEYDOWN || event->type == PP_I NPUTEVENT_TYPE_CHAR) {
1078 + SDL_PrivateKeyboard(SDL_PRESSED, &event->keysym);
1079 + } else if (event->type == PP_INPUTEVENT_TYPE_KEYUP) {
1080 + SDL_PrivateKeyboard(SDL_RELEASED, &event->keysym);
1081 + } 1105 + }
1082 + free(event); 1106 + free(event);
1083 + } 1107 + }
1084 +} 1108 +}
1085 + 1109 +
1086 +void NACL_InitOSKeymap(_THIS) { 1110 +void NACL_InitOSKeymap(_THIS) {
1087 + /* do nothing. */ 1111 + /* do nothing. */
1088 +} 1112 +}
1089 diff -urN SDL-1.2.14/src/video/nacl/SDL_naclevents_c.h SDL-1.2.14-nacl/src/video /nacl/SDL_naclevents_c.h 1113 diff -urN SDL-1.2.14/src/video/nacl/SDL_naclevents_c.h SDL-1.2.14-nacl/src/video /nacl/SDL_naclevents_c.h
1090 --- SDL-1.2.14/src/video/nacl/SDL_naclevents_c.h 1970-01-01 03:00:00.0000 00000 +0300 1114 --- SDL-1.2.14/src/video/nacl/SDL_naclevents_c.h 1970-01-01 03:00:00.0000 00000 +0300
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 @@ -33,6 +33,9 @@ 1567 @@ -33,6 +33,9 @@
1544 1568
1545 /* Available video drivers */ 1569 /* Available video drivers */
1546 static VideoBootStrap *bootstrap[] = { 1570 static VideoBootStrap *bootstrap[] = {
1547 +#if SDL_VIDEO_DRIVER_NACL 1571 +#if SDL_VIDEO_DRIVER_NACL
1548 + &NACL_bootstrap, 1572 + &NACL_bootstrap,
1549 +#endif 1573 +#endif
1550 #if SDL_VIDEO_DRIVER_QUARTZ 1574 #if SDL_VIDEO_DRIVER_QUARTZ
1551 &QZ_bootstrap, 1575 &QZ_bootstrap,
1552 #endif 1576 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698