mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Updates SDL to version 2.0.4, which makes it compatible with VS2015.
This commit is contained in:
parent
7b52fed504
commit
b63ef177f4
924 changed files with 79241 additions and 39934 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -115,22 +115,22 @@
|
|||
* This can be used for any RGB permutation of course.
|
||||
*/
|
||||
#define ALPHA_BLIT32_888(to, from, length, bpp, alpha) \
|
||||
do { \
|
||||
int i; \
|
||||
Uint32 *src = (Uint32 *)(from); \
|
||||
Uint32 *dst = (Uint32 *)(to); \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
Uint32 s1 = s & 0xff00ff; \
|
||||
Uint32 d1 = d & 0xff00ff; \
|
||||
d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \
|
||||
s &= 0xff00; \
|
||||
d &= 0xff00; \
|
||||
d = (d + ((s - d) * alpha >> 8)) & 0xff00; \
|
||||
*dst++ = d1 | d; \
|
||||
} \
|
||||
} while(0)
|
||||
do { \
|
||||
int i; \
|
||||
Uint32 *src = (Uint32 *)(from); \
|
||||
Uint32 *dst = (Uint32 *)(to); \
|
||||
for (i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
Uint32 s1 = s & 0xff00ff; \
|
||||
Uint32 d1 = d & 0xff00ff; \
|
||||
d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \
|
||||
s &= 0xff00; \
|
||||
d &= 0xff00; \
|
||||
d = (d + ((s - d) * alpha >> 8)) & 0xff00; \
|
||||
*dst++ = d1 | d; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* For 16bpp pixels we can go a step further: put the middle component
|
||||
|
|
@ -139,97 +139,97 @@
|
|||
* 5 bits, we have to scale alpha down to 5 bits as well.
|
||||
*/
|
||||
#define ALPHA_BLIT16_565(to, from, length, bpp, alpha) \
|
||||
do { \
|
||||
int i; \
|
||||
Uint16 *src = (Uint16 *)(from); \
|
||||
Uint16 *dst = (Uint16 *)(to); \
|
||||
Uint32 ALPHA = alpha >> 3; \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
s = (s | s << 16) & 0x07e0f81f; \
|
||||
d = (d | d << 16) & 0x07e0f81f; \
|
||||
d += (s - d) * ALPHA >> 5; \
|
||||
d &= 0x07e0f81f; \
|
||||
*dst++ = (Uint16)(d | d >> 16); \
|
||||
} \
|
||||
do { \
|
||||
int i; \
|
||||
Uint16 *src = (Uint16 *)(from); \
|
||||
Uint16 *dst = (Uint16 *)(to); \
|
||||
Uint32 ALPHA = alpha >> 3; \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
s = (s | s << 16) & 0x07e0f81f; \
|
||||
d = (d | d << 16) & 0x07e0f81f; \
|
||||
d += (s - d) * ALPHA >> 5; \
|
||||
d &= 0x07e0f81f; \
|
||||
*dst++ = (Uint16)(d | d >> 16); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ALPHA_BLIT16_555(to, from, length, bpp, alpha) \
|
||||
do { \
|
||||
int i; \
|
||||
Uint16 *src = (Uint16 *)(from); \
|
||||
Uint16 *dst = (Uint16 *)(to); \
|
||||
Uint32 ALPHA = alpha >> 3; \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
s = (s | s << 16) & 0x03e07c1f; \
|
||||
d = (d | d << 16) & 0x03e07c1f; \
|
||||
d += (s - d) * ALPHA >> 5; \
|
||||
d &= 0x03e07c1f; \
|
||||
*dst++ = (Uint16)(d | d >> 16); \
|
||||
} \
|
||||
do { \
|
||||
int i; \
|
||||
Uint16 *src = (Uint16 *)(from); \
|
||||
Uint16 *dst = (Uint16 *)(to); \
|
||||
Uint32 ALPHA = alpha >> 3; \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
s = (s | s << 16) & 0x03e07c1f; \
|
||||
d = (d | d << 16) & 0x03e07c1f; \
|
||||
d += (s - d) * ALPHA >> 5; \
|
||||
d &= 0x03e07c1f; \
|
||||
*dst++ = (Uint16)(d | d >> 16); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* The general slow catch-all function, for remaining depths and formats
|
||||
*/
|
||||
#define ALPHA_BLIT_ANY(to, from, length, bpp, alpha) \
|
||||
do { \
|
||||
int i; \
|
||||
Uint8 *src = from; \
|
||||
Uint8 *dst = to; \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s, d; \
|
||||
unsigned rs, gs, bs, rd, gd, bd; \
|
||||
switch(bpp) { \
|
||||
case 2: \
|
||||
s = *(Uint16 *)src; \
|
||||
d = *(Uint16 *)dst; \
|
||||
break; \
|
||||
case 3: \
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
s = (src[0] << 16) | (src[1] << 8) | src[2]; \
|
||||
d = (dst[0] << 16) | (dst[1] << 8) | dst[2]; \
|
||||
} else { \
|
||||
s = (src[2] << 16) | (src[1] << 8) | src[0]; \
|
||||
d = (dst[2] << 16) | (dst[1] << 8) | dst[0]; \
|
||||
} \
|
||||
break; \
|
||||
case 4: \
|
||||
s = *(Uint32 *)src; \
|
||||
d = *(Uint32 *)dst; \
|
||||
break; \
|
||||
} \
|
||||
RGB_FROM_PIXEL(s, fmt, rs, gs, bs); \
|
||||
RGB_FROM_PIXEL(d, fmt, rd, gd, bd); \
|
||||
rd += (rs - rd) * alpha >> 8; \
|
||||
gd += (gs - gd) * alpha >> 8; \
|
||||
bd += (bs - bd) * alpha >> 8; \
|
||||
PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \
|
||||
switch(bpp) { \
|
||||
case 2: \
|
||||
*(Uint16 *)dst = (Uint16)d; \
|
||||
break; \
|
||||
case 3: \
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
dst[0] = (Uint8)(d >> 16); \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d); \
|
||||
} else { \
|
||||
dst[0] = (Uint8)d; \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d >> 16); \
|
||||
} \
|
||||
break; \
|
||||
case 4: \
|
||||
*(Uint32 *)dst = d; \
|
||||
break; \
|
||||
} \
|
||||
src += bpp; \
|
||||
dst += bpp; \
|
||||
} \
|
||||
do { \
|
||||
int i; \
|
||||
Uint8 *src = from; \
|
||||
Uint8 *dst = to; \
|
||||
for (i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s, d; \
|
||||
unsigned rs, gs, bs, rd, gd, bd; \
|
||||
switch (bpp) { \
|
||||
case 2: \
|
||||
s = *(Uint16 *)src; \
|
||||
d = *(Uint16 *)dst; \
|
||||
break; \
|
||||
case 3: \
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
s = (src[0] << 16) | (src[1] << 8) | src[2]; \
|
||||
d = (dst[0] << 16) | (dst[1] << 8) | dst[2]; \
|
||||
} else { \
|
||||
s = (src[2] << 16) | (src[1] << 8) | src[0]; \
|
||||
d = (dst[2] << 16) | (dst[1] << 8) | dst[0]; \
|
||||
} \
|
||||
break; \
|
||||
case 4: \
|
||||
s = *(Uint32 *)src; \
|
||||
d = *(Uint32 *)dst; \
|
||||
break; \
|
||||
} \
|
||||
RGB_FROM_PIXEL(s, fmt, rs, gs, bs); \
|
||||
RGB_FROM_PIXEL(d, fmt, rd, gd, bd); \
|
||||
rd += (rs - rd) * alpha >> 8; \
|
||||
gd += (gs - gd) * alpha >> 8; \
|
||||
bd += (bs - bd) * alpha >> 8; \
|
||||
PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \
|
||||
switch (bpp) { \
|
||||
case 2: \
|
||||
*(Uint16 *)dst = (Uint16)d; \
|
||||
break; \
|
||||
case 3: \
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
dst[0] = (Uint8)(d >> 16); \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d); \
|
||||
} else { \
|
||||
dst[0] = (Uint8)d; \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d >> 16); \
|
||||
} \
|
||||
break; \
|
||||
case 4: \
|
||||
*(Uint32 *)dst = d; \
|
||||
break; \
|
||||
} \
|
||||
src += bpp; \
|
||||
dst += bpp; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
|
|
@ -241,16 +241,16 @@
|
|||
* add them. Then shift right and add the sum of the lowest bits.
|
||||
*/
|
||||
#define ALPHA_BLIT32_888_50(to, from, length, bpp, alpha) \
|
||||
do { \
|
||||
int i; \
|
||||
Uint32 *src = (Uint32 *)(from); \
|
||||
Uint32 *dst = (Uint32 *)(to); \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
*dst++ = (((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) \
|
||||
+ (s & d & 0x00010101); \
|
||||
} \
|
||||
do { \
|
||||
int i; \
|
||||
Uint32 *src = (Uint32 *)(from); \
|
||||
Uint32 *dst = (Uint32 *)(to); \
|
||||
for(i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
*dst++ = (((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) \
|
||||
+ (s & d & 0x00010101); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
|
|
@ -259,170 +259,185 @@
|
|||
*/
|
||||
|
||||
/* helper: blend a single 16 bit pixel at 50% */
|
||||
#define BLEND16_50(dst, src, mask) \
|
||||
do { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
*dst++ = (Uint16)((((s & mask) + (d & mask)) >> 1) + \
|
||||
(s & d & (~mask & 0xffff))); \
|
||||
#define BLEND16_50(dst, src, mask) \
|
||||
do { \
|
||||
Uint32 s = *src++; \
|
||||
Uint32 d = *dst; \
|
||||
*dst++ = (Uint16)((((s & mask) + (d & mask)) >> 1) + \
|
||||
(s & d & (~mask & 0xffff))); \
|
||||
} while(0)
|
||||
|
||||
/* basic 16bpp blender. mask is the pixels to keep when adding. */
|
||||
#define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask) \
|
||||
do { \
|
||||
unsigned n = (length); \
|
||||
Uint16 *src = (Uint16 *)(from); \
|
||||
Uint16 *dst = (Uint16 *)(to); \
|
||||
if(((uintptr_t)src ^ (uintptr_t)dst) & 3) { \
|
||||
/* source and destination not in phase, blit one by one */ \
|
||||
while(n--) \
|
||||
BLEND16_50(dst, src, mask); \
|
||||
} else { \
|
||||
if((uintptr_t)src & 3) { \
|
||||
/* first odd pixel */ \
|
||||
BLEND16_50(dst, src, mask); \
|
||||
n--; \
|
||||
} \
|
||||
for(; n > 1; n -= 2) { \
|
||||
Uint32 s = *(Uint32 *)src; \
|
||||
Uint32 d = *(Uint32 *)dst; \
|
||||
*(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1) \
|
||||
+ ((d & (mask | mask << 16)) >> 1) \
|
||||
+ (s & d & (~(mask | mask << 16))); \
|
||||
src += 2; \
|
||||
dst += 2; \
|
||||
} \
|
||||
if(n) \
|
||||
BLEND16_50(dst, src, mask); /* last odd pixel */ \
|
||||
} \
|
||||
do { \
|
||||
unsigned n = (length); \
|
||||
Uint16 *src = (Uint16 *)(from); \
|
||||
Uint16 *dst = (Uint16 *)(to); \
|
||||
if (((uintptr_t)src ^ (uintptr_t)dst) & 3) { \
|
||||
/* source and destination not in phase, blit one by one */ \
|
||||
while (n--) \
|
||||
BLEND16_50(dst, src, mask); \
|
||||
} else { \
|
||||
if ((uintptr_t)src & 3) { \
|
||||
/* first odd pixel */ \
|
||||
BLEND16_50(dst, src, mask); \
|
||||
n--; \
|
||||
} \
|
||||
for (; n > 1; n -= 2) { \
|
||||
Uint32 s = *(Uint32 *)src; \
|
||||
Uint32 d = *(Uint32 *)dst; \
|
||||
*(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1) \
|
||||
+ ((d & (mask | mask << 16)) >> 1) \
|
||||
+ (s & d & (~(mask | mask << 16))); \
|
||||
src += 2; \
|
||||
dst += 2; \
|
||||
} \
|
||||
if (n) \
|
||||
BLEND16_50(dst, src, mask); /* last odd pixel */ \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha) \
|
||||
#define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha) \
|
||||
ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xf7de)
|
||||
|
||||
#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \
|
||||
#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \
|
||||
ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbde)
|
||||
|
||||
#define CHOOSE_BLIT(blitter, alpha, fmt) \
|
||||
do { \
|
||||
if(alpha == 255) { \
|
||||
switch(fmt->BytesPerPixel) { \
|
||||
case 1: blitter(1, Uint8, OPAQUE_BLIT); break; \
|
||||
case 2: blitter(2, Uint8, OPAQUE_BLIT); break; \
|
||||
case 3: blitter(3, Uint8, OPAQUE_BLIT); break; \
|
||||
case 4: blitter(4, Uint16, OPAQUE_BLIT); break; \
|
||||
} \
|
||||
} else { \
|
||||
switch(fmt->BytesPerPixel) { \
|
||||
case 1: \
|
||||
/* No 8bpp alpha blitting */ \
|
||||
break; \
|
||||
\
|
||||
case 2: \
|
||||
switch(fmt->Rmask | fmt->Gmask | fmt->Bmask) { \
|
||||
case 0xffff: \
|
||||
if(fmt->Gmask == 0x07e0 \
|
||||
|| fmt->Rmask == 0x07e0 \
|
||||
|| fmt->Bmask == 0x07e0) { \
|
||||
if(alpha == 128) \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_565_50); \
|
||||
else { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_565); \
|
||||
} \
|
||||
} else \
|
||||
goto general16; \
|
||||
break; \
|
||||
\
|
||||
case 0x7fff: \
|
||||
if(fmt->Gmask == 0x03e0 \
|
||||
|| fmt->Rmask == 0x03e0 \
|
||||
|| fmt->Bmask == 0x03e0) { \
|
||||
if(alpha == 128) \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_555_50); \
|
||||
else { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_555); \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
/* fallthrough */ \
|
||||
\
|
||||
default: \
|
||||
general16: \
|
||||
blitter(2, Uint8, ALPHA_BLIT_ANY); \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
case 3: \
|
||||
blitter(3, Uint8, ALPHA_BLIT_ANY); \
|
||||
break; \
|
||||
\
|
||||
case 4: \
|
||||
if((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff \
|
||||
&& (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00 \
|
||||
|| fmt->Bmask == 0xff00)) { \
|
||||
if(alpha == 128) \
|
||||
blitter(4, Uint16, ALPHA_BLIT32_888_50); \
|
||||
else \
|
||||
blitter(4, Uint16, ALPHA_BLIT32_888); \
|
||||
} else \
|
||||
blitter(4, Uint16, ALPHA_BLIT_ANY); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
#define CHOOSE_BLIT(blitter, alpha, fmt) \
|
||||
do { \
|
||||
if (alpha == 255) { \
|
||||
switch (fmt->BytesPerPixel) { \
|
||||
case 1: blitter(1, Uint8, OPAQUE_BLIT); break; \
|
||||
case 2: blitter(2, Uint8, OPAQUE_BLIT); break; \
|
||||
case 3: blitter(3, Uint8, OPAQUE_BLIT); break; \
|
||||
case 4: blitter(4, Uint16, OPAQUE_BLIT); break; \
|
||||
} \
|
||||
} else { \
|
||||
switch (fmt->BytesPerPixel) { \
|
||||
case 1: \
|
||||
/* No 8bpp alpha blitting */ \
|
||||
break; \
|
||||
\
|
||||
case 2: \
|
||||
switch (fmt->Rmask | fmt->Gmask | fmt->Bmask) { \
|
||||
case 0xffff: \
|
||||
if (fmt->Gmask == 0x07e0 \
|
||||
|| fmt->Rmask == 0x07e0 \
|
||||
|| fmt->Bmask == 0x07e0) { \
|
||||
if (alpha == 128) { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_565_50); \
|
||||
} else { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_565); \
|
||||
} \
|
||||
} else \
|
||||
goto general16; \
|
||||
break; \
|
||||
\
|
||||
case 0x7fff: \
|
||||
if (fmt->Gmask == 0x03e0 \
|
||||
|| fmt->Rmask == 0x03e0 \
|
||||
|| fmt->Bmask == 0x03e0) { \
|
||||
if (alpha == 128) { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_555_50); \
|
||||
} else { \
|
||||
blitter(2, Uint8, ALPHA_BLIT16_555); \
|
||||
} \
|
||||
break; \
|
||||
} else \
|
||||
goto general16; \
|
||||
break; \
|
||||
\
|
||||
default: \
|
||||
general16: \
|
||||
blitter(2, Uint8, ALPHA_BLIT_ANY); \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
case 3: \
|
||||
blitter(3, Uint8, ALPHA_BLIT_ANY); \
|
||||
break; \
|
||||
\
|
||||
case 4: \
|
||||
if ((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff \
|
||||
&& (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00 \
|
||||
|| fmt->Bmask == 0xff00)) { \
|
||||
if (alpha == 128) { \
|
||||
blitter(4, Uint16, ALPHA_BLIT32_888_50); \
|
||||
} else { \
|
||||
blitter(4, Uint16, ALPHA_BLIT32_888); \
|
||||
} \
|
||||
} else \
|
||||
blitter(4, Uint16, ALPHA_BLIT_ANY); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Set a pixel value using the given format, except that the alpha value is
|
||||
* placed in the top byte. This is the format used for RLE with alpha.
|
||||
*/
|
||||
#define RLEPIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
|
||||
((g>>fmt->Gloss)<<fmt->Gshift)| \
|
||||
((b>>fmt->Bloss)<<fmt->Bshift)| \
|
||||
(a<<24); \
|
||||
}
|
||||
|
||||
/*
|
||||
* This takes care of the case when the surface is clipped on the left and/or
|
||||
* right. Top clipping has already been taken care of.
|
||||
*/
|
||||
static void
|
||||
RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
|
||||
RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
|
||||
Uint8 * dstbuf, SDL_Rect * srcrect, unsigned alpha)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_PixelFormat *fmt = surf_dst->format;
|
||||
|
||||
#define RLECLIPBLIT(bpp, Type, do_blit) \
|
||||
do { \
|
||||
int linecount = srcrect->h; \
|
||||
int ofs = 0; \
|
||||
int left = srcrect->x; \
|
||||
int right = left + srcrect->w; \
|
||||
dstbuf -= left * bpp; \
|
||||
for(;;) { \
|
||||
int run; \
|
||||
ofs += *(Type *)srcbuf; \
|
||||
run = ((Type *)srcbuf)[1]; \
|
||||
srcbuf += 2 * sizeof(Type); \
|
||||
if(run) { \
|
||||
/* clip to left and right borders */ \
|
||||
if(ofs < right) { \
|
||||
int start = 0; \
|
||||
int len = run; \
|
||||
int startcol; \
|
||||
if(left - ofs > 0) { \
|
||||
start = left - ofs; \
|
||||
len -= start; \
|
||||
if(len <= 0) \
|
||||
goto nocopy ## bpp ## do_blit; \
|
||||
} \
|
||||
startcol = ofs + start; \
|
||||
if(len > right - startcol) \
|
||||
len = right - startcol; \
|
||||
do_blit(dstbuf + startcol * bpp, srcbuf + start * bpp, \
|
||||
len, bpp, alpha); \
|
||||
} \
|
||||
nocopy ## bpp ## do_blit: \
|
||||
srcbuf += run * bpp; \
|
||||
ofs += run; \
|
||||
} else if(!ofs) \
|
||||
break; \
|
||||
if(ofs == w) { \
|
||||
ofs = 0; \
|
||||
dstbuf += dst->pitch; \
|
||||
if(!--linecount) \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
#define RLECLIPBLIT(bpp, Type, do_blit) \
|
||||
do { \
|
||||
int linecount = srcrect->h; \
|
||||
int ofs = 0; \
|
||||
int left = srcrect->x; \
|
||||
int right = left + srcrect->w; \
|
||||
dstbuf -= left * bpp; \
|
||||
for (;;) { \
|
||||
int run; \
|
||||
ofs += *(Type *)srcbuf; \
|
||||
run = ((Type *)srcbuf)[1]; \
|
||||
srcbuf += 2 * sizeof(Type); \
|
||||
if (run) { \
|
||||
/* clip to left and right borders */ \
|
||||
if (ofs < right) { \
|
||||
int start = 0; \
|
||||
int len = run; \
|
||||
int startcol; \
|
||||
if (left - ofs > 0) { \
|
||||
start = left - ofs; \
|
||||
len -= start; \
|
||||
if (len <= 0) \
|
||||
goto nocopy ## bpp ## do_blit; \
|
||||
} \
|
||||
startcol = ofs + start; \
|
||||
if (len > right - startcol) \
|
||||
len = right - startcol; \
|
||||
do_blit(dstbuf + startcol * bpp, srcbuf + start * bpp, \
|
||||
len, bpp, alpha); \
|
||||
} \
|
||||
nocopy ## bpp ## do_blit: \
|
||||
srcbuf += run * bpp; \
|
||||
ofs += run; \
|
||||
} else if (!ofs) \
|
||||
break; \
|
||||
\
|
||||
if (ofs == w) { \
|
||||
ofs = 0; \
|
||||
dstbuf += surf_dst->pitch; \
|
||||
if (!--linecount) \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt);
|
||||
|
|
@ -434,18 +449,18 @@ RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
|
|||
|
||||
/* blit a colorkeyed RLE surface */
|
||||
int
|
||||
SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
|
||||
SDL_Surface * surf_dst, SDL_Rect * dstrect)
|
||||
{
|
||||
Uint8 *dstbuf;
|
||||
Uint8 *srcbuf;
|
||||
int x, y;
|
||||
int w = src->w;
|
||||
int w = surf_src->w;
|
||||
unsigned alpha;
|
||||
|
||||
/* Lock the destination if necessary */
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
if (SDL_MUSTLOCK(surf_dst)) {
|
||||
if (SDL_LockSurface(surf_dst) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
|
@ -453,9 +468,9 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
/* Set up the source and destination pointers */
|
||||
x = dstrect->x;
|
||||
y = dstrect->y;
|
||||
dstbuf = (Uint8 *) dst->pixels
|
||||
+ y * dst->pitch + x * src->format->BytesPerPixel;
|
||||
srcbuf = (Uint8 *) src->map->data;
|
||||
dstbuf = (Uint8 *) surf_dst->pixels
|
||||
+ y * surf_dst->pitch + x * surf_src->format->BytesPerPixel;
|
||||
srcbuf = (Uint8 *) surf_src->map->data;
|
||||
|
||||
{
|
||||
/* skip lines at the top if necessary */
|
||||
|
|
@ -481,7 +496,7 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
} \
|
||||
}
|
||||
|
||||
switch (src->format->BytesPerPixel) {
|
||||
switch (surf_src->format->BytesPerPixel) {
|
||||
case 1:
|
||||
RLESKIP(1, Uint8);
|
||||
break;
|
||||
|
|
@ -501,12 +516,12 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
}
|
||||
}
|
||||
|
||||
alpha = src->map->info.a;
|
||||
alpha = surf_src->map->info.a;
|
||||
/* if left or right edge clipping needed, call clip blit */
|
||||
if (srcrect->x || srcrect->w != src->w) {
|
||||
RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha);
|
||||
if (srcrect->x || srcrect->w != surf_src->w) {
|
||||
RLEClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect, alpha);
|
||||
} else {
|
||||
SDL_PixelFormat *fmt = src->format;
|
||||
SDL_PixelFormat *fmt = surf_src->format;
|
||||
|
||||
#define RLEBLIT(bpp, Type, do_blit) \
|
||||
do { \
|
||||
|
|
@ -525,7 +540,7 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
break; \
|
||||
if(ofs == w) { \
|
||||
ofs = 0; \
|
||||
dstbuf += dst->pitch; \
|
||||
dstbuf += surf_dst->pitch; \
|
||||
if(!--linecount) \
|
||||
break; \
|
||||
} \
|
||||
|
|
@ -539,8 +554,8 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
|
||||
done:
|
||||
/* Unlock the destination if necessary */
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
SDL_UnlockSurface(dst);
|
||||
if (SDL_MUSTLOCK(surf_dst)) {
|
||||
SDL_UnlockSurface(surf_dst);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -620,10 +635,10 @@ typedef struct
|
|||
|
||||
/* blit a pixel-alpha RLE surface clipped at the right and/or left edges */
|
||||
static void
|
||||
RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
|
||||
RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
|
||||
Uint8 * dstbuf, SDL_Rect * srcrect)
|
||||
{
|
||||
SDL_PixelFormat *df = dst->format;
|
||||
SDL_PixelFormat *df = surf_dst->format;
|
||||
/*
|
||||
* clipped blitter: Ptype is the destination pixel type,
|
||||
* Ctype the translucent count type, and do_blend the macro
|
||||
|
|
@ -693,7 +708,7 @@ RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
|
|||
ofs += run; \
|
||||
} \
|
||||
} while(ofs < w); \
|
||||
dstbuf += dst->pitch; \
|
||||
dstbuf += surf_dst->pitch; \
|
||||
} while(--linecount); \
|
||||
} while(0)
|
||||
|
||||
|
|
@ -712,25 +727,25 @@ RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
|
|||
|
||||
/* blit a pixel-alpha RLE surface */
|
||||
int
|
||||
SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
|
||||
SDL_Surface * surf_dst, SDL_Rect * dstrect)
|
||||
{
|
||||
int x, y;
|
||||
int w = src->w;
|
||||
int w = surf_src->w;
|
||||
Uint8 *srcbuf, *dstbuf;
|
||||
SDL_PixelFormat *df = dst->format;
|
||||
SDL_PixelFormat *df = surf_dst->format;
|
||||
|
||||
/* Lock the destination if necessary */
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
if (SDL_MUSTLOCK(surf_dst)) {
|
||||
if (SDL_LockSurface(surf_dst) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x = dstrect->x;
|
||||
y = dstrect->y;
|
||||
dstbuf = (Uint8 *) dst->pixels + y * dst->pitch + x * df->BytesPerPixel;
|
||||
srcbuf = (Uint8 *) src->map->data + sizeof(RLEDestFormat);
|
||||
dstbuf = (Uint8 *) surf_dst->pixels + y * surf_dst->pitch + x * df->BytesPerPixel;
|
||||
srcbuf = (Uint8 *) surf_src->map->data + sizeof(RLEDestFormat);
|
||||
|
||||
{
|
||||
/* skip lines at the top if necessary */
|
||||
|
|
@ -789,8 +804,8 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
}
|
||||
|
||||
/* if left or right edge clipping needed, call clip blit */
|
||||
if (srcrect->x || srcrect->w != src->w) {
|
||||
RLEAlphaClipBlit(w, srcbuf, dst, dstbuf, srcrect);
|
||||
if (srcrect->x || srcrect->w != surf_src->w) {
|
||||
RLEAlphaClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect);
|
||||
} else {
|
||||
|
||||
/*
|
||||
|
|
@ -839,7 +854,7 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
ofs += run; \
|
||||
} \
|
||||
} while(ofs < w); \
|
||||
dstbuf += dst->pitch; \
|
||||
dstbuf += surf_dst->pitch; \
|
||||
} while(--linecount); \
|
||||
} while(0)
|
||||
|
||||
|
|
@ -859,8 +874,8 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
|
||||
done:
|
||||
/* Unlock the destination if necessary */
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
SDL_UnlockSurface(dst);
|
||||
if (SDL_MUSTLOCK(surf_dst)) {
|
||||
SDL_UnlockSurface(surf_dst);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -979,7 +994,7 @@ copy_32(void *dst, Uint32 * src, int n,
|
|||
for (i = 0; i < n; i++) {
|
||||
unsigned r, g, b, a;
|
||||
RGBA_FROM_8888(*src, sfmt, r, g, b, a);
|
||||
PIXEL_FROM_RGBA(*d, dfmt, r, g, b, a);
|
||||
RLEPIXEL_FROM_RGBA(*d, dfmt, r, g, b, a);
|
||||
d++;
|
||||
src++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -402,18 +402,18 @@ do { \
|
|||
{ \
|
||||
switch (bpp) { \
|
||||
case 1: { \
|
||||
Uint8 Pixel; \
|
||||
Uint8 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
|
||||
*((Uint8 *)(buf)) = Pixel; \
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint8 *)(buf)) = _pixel; \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
case 2: { \
|
||||
Uint16 Pixel; \
|
||||
Uint16 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
|
||||
*((Uint16 *)(buf)) = Pixel; \
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint16 *)(buf)) = _pixel; \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
|
|
@ -431,10 +431,10 @@ do { \
|
|||
break; \
|
||||
\
|
||||
case 4: { \
|
||||
Uint32 Pixel; \
|
||||
Uint32 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
|
||||
*((Uint32 *)(buf)) = Pixel; \
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint32 *)(buf)) = _pixel; \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -343,7 +343,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
|
|||
mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */
|
||||
multmask = 0x00FF;
|
||||
multmask <<= (ashift * 2);
|
||||
multmask2 = 0x00FF00FF00FF00FF;
|
||||
multmask2 = 0x00FF00FF00FF00FFULL;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
|
|
@ -530,7 +530,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
|
|||
mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */
|
||||
multmask = 0x00FF;
|
||||
multmask <<= (ashift * 2);
|
||||
multmask2 = 0x00FF00FF00FF00FF;
|
||||
multmask2 = 0x00FF00FF00FF00FFULL;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
|
|
@ -580,7 +580,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
|
|||
_mm_empty();
|
||||
}
|
||||
|
||||
#endif /* __MMX__ */
|
||||
#endif /* __3dNOW__ */
|
||||
|
||||
/* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -2114,6 +2114,33 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
|||
}
|
||||
}
|
||||
|
||||
/* blits 32 bit RGBA<->RGBA with both surfaces having the same R,G,B,A fields */
|
||||
static void
|
||||
Blit4to4CopyAlpha(SDL_BlitInfo * info)
|
||||
{
|
||||
int width = info->dst_w;
|
||||
int height = info->dst_h;
|
||||
Uint32 *src = (Uint32 *) info->src;
|
||||
int srcskip = info->src_skip;
|
||||
Uint32 *dst = (Uint32 *) info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
|
||||
/* RGBA->RGBA, COPY_ALPHA */
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src;
|
||||
++dst;
|
||||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
src = (Uint32 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
BlitNtoN(SDL_BlitInfo * info)
|
||||
{
|
||||
|
|
@ -2562,8 +2589,17 @@ SDL_CalculateBlitN(SDL_Surface * surface)
|
|||
srcfmt->Rmask == dstfmt->Rmask &&
|
||||
srcfmt->Gmask == dstfmt->Gmask &&
|
||||
srcfmt->Bmask == dstfmt->Bmask) {
|
||||
/* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
|
||||
blitfun = Blit4to4MaskAlpha;
|
||||
if (a_need == COPY_ALPHA) {
|
||||
if (srcfmt->Amask == dstfmt->Amask) {
|
||||
/* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */
|
||||
blitfun = Blit4to4CopyAlpha;
|
||||
} else {
|
||||
blitfun = BlitNtoNCopyAlpha;
|
||||
}
|
||||
} else {
|
||||
/* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
|
||||
blitfun = Blit4to4MaskAlpha;
|
||||
}
|
||||
} else if (a_need == COPY_ALPHA) {
|
||||
blitfun = BlitNtoNCopyAlpha;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,7 @@
|
|||
/* DO NOT EDIT! This file is generated by sdlgenblit.pl */
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
|
||||
|
|
@ -84,15 +85,17 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
|||
int bmpPitch;
|
||||
int i, pad;
|
||||
SDL_Surface *surface;
|
||||
Uint32 Rmask;
|
||||
Uint32 Gmask;
|
||||
Uint32 Bmask;
|
||||
Uint32 Amask;
|
||||
Uint32 Rmask = 0;
|
||||
Uint32 Gmask = 0;
|
||||
Uint32 Bmask = 0;
|
||||
Uint32 Amask = 0;
|
||||
SDL_Palette *palette;
|
||||
Uint8 *bits;
|
||||
Uint8 *top, *end;
|
||||
SDL_bool topDown;
|
||||
int ExpandBMP;
|
||||
SDL_bool haveRGBMasks = SDL_FALSE;
|
||||
SDL_bool haveAlphaMask = SDL_FALSE;
|
||||
SDL_bool correctAlpha = SDL_FALSE;
|
||||
|
||||
/* The Win32 BMP file header (14 bytes) */
|
||||
|
|
@ -143,15 +146,14 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
|||
|
||||
/* Read the Win32 BITMAPINFOHEADER */
|
||||
biSize = SDL_ReadLE32(src);
|
||||
if (biSize == 12) {
|
||||
if (biSize == 12) { /* really old BITMAPCOREHEADER */
|
||||
biWidth = (Uint32) SDL_ReadLE16(src);
|
||||
biHeight = (Uint32) SDL_ReadLE16(src);
|
||||
/* biPlanes = */ SDL_ReadLE16(src);
|
||||
biBitCount = SDL_ReadLE16(src);
|
||||
biCompression = BI_RGB;
|
||||
} else {
|
||||
const unsigned int headerSize = 40;
|
||||
|
||||
} else if (biSize >= 40) { /* some version of BITMAPINFOHEADER */
|
||||
Uint32 headerSize;
|
||||
biWidth = SDL_ReadLE32(src);
|
||||
biHeight = SDL_ReadLE32(src);
|
||||
/* biPlanes = */ SDL_ReadLE16(src);
|
||||
|
|
@ -163,6 +165,54 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
|||
biClrUsed = SDL_ReadLE32(src);
|
||||
/* biClrImportant = */ SDL_ReadLE32(src);
|
||||
|
||||
/* 64 == BITMAPCOREHEADER2, an incompatible OS/2 2.x extension. Skip this stuff for now. */
|
||||
if (biSize == 64) {
|
||||
/* ignore these extra fields. */
|
||||
if (biCompression == BI_BITFIELDS) {
|
||||
/* this value is actually huffman compression in this variant. */
|
||||
SDL_SetError("Compressed BMP files not supported");
|
||||
was_error = SDL_TRUE;
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
/* This is complicated. If compression is BI_BITFIELDS, then
|
||||
we have 3 DWORDS that specify the RGB masks. This is either
|
||||
stored here in an BITMAPV2INFOHEADER (which only differs in
|
||||
that it adds these RGB masks) and biSize >= 52, or we've got
|
||||
these masks stored in the exact same place, but strictly
|
||||
speaking, this is the bmiColors field in BITMAPINFO immediately
|
||||
following the legacy v1 info header, just past biSize. */
|
||||
if (biCompression == BI_BITFIELDS) {
|
||||
haveRGBMasks = SDL_TRUE;
|
||||
Rmask = SDL_ReadLE32(src);
|
||||
Gmask = SDL_ReadLE32(src);
|
||||
Bmask = SDL_ReadLE32(src);
|
||||
|
||||
/* ...v3 adds an alpha mask. */
|
||||
if (biSize >= 56) { /* BITMAPV3INFOHEADER; adds alpha mask */
|
||||
haveAlphaMask = SDL_TRUE;
|
||||
Amask = SDL_ReadLE32(src);
|
||||
}
|
||||
} else {
|
||||
/* the mask fields are ignored for v2+ headers if not BI_BITFIELD. */
|
||||
if (biSize >= 52) { /* BITMAPV2INFOHEADER; adds RGB masks */
|
||||
/*Rmask = */ SDL_ReadLE32(src);
|
||||
/*Gmask = */ SDL_ReadLE32(src);
|
||||
/*Bmask = */ SDL_ReadLE32(src);
|
||||
}
|
||||
if (biSize >= 56) { /* BITMAPV3INFOHEADER; adds alpha mask */
|
||||
/*Amask = */ SDL_ReadLE32(src);
|
||||
}
|
||||
}
|
||||
|
||||
/* Insert other fields here; Wikipedia and MSDN say we're up to
|
||||
v5 of this header, but we ignore those for now (they add gamma,
|
||||
color spaces, etc). Ignoring the weird OS/2 2.x format, we
|
||||
currently parse up to v3 correctly (hopefully!). */
|
||||
}
|
||||
|
||||
/* skip any header bytes we didn't handle... */
|
||||
headerSize = (Uint32) (SDL_RWtell(src) - (fp_offset + 14));
|
||||
if (biSize > headerSize) {
|
||||
SDL_RWseek(src, (biSize - headerSize), RW_SEEK_CUR);
|
||||
}
|
||||
|
|
@ -193,63 +243,46 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
|||
}
|
||||
|
||||
/* We don't support any BMP compression right now */
|
||||
Rmask = Gmask = Bmask = Amask = 0;
|
||||
switch (biCompression) {
|
||||
case BI_RGB:
|
||||
/* If there are no masks, use the defaults */
|
||||
if (bfOffBits == (14 + biSize)) {
|
||||
/* Default values for the BMP format */
|
||||
switch (biBitCount) {
|
||||
case 15:
|
||||
case 16:
|
||||
Rmask = 0x7C00;
|
||||
Gmask = 0x03E0;
|
||||
Bmask = 0x001F;
|
||||
break;
|
||||
case 24:
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
Rmask = 0x000000FF;
|
||||
Gmask = 0x0000FF00;
|
||||
Bmask = 0x00FF0000;
|
||||
#else
|
||||
Rmask = 0x00FF0000;
|
||||
Gmask = 0x0000FF00;
|
||||
Bmask = 0x000000FF;
|
||||
#endif
|
||||
break;
|
||||
case 32:
|
||||
/* We don't know if this has alpha channel or not */
|
||||
correctAlpha = SDL_TRUE;
|
||||
Amask = 0xFF000000;
|
||||
Rmask = 0x00FF0000;
|
||||
Gmask = 0x0000FF00;
|
||||
Bmask = 0x000000FF;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* Fall through -- read the RGB masks */
|
||||
|
||||
case BI_BITFIELDS:
|
||||
SDL_assert(!haveRGBMasks);
|
||||
SDL_assert(!haveAlphaMask);
|
||||
/* Default values for the BMP format */
|
||||
switch (biBitCount) {
|
||||
case 15:
|
||||
case 16:
|
||||
Rmask = SDL_ReadLE32(src);
|
||||
Gmask = SDL_ReadLE32(src);
|
||||
Bmask = SDL_ReadLE32(src);
|
||||
Rmask = 0x7C00;
|
||||
Gmask = 0x03E0;
|
||||
Bmask = 0x001F;
|
||||
break;
|
||||
case 24:
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
Rmask = 0x000000FF;
|
||||
Gmask = 0x0000FF00;
|
||||
Bmask = 0x00FF0000;
|
||||
#else
|
||||
Rmask = 0x00FF0000;
|
||||
Gmask = 0x0000FF00;
|
||||
Bmask = 0x000000FF;
|
||||
#endif
|
||||
break;
|
||||
case 32:
|
||||
Rmask = SDL_ReadLE32(src);
|
||||
Gmask = SDL_ReadLE32(src);
|
||||
Bmask = SDL_ReadLE32(src);
|
||||
Amask = SDL_ReadLE32(src);
|
||||
/* We don't know if this has alpha channel or not */
|
||||
correctAlpha = SDL_TRUE;
|
||||
Amask = 0xFF000000;
|
||||
Rmask = 0x00FF0000;
|
||||
Gmask = 0x0000FF00;
|
||||
Bmask = 0x000000FF;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BI_BITFIELDS:
|
||||
break; /* we handled this in the info header. */
|
||||
|
||||
default:
|
||||
SDL_SetError("Compressed BMP files not supported");
|
||||
was_error = SDL_TRUE;
|
||||
|
|
@ -268,20 +301,24 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
|||
/* Load the palette, if any */
|
||||
palette = (surface->format)->palette;
|
||||
if (palette) {
|
||||
SDL_assert(biBitCount <= 8);
|
||||
if (biClrUsed == 0) {
|
||||
biClrUsed = 1 << biBitCount;
|
||||
}
|
||||
if ((int) biClrUsed > palette->ncolors) {
|
||||
palette->ncolors = biClrUsed;
|
||||
palette->colors =
|
||||
SDL_Color *colors;
|
||||
int ncolors = biClrUsed;
|
||||
colors =
|
||||
(SDL_Color *) SDL_realloc(palette->colors,
|
||||
palette->ncolors *
|
||||
ncolors *
|
||||
sizeof(*palette->colors));
|
||||
if (!palette->colors) {
|
||||
if (!colors) {
|
||||
SDL_OutOfMemory();
|
||||
was_error = SDL_TRUE;
|
||||
goto done;
|
||||
}
|
||||
palette->ncolors = ncolors;
|
||||
palette->colors = colors;
|
||||
} else if ((int) biClrUsed < palette->ncolors) {
|
||||
palette->ncolors = biClrUsed;
|
||||
}
|
||||
|
|
@ -494,6 +531,10 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst)
|
|||
format.BitsPerPixel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Set no error here because it may overwrite a more useful message from
|
||||
SDL_RWFromFile() if SDL_SaveBMP_RW() is called from SDL_SaveBMP(). */
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (surface && (SDL_LockSurface(surface) == 0)) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -29,6 +29,10 @@ SDL_SetClipboardText(const char *text)
|
|||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
if (!_this) {
|
||||
return SDL_SetError("Video subsystem must be initialized to set clipboard text");
|
||||
}
|
||||
|
||||
if (!text) {
|
||||
text = "";
|
||||
}
|
||||
|
|
@ -46,6 +50,11 @@ SDL_GetClipboardText(void)
|
|||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
if (!_this) {
|
||||
SDL_SetError("Video subsystem must be initialized to get clipboard text");
|
||||
return SDL_strdup("");
|
||||
}
|
||||
|
||||
if (_this->GetClipboardText) {
|
||||
return _this->GetClipboardText(_this);
|
||||
} else {
|
||||
|
|
@ -62,6 +71,11 @@ SDL_HasClipboardText(void)
|
|||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
if (!_this) {
|
||||
SDL_SetError("Video subsystem must be initialized to check clipboard text");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (_this->HasClipboardText) {
|
||||
return _this->HasClipboardText(_this);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Simple DirectMedia Layer
|
||||
* Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
* Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -22,11 +22,22 @@
|
|||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
#include "SDL_sysvideo.h"
|
||||
#include "SDL_egl_c.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#ifdef EGL_KHR_create_context
|
||||
/* EGL_OPENGL_ES3_BIT_KHR was added in version 13 of the extension. */
|
||||
#ifndef EGL_OPENGL_ES3_BIT_KHR
|
||||
#define EGL_OPENGL_ES3_BIT_KHR 0x00000040
|
||||
#endif
|
||||
#endif /* EGL_KHR_create_context */
|
||||
|
||||
#if SDL_VIDEO_DRIVER_RPI
|
||||
/* Raspbian places the OpenGL ES/EGL binaries in a non standard path */
|
||||
#define DEFAULT_EGL "/opt/vc/lib/libEGL.so"
|
||||
|
|
@ -34,7 +45,7 @@
|
|||
#define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so"
|
||||
#define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so"
|
||||
|
||||
#elif SDL_VIDEO_DRIVER_ANDROID
|
||||
#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
|
||||
/* Android */
|
||||
#define DEFAULT_EGL "libEGL.so"
|
||||
#define DEFAULT_OGL_ES2 "libGLESv2.so"
|
||||
|
|
@ -58,13 +69,45 @@
|
|||
#endif /* SDL_VIDEO_DRIVER_RPI */
|
||||
|
||||
#define LOAD_FUNC(NAME) \
|
||||
*((void**)&_this->egl_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
|
||||
_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
|
||||
if (!_this->egl_data->NAME) \
|
||||
{ \
|
||||
return SDL_SetError("Could not retrieve EGL function " #NAME); \
|
||||
}
|
||||
|
||||
/* EGL implementation of SDL OpenGL ES support */
|
||||
#ifdef EGL_KHR_create_context
|
||||
static int SDL_EGL_HasExtension(_THIS, const char *ext)
|
||||
{
|
||||
int i;
|
||||
int len = 0;
|
||||
size_t ext_len;
|
||||
const char *exts;
|
||||
const char *ext_word;
|
||||
|
||||
ext_len = SDL_strlen(ext);
|
||||
exts = _this->egl_data->eglQueryString(_this->egl_data->egl_display, EGL_EXTENSIONS);
|
||||
|
||||
if (exts) {
|
||||
ext_word = exts;
|
||||
|
||||
for (i = 0; exts[i] != 0; i++) {
|
||||
if (exts[i] == ' ') {
|
||||
if (ext_len == len && !SDL_strncmp(ext_word, ext, len)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
len = 0;
|
||||
ext_word = &exts[i + 1];
|
||||
} else {
|
||||
len++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* EGL_KHR_create_context */
|
||||
|
||||
void *
|
||||
SDL_EGL_GetProcAddress(_THIS, const char *proc)
|
||||
|
|
@ -73,7 +116,7 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc)
|
|||
void *retval;
|
||||
|
||||
/* eglGetProcAddress is busted on Android http://code.google.com/p/android/issues/detail?id=7681 */
|
||||
#if !defined(SDL_VIDEO_DRIVER_ANDROID)
|
||||
#if !defined(SDL_VIDEO_DRIVER_ANDROID) && !defined(SDL_VIDEO_DRIVER_MIR)
|
||||
if (_this->egl_data->eglGetProcAddress) {
|
||||
retval = _this->egl_data->eglGetProcAddress(proc);
|
||||
if (retval) {
|
||||
|
|
@ -135,8 +178,11 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
|||
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
|
||||
d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER);
|
||||
if (!d3dcompiler) {
|
||||
/* By default we load the Vista+ compatible compiler */
|
||||
d3dcompiler = "d3dcompiler_46.dll";
|
||||
if (WIN_IsWindowsVistaOrGreater()) {
|
||||
d3dcompiler = "d3dcompiler_46.dll";
|
||||
} else {
|
||||
d3dcompiler = "d3dcompiler_43.dll";
|
||||
}
|
||||
}
|
||||
if (SDL_strcasecmp(d3dcompiler, "none") != 0) {
|
||||
SDL_LoadObject(d3dcompiler);
|
||||
|
|
@ -150,12 +196,11 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
|||
}
|
||||
|
||||
if (egl_dll_handle == NULL) {
|
||||
if(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
if (_this->gl_config.major_version > 1) {
|
||||
path = DEFAULT_OGL_ES2;
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
path = DEFAULT_OGL_ES;
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
if (egl_dll_handle == NULL) {
|
||||
|
|
@ -182,7 +227,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
|||
dll_handle = SDL_LoadObject(egl_path);
|
||||
}
|
||||
/* Try loading a EGL symbol, if it does not work try the default library paths */
|
||||
if (SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
|
||||
if (dll_handle == NULL || SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
|
||||
if (dll_handle != NULL) {
|
||||
SDL_UnloadObject(dll_handle);
|
||||
}
|
||||
|
|
@ -191,9 +236,13 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
|||
path = DEFAULT_EGL;
|
||||
}
|
||||
dll_handle = SDL_LoadObject(path);
|
||||
if (dll_handle == NULL) {
|
||||
if (dll_handle == NULL || SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
|
||||
if (dll_handle != NULL) {
|
||||
SDL_UnloadObject(dll_handle);
|
||||
}
|
||||
return SDL_SetError("Could not load EGL library");
|
||||
}
|
||||
SDL_ClearError();
|
||||
}
|
||||
|
||||
_this->egl_data->dll_handle = dll_handle;
|
||||
|
|
@ -215,7 +264,9 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
|||
LOAD_FUNC(eglWaitNative);
|
||||
LOAD_FUNC(eglWaitGL);
|
||||
LOAD_FUNC(eglBindAPI);
|
||||
LOAD_FUNC(eglQueryString);
|
||||
|
||||
#if !defined(__WINRT__)
|
||||
_this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display);
|
||||
if (!_this->egl_data->egl_display) {
|
||||
return SDL_SetError("Could not get EGL display");
|
||||
|
|
@ -224,9 +275,8 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
|||
if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
|
||||
return SDL_SetError("Could not initialize EGL");
|
||||
}
|
||||
#endif
|
||||
|
||||
_this->egl_data->dll_handle = dll_handle;
|
||||
_this->egl_data->egl_dll_handle = egl_dll_handle;
|
||||
_this->gl_config.driver_loaded = 1;
|
||||
|
||||
if (path) {
|
||||
|
|
@ -289,23 +339,40 @@ SDL_EGL_ChooseConfig(_THIS)
|
|||
attribs[i++] = EGL_SAMPLES;
|
||||
attribs[i++] = _this->gl_config.multisamplesamples;
|
||||
}
|
||||
|
||||
|
||||
if (_this->gl_config.framebuffer_srgb_capable) {
|
||||
#ifdef EGL_KHR_gl_colorspace
|
||||
if (SDL_EGL_HasExtension(_this, "EGL_KHR_gl_colorspace")) {
|
||||
attribs[i++] = EGL_GL_COLORSPACE_KHR;
|
||||
attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
return SDL_SetError("EGL implementation does not support sRGB system framebuffers");
|
||||
}
|
||||
}
|
||||
|
||||
attribs[i++] = EGL_RENDERABLE_TYPE;
|
||||
if(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
if (_this->gl_config.major_version == 2) {
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
#ifdef EGL_KHR_create_context
|
||||
if (_this->gl_config.major_version >= 3 &&
|
||||
SDL_EGL_HasExtension(_this, "EGL_KHR_create_context")) {
|
||||
attribs[i++] = EGL_OPENGL_ES3_BIT_KHR;
|
||||
} else
|
||||
#endif
|
||||
if (_this->gl_config.major_version >= 2) {
|
||||
attribs[i++] = EGL_OPENGL_ES2_BIT;
|
||||
} else {
|
||||
attribs[i++] = EGL_OPENGL_ES_BIT;
|
||||
}
|
||||
_this->egl_data->eglBindAPI(EGL_OPENGL_ES_API);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
attribs[i++] = EGL_OPENGL_BIT;
|
||||
_this->egl_data->eglBindAPI(EGL_OPENGL_API);
|
||||
}
|
||||
|
||||
|
||||
attribs[i++] = EGL_NONE;
|
||||
|
||||
|
||||
if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display,
|
||||
attribs,
|
||||
configs, SDL_arraysize(configs),
|
||||
|
|
@ -313,11 +380,11 @@ SDL_EGL_ChooseConfig(_THIS)
|
|||
found_configs == 0) {
|
||||
return SDL_SetError("Couldn't find matching EGL config");
|
||||
}
|
||||
|
||||
|
||||
/* eglChooseConfig returns a number of configurations that match or exceed the requested attribs. */
|
||||
/* From those, we select the one that matches our requirements more closely via a makeshift algorithm */
|
||||
|
||||
for ( i=0; i<found_configs; i++ ) {
|
||||
for (i = 0; i < found_configs; i++ ) {
|
||||
bitdiff = 0;
|
||||
for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) {
|
||||
if (attribs[j] == EGL_NONE) {
|
||||
|
|
@ -341,8 +408,10 @@ SDL_EGL_ChooseConfig(_THIS)
|
|||
|
||||
best_bitdiff = bitdiff;
|
||||
}
|
||||
|
||||
if (bitdiff == 0) break; /* we found an exact match! */
|
||||
|
||||
if (bitdiff == 0) {
|
||||
break; /* we found an exact match! */
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -351,54 +420,95 @@ SDL_EGL_ChooseConfig(_THIS)
|
|||
SDL_GLContext
|
||||
SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
||||
{
|
||||
EGLint context_attrib_list[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION,
|
||||
1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
/* max 14 values plus terminator. */
|
||||
EGLint attribs[15];
|
||||
int attr = 0;
|
||||
|
||||
EGLContext egl_context, share_context = EGL_NO_CONTEXT;
|
||||
|
||||
EGLint profile_mask = _this->gl_config.profile_mask;
|
||||
EGLint major_version = _this->gl_config.major_version;
|
||||
EGLint minor_version = _this->gl_config.minor_version;
|
||||
SDL_bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES);
|
||||
|
||||
if (!_this->egl_data) {
|
||||
/* The EGL library wasn't loaded, SDL_GetError() should have info */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (_this->gl_config.share_with_current_context) {
|
||||
share_context = (EGLContext)SDL_GL_GetCurrentContext();
|
||||
}
|
||||
|
||||
/* Bind the API */
|
||||
if(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
_this->egl_data->eglBindAPI(EGL_OPENGL_ES_API);
|
||||
if (_this->gl_config.major_version) {
|
||||
context_attrib_list[1] = _this->gl_config.major_version;
|
||||
}
|
||||
|
||||
egl_context = _this->egl_data->eglCreateContext(_this->egl_data->egl_display,
|
||||
_this->egl_data->egl_config,
|
||||
share_context, context_attrib_list);
|
||||
/* Set the context version and other attributes. */
|
||||
if ((major_version < 3 || (minor_version == 0 && profile_es)) &&
|
||||
_this->gl_config.flags == 0 &&
|
||||
(profile_mask == 0 || profile_es)) {
|
||||
/* Create a context without using EGL_KHR_create_context attribs.
|
||||
* When creating a GLES context without EGL_KHR_create_context we can
|
||||
* only specify the major version. When creating a desktop GL context
|
||||
* we can't specify any version, so we only try in that case when the
|
||||
* version is less than 3.0 (matches SDL's GLX/WGL behavior.)
|
||||
*/
|
||||
if (profile_es) {
|
||||
attribs[attr++] = EGL_CONTEXT_CLIENT_VERSION;
|
||||
attribs[attr++] = SDL_max(major_version, 1);
|
||||
}
|
||||
} else {
|
||||
#ifdef EGL_KHR_create_context
|
||||
/* The Major/minor version, context profiles, and context flags can
|
||||
* only be specified when this extension is available.
|
||||
*/
|
||||
if (SDL_EGL_HasExtension(_this, "EGL_KHR_create_context")) {
|
||||
attribs[attr++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
|
||||
attribs[attr++] = major_version;
|
||||
attribs[attr++] = EGL_CONTEXT_MINOR_VERSION_KHR;
|
||||
attribs[attr++] = minor_version;
|
||||
|
||||
/* SDL profile bits match EGL profile bits. */
|
||||
if (profile_mask != 0 && profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
attribs[attr++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
||||
attribs[attr++] = profile_mask;
|
||||
}
|
||||
|
||||
/* SDL flags match EGL flags. */
|
||||
if (_this->gl_config.flags != 0) {
|
||||
attribs[attr++] = EGL_CONTEXT_FLAGS_KHR;
|
||||
attribs[attr++] = _this->gl_config.flags;
|
||||
}
|
||||
} else
|
||||
#endif /* EGL_KHR_create_context */
|
||||
{
|
||||
SDL_SetError("Could not create EGL context (context attributes are not supported)");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
attribs[attr++] = EGL_NONE;
|
||||
|
||||
/* Bind the API */
|
||||
if (profile_es) {
|
||||
_this->egl_data->eglBindAPI(EGL_OPENGL_ES_API);
|
||||
} else {
|
||||
_this->egl_data->eglBindAPI(EGL_OPENGL_API);
|
||||
egl_context = _this->egl_data->eglCreateContext(_this->egl_data->egl_display,
|
||||
_this->egl_data->egl_config,
|
||||
share_context, NULL);
|
||||
}
|
||||
|
||||
|
||||
egl_context = _this->egl_data->eglCreateContext(_this->egl_data->egl_display,
|
||||
_this->egl_data->egl_config,
|
||||
share_context, attribs);
|
||||
|
||||
if (egl_context == EGL_NO_CONTEXT) {
|
||||
SDL_SetError("Could not create EGL context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
_this->egl_data->egl_swapinterval = 0;
|
||||
|
||||
|
||||
if (SDL_EGL_MakeCurrent(_this, egl_surface, egl_context) < 0) {
|
||||
SDL_EGL_DeleteContext(_this, egl_context);
|
||||
SDL_SetError("Could not make EGL context current");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return (SDL_GLContext) egl_context;
|
||||
}
|
||||
|
||||
|
|
@ -416,8 +526,7 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
|
|||
*/
|
||||
if (!egl_context || !egl_surface) {
|
||||
_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display,
|
||||
egl_surface, egl_surface, egl_context)) {
|
||||
return SDL_SetError("Unable to make EGL context current");
|
||||
|
|
@ -485,6 +594,20 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
|
|||
return EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
#if __ANDROID__
|
||||
{
|
||||
/* Android docs recommend doing this!
|
||||
* Ref: http://developer.android.com/reference/android/app/NativeActivity.html
|
||||
*/
|
||||
EGLint format;
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
|
||||
_this->egl_data->egl_config,
|
||||
EGL_NATIVE_VISUAL_ID, &format);
|
||||
|
||||
ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
|
||||
}
|
||||
#endif
|
||||
|
||||
return _this->egl_data->eglCreateWindowSurface(
|
||||
_this->egl_data->egl_display,
|
||||
_this->egl_data->egl_config,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -99,12 +99,11 @@ static void
|
|||
SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
||||
{
|
||||
int i, n;
|
||||
Uint8 *p = NULL;
|
||||
|
||||
|
||||
SSE_BEGIN;
|
||||
while (h--) {
|
||||
Uint8 *p = pixels;
|
||||
n = w;
|
||||
p = pixels;
|
||||
|
||||
if (n > 63) {
|
||||
int adjust = 16 - ((uintptr_t)p & 15);
|
||||
|
|
@ -118,7 +117,6 @@ SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
|||
if (n & 63) {
|
||||
int remainder = (n & 63);
|
||||
SDL_memset(p, color, remainder);
|
||||
p += remainder;
|
||||
}
|
||||
pixels += pitch;
|
||||
}
|
||||
|
|
@ -198,9 +196,15 @@ SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
|
|||
static void
|
||||
SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
|
||||
{
|
||||
Uint8 r = (Uint8) ((color >> 16) & 0xFF);
|
||||
Uint8 g = (Uint8) ((color >> 8) & 0xFF);
|
||||
Uint8 b = (Uint8) (color & 0xFF);
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
Uint8 b1 = (Uint8) (color & 0xFF);
|
||||
Uint8 b2 = (Uint8) ((color >> 8) & 0xFF);
|
||||
Uint8 b3 = (Uint8) ((color >> 16) & 0xFF);
|
||||
#elif SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
Uint8 b1 = (Uint8) ((color >> 16) & 0xFF);
|
||||
Uint8 b2 = (Uint8) ((color >> 8) & 0xFF);
|
||||
Uint8 b3 = (Uint8) (color & 0xFF);
|
||||
#endif
|
||||
int n;
|
||||
Uint8 *p = NULL;
|
||||
|
||||
|
|
@ -209,9 +213,9 @@ SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
|
|||
p = pixels;
|
||||
|
||||
while (n--) {
|
||||
*p++ = r;
|
||||
*p++ = g;
|
||||
*p++ = b;
|
||||
*p++ = b1;
|
||||
*p++ = b2;
|
||||
*p++ = b3;
|
||||
}
|
||||
pixels += pitch;
|
||||
}
|
||||
|
|
@ -253,6 +257,10 @@ SDL_FillRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color)
|
|||
rect = &clipped;
|
||||
} else {
|
||||
rect = &dst->clip_rect;
|
||||
/* Don't attempt to fill if the surface's clip_rect is empty */
|
||||
if (SDL_RectEmpty(rect)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform software fill */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -122,6 +122,8 @@ SDL_GetPixelFormatName(Uint32 format)
|
|||
CASE(SDL_PIXELFORMAT_YUY2)
|
||||
CASE(SDL_PIXELFORMAT_UYVY)
|
||||
CASE(SDL_PIXELFORMAT_YVYU)
|
||||
CASE(SDL_PIXELFORMAT_NV12)
|
||||
CASE(SDL_PIXELFORMAT_NV21)
|
||||
#undef CASE
|
||||
default:
|
||||
return "SDL_PIXELFORMAT_UNKNOWN";
|
||||
|
|
@ -1099,9 +1101,7 @@ SDL_CalculateGammaRamp(float gamma, Uint16 * ramp)
|
|||
|
||||
/* 0.0 gamma is all black */
|
||||
if (gamma == 0.0f) {
|
||||
for (i = 0; i < 256; ++i) {
|
||||
ramp[i] = 0;
|
||||
}
|
||||
SDL_memset(ramp, 0, 256 * sizeof(Uint16));
|
||||
return;
|
||||
} else if (gamma == 1.0f) {
|
||||
/* 1.0 gamma is identity */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -128,6 +128,7 @@ RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rec
|
|||
SDL_Color key;
|
||||
SDL_ShapeTree* result = (SDL_ShapeTree*)SDL_malloc(sizeof(SDL_ShapeTree));
|
||||
SDL_Rect next = {0,0,0,0};
|
||||
|
||||
for(y=dimensions.y;y<dimensions.y + dimensions.h;y++) {
|
||||
for(x=dimensions.x;x<dimensions.x + dimensions.w;x++) {
|
||||
pixel_value = 0;
|
||||
|
|
@ -165,27 +166,37 @@ RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rec
|
|||
if(last_opaque == -1)
|
||||
last_opaque = pixel_opaque;
|
||||
if(last_opaque != pixel_opaque) {
|
||||
const int halfwidth = dimensions.w / 2;
|
||||
const int halfheight = dimensions.h / 2;
|
||||
|
||||
result->kind = QuadShape;
|
||||
/* These will stay the same. */
|
||||
next.w = dimensions.w / 2;
|
||||
next.h = dimensions.h / 2;
|
||||
/* These will change from recursion to recursion. */
|
||||
|
||||
next.x = dimensions.x;
|
||||
next.y = dimensions.y;
|
||||
next.w = halfwidth;
|
||||
next.h = halfheight;
|
||||
result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
|
||||
next.x += next.w;
|
||||
/* Unneeded: next.y = dimensions.y; */
|
||||
|
||||
next.x = dimensions.x + halfwidth;
|
||||
next.w = dimensions.w - halfwidth;
|
||||
result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
|
||||
|
||||
next.x = dimensions.x;
|
||||
next.y += next.h;
|
||||
next.w = halfwidth;
|
||||
next.y = dimensions.y + halfheight;
|
||||
next.h = dimensions.h - halfheight;
|
||||
result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
|
||||
next.x += next.w;
|
||||
/* Unneeded: next.y = dimensions.y + dimensions.h /2; */
|
||||
|
||||
next.x = dimensions.x + halfwidth;
|
||||
next.w = dimensions.w - halfwidth;
|
||||
result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* If we never recursed, all the pixels in this quadrant have the same "value". */
|
||||
result->kind = (last_opaque == SDL_TRUE ? OpaqueShape : TransparentShape);
|
||||
result->data.shape = dimensions;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -26,7 +26,6 @@
|
|||
#include "SDL_RLEaccel_c.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
|
||||
|
||||
/* Public routines */
|
||||
/*
|
||||
* Create an empty RGB surface of the appropriate depth
|
||||
|
|
@ -145,7 +144,12 @@ SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette)
|
|||
if (!surface) {
|
||||
return SDL_SetError("SDL_SetSurfacePalette() passed a NULL surface");
|
||||
}
|
||||
return SDL_SetPixelFormatPalette(surface->format, palette);
|
||||
if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
|
||||
return -1;
|
||||
}
|
||||
SDL_InvalidateMap(surface->map);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -618,7 +622,12 @@ int
|
|||
SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
{
|
||||
SDL_Rect final_src, final_dst, fulldst;
|
||||
double src_x0, src_y0, src_x1, src_y1;
|
||||
double dst_x0, dst_y0, dst_x1, dst_y1;
|
||||
SDL_Rect final_src, final_dst;
|
||||
double scaling_w, scaling_h;
|
||||
int src_w, src_h;
|
||||
int dst_w, dst_h;
|
||||
|
||||
/* Make sure the surfaces aren't locked */
|
||||
if (!src || !dst) {
|
||||
|
|
@ -628,78 +637,135 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||
return SDL_SetError("Surfaces must not be locked during blit");
|
||||
}
|
||||
|
||||
/* If the destination rectangle is NULL, use the entire dest surface */
|
||||
if (dstrect == NULL) {
|
||||
fulldst.x = fulldst.y = 0;
|
||||
fulldst.w = dst->w;
|
||||
fulldst.h = dst->h;
|
||||
dstrect = &fulldst;
|
||||
}
|
||||
|
||||
/* clip the source rectangle to the source surface */
|
||||
if (srcrect) {
|
||||
int maxw, maxh;
|
||||
|
||||
final_src.x = srcrect->x;
|
||||
final_src.w = srcrect->w;
|
||||
if (final_src.x < 0) {
|
||||
final_src.w += final_src.x;
|
||||
final_src.x = 0;
|
||||
}
|
||||
maxw = src->w - final_src.x;
|
||||
if (maxw < final_src.w)
|
||||
final_src.w = maxw;
|
||||
|
||||
final_src.y = srcrect->y;
|
||||
final_src.h = srcrect->h;
|
||||
if (final_src.y < 0) {
|
||||
final_src.h += final_src.y;
|
||||
final_src.y = 0;
|
||||
}
|
||||
maxh = src->h - final_src.y;
|
||||
if (maxh < final_src.h)
|
||||
final_src.h = maxh;
|
||||
|
||||
if (NULL == srcrect) {
|
||||
src_w = src->w;
|
||||
src_h = src->h;
|
||||
} else {
|
||||
final_src.x = final_src.y = 0;
|
||||
final_src.w = src->w;
|
||||
final_src.h = src->h;
|
||||
src_w = srcrect->w;
|
||||
src_h = srcrect->h;
|
||||
}
|
||||
|
||||
/* clip the destination rectangle against the clip rectangle */
|
||||
if (dstrect) {
|
||||
int maxw, maxh;
|
||||
|
||||
final_dst.x = dstrect->x;
|
||||
final_dst.w = dstrect->w;
|
||||
if (final_dst.x < 0) {
|
||||
final_dst.w += final_dst.x;
|
||||
final_dst.x = 0;
|
||||
}
|
||||
maxw = dst->w - final_dst.x;
|
||||
if (maxw < final_dst.w)
|
||||
final_dst.w = maxw;
|
||||
|
||||
final_dst.y = dstrect->y;
|
||||
final_dst.h = dstrect->h;
|
||||
if (final_dst.y < 0) {
|
||||
final_dst.h += final_dst.y;
|
||||
final_dst.y = 0;
|
||||
}
|
||||
maxh = dst->h - final_dst.y;
|
||||
if (maxh < final_dst.h)
|
||||
final_dst.h = maxh;
|
||||
if (NULL == dstrect) {
|
||||
dst_w = dst->w;
|
||||
dst_h = dst->h;
|
||||
} else {
|
||||
final_dst.x = final_dst.y = 0;
|
||||
final_dst.w = dst->w;
|
||||
final_dst.h = dst->h;
|
||||
dst_w = dstrect->w;
|
||||
dst_h = dstrect->h;
|
||||
}
|
||||
|
||||
if (final_dst.w > 0 && final_dst.h > 0) {
|
||||
return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst);
|
||||
if (dst_w == src_w && dst_h == src_h) {
|
||||
/* No scaling, defer to regular blit */
|
||||
return SDL_BlitSurface(src, srcrect, dst, dstrect);
|
||||
}
|
||||
|
||||
return 0;
|
||||
scaling_w = (double)dst_w / src_w;
|
||||
scaling_h = (double)dst_h / src_h;
|
||||
|
||||
if (NULL == dstrect) {
|
||||
dst_x0 = 0;
|
||||
dst_y0 = 0;
|
||||
dst_x1 = dst_w - 1;
|
||||
dst_y1 = dst_h - 1;
|
||||
} else {
|
||||
dst_x0 = dstrect->x;
|
||||
dst_y0 = dstrect->y;
|
||||
dst_x1 = dst_x0 + dst_w - 1;
|
||||
dst_y1 = dst_y0 + dst_h - 1;
|
||||
}
|
||||
|
||||
if (NULL == srcrect) {
|
||||
src_x0 = 0;
|
||||
src_y0 = 0;
|
||||
src_x1 = src_w - 1;
|
||||
src_y1 = src_h - 1;
|
||||
} else {
|
||||
src_x0 = srcrect->x;
|
||||
src_y0 = srcrect->y;
|
||||
src_x1 = src_x0 + src_w - 1;
|
||||
src_y1 = src_y0 + src_h - 1;
|
||||
|
||||
/* Clip source rectangle to the source surface */
|
||||
|
||||
if (src_x0 < 0) {
|
||||
dst_x0 -= src_x0 * scaling_w;
|
||||
src_x0 = 0;
|
||||
}
|
||||
|
||||
if (src_x1 >= src->w) {
|
||||
dst_x1 -= (src_x1 - src->w + 1) * scaling_w;
|
||||
src_x1 = src->w - 1;
|
||||
}
|
||||
|
||||
if (src_y0 < 0) {
|
||||
dst_y0 -= src_y0 * scaling_h;
|
||||
src_y0 = 0;
|
||||
}
|
||||
|
||||
if (src_y1 >= src->h) {
|
||||
dst_y1 -= (src_y1 - src->h + 1) * scaling_h;
|
||||
src_y1 = src->h - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clip destination rectangle to the clip rectangle */
|
||||
|
||||
/* Translate to clip space for easier calculations */
|
||||
dst_x0 -= dst->clip_rect.x;
|
||||
dst_x1 -= dst->clip_rect.x;
|
||||
dst_y0 -= dst->clip_rect.y;
|
||||
dst_y1 -= dst->clip_rect.y;
|
||||
|
||||
if (dst_x0 < 0) {
|
||||
src_x0 -= dst_x0 / scaling_w;
|
||||
dst_x0 = 0;
|
||||
}
|
||||
|
||||
if (dst_x1 >= dst->clip_rect.w) {
|
||||
src_x1 -= (dst_x1 - dst->clip_rect.w + 1) / scaling_w;
|
||||
dst_x1 = dst->clip_rect.w - 1;
|
||||
}
|
||||
|
||||
if (dst_y0 < 0) {
|
||||
src_y0 -= dst_y0 / scaling_h;
|
||||
dst_y0 = 0;
|
||||
}
|
||||
|
||||
if (dst_y1 >= dst->clip_rect.h) {
|
||||
src_y1 -= (dst_y1 - dst->clip_rect.h + 1) / scaling_h;
|
||||
dst_y1 = dst->clip_rect.h - 1;
|
||||
}
|
||||
|
||||
/* Translate back to surface coordinates */
|
||||
dst_x0 += dst->clip_rect.x;
|
||||
dst_x1 += dst->clip_rect.x;
|
||||
dst_y0 += dst->clip_rect.y;
|
||||
dst_y1 += dst->clip_rect.y;
|
||||
|
||||
final_src.x = (int)SDL_floor(src_x0 + 0.5);
|
||||
final_src.y = (int)SDL_floor(src_y0 + 0.5);
|
||||
final_src.w = (int)SDL_floor(src_x1 - src_x0 + 1.5);
|
||||
final_src.h = (int)SDL_floor(src_y1 - src_y0 + 1.5);
|
||||
|
||||
final_dst.x = (int)SDL_floor(dst_x0 + 0.5);
|
||||
final_dst.y = (int)SDL_floor(dst_y0 + 0.5);
|
||||
final_dst.w = (int)SDL_floor(dst_x1 - dst_x0 + 1.5);
|
||||
final_dst.h = (int)SDL_floor(dst_y1 - dst_y0 + 1.5);
|
||||
|
||||
if (final_dst.w < 0)
|
||||
final_dst.w = 0;
|
||||
if (final_dst.h < 0)
|
||||
final_dst.h = 0;
|
||||
|
||||
if (dstrect)
|
||||
*dstrect = final_dst;
|
||||
|
||||
if (final_dst.w == 0 || final_dst.h == 0 ||
|
||||
final_src.w <= 0 || final_src.h <= 0) {
|
||||
/* No-op. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -716,43 +782,6 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
SDL_COPY_COLORKEY
|
||||
);
|
||||
|
||||
/* Save off the original dst width, height */
|
||||
int dstW = dstrect->w;
|
||||
int dstH = dstrect->h;
|
||||
SDL_Rect full_rect;
|
||||
SDL_Rect final_dst = *dstrect;
|
||||
SDL_Rect final_src = *srcrect;
|
||||
|
||||
/* Clip the dst surface to the dstrect */
|
||||
full_rect.x = 0;
|
||||
full_rect.y = 0;
|
||||
full_rect.w = dst->w;
|
||||
full_rect.h = dst->h;
|
||||
if (!SDL_IntersectRect(&final_dst, &full_rect, &final_dst)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Did the dst width change? */
|
||||
if ( dstW != final_dst.w ) {
|
||||
/* scale the src width appropriately */
|
||||
final_src.w = final_src.w * dst->clip_rect.w / dstW;
|
||||
}
|
||||
|
||||
/* Did the dst height change? */
|
||||
if ( dstH != final_dst.h ) {
|
||||
/* scale the src width appropriately */
|
||||
final_src.h = final_src.h * dst->clip_rect.h / dstH;
|
||||
}
|
||||
|
||||
/* Clip the src surface to the srcrect */
|
||||
full_rect.x = 0;
|
||||
full_rect.y = 0;
|
||||
full_rect.w = src->w;
|
||||
full_rect.h = src->h;
|
||||
if (!SDL_IntersectRect(&final_src, &full_rect, &final_src)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(src->map->info.flags & SDL_COPY_NEAREST)) {
|
||||
src->map->info.flags |= SDL_COPY_NEAREST;
|
||||
SDL_InvalidateMap(src->map);
|
||||
|
|
@ -761,9 +790,9 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
if ( !(src->map->info.flags & complex_copy_flags) &&
|
||||
src->format->format == dst->format->format &&
|
||||
!SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) {
|
||||
return SDL_SoftStretch( src, &final_src, dst, &final_dst );
|
||||
return SDL_SoftStretch( src, srcrect, dst, dstrect );
|
||||
} else {
|
||||
return SDL_LowerBlit( src, &final_src, dst, &final_dst );
|
||||
return SDL_LowerBlit( src, srcrect, dst, dstrect );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1000,7 +1029,7 @@ int SDL_ConvertPixels(int width, int height,
|
|||
SDL_Rect rect;
|
||||
void *nonconst_src = (void *) src;
|
||||
|
||||
/* Check to make sure we are bliting somewhere, so we don't crash */
|
||||
/* Check to make sure we are blitting somewhere, so we don't crash */
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("dst");
|
||||
}
|
||||
|
|
@ -1010,17 +1039,21 @@ int SDL_ConvertPixels(int width, int height,
|
|||
|
||||
/* Fast path for same format copy */
|
||||
if (src_format == dst_format) {
|
||||
int bpp;
|
||||
int bpp, i;
|
||||
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(src_format)) {
|
||||
switch (src_format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
case SDL_PIXELFORMAT_YUY2:
|
||||
case SDL_PIXELFORMAT_UYVY:
|
||||
case SDL_PIXELFORMAT_YVYU:
|
||||
bpp = 2;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
case SDL_PIXELFORMAT_NV21:
|
||||
bpp = 1;
|
||||
break;
|
||||
default:
|
||||
return SDL_SetError("Unknown FOURCC pixel format");
|
||||
}
|
||||
|
|
@ -1029,11 +1062,32 @@ int SDL_ConvertPixels(int width, int height,
|
|||
}
|
||||
width *= bpp;
|
||||
|
||||
while (height-- > 0) {
|
||||
for (i = height; i--;) {
|
||||
SDL_memcpy(dst, src, width);
|
||||
src = (Uint8*)src + src_pitch;
|
||||
dst = (Uint8*)dst + dst_pitch;
|
||||
}
|
||||
|
||||
if (src_format == SDL_PIXELFORMAT_YV12 || src_format == SDL_PIXELFORMAT_IYUV) {
|
||||
/* U and V planes are a quarter the size of the Y plane */
|
||||
width /= 2;
|
||||
height /= 2;
|
||||
src_pitch /= 2;
|
||||
dst_pitch /= 2;
|
||||
for (i = height * 2; i--;) {
|
||||
SDL_memcpy(dst, src, width);
|
||||
src = (Uint8*)src + src_pitch;
|
||||
dst = (Uint8*)dst + dst_pitch;
|
||||
}
|
||||
} else if (src_format == SDL_PIXELFORMAT_NV12 || src_format == SDL_PIXELFORMAT_NV21) {
|
||||
/* U/V plane is half the height of the Y plane */
|
||||
height /= 2;
|
||||
for (i = height; i--;) {
|
||||
SDL_memcpy(dst, src, width);
|
||||
src = (Uint8*)src + src_pitch;
|
||||
dst = (Uint8*)dst + dst_pitch;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -93,10 +93,14 @@ struct SDL_Window
|
|||
SDL_Surface *surface;
|
||||
SDL_bool surface_valid;
|
||||
|
||||
SDL_bool is_hiding;
|
||||
SDL_bool is_destroying;
|
||||
|
||||
SDL_WindowShaper *shaper;
|
||||
|
||||
SDL_HitTest hit_test;
|
||||
void *hit_test_data;
|
||||
|
||||
SDL_WindowUserData *data;
|
||||
|
||||
void *driverdata;
|
||||
|
|
@ -166,6 +170,11 @@ struct SDL_VideoDevice
|
|||
*/
|
||||
int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
|
||||
/*
|
||||
* Get the dots/pixels-per-inch of a display
|
||||
*/
|
||||
int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
|
||||
|
||||
/*
|
||||
* Get a list of the available display modes for a display.
|
||||
*/
|
||||
|
|
@ -215,8 +224,8 @@ struct SDL_VideoDevice
|
|||
SDL_ShapeDriver shape_driver;
|
||||
|
||||
/* Get some platform dependent window information */
|
||||
SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo * info);
|
||||
SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo * info);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
|
|
@ -261,12 +270,16 @@ struct SDL_VideoDevice
|
|||
/* MessageBox */
|
||||
int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
|
||||
/* Hit-testing */
|
||||
int (*SetWindowHitTest)(SDL_Window * window, SDL_bool enabled);
|
||||
|
||||
/* * * */
|
||||
/* Data common to all drivers */
|
||||
SDL_bool suspend_screensaver;
|
||||
int num_displays;
|
||||
SDL_VideoDisplay *displays;
|
||||
SDL_Window *windows;
|
||||
SDL_Window *grabbed_window;
|
||||
Uint8 window_magic;
|
||||
Uint32 next_object_id;
|
||||
char * clipboard_text;
|
||||
|
|
@ -296,6 +309,7 @@ struct SDL_VideoDevice
|
|||
int flags;
|
||||
int profile_mask;
|
||||
int share_with_current_context;
|
||||
int release_behavior;
|
||||
int framebuffer_srgb_capable;
|
||||
int retained_backing;
|
||||
int driver_loaded;
|
||||
|
|
@ -381,6 +395,15 @@ extern VideoBootStrap DUMMY_bootstrap;
|
|||
#if SDL_VIDEO_DRIVER_WAYLAND
|
||||
extern VideoBootStrap Wayland_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_NACL
|
||||
extern VideoBootStrap NACL_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_VIVANTE
|
||||
extern VideoBootStrap VIVANTE_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_EMSCRIPTEN
|
||||
extern VideoBootStrap Emscripten_bootstrap;
|
||||
#endif
|
||||
|
||||
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
|
||||
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
|
||||
|
|
@ -405,6 +428,8 @@ extern SDL_Window * SDL_GetFocusWindow(void);
|
|||
|
||||
extern SDL_bool SDL_ShouldAllowTopmost(void);
|
||||
|
||||
extern float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches);
|
||||
|
||||
#endif /* _SDL_sysvideo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -29,18 +29,29 @@
|
|||
#include "SDL_events.h"
|
||||
#include "SDL_androidwindow.h"
|
||||
|
||||
|
||||
void android_egl_context_backup();
|
||||
void android_egl_context_restore();
|
||||
|
||||
#if SDL_AUDIO_DRIVER_ANDROID
|
||||
void AndroidAUD_ResumeDevices(void);
|
||||
void AndroidAUD_PauseDevices(void);
|
||||
#else
|
||||
static void AndroidAUD_ResumeDevices(void) {}
|
||||
static void AndroidAUD_PauseDevices(void) {}
|
||||
#endif
|
||||
|
||||
void
|
||||
android_egl_context_restore()
|
||||
{
|
||||
SDL_Event event;
|
||||
SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata;
|
||||
if (SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context) < 0) {
|
||||
/* The context is no longer valid, create a new one */
|
||||
/* FIXME: Notify the user that the context changed and textures need to be re created */
|
||||
data->egl_context = (EGLContext) SDL_GL_CreateContext(Android_Window);
|
||||
SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context);
|
||||
event.type = SDL_RENDER_DEVICE_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,13 +83,14 @@ Android_PumpEvents(_THIS)
|
|||
if (isPaused && !isPausing) {
|
||||
/* Make sure this is the last thing we do before pausing */
|
||||
android_egl_context_backup();
|
||||
AndroidAUD_PauseDevices();
|
||||
if(SDL_SemWait(Android_ResumeSem) == 0) {
|
||||
#else
|
||||
if (isPaused) {
|
||||
if(SDL_SemTryWait(Android_ResumeSem) == 0) {
|
||||
#endif
|
||||
isPaused = 0;
|
||||
|
||||
AndroidAUD_ResumeDevices();
|
||||
/* Restore the GL Context from here, as this operation is thread dependent */
|
||||
if (!SDL_HasEvent(SDL_QUIT)) {
|
||||
android_egl_context_restore();
|
||||
|
|
@ -101,6 +113,7 @@ Android_PumpEvents(_THIS)
|
|||
#else
|
||||
if(SDL_SemTryWait(Android_PauseSem) == 0) {
|
||||
android_egl_context_backup();
|
||||
AndroidAUD_PauseDevices();
|
||||
isPaused = 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -41,9 +41,13 @@ SDL_EGL_MakeCurrent_impl(Android)
|
|||
void
|
||||
Android_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
/* FIXME: These two functions were in the Java code, do we really need them? */
|
||||
_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
|
||||
_this->egl_data->eglWaitGL();
|
||||
/* The following two calls existed in the original Java code
|
||||
* If you happen to have a device that's affected by their removal,
|
||||
* please report to Bugzilla. -- Gabriel
|
||||
*/
|
||||
|
||||
/*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
|
||||
_this->egl_data->eglWaitGL();*/
|
||||
SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -253,8 +253,8 @@ static SDL_Scancode Android_Keycodes[] = {
|
|||
SDL_SCANCODE_CALCULATOR, /* AKEYCODE_CALCULATOR */
|
||||
SDL_SCANCODE_LANG5, /* AKEYCODE_ZENKAKU_HANKAKU */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EISU */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUHENKAN */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HENKAN */
|
||||
SDL_SCANCODE_INTERNATIONAL5, /* AKEYCODE_MUHENKAN */
|
||||
SDL_SCANCODE_INTERNATIONAL4, /* AKEYCODE_HENKAN */
|
||||
SDL_SCANCODE_LANG3, /* AKEYCODE_KATAKANA_HIRAGANA */
|
||||
SDL_SCANCODE_INTERNATIONAL3, /* AKEYCODE_YEN */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_RO */
|
||||
|
|
@ -263,6 +263,59 @@ static SDL_Scancode Android_Keycodes[] = {
|
|||
SDL_SCANCODE_BRIGHTNESSDOWN, /* AKEYCODE_BRIGHTNESS_DOWN */
|
||||
SDL_SCANCODE_BRIGHTNESSUP, /* AKEYCODE_BRIGHTNESS_UP */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_AUDIO_TRACK */
|
||||
SDL_SCANCODE_SLEEP, /* AKEYCODE_SLEEP */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WAKEUP */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PAIRING */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_TOP_MENU */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_11 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_12 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LAST_CHANNEL */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_DATA_SERVICE */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOICE_ASSIST */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_RADIO_SERVICE */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TELETEXT */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NUMBER_ENTRY */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_ANALOG */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_DIGITAL */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_BS */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_CS */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_SERVICE */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NETWORK */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ANTENNA_CABLE */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_1 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_2 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_3 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_4 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_1 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_2 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_1 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_2 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_VGA_1 */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ZOOM_MODE */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_CONTENTS_MENU */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_MEDIA_CONTEXT_MENU */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TIMER_PROGRAMMING */
|
||||
SDL_SCANCODE_HELP, /* AKEYCODE_HELP */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_PREVIOUS */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_NEXT */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_IN */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_OUT */
|
||||
SDL_SCANCODE_UNKNOWN,
|
||||
SDL_SCANCODE_UNKNOWN,
|
||||
SDL_SCANCODE_UNKNOWN,
|
||||
SDL_SCANCODE_UNKNOWN,
|
||||
SDL_SCANCODE_UNKNOWN,
|
||||
SDL_SCANCODE_UNKNOWN,
|
||||
SDL_SCANCODE_UNKNOWN,
|
||||
SDL_SCANCODE_UNKNOWN,
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_FORWARD */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_BACKWARD */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_FORWARD */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_BACKWARD */
|
||||
};
|
||||
|
||||
static SDL_Scancode
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
37
Engine/lib/sdl/src/video/android/SDL_androidmessagebox.c
Normal file
37
Engine/lib/sdl/src/video/android/SDL_androidmessagebox.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
|
||||
#include "SDL_messagebox.h"
|
||||
|
||||
int
|
||||
Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{
|
||||
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
|
||||
return Android_JNI_ShowMessageBox(messageboxdata, buttonid);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_ANDROID */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
29
Engine/lib/sdl/src/video/android/SDL_androidmessagebox.h
Normal file
29
Engine/lib/sdl/src/video/android/SDL_androidmessagebox.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
|
||||
extern int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_ANDROID */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
84
Engine/lib/sdl/src/video/android/SDL_androidmouse.c
Normal file
84
Engine/lib/sdl/src/video/android/SDL_androidmouse.c
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
|
||||
#include "SDL_androidmouse.h"
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
#define ACTION_DOWN 0
|
||||
#define ACTION_UP 1
|
||||
#define ACTION_HOVER_MOVE 7
|
||||
#define ACTION_SCROLL 8
|
||||
#define BUTTON_PRIMARY 1
|
||||
#define BUTTON_SECONDARY 2
|
||||
#define BUTTON_TERTIARY 4
|
||||
|
||||
void Android_OnMouse( int androidButton, int action, float x, float y) {
|
||||
static Uint8 SDLButton;
|
||||
|
||||
if (!Android_Window) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch(action) {
|
||||
case ACTION_DOWN:
|
||||
// Determine which button originated the event, and store it for ACTION_UP
|
||||
SDLButton = SDL_BUTTON_LEFT;
|
||||
if (androidButton == BUTTON_SECONDARY) {
|
||||
SDLButton = SDL_BUTTON_RIGHT;
|
||||
} else if (androidButton == BUTTON_TERTIARY) {
|
||||
SDLButton = SDL_BUTTON_MIDDLE;
|
||||
}
|
||||
SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
|
||||
SDL_SendMouseButton(Android_Window, 0, SDL_PRESSED, SDLButton);
|
||||
break;
|
||||
|
||||
case ACTION_UP:
|
||||
// Android won't give us the button that originated the ACTION_DOWN event, so we'll
|
||||
// assume it's the one we stored
|
||||
SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
|
||||
SDL_SendMouseButton(Android_Window, 0, SDL_RELEASED, SDLButton);
|
||||
break;
|
||||
|
||||
case ACTION_HOVER_MOVE:
|
||||
SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
|
||||
break;
|
||||
|
||||
case ACTION_SCROLL:
|
||||
SDL_SendMouseWheel(Android_Window, 0, x, y, SDL_MOUSEWHEEL_NORMAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_ANDROID */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
31
Engine/lib/sdl/src/video/android/SDL_androidmouse.h
Normal file
31
Engine/lib/sdl/src/video/android/SDL_androidmouse.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_androidmouse_h
|
||||
#define _SDL_androidmouse_h
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
|
||||
extern void Android_OnMouse( int button, int action, float x, float y);
|
||||
|
||||
#endif /* _SDL_androidmouse_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -24,13 +24,12 @@
|
|||
|
||||
#include <android/log.h>
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_androidtouch.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
#include "SDL_log.h"
|
||||
|
||||
#include "SDL_androidtouch.h"
|
||||
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
#define ACTION_DOWN 0
|
||||
|
|
@ -51,11 +50,29 @@ static void Android_GetWindowCoordinates(float x, float y,
|
|||
*window_y = (int)(y * window_h);
|
||||
}
|
||||
|
||||
static volatile SDL_bool separate_mouse_and_touch = SDL_FALSE;
|
||||
|
||||
static void
|
||||
SeparateEventsHintWatcher(void *userdata, const char *name,
|
||||
const char *oldValue, const char *newValue)
|
||||
{
|
||||
jclass mActivityClass = Android_JNI_GetActivityClass();
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
jfieldID fid = (*env)->GetStaticFieldID(env, mActivityClass, "mSeparateMouseAndTouch", "Z");
|
||||
|
||||
separate_mouse_and_touch = (newValue && (SDL_strcmp(newValue, "1") == 0));
|
||||
(*env)->SetStaticBooleanField(env, mActivityClass, fid, separate_mouse_and_touch ? JNI_TRUE : JNI_FALSE);
|
||||
}
|
||||
|
||||
void Android_InitTouch(void)
|
||||
{
|
||||
int i;
|
||||
int* ids;
|
||||
int number = Android_JNI_GetTouchDeviceIds(&ids);
|
||||
const int number = Android_JNI_GetTouchDeviceIds(&ids);
|
||||
|
||||
SDL_AddHintCallback(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH,
|
||||
SeparateEventsHintWatcher, NULL);
|
||||
|
||||
if (0 < number) {
|
||||
for (i = 0; i < number; ++i) {
|
||||
SDL_AddTouch((SDL_TouchID) ids[i], ""); /* no error handling */
|
||||
|
|
@ -64,6 +81,13 @@ void Android_InitTouch(void)
|
|||
}
|
||||
}
|
||||
|
||||
void Android_QuitTouch(void)
|
||||
{
|
||||
SDL_DelHintCallback(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH,
|
||||
SeparateEventsHintWatcher, NULL);
|
||||
separate_mouse_and_touch = SDL_FALSE;
|
||||
}
|
||||
|
||||
void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
|
||||
{
|
||||
SDL_TouchID touchDeviceId = 0;
|
||||
|
|
@ -84,37 +108,42 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio
|
|||
switch (action) {
|
||||
case ACTION_DOWN:
|
||||
/* Primary pointer down */
|
||||
Android_GetWindowCoordinates(x, y, &window_x, &window_y);
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
|
||||
/* send mouse down event */
|
||||
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
if (!separate_mouse_and_touch) {
|
||||
Android_GetWindowCoordinates(x, y, &window_x, &window_y);
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
|
||||
/* send mouse down event */
|
||||
SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
pointerFingerID = fingerId;
|
||||
case ACTION_POINTER_DOWN:
|
||||
/* Non primary pointer down */
|
||||
SDL_SendTouch(touchDeviceId, fingerId, SDL_TRUE, x, y, p);
|
||||
break;
|
||||
|
||||
|
||||
case ACTION_MOVE:
|
||||
if (!pointerFingerID) {
|
||||
Android_GetWindowCoordinates(x, y, &window_x, &window_y);
|
||||
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
|
||||
if (!separate_mouse_and_touch) {
|
||||
Android_GetWindowCoordinates(x, y, &window_x, &window_y);
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
|
||||
}
|
||||
}
|
||||
SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
|
||||
break;
|
||||
|
||||
|
||||
case ACTION_UP:
|
||||
/* Primary pointer up */
|
||||
/* send mouse up */
|
||||
if (!separate_mouse_and_touch) {
|
||||
/* send mouse up */
|
||||
SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
pointerFingerID = (SDL_FingerID) 0;
|
||||
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
case ACTION_POINTER_UP:
|
||||
/* Non primary pointer up */
|
||||
SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
#include "SDL_androidvideo.h"
|
||||
|
||||
extern void Android_InitTouch(void);
|
||||
extern void Android_QuitTouch(void);
|
||||
extern void Android_OnTouch( int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -64,6 +64,8 @@ extern int Android_GLES_LoadLibrary(_THIS, const char *path);
|
|||
int Android_ScreenWidth = 0;
|
||||
int Android_ScreenHeight = 0;
|
||||
Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
|
||||
int Android_ScreenRate = 0;
|
||||
|
||||
SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL;
|
||||
|
||||
/* Currently only one window */
|
||||
|
|
@ -75,9 +77,16 @@ Android_Available(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
Android_SuspendScreenSaver(_THIS)
|
||||
{
|
||||
Android_JNI_SuspendScreenSaver(_this->suspend_screensaver);
|
||||
}
|
||||
|
||||
static void
|
||||
Android_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +120,7 @@ Android_CreateDevice(int devindex)
|
|||
device->CreateWindow = Android_CreateWindow;
|
||||
device->SetWindowTitle = Android_SetWindowTitle;
|
||||
device->DestroyWindow = Android_DestroyWindow;
|
||||
device->GetWindowWMInfo = Android_GetWindowWMInfo;
|
||||
|
||||
device->free = Android_DeleteDevice;
|
||||
|
||||
|
|
@ -125,6 +135,9 @@ Android_CreateDevice(int devindex)
|
|||
device->GL_SwapWindow = Android_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = Android_GLES_DeleteContext;
|
||||
|
||||
/* Screensaver */
|
||||
device->SuspendScreenSaver = Android_SuspendScreenSaver;
|
||||
|
||||
/* Text input */
|
||||
device->StartTextInput = Android_StartTextInput;
|
||||
device->StopTextInput = Android_StopTextInput;
|
||||
|
|
@ -156,7 +169,7 @@ Android_VideoInit(_THIS)
|
|||
mode.format = Android_ScreenFormat;
|
||||
mode.w = Android_ScreenWidth;
|
||||
mode.h = Android_ScreenHeight;
|
||||
mode.refresh_rate = 0;
|
||||
mode.refresh_rate = Android_ScreenRate;
|
||||
mode.driverdata = NULL;
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
return -1;
|
||||
|
|
@ -175,15 +188,17 @@ Android_VideoInit(_THIS)
|
|||
void
|
||||
Android_VideoQuit(_THIS)
|
||||
{
|
||||
Android_QuitTouch();
|
||||
}
|
||||
|
||||
/* This function gets called before VideoInit() */
|
||||
void
|
||||
Android_SetScreenResolution(int width, int height, Uint32 format)
|
||||
Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
|
||||
{
|
||||
Android_ScreenWidth = width;
|
||||
Android_ScreenHeight = height;
|
||||
Android_ScreenFormat = format;
|
||||
Android_ScreenRate = rate;
|
||||
|
||||
if (Android_Window) {
|
||||
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
#include "../SDL_sysvideo.h"
|
||||
|
||||
/* Called by the JNI layer when the screen changes size or format */
|
||||
extern void Android_SetScreenResolution(int width, int height, Uint32 format);
|
||||
extern void Android_SetScreenResolution(int width, int height, Uint32 format, float rate);
|
||||
|
||||
/* Private display data */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
|
||||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
|
@ -106,7 +107,7 @@ Android_DestroyWindow(_THIS, SDL_Window * window)
|
|||
if (data->egl_surface != EGL_NO_SURFACE) {
|
||||
SDL_EGL_DestroySurface(_this, data->egl_surface);
|
||||
}
|
||||
if(data->native_window) {
|
||||
if (data->native_window) {
|
||||
ANativeWindow_release(data->native_window);
|
||||
}
|
||||
SDL_free(window->driverdata);
|
||||
|
|
@ -115,6 +116,24 @@ Android_DestroyWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
Android_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (info->version.major == SDL_MAJOR_VERSION &&
|
||||
info->version.minor == SDL_MINOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_ANDROID;
|
||||
info->info.android.window = data->native_window;
|
||||
info->info.android.surface = data->egl_surface;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_ANDROID */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
extern int Android_CreateWindow(_THIS, SDL_Window * window);
|
||||
extern void Android_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
extern void Android_DestroyWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo * info);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -28,9 +28,7 @@
|
|||
static NSString *
|
||||
GetTextFormat(_THIS)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (data->osversion >= 0x1060) {
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
|
||||
return NSPasteboardTypeString;
|
||||
} else {
|
||||
return NSStringPboardType;
|
||||
|
|
@ -39,34 +37,28 @@ GetTextFormat(_THIS)
|
|||
|
||||
int
|
||||
Cocoa_SetClipboardText(_THIS, const char *text)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = GetTextFormat(_this);
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||
[pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
|
||||
|
||||
[pool release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
}}
|
||||
|
||||
char *
|
||||
Cocoa_GetClipboardText(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = GetTextFormat(_this);
|
||||
NSString *available;
|
||||
char *text;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
|
||||
if ([available isEqualToString:format]) {
|
||||
|
|
@ -84,10 +76,8 @@ Cocoa_GetClipboardText(_THIS)
|
|||
text = SDL_strdup("");
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return text;
|
||||
}
|
||||
}}
|
||||
|
||||
SDL_bool
|
||||
Cocoa_HasClipboardText(_THIS)
|
||||
|
|
@ -96,20 +86,18 @@ Cocoa_HasClipboardText(_THIS)
|
|||
char *text = Cocoa_GetClipboardText(_this);
|
||||
if (text) {
|
||||
result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
|
||||
SDL_free(text);
|
||||
SDL_free(text);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSInteger count;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
count = [pasteboard changeCount];
|
||||
if (count != data->clipboard_count) {
|
||||
|
|
@ -118,9 +106,7 @@ Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
|||
}
|
||||
data->clipboard_count = count;
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
}}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
extern void Cocoa_RegisterApp(void);
|
||||
extern void Cocoa_PumpEvents(_THIS);
|
||||
extern void Cocoa_SuspendScreenSaver(_THIS);
|
||||
|
||||
#endif /* _SDL_cocoaevents_h */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -25,15 +25,12 @@
|
|||
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#if !defined(UsrActivity) && defined(__LP64__) && !defined(__POWER__)
|
||||
/*
|
||||
* Workaround for a bug in the 10.5 SDK: By accident, OSService.h does
|
||||
* not include Power.h at all when compiling in 64bit mode. This has
|
||||
* been fixed in 10.6, but for 10.5, we manually define UsrActivity
|
||||
* to ensure compilation works.
|
||||
*/
|
||||
#define UsrActivity 1
|
||||
/* This define was added in the 10.9 SDK. */
|
||||
#ifndef kIOPMAssertPreventUserIdleDisplaySleep
|
||||
#define kIOPMAssertPreventUserIdleDisplaySleep kIOPMAssertionTypePreventUserIdleDisplaySleep
|
||||
#endif
|
||||
|
||||
@interface SDLApplication : NSApplication
|
||||
|
|
@ -57,7 +54,7 @@
|
|||
- (void)setAppleMenu:(NSMenu *)menu;
|
||||
@end
|
||||
|
||||
@interface SDLAppDelegate : NSObject {
|
||||
@interface SDLAppDelegate : NSObject <NSApplicationDelegate> {
|
||||
@public
|
||||
BOOL seenFirstActivate;
|
||||
}
|
||||
|
|
@ -69,13 +66,20 @@
|
|||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
seenFirstActivate = NO;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(focusSomeWindow:)
|
||||
name:NSApplicationDidBecomeActiveNotification
|
||||
object:nil];
|
||||
|
||||
[center addObserver:self
|
||||
selector:@selector(windowWillClose:)
|
||||
name:NSWindowWillCloseNotification
|
||||
object:nil];
|
||||
|
||||
[center addObserver:self
|
||||
selector:@selector(focusSomeWindow:)
|
||||
name:NSApplicationDidBecomeActiveNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
@ -83,16 +87,65 @@
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[center removeObserver:self name:NSWindowWillCloseNotification object:nil];
|
||||
[center removeObserver:self name:NSApplicationDidBecomeActiveNotification object:nil];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification;
|
||||
{
|
||||
NSWindow *win = (NSWindow*)[notification object];
|
||||
|
||||
if (![win isKeyWindow]) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* HACK: Make the next window in the z-order key when the key window is
|
||||
* closed. The custom event loop and/or windowing code we have seems to
|
||||
* prevent the normal behavior: https://bugzilla.libsdl.org/show_bug.cgi?id=1825
|
||||
*/
|
||||
|
||||
/* +[NSApp orderedWindows] never includes the 'About' window, but we still
|
||||
* want to try its list first since the behavior in other apps is to only
|
||||
* make the 'About' window key if no other windows are on-screen.
|
||||
*/
|
||||
for (NSWindow *window in [NSApp orderedWindows]) {
|
||||
if (window != win && [window canBecomeKeyWindow]) {
|
||||
if ([window respondsToSelector:@selector(isOnActiveSpace)]) {
|
||||
if (![window isOnActiveSpace]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
[window makeKeyAndOrderFront:self];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* If a window wasn't found above, iterate through all visible windows
|
||||
* (including the 'About' window, if it's shown) and make the first one key.
|
||||
* Note that +[NSWindow windowNumbersWithOptions:] was added in 10.6.
|
||||
*/
|
||||
if ([NSWindow respondsToSelector:@selector(windowNumbersWithOptions:)]) {
|
||||
/* Get all visible windows in the active Space, in z-order. */
|
||||
for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
|
||||
NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
|
||||
if (window && window != win && [window canBecomeKeyWindow]) {
|
||||
[window makeKeyAndOrderFront:self];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)focusSomeWindow:(NSNotification *)aNotification
|
||||
{
|
||||
/* HACK: Ignore the first call. The application gets a
|
||||
* applicationDidBecomeActive: a little bit after the first window is
|
||||
* created, and if we don't ignore it, a window that has been created with
|
||||
* SDL_WINDOW_MINIZED will ~immediately be restored.
|
||||
* SDL_WINDOW_MINIMIZED will ~immediately be restored.
|
||||
*/
|
||||
if (!seenFirstActivate) {
|
||||
seenFirstActivate = YES;
|
||||
|
|
@ -100,15 +153,12 @@
|
|||
}
|
||||
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
if (device && device->windows)
|
||||
{
|
||||
if (device && device->windows) {
|
||||
SDL_Window *window = device->windows;
|
||||
int i;
|
||||
for (i = 0; i < device->num_displays; ++i)
|
||||
{
|
||||
for (i = 0; i < device->num_displays; ++i) {
|
||||
SDL_Window *fullscreen_window = device->displays[i].fullscreen_window;
|
||||
if (fullscreen_window)
|
||||
{
|
||||
if (fullscreen_window) {
|
||||
if (fullscreen_window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
SDL_RestoreWindow(fullscreen_window);
|
||||
}
|
||||
|
|
@ -139,11 +189,13 @@ GetApplicationName(void)
|
|||
|
||||
/* Determine the application name */
|
||||
appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
if (!appName)
|
||||
if (!appName) {
|
||||
appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
|
||||
}
|
||||
|
||||
if (![appName length])
|
||||
if (![appName length]) {
|
||||
appName = [[NSProcessInfo processInfo] processName];
|
||||
}
|
||||
|
||||
return appName;
|
||||
}
|
||||
|
|
@ -158,13 +210,19 @@ CreateApplicationMenus(void)
|
|||
NSMenu *windowMenu;
|
||||
NSMenu *viewMenu;
|
||||
NSMenuItem *menuItem;
|
||||
NSMenu *mainMenu;
|
||||
|
||||
if (NSApp == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mainMenu = [[NSMenu alloc] init];
|
||||
|
||||
/* Create the main menu bar */
|
||||
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||
[NSApp setMainMenu:mainMenu];
|
||||
|
||||
[mainMenu release]; /* we're done with it, let NSApp own it. */
|
||||
mainMenu = nil;
|
||||
|
||||
/* Create the application menu */
|
||||
appName = GetApplicationName();
|
||||
|
|
@ -253,20 +311,29 @@ CreateApplicationMenus(void)
|
|||
|
||||
void
|
||||
Cocoa_RegisterApp(void)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
/* This can get called more than once! Be careful what you initialize! */
|
||||
ProcessSerialNumber psn;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
if (!GetCurrentProcess(&psn)) {
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
SetFrontProcess(&psn);
|
||||
}
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
if (NSApp == nil) {
|
||||
[SDLApplication sharedApplication];
|
||||
SDL_assert(NSApp != nil);
|
||||
|
||||
const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
|
||||
if (!hint || *hint == '0') {
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
|
||||
if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
|
||||
#endif
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
|
||||
} else {
|
||||
ProcessSerialNumber psn = {0, kCurrentProcess};
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
}
|
||||
#endif
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
if ([NSApp mainMenu] == nil) {
|
||||
CreateApplicationMenus();
|
||||
}
|
||||
|
|
@ -274,9 +341,10 @@ Cocoa_RegisterApp(void)
|
|||
NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported",
|
||||
[NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled",
|
||||
[NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
|
||||
nil];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
|
||||
|
||||
[appDefaults release];
|
||||
}
|
||||
if (NSApp && !appDelegate) {
|
||||
appDelegate = [[SDLAppDelegate alloc] init];
|
||||
|
|
@ -285,22 +353,20 @@ Cocoa_RegisterApp(void)
|
|||
* termination into SDL_Quit, and we can't handle application:openFile:
|
||||
*/
|
||||
if (![NSApp delegate]) {
|
||||
[NSApp setDelegate:appDelegate];
|
||||
[(NSApplication *)NSApp setDelegate:appDelegate];
|
||||
} else {
|
||||
appDelegate->seenFirstActivate = YES;
|
||||
}
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_PumpEvents(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
/* Update activity every 30 seconds to prevent screensaver */
|
||||
if (_this->suspend_screensaver) {
|
||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||
if (_this->suspend_screensaver && !data->screensaver_use_iopm) {
|
||||
Uint32 now = SDL_GetTicks();
|
||||
if (!data->screensaver_activity ||
|
||||
SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) {
|
||||
|
|
@ -309,7 +375,6 @@ Cocoa_PumpEvents(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
for ( ; ; ) {
|
||||
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
|
||||
if ( event == nil ) {
|
||||
|
|
@ -341,8 +406,36 @@ Cocoa_PumpEvents(_THIS)
|
|||
/* Pass through to NSApp to make sure everything stays in sync */
|
||||
[NSApp sendEvent:event];
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_SuspendScreenSaver(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||
|
||||
if (!data->screensaver_use_iopm) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->screensaver_assertion) {
|
||||
IOPMAssertionRelease(data->screensaver_assertion);
|
||||
data->screensaver_assertion = 0;
|
||||
}
|
||||
|
||||
if (_this->suspend_screensaver) {
|
||||
/* FIXME: this should ideally describe the real reason why the game
|
||||
* called SDL_DisableScreenSaver. Note that the name is only meant to be
|
||||
* seen by OS X power users. there's an additional optional human-readable
|
||||
* (localized) reason parameter which we don't set.
|
||||
*/
|
||||
NSString *name = [GetApplicationName() stringByAppendingString:@" using SDL_DisableScreenSaver"];
|
||||
IOPMAssertionCreateWithDescription(kIOPMAssertPreventUserIdleDisplaySleep,
|
||||
(CFStringRef) name,
|
||||
NULL, NULL, NULL, 0, NULL,
|
||||
&data->screensaver_assertion);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "SDL_cocoavideo.h"
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/scancodes_darwin.h"
|
||||
|
||||
|
|
@ -32,66 +33,51 @@
|
|||
/*#define DEBUG_IME NSLog */
|
||||
#define DEBUG_IME(...)
|
||||
|
||||
#ifndef NX_DEVICERCTLKEYMASK
|
||||
#define NX_DEVICELCTLKEYMASK 0x00000001
|
||||
#endif
|
||||
#ifndef NX_DEVICELSHIFTKEYMASK
|
||||
#define NX_DEVICELSHIFTKEYMASK 0x00000002
|
||||
#endif
|
||||
#ifndef NX_DEVICERSHIFTKEYMASK
|
||||
#define NX_DEVICERSHIFTKEYMASK 0x00000004
|
||||
#endif
|
||||
#ifndef NX_DEVICELCMDKEYMASK
|
||||
#define NX_DEVICELCMDKEYMASK 0x00000008
|
||||
#endif
|
||||
#ifndef NX_DEVICERCMDKEYMASK
|
||||
#define NX_DEVICERCMDKEYMASK 0x00000010
|
||||
#endif
|
||||
#ifndef NX_DEVICELALTKEYMASK
|
||||
#define NX_DEVICELALTKEYMASK 0x00000020
|
||||
#endif
|
||||
#ifndef NX_DEVICERALTKEYMASK
|
||||
#define NX_DEVICERALTKEYMASK 0x00000040
|
||||
#endif
|
||||
#ifndef NX_DEVICERCTLKEYMASK
|
||||
#define NX_DEVICERCTLKEYMASK 0x00002000
|
||||
#endif
|
||||
|
||||
@interface SDLTranslatorResponder : NSView <NSTextInput>
|
||||
{
|
||||
@interface SDLTranslatorResponder : NSView <NSTextInputClient> {
|
||||
NSString *_markedText;
|
||||
NSRange _markedRange;
|
||||
NSRange _selectedRange;
|
||||
SDL_Rect _inputRect;
|
||||
}
|
||||
- (void) doCommandBySelector:(SEL)myselector;
|
||||
- (void) setInputRect:(SDL_Rect *) rect;
|
||||
- (void)doCommandBySelector:(SEL)myselector;
|
||||
- (void)setInputRect:(SDL_Rect *)rect;
|
||||
@end
|
||||
|
||||
@implementation SDLTranslatorResponder
|
||||
|
||||
- (void) setInputRect:(SDL_Rect *) rect
|
||||
- (void)setInputRect:(SDL_Rect *)rect
|
||||
{
|
||||
_inputRect = *rect;
|
||||
}
|
||||
|
||||
- (void) insertText:(id) aString
|
||||
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||
{
|
||||
/* TODO: Make use of replacementRange? */
|
||||
|
||||
const char *str;
|
||||
|
||||
DEBUG_IME(@"insertText: %@", aString);
|
||||
|
||||
/* Could be NSString or NSAttributedString, so we have
|
||||
* to test and convert it before return as SDL event */
|
||||
if ([aString isKindOfClass: [NSAttributedString class]])
|
||||
if ([aString isKindOfClass: [NSAttributedString class]]) {
|
||||
str = [[aString string] UTF8String];
|
||||
else
|
||||
} else {
|
||||
str = [aString UTF8String];
|
||||
}
|
||||
|
||||
SDL_SendKeyboardText(str);
|
||||
}
|
||||
|
||||
- (void) doCommandBySelector:(SEL) myselector
|
||||
- (void)insertText:(id)insertString
|
||||
{
|
||||
/* This method is part of NSTextInput and not NSTextInputClient, but
|
||||
* apparently it still might be called in OS X 10.5 and can cause beeps if
|
||||
* the implementation is missing: http://crbug.com/47890 */
|
||||
[self insertText:insertString replacementRange:NSMakeRange(0, 0)];
|
||||
}
|
||||
|
||||
- (void)doCommandBySelector:(SEL)myselector
|
||||
{
|
||||
/* No need to do anything since we are not using Cocoa
|
||||
selectors to handle special keys, instead we use SDL
|
||||
|
|
@ -99,50 +85,48 @@
|
|||
*/
|
||||
}
|
||||
|
||||
- (BOOL) hasMarkedText
|
||||
- (BOOL)hasMarkedText
|
||||
{
|
||||
return _markedText != nil;
|
||||
}
|
||||
|
||||
- (NSRange) markedRange
|
||||
- (NSRange)markedRange
|
||||
{
|
||||
return _markedRange;
|
||||
}
|
||||
|
||||
- (NSRange) selectedRange
|
||||
- (NSRange)selectedRange
|
||||
{
|
||||
return _selectedRange;
|
||||
}
|
||||
|
||||
- (void) setMarkedText:(id) aString
|
||||
selectedRange:(NSRange) selRange
|
||||
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange;
|
||||
{
|
||||
if ([aString isKindOfClass: [NSAttributedString class]])
|
||||
if ([aString isKindOfClass: [NSAttributedString class]]) {
|
||||
aString = [aString string];
|
||||
}
|
||||
|
||||
if ([aString length] == 0)
|
||||
{
|
||||
if ([aString length] == 0) {
|
||||
[self unmarkText];
|
||||
return;
|
||||
}
|
||||
|
||||
if (_markedText != aString)
|
||||
{
|
||||
if (_markedText != aString) {
|
||||
[_markedText release];
|
||||
_markedText = [aString retain];
|
||||
}
|
||||
|
||||
_selectedRange = selRange;
|
||||
_selectedRange = selectedRange;
|
||||
_markedRange = NSMakeRange(0, [aString length]);
|
||||
|
||||
SDL_SendEditingText([aString UTF8String],
|
||||
selRange.location, selRange.length);
|
||||
selectedRange.location, selectedRange.length);
|
||||
|
||||
DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText,
|
||||
selRange.location, selRange.length);
|
||||
}
|
||||
|
||||
- (void) unmarkText
|
||||
- (void)unmarkText
|
||||
{
|
||||
[_markedText release];
|
||||
_markedText = nil;
|
||||
|
|
@ -150,29 +134,38 @@
|
|||
SDL_SendEditingText("", 0, 0);
|
||||
}
|
||||
|
||||
- (NSRect) firstRectForCharacterRange: (NSRange) theRange
|
||||
- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange;
|
||||
{
|
||||
NSWindow *window = [self window];
|
||||
NSRect contentRect = [window contentRectForFrameRect: [window frame]];
|
||||
NSRect contentRect = [window contentRectForFrameRect:[window frame]];
|
||||
float windowHeight = contentRect.size.height;
|
||||
NSRect rect = NSMakeRect(_inputRect.x, windowHeight - _inputRect.y - _inputRect.h,
|
||||
_inputRect.w, _inputRect.h);
|
||||
|
||||
if (actualRange) {
|
||||
*actualRange = aRange;
|
||||
}
|
||||
|
||||
DEBUG_IME(@"firstRectForCharacterRange: (%d, %d): windowHeight = %g, rect = %@",
|
||||
theRange.location, theRange.length, windowHeight,
|
||||
aRange.location, aRange.length, windowHeight,
|
||||
NSStringFromRect(rect));
|
||||
rect.origin = [[self window] convertBaseToScreen: rect.origin];
|
||||
|
||||
if ([[self window] respondsToSelector:@selector(convertRectToScreen:)]) {
|
||||
rect = [[self window] convertRectToScreen:rect];
|
||||
} else {
|
||||
rect.origin = [[self window] convertBaseToScreen:rect.origin];
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (NSAttributedString *) attributedSubstringFromRange: (NSRange) theRange
|
||||
- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange;
|
||||
{
|
||||
DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", theRange.location, theRange.length);
|
||||
DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", aRange.location, aRange.length);
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSInteger) conversationIdentifier
|
||||
- (NSInteger)conversationIdentifier
|
||||
{
|
||||
return (NSInteger) self;
|
||||
}
|
||||
|
|
@ -180,7 +173,7 @@
|
|||
/* This method returns the index for character that is
|
||||
* nearest to thePoint. thPoint is in screen coordinate system.
|
||||
*/
|
||||
- (NSUInteger) characterIndexForPoint:(NSPoint) thePoint
|
||||
- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
|
||||
{
|
||||
DEBUG_IME(@"characterIndexForPoint: (%g, %g)", thePoint.x, thePoint.y);
|
||||
return 0;
|
||||
|
|
@ -191,7 +184,7 @@
|
|||
* NSInputServer examines the return value of this
|
||||
* method & constructs appropriate attributed string.
|
||||
*/
|
||||
- (NSArray *) validAttributesForMarkedText
|
||||
- (NSArray *)validAttributesForMarkedText
|
||||
{
|
||||
return [NSArray array];
|
||||
}
|
||||
|
|
@ -424,7 +417,7 @@ HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags)
|
|||
}
|
||||
|
||||
static void
|
||||
UpdateKeymap(SDL_VideoData *data)
|
||||
UpdateKeymap(SDL_VideoData *data, SDL_bool send_event)
|
||||
{
|
||||
TISInputSourceRef key_layout;
|
||||
const void *chr_data;
|
||||
|
|
@ -443,10 +436,11 @@ UpdateKeymap(SDL_VideoData *data)
|
|||
|
||||
/* Try Unicode data first */
|
||||
CFDataRef uchrDataRef = TISGetInputSourceProperty(key_layout, kTISPropertyUnicodeKeyLayoutData);
|
||||
if (uchrDataRef)
|
||||
if (uchrDataRef) {
|
||||
chr_data = CFDataGetBytePtr(uchrDataRef);
|
||||
else
|
||||
} else {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (chr_data) {
|
||||
UInt32 keyboard_type = LMGetKbdType();
|
||||
|
|
@ -470,14 +464,18 @@ UpdateKeymap(SDL_VideoData *data)
|
|||
0, keyboard_type,
|
||||
kUCKeyTranslateNoDeadKeysMask,
|
||||
&dead_key_state, 8, &len, s);
|
||||
if (err != noErr)
|
||||
if (err != noErr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (len > 0 && s[0] != 0x10) {
|
||||
keymap[scancode] = s[0];
|
||||
}
|
||||
}
|
||||
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
|
||||
if (send_event) {
|
||||
SDL_SendKeymapChangedEvent();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -490,7 +488,7 @@ Cocoa_InitKeyboard(_THIS)
|
|||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
UpdateKeymap(data);
|
||||
UpdateKeymap(data, SDL_FALSE);
|
||||
|
||||
/* Set our own names for the platform-dependent but layout-independent keys */
|
||||
/* This key is NumLock on the MacBook keyboard. :) */
|
||||
|
|
@ -499,17 +497,24 @@ Cocoa_InitKeyboard(_THIS)
|
|||
SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Command");
|
||||
SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
|
||||
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
|
||||
|
||||
/* On pre-10.6, you might have the initial capslock key state wrong. */
|
||||
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
|
||||
data->modifierFlags = [NSEvent modifierFlags];
|
||||
SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_StartTextInput(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||
NSWindow *nswindow = nil;
|
||||
if (window)
|
||||
if (window) {
|
||||
nswindow = ((SDL_WindowData*)window->driverdata)->nswindow;
|
||||
}
|
||||
|
||||
NSView *parentView = [nswindow contentView];
|
||||
|
||||
|
|
@ -523,30 +528,26 @@ Cocoa_StartTextInput(_THIS)
|
|||
[[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
|
||||
}
|
||||
|
||||
if (![[data->fieldEdit superview] isEqual: parentView])
|
||||
{
|
||||
if (![[data->fieldEdit superview] isEqual:parentView]) {
|
||||
/* DEBUG_IME(@"add fieldEdit to window contentView"); */
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
[parentView addSubview: data->fieldEdit];
|
||||
[nswindow makeFirstResponder: data->fieldEdit];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_StopTextInput(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (data && data->fieldEdit) {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
[data->fieldEdit release];
|
||||
data->fieldEdit = nil;
|
||||
[pool release];
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
|
|
@ -554,17 +555,21 @@ Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
|
|||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (!rect) {
|
||||
SDL_InvalidParamError("rect");
|
||||
return;
|
||||
SDL_InvalidParamError("rect");
|
||||
return;
|
||||
}
|
||||
|
||||
[data->fieldEdit setInputRect: rect];
|
||||
[data->fieldEdit setInputRect:rect];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
if (!data) {
|
||||
return; /* can happen when returning from fullscreen Space on shutdown */
|
||||
}
|
||||
|
||||
unsigned short scancode = [event keyCode];
|
||||
SDL_Scancode code;
|
||||
#if 0
|
||||
|
|
@ -575,10 +580,10 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
|||
/* see comments in SDL_cocoakeys.h */
|
||||
scancode = 60 - scancode;
|
||||
}
|
||||
|
||||
if (scancode < SDL_arraysize(darwin_scancode_table)) {
|
||||
code = darwin_scancode_table[scancode];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Hmm, does this ever happen? If so, need to extend the keymap... */
|
||||
code = SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
|
|
@ -587,7 +592,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
|||
case NSKeyDown:
|
||||
if (![event isARepeat]) {
|
||||
/* See if we need to rebuild the keyboard layout */
|
||||
UpdateKeymap(data);
|
||||
UpdateKeymap(data, SDL_TRUE);
|
||||
}
|
||||
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -22,13 +22,6 @@
|
|||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
|
||||
#if defined(__APPLE__) && defined(__POWERPC__) && !defined(__APPLE_ALTIVEC__)
|
||||
#include <altivec.h>
|
||||
#undef bool
|
||||
#undef vector
|
||||
#undef pixel
|
||||
#endif
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_messagebox.h"
|
||||
|
|
@ -86,11 +79,10 @@
|
|||
/* Display a Cocoa message box */
|
||||
int
|
||||
Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
Cocoa_RegisterApp();
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
|
||||
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
|
||||
|
|
@ -125,20 +117,15 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
|
||||
int returnValue = 0;
|
||||
NSInteger clicked = presenter->clicked;
|
||||
if (clicked >= NSAlertFirstButtonReturn)
|
||||
{
|
||||
if (clicked >= NSAlertFirstButtonReturn) {
|
||||
clicked -= NSAlertFirstButtonReturn;
|
||||
*buttonid = buttons[clicked].buttonid;
|
||||
} else {
|
||||
returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = SDL_SetError("Did not get a valid `clicked button' id: %d", clicked);
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
}}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -27,6 +27,10 @@
|
|||
/* We need this for IODisplayCreateInfoDictionary and kIODisplayOnlyPreferredName */
|
||||
#include <IOKit/graphics/IOGraphicsLib.h>
|
||||
|
||||
/* We need this for CVDisplayLinkGetNominalOutputVideoRefreshPeriod */
|
||||
#include <CoreVideo/CVBase.h>
|
||||
#include <CoreVideo/CVDisplayLink.h>
|
||||
|
||||
/* we need this for ShowMenuBar() and HideMenuBar(). */
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
|
|
@ -43,10 +47,11 @@ Cocoa_ToggleMenuBar(const BOOL show)
|
|||
* we can just simply do without it on newer OSes...
|
||||
*/
|
||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && !defined(__LP64__)
|
||||
if (show)
|
||||
if (show) {
|
||||
ShowMenuBar();
|
||||
else
|
||||
} else {
|
||||
HideMenuBar();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -60,12 +65,12 @@ Cocoa_ToggleMenuBar(const BOOL show)
|
|||
#endif
|
||||
|
||||
static BOOL
|
||||
IS_SNOW_LEOPARD_OR_LATER(_THIS)
|
||||
IS_SNOW_LEOPARD_OR_LATER()
|
||||
{
|
||||
#if FORCE_OLD_API
|
||||
return NO;
|
||||
#else
|
||||
return ((((SDL_VideoData *) _this->driverdata))->osversion >= 0x1060);
|
||||
return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +118,7 @@ CG_SetError(const char *prefix, CGDisplayErr result)
|
|||
}
|
||||
|
||||
static SDL_bool
|
||||
GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
|
||||
GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMode *mode)
|
||||
{
|
||||
SDL_DisplayModeData *data;
|
||||
long width = 0;
|
||||
|
|
@ -127,12 +132,12 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
|
|||
}
|
||||
data->moderef = moderef;
|
||||
|
||||
if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CGDisplayModeRef vidmode = (CGDisplayModeRef) moderef;
|
||||
CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);
|
||||
width = (long) CGDisplayModeGetWidth(vidmode);
|
||||
height = (long) CGDisplayModeGetHeight(vidmode);
|
||||
refreshRate = (long) CGDisplayModeGetRefreshRate(vidmode);
|
||||
refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
|
||||
|
||||
if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
|
|
@ -140,6 +145,9 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
|
|||
} else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
bpp = 16;
|
||||
} else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
bpp = 30;
|
||||
} else {
|
||||
bpp = 0; /* ignore 8-bit and such for now. */
|
||||
}
|
||||
|
|
@ -148,8 +156,9 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
|
|||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CFNumberRef number;
|
||||
double refresh;
|
||||
CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
|
||||
number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
|
||||
CFNumberGetValue(number, kCFNumberLongType, &width);
|
||||
|
|
@ -158,20 +167,33 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
|
|||
number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel);
|
||||
CFNumberGetValue(number, kCFNumberLongType, &bpp);
|
||||
number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate);
|
||||
CFNumberGetValue(number, kCFNumberLongType, &refreshRate);
|
||||
CFNumberGetValue(number, kCFNumberDoubleType, &refresh);
|
||||
refreshRate = (long) (refresh + 0.5);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */
|
||||
if (refreshRate == 0 && link != NULL) {
|
||||
CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
|
||||
if ((time.flags & kCVTimeIsIndefinite) == 0 && time.timeValue != 0) {
|
||||
refreshRate = (long) ((time.timeScale / (double) time.timeValue) + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
mode->format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
switch (bpp) {
|
||||
case 16:
|
||||
mode->format = SDL_PIXELFORMAT_ARGB1555;
|
||||
break;
|
||||
case 30:
|
||||
mode->format = SDL_PIXELFORMAT_ARGB2101010;
|
||||
break;
|
||||
case 32:
|
||||
mode->format = SDL_PIXELFORMAT_ARGB8888;
|
||||
break;
|
||||
case 8: /* We don't support palettized modes now */
|
||||
default: /* Totally unrecognizable bit depth. */
|
||||
SDL_free(data);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
mode->w = width;
|
||||
|
|
@ -184,7 +206,7 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
|
|||
static void
|
||||
Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
|
||||
{
|
||||
if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CGDisplayModeRelease((CGDisplayModeRef) moderef); /* NULL is ok */
|
||||
}
|
||||
}
|
||||
|
|
@ -192,7 +214,7 @@ Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
|
|||
static void
|
||||
Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
|
||||
{
|
||||
if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CFRelease(modelist); /* NULL is ok */
|
||||
}
|
||||
}
|
||||
|
|
@ -200,21 +222,21 @@ Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
|
|||
static const char *
|
||||
Cocoa_GetDisplayName(CGDirectDisplayID displayID)
|
||||
{
|
||||
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
|
||||
NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
|
||||
CFDictionaryRef deviceInfo = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
|
||||
NSDictionary *localizedNames = [(NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
|
||||
const char* displayName = NULL;
|
||||
|
||||
if ([localizedNames count] > 0) {
|
||||
displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]);
|
||||
}
|
||||
[deviceInfo release];
|
||||
CFRelease(deviceInfo);
|
||||
return displayName;
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_InitModes(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
CGDisplayErr result;
|
||||
CGDirectDisplayID *displays;
|
||||
CGDisplayCount numDisplays;
|
||||
|
|
@ -223,7 +245,6 @@ Cocoa_InitModes(_THIS)
|
|||
result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
|
||||
if (result != kCGErrorSuccess) {
|
||||
CG_SetError("CGGetOnlineDisplayList()", result);
|
||||
[pool release];
|
||||
return;
|
||||
}
|
||||
displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays);
|
||||
|
|
@ -231,7 +252,6 @@ Cocoa_InitModes(_THIS)
|
|||
if (result != kCGErrorSuccess) {
|
||||
CG_SetError("CGGetOnlineDisplayList()", result);
|
||||
SDL_stack_free(displays);
|
||||
[pool release];
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -242,6 +262,7 @@ Cocoa_InitModes(_THIS)
|
|||
SDL_DisplayData *displaydata;
|
||||
SDL_DisplayMode mode;
|
||||
const void *moderef = NULL;
|
||||
CVDisplayLinkRef link = NULL;
|
||||
|
||||
if (pass == 0) {
|
||||
if (!CGDisplayIsMain(displays[i])) {
|
||||
|
|
@ -257,12 +278,12 @@ Cocoa_InitModes(_THIS)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
moderef = CGDisplayCopyDisplayMode(displays[i]);
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
moderef = CGDisplayCurrentMode(displays[i]);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -278,16 +299,21 @@ Cocoa_InitModes(_THIS)
|
|||
}
|
||||
displaydata->display = displays[i];
|
||||
|
||||
CVDisplayLinkCreateWithCGDisplay(displays[i], &link);
|
||||
|
||||
SDL_zero(display);
|
||||
/* this returns a stddup'ed string */
|
||||
display.name = (char *)Cocoa_GetDisplayName(displays[i]);
|
||||
if (!GetDisplayMode (_this, moderef, &mode)) {
|
||||
if (!GetDisplayMode(_this, moderef, link, &mode)) {
|
||||
CVDisplayLinkRelease(link);
|
||||
Cocoa_ReleaseDisplayMode(_this, moderef);
|
||||
SDL_free(display.name);
|
||||
SDL_free(displaydata);
|
||||
continue;
|
||||
}
|
||||
|
||||
CVDisplayLinkRelease(link);
|
||||
|
||||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = displaydata;
|
||||
|
|
@ -296,8 +322,7 @@ Cocoa_InitModes(_THIS)
|
|||
}
|
||||
}
|
||||
SDL_stack_free(displays);
|
||||
[pool release];
|
||||
}
|
||||
}}
|
||||
|
||||
int
|
||||
Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
||||
|
|
@ -319,31 +344,35 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
|||
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
|
||||
CFArrayRef modes = NULL;
|
||||
|
||||
if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
modes = CGDisplayAvailableModes(data->display);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (modes) {
|
||||
CVDisplayLinkRef link = NULL;
|
||||
const CFIndex count = CFArrayGetCount(modes);
|
||||
CFIndex i;
|
||||
|
||||
CVDisplayLinkCreateWithCGDisplay(data->display, &link);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
const void *moderef = CFArrayGetValueAtIndex(modes, i);
|
||||
SDL_DisplayMode mode;
|
||||
if (GetDisplayMode(_this, moderef, &mode)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (GetDisplayMode(_this, moderef, link, &mode)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CGDisplayModeRetain((CGDisplayModeRef) moderef);
|
||||
}
|
||||
SDL_AddDisplayMode(display, &mode);
|
||||
}
|
||||
}
|
||||
|
||||
CVDisplayLinkRelease(link);
|
||||
Cocoa_ReleaseDisplayModeList(_this, modes);
|
||||
}
|
||||
}
|
||||
|
|
@ -351,12 +380,12 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
|||
static CGError
|
||||
Cocoa_SwitchMode(_THIS, CGDirectDisplayID display, const void *mode)
|
||||
{
|
||||
if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
return CGDisplaySetDisplayMode(display, (CGDisplayModeRef) mode, NULL);
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER(_this)) {
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
return CGDisplaySwitchToMode(display, (CFDictionaryRef) mode);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -66,8 +66,8 @@
|
|||
|
||||
static SDL_Cursor *
|
||||
Cocoa_CreateDefaultCursor()
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSCursor *nscursor;
|
||||
SDL_Cursor *cursor = NULL;
|
||||
|
||||
|
|
@ -81,15 +81,13 @@ Cocoa_CreateDefaultCursor()
|
|||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return cursor;
|
||||
}
|
||||
}}
|
||||
|
||||
static SDL_Cursor *
|
||||
Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSImage *nsimage;
|
||||
NSCursor *nscursor = NULL;
|
||||
SDL_Cursor *cursor = NULL;
|
||||
|
|
@ -108,20 +106,17 @@ Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return cursor;
|
||||
}
|
||||
}}
|
||||
|
||||
static SDL_Cursor *
|
||||
Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSCursor *nscursor = NULL;
|
||||
SDL_Cursor *cursor = NULL;
|
||||
|
||||
switch(id)
|
||||
{
|
||||
switch(id) {
|
||||
case SDL_SYSTEM_CURSOR_ARROW:
|
||||
nscursor = [NSCursor arrowCursor];
|
||||
break;
|
||||
|
|
@ -170,28 +165,23 @@ Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
|||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return cursor;
|
||||
}
|
||||
}}
|
||||
|
||||
static void
|
||||
Cocoa_FreeCursor(SDL_Cursor * cursor)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
||||
|
||||
[nscursor release];
|
||||
SDL_free(cursor);
|
||||
|
||||
[pool release];
|
||||
}
|
||||
}}
|
||||
|
||||
static int
|
||||
Cocoa_ShowCursor(SDL_Cursor * cursor)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
SDL_Window *window = (device ? device->windows : NULL);
|
||||
for (; window != NULL; window = window->next) {
|
||||
|
|
@ -202,26 +192,37 @@ Cocoa_ShowCursor(SDL_Cursor * cursor)
|
|||
waitUntilDone:NO];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
}}
|
||||
|
||||
static void
|
||||
Cocoa_WarpMouse(SDL_Window * window, int x, int y)
|
||||
static SDL_Window *
|
||||
SDL_FindWindowAtPoint(const int x, const int y)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
if ([data->listener isMoving])
|
||||
{
|
||||
DLog("Postponing warp, window being moved.");
|
||||
[data->listener setPendingMoveX:x
|
||||
Y:y];
|
||||
return;
|
||||
const SDL_Point pt = { x, y };
|
||||
SDL_Window *i;
|
||||
for (i = SDL_GetVideoDevice()->windows; i; i = i->next) {
|
||||
const SDL_Rect r = { i->x, i->y, i->w, i->h };
|
||||
if (SDL_PointInRect(&pt, &r)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
Cocoa_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
CGPoint point = CGPointMake(x + (float)window->x, y + (float)window->y);
|
||||
if (mouse->focus) {
|
||||
SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata;
|
||||
if ([data->listener isMoving]) {
|
||||
DLog("Postponing warp, window being moved.");
|
||||
[data->listener setPendingMoveX:x Y:y];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
const CGPoint point = CGPointMake((float)x, (float)y);
|
||||
|
||||
Cocoa_HandleMouseWarp(point.x, point.y);
|
||||
|
||||
|
|
@ -233,12 +234,25 @@ Cocoa_WarpMouse(SDL_Window * window, int x, int y)
|
|||
CGWarpMouseCursorPosition(point);
|
||||
CGSetLocalEventsSuppressionInterval(0.25);
|
||||
|
||||
/* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
|
||||
* other implementations' APIs. Send what's appropriate.
|
||||
*/
|
||||
if (!mouse->relative_mode) {
|
||||
/* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
|
||||
* other implementations' APIs.
|
||||
*/
|
||||
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
|
||||
SDL_Window *win = SDL_FindWindowAtPoint(x, y);
|
||||
SDL_SetMouseFocus(win);
|
||||
if (win) {
|
||||
SDL_assert(win == mouse->focus);
|
||||
SDL_SendMouseMotion(win, mouse->mouseID, 0, x - win->x, y - win->y);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
Cocoa_WarpMouse(SDL_Window * window, int x, int y)
|
||||
{
|
||||
Cocoa_WarpMouseGlobal(x + window->x, y + window->y);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -271,9 +285,51 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled)
|
|||
if (result != kCGErrorSuccess) {
|
||||
return SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed");
|
||||
}
|
||||
|
||||
/* The hide/unhide calls are redundant most of the time, but they fix
|
||||
* https://bugzilla.libsdl.org/show_bug.cgi?id=2550
|
||||
*/
|
||||
if (enabled) {
|
||||
[NSCursor hide];
|
||||
} else {
|
||||
[NSCursor unhide];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
Cocoa_CaptureMouse(SDL_Window *window)
|
||||
{
|
||||
/* our Cocoa event code already tracks the mouse outside the window,
|
||||
so all we have to do here is say "okay" and do what we always do. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Uint32
|
||||
Cocoa_GetGlobalMouseState(int *x, int *y)
|
||||
{
|
||||
const NSUInteger cocoaButtons = [NSEvent pressedMouseButtons];
|
||||
const NSPoint cocoaLocation = [NSEvent mouseLocation];
|
||||
Uint32 retval = 0;
|
||||
|
||||
for (NSScreen *screen in [NSScreen screens]) {
|
||||
NSRect frame = [screen frame];
|
||||
if (NSPointInRect(cocoaLocation, frame)) {
|
||||
*x = (int) cocoaLocation.x;
|
||||
*y = (int) ((frame.origin.y + frame.size.height) - cocoaLocation.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
retval |= (cocoaButtons & (1 << 0)) ? SDL_BUTTON_LMASK : 0;
|
||||
retval |= (cocoaButtons & (1 << 1)) ? SDL_BUTTON_RMASK : 0;
|
||||
retval |= (cocoaButtons & (1 << 2)) ? SDL_BUTTON_MMASK : 0;
|
||||
retval |= (cocoaButtons & (1 << 3)) ? SDL_BUTTON_X1MASK : 0;
|
||||
retval |= (cocoaButtons & (1 << 4)) ? SDL_BUTTON_X2MASK : 0;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_InitMouse(_THIS)
|
||||
{
|
||||
|
|
@ -286,7 +342,10 @@ Cocoa_InitMouse(_THIS)
|
|||
mouse->ShowCursor = Cocoa_ShowCursor;
|
||||
mouse->FreeCursor = Cocoa_FreeCursor;
|
||||
mouse->WarpMouse = Cocoa_WarpMouse;
|
||||
mouse->WarpMouseGlobal = Cocoa_WarpMouseGlobal;
|
||||
mouse->SetRelativeMouseMode = Cocoa_SetRelativeMouseMode;
|
||||
mouse->CaptureMouse = Cocoa_CaptureMouse;
|
||||
mouse->GetGlobalMouseState = Cocoa_GetGlobalMouseState;
|
||||
|
||||
SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor());
|
||||
|
||||
|
|
@ -301,8 +360,7 @@ Cocoa_InitMouse(_THIS)
|
|||
void
|
||||
Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
|
||||
{
|
||||
switch ([event type])
|
||||
{
|
||||
switch ([event type]) {
|
||||
case NSMouseMoved:
|
||||
case NSLeftMouseDragged:
|
||||
case NSRightMouseDragged:
|
||||
|
|
@ -315,8 +373,11 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
|
|||
}
|
||||
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata;
|
||||
if (!driverdata) {
|
||||
return; /* can happen when returning from fullscreen Space on shutdown */
|
||||
}
|
||||
|
||||
const SDL_bool seenWarp = driverdata->seenWarp;
|
||||
driverdata->seenWarp = NO;
|
||||
|
||||
|
|
@ -343,8 +404,7 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
|
|||
float deltaX = [event deltaX];
|
||||
float deltaY = [event deltaY];
|
||||
|
||||
if (seenWarp)
|
||||
{
|
||||
if (seenWarp) {
|
||||
deltaX += (lastMoveX - driverdata->lastWarpX);
|
||||
deltaY += ((CGDisplayPixelsHigh(kCGDirectMainDisplay) - lastMoveY) - driverdata->lastWarpY);
|
||||
|
||||
|
|
@ -361,6 +421,13 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
|||
|
||||
float x = -[event deltaX];
|
||||
float y = [event deltaY];
|
||||
SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
|
||||
|
||||
if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
|
||||
if ([event isDirectionInvertedFromDevice] == YES) {
|
||||
direction = SDL_MOUSEWHEEL_FLIPPED;
|
||||
}
|
||||
}
|
||||
|
||||
if (x > 0) {
|
||||
x += 0.9f;
|
||||
|
|
@ -372,7 +439,7 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
|||
} else if (y < 0) {
|
||||
y -= 0.9f;
|
||||
}
|
||||
SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y);
|
||||
SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y, direction);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -67,8 +67,7 @@ Cocoa_MouseTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event
|
|||
NSRect windowRect;
|
||||
CGPoint eventLocation;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case kCGEventTapDisabledByTimeout:
|
||||
case kCGEventTapDisabledByUserInput:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -35,16 +35,6 @@
|
|||
|
||||
#define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
|
||||
|
||||
#ifndef NSOpenGLPFAOpenGLProfile
|
||||
#define NSOpenGLPFAOpenGLProfile 99
|
||||
#endif
|
||||
#ifndef NSOpenGLProfileVersionLegacy
|
||||
#define NSOpenGLProfileVersionLegacy 0x1000
|
||||
#endif
|
||||
#ifndef NSOpenGLProfileVersion3_2Core
|
||||
#define NSOpenGLProfileVersion3_2Core 0x3200
|
||||
#endif
|
||||
|
||||
@implementation SDLOpenGLContext : NSOpenGLContext
|
||||
|
||||
- (id)initWithFormat:(NSOpenGLPixelFormat *)format
|
||||
|
|
@ -160,11 +150,11 @@ Cocoa_GL_UnloadLibrary(_THIS)
|
|||
|
||||
SDL_GLContext
|
||||
Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
NSAutoreleasePool *pool;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
||||
SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
|
||||
NSOpenGLPixelFormatAttribute attr[32];
|
||||
NSOpenGLPixelFormat *fmt;
|
||||
SDLOpenGLContext *context;
|
||||
|
|
@ -178,15 +168,13 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
SDL_SetError ("OpenGL ES is not supported on this platform");
|
||||
return NULL;
|
||||
}
|
||||
if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && (data->osversion < 0x1070)) {
|
||||
if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && !lion_or_later) {
|
||||
SDL_SetError ("OpenGL Core Profile is not supported on this platform version");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
/* specify a profile if we're on Lion (10.7) or later. */
|
||||
if (data->osversion >= 0x1070) {
|
||||
if (lion_or_later) {
|
||||
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
||||
profile = NSOpenGLProfileVersion3_2Core;
|
||||
|
|
@ -249,7 +237,6 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
|
||||
if (fmt == nil) {
|
||||
SDL_SetError("Failed creating OpenGL pixel format");
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -263,12 +250,9 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
|
||||
if (context == nil) {
|
||||
SDL_SetError("Failed creating OpenGL context");
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
SDL_SetError("Failed making OpenGL context current");
|
||||
|
|
@ -316,15 +300,12 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
/*_this->gl_config.minor_version = glversion_minor;*/
|
||||
}
|
||||
return context;
|
||||
}
|
||||
}}
|
||||
|
||||
int
|
||||
Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if (context) {
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
|
||||
[nscontext setWindow:window];
|
||||
|
|
@ -334,9 +315,8 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
[NSOpenGLContext clearCurrentContext];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
|
|
@ -362,8 +342,8 @@ Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
|||
|
||||
int
|
||||
Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSOpenGLContext *nscontext;
|
||||
GLint value;
|
||||
int status;
|
||||
|
|
@ -372,8 +352,6 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
|||
return SDL_SetError("Late swap tearing currently unsupported");
|
||||
}
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
if (nscontext != nil) {
|
||||
value = interval;
|
||||
|
|
@ -383,57 +361,44 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
|||
status = SDL_SetError("No current OpenGL context");
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return status;
|
||||
}
|
||||
}}
|
||||
|
||||
int
|
||||
Cocoa_GL_GetSwapInterval(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSOpenGLContext *nscontext;
|
||||
GLint value;
|
||||
int status = 0;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
if (nscontext != nil) {
|
||||
[nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
status = (int)value;
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return status;
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
[nscontext flushBuffer];
|
||||
[nscontext updateIfNeeded];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[nscontext setWindow:NULL];
|
||||
[nscontext release];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
}}
|
||||
|
||||
#endif /* SDL_VIDEO_OPENGL_CGL */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -30,7 +30,8 @@
|
|||
#include "SDL_assert.h"
|
||||
|
||||
SDL_WindowShaper*
|
||||
Cocoa_CreateShaper(SDL_Window* window) {
|
||||
Cocoa_CreateShaper(SDL_Window* window)
|
||||
{
|
||||
SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
|
||||
[windata->nswindow setOpaque:NO];
|
||||
|
||||
|
|
@ -63,7 +64,8 @@ typedef struct {
|
|||
} SDL_CocoaClosure;
|
||||
|
||||
void
|
||||
ConvertRects(SDL_ShapeTree* tree,void* closure) {
|
||||
ConvertRects(SDL_ShapeTree* tree, void* closure)
|
||||
{
|
||||
SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure;
|
||||
if(tree->kind == OpaqueShape) {
|
||||
NSRect rect = NSMakeRect(tree->data.shape.x,data->window->h - tree->data.shape.y,tree->data.shape.w,tree->data.shape.h);
|
||||
|
|
@ -72,11 +74,12 @@ ConvertRects(SDL_ShapeTree* tree,void* closure) {
|
|||
}
|
||||
|
||||
int
|
||||
Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
|
||||
Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
|
||||
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
|
||||
SDL_CocoaClosure closure;
|
||||
NSAutoreleasePool *pool = NULL;
|
||||
if(data->saved == SDL_TRUE) {
|
||||
[data->context restoreGraphicsState];
|
||||
data->saved = SDL_FALSE;
|
||||
|
|
@ -90,19 +93,18 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape
|
|||
NSRectFill([[windata->nswindow contentView] frame]);
|
||||
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
closure.view = [windata->nswindow contentView];
|
||||
closure.path = [[NSBezierPath bezierPath] init];
|
||||
closure.path = [NSBezierPath bezierPath];
|
||||
closure.window = shaper->window;
|
||||
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
|
||||
[closure.path addClip];
|
||||
[pool release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
}}
|
||||
|
||||
int
|
||||
Cocoa_ResizeWindowShape(SDL_Window *window) {
|
||||
Cocoa_ResizeWindowShape(SDL_Window *window)
|
||||
{
|
||||
SDL_ShapeData* data = window->shaper->driverdata;
|
||||
SDL_assert(data != NULL);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
#include "SDL_opengl.h"
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
#include "SDL_keycode.h"
|
||||
|
|
@ -45,13 +46,15 @@
|
|||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
SInt32 osversion;
|
||||
int allow_spaces;
|
||||
unsigned int modifierFlags;
|
||||
void *key_layout;
|
||||
SDLTranslatorResponder *fieldEdit;
|
||||
NSInteger clipboard_count;
|
||||
Uint32 screensaver_activity;
|
||||
BOOL screensaver_use_iopm;
|
||||
IOPMAssertionID screensaver_assertion;
|
||||
|
||||
} SDL_VideoData;
|
||||
|
||||
/* Utility functions */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -22,13 +22,6 @@
|
|||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
|
||||
#if defined(__APPLE__) && defined(__POWERPC__) && !defined(__APPLE_ALTIVEC__)
|
||||
#include <altivec.h>
|
||||
#undef bool
|
||||
#undef vector
|
||||
#undef pixel
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_cocoavideo.h"
|
||||
|
|
@ -76,9 +69,6 @@ Cocoa_CreateDevice(int devindex)
|
|||
}
|
||||
device->driverdata = data;
|
||||
|
||||
/* Find out what version of Mac OS X we're running */
|
||||
Gestalt(gestaltSystemVersion, &data->osversion);
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = Cocoa_VideoInit;
|
||||
device->VideoQuit = Cocoa_VideoQuit;
|
||||
|
|
@ -86,6 +76,7 @@ Cocoa_CreateDevice(int devindex)
|
|||
device->GetDisplayModes = Cocoa_GetDisplayModes;
|
||||
device->SetDisplayMode = Cocoa_SetDisplayMode;
|
||||
device->PumpEvents = Cocoa_PumpEvents;
|
||||
device->SuspendScreenSaver = Cocoa_SuspendScreenSaver;
|
||||
|
||||
device->CreateWindow = Cocoa_CreateWindow;
|
||||
device->CreateWindowFrom = Cocoa_CreateWindowFrom;
|
||||
|
|
@ -108,6 +99,7 @@ Cocoa_CreateDevice(int devindex)
|
|||
device->SetWindowGrab = Cocoa_SetWindowGrab;
|
||||
device->DestroyWindow = Cocoa_DestroyWindow;
|
||||
device->GetWindowWMInfo = Cocoa_GetWindowWMInfo;
|
||||
device->SetWindowHitTest = Cocoa_SetWindowHitTest;
|
||||
|
||||
device->shape_driver.CreateShaper = Cocoa_CreateShaper;
|
||||
device->shape_driver.SetWindowShape = Cocoa_SetWindowShape;
|
||||
|
|
@ -155,7 +147,10 @@ Cocoa_VideoInit(_THIS)
|
|||
Cocoa_InitMouse(_this);
|
||||
|
||||
const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES);
|
||||
data->allow_spaces = ( (data->osversion >= 0x1070) && (!hint || (*hint != '0')) );
|
||||
data->allow_spaces = ( (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && (!hint || (*hint != '0')) );
|
||||
|
||||
/* The IOPM assertion API can disable the screensaver as of 10.7. */
|
||||
data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -45,6 +45,7 @@ typedef enum
|
|||
PendingWindowOperation pendingWindowOperation;
|
||||
BOOL isMoving;
|
||||
int pendingWindowWarpX, pendingWindowWarpY;
|
||||
BOOL isDragAreaRunning;
|
||||
}
|
||||
|
||||
-(void) listen:(SDL_WindowData *) data;
|
||||
|
|
@ -69,12 +70,16 @@ typedef enum
|
|||
-(void) windowDidDeminiaturize:(NSNotification *) aNotification;
|
||||
-(void) windowDidBecomeKey:(NSNotification *) aNotification;
|
||||
-(void) windowDidResignKey:(NSNotification *) aNotification;
|
||||
-(void) windowDidChangeBackingProperties:(NSNotification *) aNotification;
|
||||
-(void) windowWillEnterFullScreen:(NSNotification *) aNotification;
|
||||
-(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
|
||||
-(void) windowWillExitFullScreen:(NSNotification *) aNotification;
|
||||
-(void) windowDidExitFullScreen:(NSNotification *) aNotification;
|
||||
-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
|
||||
|
||||
/* See if event is in a drag area, toggle on window dragging. */
|
||||
-(BOOL) processHitTest:(NSEvent *)theEvent;
|
||||
|
||||
/* Window event handling */
|
||||
-(void) mouseDown:(NSEvent *) theEvent;
|
||||
-(void) rightMouseDown:(NSEvent *) theEvent;
|
||||
|
|
@ -93,13 +98,7 @@ typedef enum
|
|||
-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
|
||||
|
||||
/* Touch event handling */
|
||||
typedef enum {
|
||||
COCOA_TOUCH_DOWN,
|
||||
COCOA_TOUCH_UP,
|
||||
COCOA_TOUCH_MOVE,
|
||||
COCOA_TOUCH_CANCELLED
|
||||
} cocoaTouchType;
|
||||
-(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
|
||||
-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
|
||||
|
||||
@end
|
||||
/* *INDENT-ON* */
|
||||
|
|
@ -138,8 +137,8 @@ extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * r
|
|||
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo *info);
|
||||
extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info);
|
||||
extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
||||
|
||||
#endif /* _SDL_cocoawindow_h */
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -161,7 +161,7 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
|
|||
y, w - 2 * d);
|
||||
|
||||
/* Caption */
|
||||
if (window->title) {
|
||||
if (*window->title) {
|
||||
s->SetColor(s, COLOR_EXPAND(t->font_color));
|
||||
DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
#define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL)
|
||||
|
||||
|
||||
/* GDI renderer implementation */
|
||||
/* DirectFB renderer implementation */
|
||||
|
||||
static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window,
|
||||
Uint32 flags);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -156,7 +156,7 @@ DirectFB_CreateDevice(int devindex)
|
|||
return device;
|
||||
error:
|
||||
if (device)
|
||||
free(device);
|
||||
SDL_free(device);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ DirectFB_VideoInit(_THIS)
|
|||
|
||||
if (!devdata->use_linux_input)
|
||||
{
|
||||
SDL_DFB_LOG("Disabling linxu input\n");
|
||||
SDL_DFB_LOG("Disabling linux input\n");
|
||||
DirectFBSetOption("disable-module", "linux_input");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -90,7 +90,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
|||
desc.height = windata->size.h;
|
||||
desc.pixelformat = dispdata->pixelformat;
|
||||
desc.surface_caps = DSCAPS_PREMULTIPLIED;
|
||||
#if DIRECTFB_MAJOR_VERSION == 1 && DIRECTFB_MINOR_VERSION >= 4
|
||||
#if DIRECTFB_MAJOR_VERSION == 1 && DIRECTFB_MINOR_VERSION >= 6
|
||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
desc.surface_caps |= DSCAPS_GL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -82,7 +82,6 @@ DUMMY_CreateDevice(int devindex)
|
|||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (!device) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(device);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
644
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenevents.c
Normal file
644
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenevents.c
Normal file
|
|
@ -0,0 +1,644 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_EMSCRIPTEN
|
||||
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
|
||||
#include "SDL_emscriptenevents.h"
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
|
||||
|
||||
/*
|
||||
.keyCode to scancode
|
||||
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
|
||||
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
|
||||
*/
|
||||
static const SDL_Scancode emscripten_scancode_table[] = {
|
||||
/* 0 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 1 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 2 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 3 */ SDL_SCANCODE_CANCEL,
|
||||
/* 4 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 5 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 6 */ SDL_SCANCODE_HELP,
|
||||
/* 7 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 8 */ SDL_SCANCODE_BACKSPACE,
|
||||
/* 9 */ SDL_SCANCODE_TAB,
|
||||
/* 10 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 11 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 12 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 13 */ SDL_SCANCODE_RETURN,
|
||||
/* 14 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 15 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 16 */ SDL_SCANCODE_LSHIFT,
|
||||
/* 17 */ SDL_SCANCODE_LCTRL,
|
||||
/* 18 */ SDL_SCANCODE_LALT,
|
||||
/* 19 */ SDL_SCANCODE_PAUSE,
|
||||
/* 20 */ SDL_SCANCODE_CAPSLOCK,
|
||||
/* 21 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 22 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 23 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 24 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 25 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 26 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 27 */ SDL_SCANCODE_ESCAPE,
|
||||
/* 28 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 29 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 30 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 31 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 32 */ SDL_SCANCODE_SPACE,
|
||||
/* 33 */ SDL_SCANCODE_PAGEUP,
|
||||
/* 34 */ SDL_SCANCODE_PAGEDOWN,
|
||||
/* 35 */ SDL_SCANCODE_END,
|
||||
/* 36 */ SDL_SCANCODE_HOME,
|
||||
/* 37 */ SDL_SCANCODE_LEFT,
|
||||
/* 38 */ SDL_SCANCODE_UP,
|
||||
/* 39 */ SDL_SCANCODE_RIGHT,
|
||||
/* 40 */ SDL_SCANCODE_DOWN,
|
||||
/* 41 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 42 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 43 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 44 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 45 */ SDL_SCANCODE_INSERT,
|
||||
/* 46 */ SDL_SCANCODE_DELETE,
|
||||
/* 47 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 48 */ SDL_SCANCODE_0,
|
||||
/* 49 */ SDL_SCANCODE_1,
|
||||
/* 50 */ SDL_SCANCODE_2,
|
||||
/* 51 */ SDL_SCANCODE_3,
|
||||
/* 52 */ SDL_SCANCODE_4,
|
||||
/* 53 */ SDL_SCANCODE_5,
|
||||
/* 54 */ SDL_SCANCODE_6,
|
||||
/* 55 */ SDL_SCANCODE_7,
|
||||
/* 56 */ SDL_SCANCODE_8,
|
||||
/* 57 */ SDL_SCANCODE_9,
|
||||
/* 58 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 59 */ SDL_SCANCODE_SEMICOLON,
|
||||
/* 60 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 61 */ SDL_SCANCODE_EQUALS,
|
||||
/* 62 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 63 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 64 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 65 */ SDL_SCANCODE_A,
|
||||
/* 66 */ SDL_SCANCODE_B,
|
||||
/* 67 */ SDL_SCANCODE_C,
|
||||
/* 68 */ SDL_SCANCODE_D,
|
||||
/* 69 */ SDL_SCANCODE_E,
|
||||
/* 70 */ SDL_SCANCODE_F,
|
||||
/* 71 */ SDL_SCANCODE_G,
|
||||
/* 72 */ SDL_SCANCODE_H,
|
||||
/* 73 */ SDL_SCANCODE_I,
|
||||
/* 74 */ SDL_SCANCODE_J,
|
||||
/* 75 */ SDL_SCANCODE_K,
|
||||
/* 76 */ SDL_SCANCODE_L,
|
||||
/* 77 */ SDL_SCANCODE_M,
|
||||
/* 78 */ SDL_SCANCODE_N,
|
||||
/* 79 */ SDL_SCANCODE_O,
|
||||
/* 80 */ SDL_SCANCODE_P,
|
||||
/* 81 */ SDL_SCANCODE_Q,
|
||||
/* 82 */ SDL_SCANCODE_R,
|
||||
/* 83 */ SDL_SCANCODE_S,
|
||||
/* 84 */ SDL_SCANCODE_T,
|
||||
/* 85 */ SDL_SCANCODE_U,
|
||||
/* 86 */ SDL_SCANCODE_V,
|
||||
/* 87 */ SDL_SCANCODE_W,
|
||||
/* 88 */ SDL_SCANCODE_X,
|
||||
/* 89 */ SDL_SCANCODE_Y,
|
||||
/* 90 */ SDL_SCANCODE_Z,
|
||||
/* 91 */ SDL_SCANCODE_LGUI,
|
||||
/* 92 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 93 */ SDL_SCANCODE_APPLICATION,
|
||||
/* 94 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 95 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 96 */ SDL_SCANCODE_KP_0,
|
||||
/* 97 */ SDL_SCANCODE_KP_1,
|
||||
/* 98 */ SDL_SCANCODE_KP_2,
|
||||
/* 99 */ SDL_SCANCODE_KP_3,
|
||||
/* 100 */ SDL_SCANCODE_KP_4,
|
||||
/* 101 */ SDL_SCANCODE_KP_5,
|
||||
/* 102 */ SDL_SCANCODE_KP_6,
|
||||
/* 103 */ SDL_SCANCODE_KP_7,
|
||||
/* 104 */ SDL_SCANCODE_KP_8,
|
||||
/* 105 */ SDL_SCANCODE_KP_9,
|
||||
/* 106 */ SDL_SCANCODE_KP_MULTIPLY,
|
||||
/* 107 */ SDL_SCANCODE_KP_PLUS,
|
||||
/* 108 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 109 */ SDL_SCANCODE_KP_MINUS,
|
||||
/* 110 */ SDL_SCANCODE_KP_PERIOD,
|
||||
/* 111 */ SDL_SCANCODE_KP_DIVIDE,
|
||||
/* 112 */ SDL_SCANCODE_F1,
|
||||
/* 113 */ SDL_SCANCODE_F2,
|
||||
/* 114 */ SDL_SCANCODE_F3,
|
||||
/* 115 */ SDL_SCANCODE_F4,
|
||||
/* 116 */ SDL_SCANCODE_F5,
|
||||
/* 117 */ SDL_SCANCODE_F6,
|
||||
/* 118 */ SDL_SCANCODE_F7,
|
||||
/* 119 */ SDL_SCANCODE_F8,
|
||||
/* 120 */ SDL_SCANCODE_F9,
|
||||
/* 121 */ SDL_SCANCODE_F10,
|
||||
/* 122 */ SDL_SCANCODE_F11,
|
||||
/* 123 */ SDL_SCANCODE_F12,
|
||||
/* 124 */ SDL_SCANCODE_F13,
|
||||
/* 125 */ SDL_SCANCODE_F14,
|
||||
/* 126 */ SDL_SCANCODE_F15,
|
||||
/* 127 */ SDL_SCANCODE_F16,
|
||||
/* 128 */ SDL_SCANCODE_F17,
|
||||
/* 129 */ SDL_SCANCODE_F18,
|
||||
/* 130 */ SDL_SCANCODE_F19,
|
||||
/* 131 */ SDL_SCANCODE_F20,
|
||||
/* 132 */ SDL_SCANCODE_F21,
|
||||
/* 133 */ SDL_SCANCODE_F22,
|
||||
/* 134 */ SDL_SCANCODE_F23,
|
||||
/* 135 */ SDL_SCANCODE_F24,
|
||||
/* 136 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 137 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 138 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 139 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 140 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 141 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 142 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 143 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 144 */ SDL_SCANCODE_NUMLOCKCLEAR,
|
||||
/* 145 */ SDL_SCANCODE_SCROLLLOCK,
|
||||
/* 146 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 147 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 148 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 149 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 150 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 151 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 152 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 153 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 154 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 155 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 156 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 157 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 158 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 159 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 160 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 161 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 162 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 163 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 164 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 165 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 166 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 167 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 168 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 169 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 170 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 171 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 172 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 173 */ SDL_SCANCODE_MINUS, /*FX*/
|
||||
/* 174 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 175 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 176 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 177 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 178 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 179 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 180 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 181 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 182 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 183 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 184 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 185 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 186 */ SDL_SCANCODE_SEMICOLON, /*IE, Chrome, D3E legacy*/
|
||||
/* 187 */ SDL_SCANCODE_EQUALS, /*IE, Chrome, D3E legacy*/
|
||||
/* 188 */ SDL_SCANCODE_COMMA,
|
||||
/* 189 */ SDL_SCANCODE_MINUS, /*IE, Chrome, D3E legacy*/
|
||||
/* 190 */ SDL_SCANCODE_PERIOD,
|
||||
/* 191 */ SDL_SCANCODE_SLASH,
|
||||
/* 192 */ SDL_SCANCODE_GRAVE, /*FX, D3E legacy (SDL_SCANCODE_APOSTROPHE in IE/Chrome)*/
|
||||
/* 193 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 194 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 195 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 196 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 197 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 198 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 199 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 200 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 201 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 202 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 203 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 204 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 205 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 206 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 207 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 208 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 209 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 210 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 211 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 212 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 213 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 214 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 215 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 216 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 217 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 218 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 219 */ SDL_SCANCODE_LEFTBRACKET,
|
||||
/* 220 */ SDL_SCANCODE_BACKSLASH,
|
||||
/* 221 */ SDL_SCANCODE_RIGHTBRACKET,
|
||||
/* 222 */ SDL_SCANCODE_APOSTROPHE, /*FX, D3E legacy*/
|
||||
};
|
||||
|
||||
|
||||
/* "borrowed" from SDL_windowsevents.c */
|
||||
int
|
||||
Emscripten_ConvertUTF32toUTF8(Uint32 codepoint, char * text)
|
||||
{
|
||||
if (codepoint <= 0x7F) {
|
||||
text[0] = (char) codepoint;
|
||||
text[1] = '\0';
|
||||
} else if (codepoint <= 0x7FF) {
|
||||
text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F);
|
||||
text[1] = 0x80 | (char) (codepoint & 0x3F);
|
||||
text[2] = '\0';
|
||||
} else if (codepoint <= 0xFFFF) {
|
||||
text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F);
|
||||
text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
|
||||
text[2] = 0x80 | (char) (codepoint & 0x3F);
|
||||
text[3] = '\0';
|
||||
} else if (codepoint <= 0x10FFFF) {
|
||||
text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F);
|
||||
text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F);
|
||||
text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
|
||||
text[3] = 0x80 | (char) (codepoint & 0x3F);
|
||||
text[4] = '\0';
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
int mx = mouseEvent->canvasX, my = mouseEvent->canvasY;
|
||||
EmscriptenPointerlockChangeEvent pointerlock_status;
|
||||
|
||||
/* check for pointer lock */
|
||||
emscripten_get_pointerlock_status(&pointerlock_status);
|
||||
|
||||
if (pointerlock_status.isActive) {
|
||||
mx = mouseEvent->movementX;
|
||||
my = mouseEvent->movementY;
|
||||
}
|
||||
|
||||
/* rescale (in case canvas is being scaled)*/
|
||||
double client_w, client_h;
|
||||
emscripten_get_element_css_size(NULL, &client_w, &client_h);
|
||||
|
||||
mx = mx * (window_data->window->w / (client_w * window_data->pixel_ratio));
|
||||
my = my * (window_data->window->h / (client_h * window_data->pixel_ratio));
|
||||
|
||||
SDL_SendMouseMotion(window_data->window, 0, pointerlock_status.isActive, mx, my);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
uint32_t sdl_button;
|
||||
switch (mouseEvent->button) {
|
||||
case 0:
|
||||
sdl_button = SDL_BUTTON_LEFT;
|
||||
break;
|
||||
case 1:
|
||||
sdl_button = SDL_BUTTON_MIDDLE;
|
||||
break;
|
||||
case 2:
|
||||
sdl_button = SDL_BUTTON_RIGHT;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
SDL_SendMouseButton(window_data->window, 0, eventType == EMSCRIPTEN_EVENT_MOUSEDOWN ? SDL_PRESSED : SDL_RELEASED, sdl_button);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? SDL_WINDOWEVENT_ENTER : SDL_WINDOWEVENT_LEAVE, 0, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
SDL_SendMouseWheel(window_data->window, 0, wheelEvent->deltaX, -wheelEvent->deltaY, SDL_MOUSEWHEEL_NORMAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_FOCUS ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
int i;
|
||||
|
||||
SDL_TouchID deviceId = 1;
|
||||
if (SDL_AddTouch(deviceId, "") < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < touchEvent->numTouches; i++) {
|
||||
SDL_FingerID id;
|
||||
float x, y;
|
||||
|
||||
if (!touchEvent->touches[i].isChanged)
|
||||
continue;
|
||||
|
||||
id = touchEvent->touches[i].identifier;
|
||||
x = touchEvent->touches[i].canvasX / (float)window_data->windowed_width;
|
||||
y = touchEvent->touches[i].canvasY / (float)window_data->windowed_height;
|
||||
|
||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
|
||||
SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
|
||||
} else if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
|
||||
SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
|
||||
} else {
|
||||
SDL_SendTouch(deviceId, id, SDL_FALSE, x, y, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
|
||||
{
|
||||
Uint32 scancode;
|
||||
|
||||
/* .keyCode is deprecated, but still the most reliable way to get keys */
|
||||
if (keyEvent->keyCode < SDL_arraysize(emscripten_scancode_table)) {
|
||||
scancode = emscripten_scancode_table[keyEvent->keyCode];
|
||||
|
||||
if (scancode != SDL_SCANCODE_UNKNOWN) {
|
||||
|
||||
if (keyEvent->location == DOM_KEY_LOCATION_RIGHT) {
|
||||
switch (scancode) {
|
||||
case SDL_SCANCODE_LSHIFT:
|
||||
scancode = SDL_SCANCODE_RSHIFT;
|
||||
break;
|
||||
case SDL_SCANCODE_LCTRL:
|
||||
scancode = SDL_SCANCODE_RCTRL;
|
||||
break;
|
||||
case SDL_SCANCODE_LALT:
|
||||
scancode = SDL_SCANCODE_RALT;
|
||||
break;
|
||||
case SDL_SCANCODE_LGUI:
|
||||
scancode = SDL_SCANCODE_RGUI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ?
|
||||
SDL_PRESSED : SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
|
||||
/* if we prevent keydown, we won't get keypress
|
||||
* also we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX
|
||||
*/
|
||||
return SDL_GetEventState(SDL_TEXTINPUT) != SDL_ENABLE || eventType != EMSCRIPTEN_EVENT_KEYDOWN
|
||||
|| keyEvent->keyCode == 8 /* backspace */ || keyEvent->keyCode == 9 /* tab */;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
|
||||
{
|
||||
char text[5];
|
||||
if (Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text)) {
|
||||
SDL_SendKeyboardText(text);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)
|
||||
{
|
||||
/*make sure this is actually our element going fullscreen*/
|
||||
if(SDL_strcmp(fullscreenChangeEvent->id, "SDLFullscreenElement") != 0)
|
||||
return 0;
|
||||
|
||||
SDL_WindowData *window_data = userData;
|
||||
if(fullscreenChangeEvent->isFullscreen)
|
||||
{
|
||||
SDL_bool is_desktop_fullscreen;
|
||||
window_data->window->flags |= window_data->requested_fullscreen_mode;
|
||||
|
||||
if(!window_data->requested_fullscreen_mode)
|
||||
window_data->window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; /*we didn't reqest fullscreen*/
|
||||
|
||||
window_data->requested_fullscreen_mode = 0;
|
||||
|
||||
is_desktop_fullscreen = (window_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
|
||||
/*update size*/
|
||||
if(window_data->window->flags & SDL_WINDOW_RESIZABLE || is_desktop_fullscreen)
|
||||
{
|
||||
emscripten_set_canvas_size(fullscreenChangeEvent->screenWidth, fullscreenChangeEvent->screenHeight);
|
||||
SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, fullscreenChangeEvent->screenWidth, fullscreenChangeEvent->screenHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*preserve ratio*/
|
||||
double w = window_data->window->w;
|
||||
double h = window_data->window->h;
|
||||
double factor = SDL_min(fullscreenChangeEvent->screenWidth / w, fullscreenChangeEvent->screenHeight / h);
|
||||
emscripten_set_element_css_size(NULL, w * factor, h * factor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EM_ASM({
|
||||
//un-reparent canvas (similar to Module.requestFullscreen)
|
||||
var canvas = Module['canvas'];
|
||||
if(canvas.parentNode.id == "SDLFullscreenElement") {
|
||||
var canvasContainer = canvas.parentNode;
|
||||
canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
|
||||
canvasContainer.parentNode.removeChild(canvasContainer);
|
||||
}
|
||||
});
|
||||
double unscaled_w = window_data->windowed_width / window_data->pixel_ratio;
|
||||
double unscaled_h = window_data->windowed_height / window_data->pixel_ratio;
|
||||
emscripten_set_canvas_size(window_data->windowed_width, window_data->windowed_height);
|
||||
|
||||
if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
|
||||
emscripten_set_element_css_size(NULL, unscaled_w, unscaled_h);
|
||||
}
|
||||
|
||||
SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, unscaled_w, unscaled_h);
|
||||
|
||||
window_data->window->flags &= ~FULLSCREEN_MASK;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData)
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
if(window_data->window->flags & FULLSCREEN_MASK)
|
||||
{
|
||||
SDL_bool is_desktop_fullscreen = (window_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
|
||||
if(window_data->window->flags & SDL_WINDOW_RESIZABLE || is_desktop_fullscreen)
|
||||
{
|
||||
emscripten_set_canvas_size(uiEvent->windowInnerWidth * window_data->pixel_ratio, uiEvent->windowInnerHeight * window_data->pixel_ratio);
|
||||
SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, uiEvent->windowInnerWidth, uiEvent->windowInnerHeight);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this will only work if the canvas size is set through css */
|
||||
if(window_data->window->flags & SDL_WINDOW_RESIZABLE)
|
||||
{
|
||||
double w = window_data->window->w;
|
||||
double h = window_data->window->h;
|
||||
|
||||
if(window_data->external_size) {
|
||||
emscripten_get_element_css_size(NULL, &w, &h);
|
||||
}
|
||||
|
||||
emscripten_set_canvas_size(w * window_data->pixel_ratio, h * window_data->pixel_ratio);
|
||||
|
||||
/* set_canvas_size unsets this */
|
||||
if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
|
||||
emscripten_set_element_css_size(NULL, w, h);
|
||||
}
|
||||
|
||||
SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
EM_BOOL
|
||||
Emscripten_HandleVisibilityChange(int eventType, const EmscriptenVisibilityChangeEvent *visEvent, void *userData)
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
SDL_SendWindowEvent(window_data->window, visEvent->hidden ? SDL_WINDOWEVENT_HIDDEN : SDL_WINDOWEVENT_SHOWN, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Emscripten_RegisterEventHandlers(SDL_WindowData *data)
|
||||
{
|
||||
/* There is only one window and that window is the canvas */
|
||||
emscripten_set_mousemove_callback("#canvas", data, 0, Emscripten_HandleMouseMove);
|
||||
|
||||
emscripten_set_mousedown_callback("#canvas", data, 0, Emscripten_HandleMouseButton);
|
||||
emscripten_set_mouseup_callback("#canvas", data, 0, Emscripten_HandleMouseButton);
|
||||
|
||||
emscripten_set_mouseenter_callback("#canvas", data, 0, Emscripten_HandleMouseFocus);
|
||||
emscripten_set_mouseleave_callback("#canvas", data, 0, Emscripten_HandleMouseFocus);
|
||||
|
||||
emscripten_set_wheel_callback("#canvas", data, 0, Emscripten_HandleWheel);
|
||||
|
||||
emscripten_set_focus_callback("#canvas", data, 0, Emscripten_HandleFocus);
|
||||
emscripten_set_blur_callback("#canvas", data, 0, Emscripten_HandleFocus);
|
||||
|
||||
emscripten_set_touchstart_callback("#canvas", data, 0, Emscripten_HandleTouch);
|
||||
emscripten_set_touchend_callback("#canvas", data, 0, Emscripten_HandleTouch);
|
||||
emscripten_set_touchmove_callback("#canvas", data, 0, Emscripten_HandleTouch);
|
||||
emscripten_set_touchcancel_callback("#canvas", data, 0, Emscripten_HandleTouch);
|
||||
|
||||
/* Keyboard events are awkward */
|
||||
const char *keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
|
||||
if (!keyElement) keyElement = "#window";
|
||||
|
||||
emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey);
|
||||
emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey);
|
||||
emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress);
|
||||
|
||||
emscripten_set_fullscreenchange_callback("#document", data, 0, Emscripten_HandleFullscreenChange);
|
||||
|
||||
emscripten_set_resize_callback("#window", data, 0, Emscripten_HandleResize);
|
||||
|
||||
emscripten_set_visibilitychange_callback(data, 0, Emscripten_HandleVisibilityChange);
|
||||
}
|
||||
|
||||
void
|
||||
Emscripten_UnregisterEventHandlers(SDL_WindowData *data)
|
||||
{
|
||||
/* only works due to having one window */
|
||||
emscripten_set_mousemove_callback("#canvas", NULL, 0, NULL);
|
||||
|
||||
emscripten_set_mousedown_callback("#canvas", NULL, 0, NULL);
|
||||
emscripten_set_mouseup_callback("#canvas", NULL, 0, NULL);
|
||||
|
||||
emscripten_set_mouseenter_callback("#canvas", NULL, 0, NULL);
|
||||
emscripten_set_mouseleave_callback("#canvas", NULL, 0, NULL);
|
||||
|
||||
emscripten_set_wheel_callback("#canvas", NULL, 0, NULL);
|
||||
|
||||
emscripten_set_focus_callback("#canvas", NULL, 0, NULL);
|
||||
emscripten_set_blur_callback("#canvas", NULL, 0, NULL);
|
||||
|
||||
emscripten_set_touchstart_callback("#canvas", NULL, 0, NULL);
|
||||
emscripten_set_touchend_callback("#canvas", NULL, 0, NULL);
|
||||
emscripten_set_touchmove_callback("#canvas", NULL, 0, NULL);
|
||||
emscripten_set_touchcancel_callback("#canvas", NULL, 0, NULL);
|
||||
|
||||
const char *target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
|
||||
if (!target) {
|
||||
target = "#window";
|
||||
}
|
||||
|
||||
emscripten_set_keydown_callback(target, NULL, 0, NULL);
|
||||
emscripten_set_keyup_callback(target, NULL, 0, NULL);
|
||||
|
||||
emscripten_set_keypress_callback(target, NULL, 0, NULL);
|
||||
|
||||
emscripten_set_fullscreenchange_callback("#document", NULL, 0, NULL);
|
||||
|
||||
emscripten_set_resize_callback("#window", NULL, 0, NULL);
|
||||
|
||||
emscripten_set_visibilitychange_callback(NULL, 0, NULL);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
36
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenevents.h
Normal file
36
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenevents.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SDL_emscriptenevents_h
|
||||
#define _SDL_emscriptenevents_h
|
||||
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
|
||||
extern void
|
||||
Emscripten_RegisterEventHandlers(SDL_WindowData *data);
|
||||
|
||||
extern void
|
||||
Emscripten_UnregisterEventHandlers(SDL_WindowData *data);
|
||||
#endif /* _SDL_emscriptenevents_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
136
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenframebuffer.c
Normal file
136
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenframebuffer.c
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_EMSCRIPTEN
|
||||
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
#include "SDL_emscriptenframebuffer.h"
|
||||
|
||||
|
||||
int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
const Uint32 surface_format = SDL_PIXELFORMAT_BGR888;
|
||||
int w, h;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
surface = data->surface;
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
/* Create a new one */
|
||||
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
|
||||
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Save the info and return! */
|
||||
data->surface = surface;
|
||||
*format = surface_format;
|
||||
*pixels = surface->pixels;
|
||||
*pitch = surface->pitch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
surface = data->surface;
|
||||
if (!surface) {
|
||||
return SDL_SetError("Couldn't find framebuffer surface for window");
|
||||
}
|
||||
|
||||
/* Send the data to the display */
|
||||
|
||||
EM_ASM_INT({
|
||||
//TODO: don't create context every update
|
||||
var ctx = Module['canvas'].getContext('2d');
|
||||
|
||||
//library_sdl.js SDL_UnlockSurface
|
||||
var image = ctx.createImageData($0, $1);
|
||||
var data = image.data;
|
||||
var src = $2 >> 2;
|
||||
var dst = 0;
|
||||
var isScreen = true;
|
||||
var num;
|
||||
if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) {
|
||||
// IE10/IE11: ImageData objects are backed by the deprecated CanvasPixelArray,
|
||||
// not UInt8ClampedArray. These don't have buffers, so we need to revert
|
||||
// to copying a byte at a time. We do the undefined check because modern
|
||||
// browsers do not define CanvasPixelArray anymore.
|
||||
num = data.length;
|
||||
while (dst < num) {
|
||||
var val = HEAP32[src]; // This is optimized. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
|
||||
data[dst ] = val & 0xff;
|
||||
data[dst+1] = (val >> 8) & 0xff;
|
||||
data[dst+2] = (val >> 16) & 0xff;
|
||||
data[dst+3] = isScreen ? 0xff : ((val >> 24) & 0xff);
|
||||
src++;
|
||||
dst += 4;
|
||||
}
|
||||
} else {
|
||||
var data32 = new Uint32Array(data.buffer);
|
||||
num = data32.length;
|
||||
if (isScreen) {
|
||||
while (dst < num) {
|
||||
// HEAP32[src++] is an optimization. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
|
||||
data32[dst++] = HEAP32[src++] | 0xff000000;
|
||||
}
|
||||
} else {
|
||||
while (dst < num) {
|
||||
data32[dst++] = HEAP32[src++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctx.putImageData(image, 0, 0);
|
||||
return 0;
|
||||
}, surface->w, surface->h, surface->pixels);
|
||||
|
||||
/*if (SDL_getenv("SDL_VIDEO_Emscripten_SAVE_FRAMES")) {
|
||||
static int frame_number = 0;
|
||||
char file[128];
|
||||
SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
|
||||
SDL_GetWindowID(window), ++frame_number);
|
||||
SDL_SaveBMP(surface, file);
|
||||
}*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
SDL_FreeSurface(data->surface);
|
||||
data->surface = NULL;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef _SDL_emscriptenframebuffer_h
|
||||
#define _SDL_emscriptenframebuffer_h
|
||||
|
||||
extern int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
|
||||
extern int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
|
||||
extern void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
|
||||
|
||||
#endif /* _SDL_emscriptenframebuffer_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
232
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenmouse.c
Normal file
232
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenmouse.c
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_EMSCRIPTEN
|
||||
|
||||
#include <emscripten/emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
#include "SDL_emscriptenmouse.h"
|
||||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
|
||||
static SDL_Cursor*
|
||||
Emscripten_CreateDefaultCursor()
|
||||
{
|
||||
SDL_Cursor* cursor;
|
||||
Emscripten_CursorData *curdata;
|
||||
|
||||
cursor = SDL_calloc(1, sizeof(SDL_Cursor));
|
||||
if (cursor) {
|
||||
curdata = (Emscripten_CursorData *) SDL_calloc(1, sizeof(*curdata));
|
||||
if (!curdata) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
curdata->system_cursor = "default";
|
||||
cursor->driverdata = curdata;
|
||||
}
|
||||
else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static SDL_Cursor*
|
||||
Emscripten_CreateCursor(SDL_Surface* sruface, int hot_x, int hot_y)
|
||||
{
|
||||
return Emscripten_CreateDefaultCursor();
|
||||
}
|
||||
|
||||
static SDL_Cursor*
|
||||
Emscripten_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{
|
||||
SDL_Cursor *cursor;
|
||||
Emscripten_CursorData *curdata;
|
||||
const char *cursor_name = NULL;
|
||||
|
||||
switch(id) {
|
||||
case SDL_SYSTEM_CURSOR_ARROW:
|
||||
cursor_name = "default";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_IBEAM:
|
||||
cursor_name = "text";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT:
|
||||
cursor_name = "wait";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_CROSSHAIR:
|
||||
cursor_name = "crosshair";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW:
|
||||
cursor_name = "progress";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE:
|
||||
cursor_name = "nwse-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW:
|
||||
cursor_name = "nesw-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEWE:
|
||||
cursor_name = "ew-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENS:
|
||||
cursor_name = "ns-resize";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEALL:
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_NO:
|
||||
cursor_name = "not-allowed";
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_HAND:
|
||||
cursor_name = "pointer";
|
||||
break;
|
||||
default:
|
||||
SDL_assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
|
||||
if (!cursor) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
curdata = (Emscripten_CursorData *) SDL_calloc(1, sizeof(*curdata));
|
||||
if (!curdata) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
curdata->system_cursor = cursor_name;
|
||||
cursor->driverdata = curdata;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
Emscripten_FreeCursor(SDL_Cursor* cursor)
|
||||
{
|
||||
Emscripten_CursorData *curdata;
|
||||
if (cursor) {
|
||||
curdata = (Emscripten_CursorData *) cursor->driverdata;
|
||||
|
||||
if (curdata != NULL) {
|
||||
SDL_free(cursor->driverdata);
|
||||
}
|
||||
|
||||
SDL_free(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Emscripten_ShowCursor(SDL_Cursor* cursor)
|
||||
{
|
||||
Emscripten_CursorData *curdata;
|
||||
if (SDL_GetMouseFocus() != NULL) {
|
||||
if(cursor && cursor->driverdata) {
|
||||
curdata = (Emscripten_CursorData *) cursor->driverdata;
|
||||
|
||||
if(curdata->system_cursor) {
|
||||
EM_ASM_INT({
|
||||
if (Module['canvas']) {
|
||||
Module['canvas'].style['cursor'] = Module['Pointer_stringify']($0);
|
||||
}
|
||||
return 0;
|
||||
}, curdata->system_cursor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
EM_ASM(
|
||||
if (Module['canvas']) {
|
||||
Module['canvas'].style['cursor'] = 'none';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
Emscripten_WarpMouse(SDL_Window* window, int x, int y)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
static int
|
||||
Emscripten_SetRelativeMouseMode(SDL_bool enabled)
|
||||
{
|
||||
/* TODO: pointer lock isn't actually enabled yet */
|
||||
if(enabled) {
|
||||
if(emscripten_request_pointerlock(NULL, 1) >= EMSCRIPTEN_RESULT_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if(emscripten_exit_pointerlock() >= EMSCRIPTEN_RESULT_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
Emscripten_InitMouse()
|
||||
{
|
||||
SDL_Mouse* mouse = SDL_GetMouse();
|
||||
|
||||
mouse->CreateCursor = Emscripten_CreateCursor;
|
||||
mouse->ShowCursor = Emscripten_ShowCursor;
|
||||
mouse->FreeCursor = Emscripten_FreeCursor;
|
||||
mouse->WarpMouse = Emscripten_WarpMouse;
|
||||
mouse->CreateSystemCursor = Emscripten_CreateSystemCursor;
|
||||
mouse->SetRelativeMouseMode = Emscripten_SetRelativeMouseMode;
|
||||
|
||||
SDL_SetDefaultCursor(Emscripten_CreateDefaultCursor());
|
||||
}
|
||||
|
||||
void
|
||||
Emscripten_FiniMouse()
|
||||
{
|
||||
SDL_Mouse* mouse = SDL_GetMouse();
|
||||
|
||||
Emscripten_FreeCursor(mouse->def_cursor);
|
||||
mouse->def_cursor = NULL;
|
||||
|
||||
mouse->CreateCursor = NULL;
|
||||
mouse->ShowCursor = NULL;
|
||||
mouse->FreeCursor = NULL;
|
||||
mouse->WarpMouse = NULL;
|
||||
mouse->CreateSystemCursor = NULL;
|
||||
mouse->SetRelativeMouseMode = NULL;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
39
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenmouse.h
Normal file
39
Engine/lib/sdl/src/video/emscripten/SDL_emscriptenmouse.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SDL_emscriptenmouse_h
|
||||
#define _SDL_emscriptenmouse_h
|
||||
|
||||
typedef struct _Emscripten_CursorData
|
||||
{
|
||||
const char *system_cursor;
|
||||
} Emscripten_CursorData;
|
||||
|
||||
extern void
|
||||
Emscripten_InitMouse();
|
||||
|
||||
extern void
|
||||
Emscripten_FiniMouse();
|
||||
|
||||
#endif /* _SDL_emscriptenmouse_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue