summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-02 01:15:35 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-02 01:15:35 +0300
commitd122d5d9f5fd9a54dba7f02e5b421f6b60330b55 (patch)
tree4c471cdd93c3125df72f5628fa1ae353beb248c6
parent331468dbfb8de05723c62149036cb8a51e769baf (diff)
downloadmanaverse-d122d5d9f5fd9a54dba7f02e5b421f6b60330b55.tar.gz
manaverse-d122d5d9f5fd9a54dba7f02e5b421f6b60330b55.tar.bz2
manaverse-d122d5d9f5fd9a54dba7f02e5b421f6b60330b55.tar.xz
manaverse-d122d5d9f5fd9a54dba7f02e5b421f6b60330b55.zip
Update nacl ports.
-rw-r--r--packaging/nacl/ports/sdl/nacl.patch151
1 files changed, 111 insertions, 40 deletions
diff --git a/packaging/nacl/ports/sdl/nacl.patch b/packaging/nacl/ports/sdl/nacl.patch
index 36846f48c..7c82591cc 100644
--- a/packaging/nacl/ports/sdl/nacl.patch
+++ b/packaging/nacl/ports/sdl/nacl.patch
@@ -1,7 +1,7 @@
diff --git a/configure.in b/configure.in
-index ab0e314..93c79be 100644
+index ab0e314..c7ae13b 100644
--- a/configure.in
-+++ b/configure.in
++++ b/configure.in
@@ -957,7 +957,7 @@ AC_HELP_STRING([--enable-naclvideo], [enable the nacl video driver [[default=yes
AC_DEFINE(SDL_VIDEO_DRIVER_NACL)
SOURCES="$SOURCES $srcdir/src/video/nacl/*.c"
@@ -20,19 +20,24 @@ index ab0e314..93c79be 100644
;;
*-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
case "$host" in
-diff --git a/include/SDL_main.h b/include/SDL_main.h
-index 067d15e..ae6a9a6 100644
---- a/include/SDL_main.h
-+++ b/include/SDL_main.h
-@@ -54,7 +54,7 @@
- #define main SDL_main
-
- /** The prototype for the application's main() function */
--extern C_LINKAGE int SDL_main(int argc, char *argv[]);
-+extern C_LINKAGE int SDL_main(int argc, char *argv[]);
-
-
- /** @name From the SDL library code -- needed for registering the app on Win32 */
+diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
+index 5753927..da37fe6 100644
+--- a/src/events/SDL_keyboard.c
++++ b/src/events/SDL_keyboard.c
+@@ -371,6 +371,13 @@ Uint8 * SDL_GetKeyState (int *numkeys)
+ *numkeys = SDLK_LAST;
+ return(SDL_KeyState);
+ }
++
++// private (used in naclevents.c)
++void SDL_SetKeyState (SDLKey key, Uint8 state)
++{
++ SDL_KeyState[key] = state;
++}
++
+ SDLMod SDL_GetModState (void)
+ {
+ return(SDL_ModState);
diff --git a/src/main/nacl/SDL_nacl_main.c b/src/main/nacl/SDL_nacl_main.c
deleted file mode 100644
index ef26120..0000000
@@ -168,7 +173,7 @@ diff --git a/src/main/nacl/SDL_nacl_main.cc b/src/main/nacl/SDL_nacl_main.cc
new file mode 100644
index 0000000..ee80b9a
--- /dev/null
-+++ b/src/main/nacl/SDL_nacl_main.cc
++++ b/src/main/nacl/SDL_nacl_main.cc
@@ -0,0 +1,129 @@
+/*
+ Simple DirectMedia Layer
@@ -299,26 +304,8 @@ index 0000000..ee80b9a
+}
+
+#endif /* SDL_VIDEO_DRIVER_NACL */
-diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
-index 5753927..da37fe6 100644
---- a/src/events/SDL_keyboard.c
-+++ b/src/events/SDL_keyboard.c
-@@ -371,6 +371,13 @@ Uint8 * SDL_GetKeyState (int *numkeys)
- *numkeys = SDLK_LAST;
- return(SDL_KeyState);
- }
-+
-+// private (used in naclevents.c)
-+void SDL_SetKeyState (SDLKey key, Uint8 state)
-+{
-+ SDL_KeyState[key] = state;
-+}
-+
- SDLMod SDL_GetModState (void)
- {
- return(SDL_ModState);
diff --git a/src/video/nacl/SDL_naclevents.c b/src/video/nacl/SDL_naclevents.c
-index a2f7e19..461e1ca 100644
+index a2f7e19..a97134f 100644
--- a/src/video/nacl/SDL_naclevents.c
+++ b/src/video/nacl/SDL_naclevents.c
@@ -29,6 +29,7 @@
@@ -329,12 +316,82 @@ index a2f7e19..461e1ca 100644
#define PPAPI_KEY_CTRL 17
#define PPAPI_KEY_ALT 18
-@@ -176,12 +177,15 @@ static SDLKey translateKey(uint32_t code) {
+@@ -176,12 +177,85 @@ static SDLKey translateKey(uint32_t code) {
}
}
+static SDL_bool SDL_NeedModUpdate = SDL_TRUE;
+
++static int Utf8ToUtf16(const Uint8 *utf8, const int utf8_length, Uint16 *utf16, const int utf16_max_length) {
++
++ /* p moves over the output buffer. max_ptr points to the next to the last slot of the buffer. */
++ Uint16 *p = utf16;
++ Uint16 const *const max_ptr = utf16 + utf16_max_length;
++
++ /* end_of_input points to the last byte of input as opposed to the next to the last byte. */
++ Uint8 const *const end_of_input = utf8 + utf8_length - 1;
++
++ while (utf8 <= end_of_input) {
++ Uint8 const c = *utf8;
++ if (p >= max_ptr) {
++ /* No more output space. */
++ return -1;
++ }
++ if (c < 0x80) {
++ /* One byte ASCII. */
++ *p++ = c;
++ utf8 += 1;
++ } else if (c < 0xC0) {
++ /* Follower byte without preceeding leader bytes. */
++ return -1;
++ } else if (c < 0xE0) {
++ /* Two byte sequence. We need one follower byte. */
++ if (end_of_input - utf8 < 1 || (((utf8[1] ^ 0x80)) & 0xC0)) {
++ return -1;
++ }
++ *p++ = (Uint16)(0xCF80 + (c << 6) + utf8[1]);
++ utf8 += 2;
++ } else if (c < 0xF0) {
++ /* Three byte sequence. We need two follower byte. */
++ if (end_of_input - utf8 < 2 || (((utf8[1] ^ 0x80) | (utf8[2] ^ 0x80)) & 0xC0)) {
++ return -1;
++ }
++ *p++ = (Uint16)(0xDF80 + (c << 12) + (utf8[1] << 6) + utf8[2]);
++ utf8 += 3;
++ } else if (c < 0xF8) {
++ int plane;
++ /* Four byte sequence. We need three follower bytes. */
++ if (end_of_input - utf8 < 3 || (((utf8[1] ^ 0x80) | (utf8[2] ^0x80) | (utf8[3] ^ 0x80)) & 0xC0)) {
++ return -1;
++ }
++ plane = (-0xC8 + (c << 2) + (utf8[1] >> 4));
++ if (plane == 0) {
++ /* This four byte sequence is an alias that
++ corresponds to a Unicode scalar value in BMP.
++ It fits in an UTF-16 encoding unit. */
++ *p++ = (Uint16)(0xDF80 + (utf8[1] << 12) + (utf8[2] << 6) + utf8[3]);
++ } else if (plane <= 16) {
++ /* This is a legal four byte sequence that corresponds to a surrogate pair. */
++ if (p + 1 >= max_ptr) {
++ /* No enough space on the output buffer for the pair. */
++ return -1;
++ }
++ *p++ = (Uint16)(0xE5B8 + (c << 8) + (utf8[1] << 2) + (utf8[2] >> 4));
++ *p++ = (Uint16)(0xDB80 + ((utf8[2] & 0x0F) << 6) + utf8[3]);
++ } else {
++ /* This four byte sequence is out of UTF-16 code space. */
++ return -1;
++ }
++ utf8 += 4;
++ } else {
++ /* Longer sequence or unused byte. */
++ return -1;
++ }
++ }
++ return p - utf16;
++}
++
++
void HandleInputEvent(_THIS, PP_Resource event) {
static Uint8 last_scancode = 0;
static int alt_down = 0;
@@ -345,7 +402,7 @@ index a2f7e19..461e1ca 100644
Uint8 button;
Uint8 state;
Uint8 gained;
-@@ -197,9 +201,49 @@ void HandleInputEvent(_THIS, PP_Resource event) {
+@@ -197,9 +271,49 @@ void HandleInputEvent(_THIS, PP_Resource event) {
int sdl_wheel_clicks_y;
int i;
@@ -395,7 +452,7 @@ index a2f7e19..461e1ca 100644
switch (type) {
case PP_INPUTEVENT_TYPE_MOUSEDOWN:
case PP_INPUTEVENT_TYPE_MOUSEUP:
-@@ -216,13 +260,13 @@ void HandleInputEvent(_THIS, PP_Resource event) {
+@@ -216,13 +330,13 @@ void HandleInputEvent(_THIS, PP_Resource event) {
sdl_wheel_clicks_y = trunc(wheel_clicks_y);
button = (sdl_wheel_clicks_x > 0) ? SDL_BUTTON_X1 : SDL_BUTTON_X2;
for (i = 0; i < abs(sdl_wheel_clicks_x); i++) {
@@ -413,7 +470,21 @@ index a2f7e19..461e1ca 100644
}
wheel_clicks_x -= sdl_wheel_clicks_x;
wheel_clicks_y -= sdl_wheel_clicks_y;
-@@ -318,6 +362,34 @@ void HandleInputEvent(_THIS, PP_Resource event) {
+@@ -259,7 +373,12 @@ void HandleInputEvent(_THIS, PP_Resource event) {
+ // It seems that SDL 1.3 is better in this regard.
+ keysym.scancode = dd->ppb_keyboard_input_event->GetKeyCode(event);
+ unicode_var = dd->ppb_keyboard_input_event->GetCharacterText(event);
+- keysym.unicode = dd->ppb_var->VarToUtf8(unicode_var, &unicode_var_len)[0];
++ const Uint8 *utf8_buf = dd->ppb_var->VarToUtf8(unicode_var, &unicode_var_len);
++
++ Uint8 utf16_buf[10];
++ Utf8ToUtf16(utf8_buf, unicode_var_len, (Uint16*)&utf16_buf[0], 1);
++ keysym.unicode = *(Uint16*)&utf16_buf[0];
++
+ dd->ppb_var->Release(unicode_var);
+ keysym.sym = translateKey(keysym.scancode);
+
+@@ -318,6 +437,34 @@ void HandleInputEvent(_THIS, PP_Resource event) {
state = SDL_RELEASED;
last_scancode = 0;
}
@@ -448,7 +519,7 @@ index a2f7e19..461e1ca 100644
keysym.mod = KMOD_NONE;
SDL_TRACE("Key event: %d: %s\n", state, SDL_GetKeyName(keysym.sym));
SDL_PrivateKeyboard(state, &keysym);
-@@ -352,6 +424,7 @@ static void HandleEvent(_THIS, PSEvent* ps_event) {
+@@ -352,6 +499,7 @@ static void HandleEvent(_THIS, PSEvent* ps_event) {
/* From DidChangeFocus, contains a PP_Bool with the current focus state. */
case PSE_INSTANCE_DIDCHANGEFOCUS: