Updated SDL 1.3 to rev 5001

This commit is contained in:
pelya
2011-01-14 12:23:36 +00:00
parent 0d2fdd9f1d
commit e41d56798a
69 changed files with 1605 additions and 1673 deletions

View File

@@ -1 +1 @@
ufoai
alienblaster

View File

@@ -25,6 +25,9 @@
#include "SDL_error.h"
#include "SDL_error_c.h"
#ifdef ANDROID
#include <android/log.h>
#endif
/* Routine to get the thread-specific error variable */
#if SDL_THREADS_DISABLED
@@ -108,7 +111,10 @@ void SDL_SetError (const char *fmt, ...)
/* If we are in debug mode, print out an error message */
#ifdef DEBUG_ERROR
fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
fprintf(stderr, "ERROR: %s\n", SDL_GetError());
#endif
#ifdef ANDROID
__android_log_print(ANDROID_LOG_ERROR, "libSDL", "ERROR: %s", SDL_GetError());
#endif
}

View File

@@ -0,0 +1,64 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* \file SDL_blendmode.h
*
* Header file declaring the SDL_BlendMode enumeration
*/
#ifndef _SDL_blendmode_h
#define _SDL_blendmode_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/**
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
*/
typedef enum
{
SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */
SDL_BLENDMODE_MASK = 0x00000001, /**< dst = A ? src : dst
(alpha is mask) */
SDL_BLENDMODE_BLEND = 0x00000002, /**< dst = (src * A) + (dst * (1-A)) */
SDL_BLENDMODE_ADD = 0x00000004, /**< dst = (src * A) + dst */
SDL_BLENDMODE_MOD = 0x00000008 /**< dst = src * dst */
} SDL_BlendMode;
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_video_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -202,6 +202,14 @@ typedef enum
SDL_GRAB_ON = 1
} SDL_GrabMode;
typedef enum
{
SDL_TEXTURESCALEMODE_NONE = SDL_SCALEMODE_NONE,
SDL_TEXTURESCALEMODE_FAST = SDL_SCALEMODE_FAST,
SDL_TEXTURESCALEMODE_SLOW = SDL_SCALEMODE_SLOW,
SDL_TEXTURESCALEMODE_BEST = SDL_SCALEMODE_BEST
} SDL_TextureScaleMode;
struct SDL_SysWMinfo;
/**
@@ -319,8 +327,9 @@ extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
#define SDL_TextureID SDL_Texture*
#define SDL_WindowID SDL_Window*
typedef SDL_Texture* SDL_TextureID;
typedef SDL_Window* SDL_WindowID;
#define SDL_RenderPoint SDL_RenderDrawPoint
#define SDL_RenderLine SDL_RenderDrawLine
#define SDL_RenderFill(X) (X) ? SDL_RenderFillRect(X) : SDL_RenderClear()

View File

@@ -34,6 +34,8 @@
/* Add any platform that doesn't build using the configure system. */
#if defined(__NINTENDODS__)
#include "SDL_config_nintendods.h"
#elif defined(__ANDROID__)
#include "SDL_config_android.h"
#elif defined(__IPHONEOS__)
#include "SDL_config_iphoneos.h"
#elif defined(__MACOSX__)

View File

@@ -108,6 +108,8 @@
#define HAVE_NANOSLEEP 1
#define HAVE_SYSCONF 1
#define HAVE_SYSCTLBYNAME 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_COREAUDIO 1

View File

@@ -66,8 +66,8 @@ typedef enum
SDL_SYSWMEVENT, /**< System specific event */
/* Keyboard events */
SDL_KEYDOWN = 0x300, /**< Keys pressed */
SDL_KEYUP, /**< Keys released */
SDL_KEYDOWN = 0x300, /**< Key pressed */
SDL_KEYUP, /**< Key released */
SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
SDL_TEXTINPUT, /**< Keyboard text input */
@@ -436,8 +436,8 @@ typedef union SDL_Event
SDL_SysWMEvent syswm; /**< System dependent window event data */
SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
SDL_TouchButtonEvent tbutton; /**< Touch button event data */
SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data*/
SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data*/
SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */
SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */
/** Temporarily here for backwards compatibility */
/*@{*/

View File

@@ -33,7 +33,8 @@
#if defined(__WIN32__) || \
(defined(__MWERKS__) && !defined(__BEOS__)) || \
defined(__SYMBIAN32__) || defined(__IPHONEOS__) || defined(ANDROID)
defined(__SYMBIAN32__) || defined(__IPHONEOS__) || \
defined(ANDROID)
#ifdef __cplusplus
#define C_LINKAGE "C"

View File

@@ -38,6 +38,10 @@
#endif
#include <windows.h>
#endif
#ifdef __glext_h_
/* Someone has already included glext.h */
#define NO_SDL_GLEXT
#endif
#ifndef NO_SDL_GLEXT
#define __glext_h_ /* Don't let gl.h include glext.h */
#endif

View File

@@ -138,6 +138,7 @@ enum
#define SDL_ISPIXELFORMAT_FOURCC(format) \
((format) && !((format) & 0x80000000))
/* Note: If you modify this list, update SDL_GetPixelFormatName() */
enum
{
SDL_PIXELFORMAT_UNKNOWN,
@@ -170,20 +171,26 @@ enum
SDL_PIXELFORMAT_ARGB4444 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
SDL_PACKEDLAYOUT_4444, 16, 2),
SDL_PIXELFORMAT_RGBA4444 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
SDL_PACKEDLAYOUT_4444, 16, 2),
SDL_PIXELFORMAT_ABGR4444 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
SDL_PACKEDLAYOUT_4444, 16, 2),
SDL_PIXELFORMAT_RGBA4444 = /* Android-specific */
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
SDL_PIXELFORMAT_BGRA4444 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
SDL_PACKEDLAYOUT_4444, 16, 2),
SDL_PIXELFORMAT_ARGB1555 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
SDL_PACKEDLAYOUT_1555, 16, 2),
SDL_PIXELFORMAT_RGBA5551 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
SDL_PACKEDLAYOUT_5551, 16, 2),
SDL_PIXELFORMAT_ABGR1555 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
SDL_PACKEDLAYOUT_1555, 16, 2),
SDL_PIXELFORMAT_RGBA5551 = /* Android-specific */
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
SDL_PIXELFORMAT_BGRA5551 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
SDL_PACKEDLAYOUT_5551, 16, 2),
SDL_PIXELFORMAT_RGB565 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
@@ -275,6 +282,11 @@ typedef struct SDL_PixelFormat
Uint32 Amask;
} SDL_PixelFormat;
/**
* \brief Get the human readable name of a pixel format
*/
extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
/**
* \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
*

View File

@@ -77,8 +77,16 @@
#if defined(__APPLE__)
/* lets us know what version of Mac OS X we're compiling on */
#include "AvailabilityMacros.h"
#ifdef MAC_OS_X_VERSION_10_3
#include "TargetConditionals.h" /* this header is in 10.3 or later */
#include "TargetConditionals.h"
#ifndef MAC_OS_X_VERSION_10_4
#define MAC_OS_X_VERSION_10_4 1040
#endif
#ifndef MAC_OS_X_VERSION_10_5
#define MAC_OS_X_VERSION_10_5 1050
#endif
#ifndef MAC_OS_X_VERSION_10_6
#define MAC_OS_X_VERSION_10_6 1060
#endif
#if TARGET_OS_IPHONE
/* if compiling for iPhone */
#undef __IPHONEOS__
@@ -89,12 +97,6 @@
#undef __MACOSX__
#define __MACOSX__ 1
#endif /* TARGET_OS_IPHONE */
#else
/* if earlier verion of Mac OS X than version 10.3 */
#undef __MACOSX__
#define __MACOSX__ 1
#endif
#endif /* defined(__APPLE__) */
#if defined(__NetBSD__)

View File

@@ -1 +1 @@
#define SDL_REVISION "hg-4904:c0021a587dc7"
#define SDL_REVISION "hg-5001:77df56570442"

View File

@@ -24,7 +24,7 @@
* \file SDL_rwops.h
*
* This file provides a general interface for SDL to read and write
* data sources. It can easily be extended to files, memory, etc.
* data streams. It can easily be extended to files, memory, etc.
*/
#ifndef _SDL_rwops_h
@@ -50,14 +50,14 @@ typedef struct SDL_RWops
* Seek to \c offset relative to \c whence, one of stdio's whence values:
* RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
*
* \return the final offset in the data source.
* \return the final offset in the data stream.
*/
long (SDLCALL * seek) (struct SDL_RWops * context, long offset,
int whence);
/**
* Read up to \c maxnum objects each of size \c size from the data
* source to the area pointed at by \c ptr.
* stream to the area pointed at by \c ptr.
*
* \return the number of objects read, or 0 at error or end of file.
*/
@@ -66,7 +66,7 @@ typedef struct SDL_RWops
/**
* Write exactly \c num objects each of size \c size from the area
* pointed at by \c ptr to data source.
* pointed at by \c ptr to data stream.
*
* \return the number of objects written, or 0 at error or end of file.
*/
@@ -121,7 +121,7 @@ typedef struct SDL_RWops
/**
* \name RWFrom functions
*
* Functions to create SDL_RWops structures from various data sources.
* Functions to create SDL_RWops structures from various data streams.
*/
/*@{*/

View File

@@ -0,0 +1,69 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* \file SDL_scalemode.h
*
* Header file declaring the SDL_ScaleMode enumeration
*/
#ifndef _SDL_scalemode_h
#define _SDL_scalemode_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/**
* \brief The texture scale mode used in SDL_RenderCopy().
*/
typedef enum
{
SDL_SCALEMODE_NONE = 0x00000000, /**< No scaling, rectangles must
match dimensions */
SDL_SCALEMODE_FAST = 0x00000001, /**< Point sampling or
equivalent algorithm */
SDL_SCALEMODE_SLOW = 0x00000002, /**< Linear filtering or
equivalent algorithm */
SDL_SCALEMODE_BEST = 0x00000004 /**< Bicubic filtering or
equivalent algorithm */
} SDL_ScaleMode;
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_video_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -32,6 +32,8 @@
#include "SDL_stdinc.h"
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_blendmode.h"
#include "SDL_scalemode.h"
#include "SDL_rwops.h"
#include "begin_code.h"
@@ -88,7 +90,7 @@ typedef struct SDL_Surface
struct SDL_BlitMap *map; /**< Private */
/** format version, bumped at every change to invalidate blit maps */
unsigned int format_version; /**< Private */
int format_version; /**< Private */
/** Reference count -- used when freeing surface */
int refcount; /**< Read-mostly */
@@ -159,9 +161,9 @@ extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
/**
* Load a surface from a seekable SDL data source (memory or file).
* Load a surface from a seekable SDL data stream (memory or file).
*
* If \c freesrc is non-zero, the source will be closed after being read.
* If \c freesrc is non-zero, the stream will be closed after being read.
*
* The new surface should be freed with SDL_FreeSurface().
*
@@ -178,9 +180,9 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
/**
* Save a surface to a seekable SDL data source (memory or file).
* Save a surface to a seekable SDL data stream (memory or file).
*
* If \c freedst is non-zero, the source will be closed after being written.
* If \c freedst is non-zero, the stream will be closed after being written.
*
* \return 0 if successful or -1 if there was an error.
*/
@@ -235,9 +237,9 @@ extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
* \brief Set an additional color value used in blit operations.
*
* \param surface The surface to update.
* \param r The red source color value multiplied into blit operations.
* \param g The green source color value multiplied into blit operations.
* \param b The blue source color value multiplied into blit operations.
* \param r The red color value multiplied into blit operations.
* \param g The green color value multiplied into blit operations.
* \param b The blue color value multiplied into blit operations.
*
* \return 0 on success, or -1 if the surface is not valid.
*
@@ -251,9 +253,9 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
* \brief Get the additional color value used in blit operations.
*
* \param surface The surface to query.
* \param r A pointer filled in with the source red color value.
* \param g A pointer filled in with the source green color value.
* \param b A pointer filled in with the source blue color value.
* \param r A pointer filled in with the current red color value.
* \param g A pointer filled in with the current green color value.
* \param b A pointer filled in with the current blue color value.
*
* \return 0 on success, or -1 if the surface is not valid.
*
@@ -267,7 +269,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
* \brief Set an additional alpha value used in blit operations.
*
* \param surface The surface to update.
* \param alpha The source alpha value multiplied into blit operations.
* \param alpha The alpha value multiplied into blit operations.
*
* \return 0 on success, or -1 if the surface is not valid.
*
@@ -280,7 +282,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
* \brief Get the additional alpha value used in blit operations.
*
* \param surface The surface to query.
* \param alpha A pointer filled in with the source alpha value.
* \param alpha A pointer filled in with the current alpha value.
*
* \return 0 on success, or -1 if the surface is not valid.
*
@@ -300,7 +302,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
* \sa SDL_GetSurfaceBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
int blendMode);
SDL_BlendMode blendMode);
/**
* \brief Get the blend mode used for blit operations.
@@ -313,13 +315,13 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
* \sa SDL_SetSurfaceBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
int *blendMode);
SDL_BlendMode *blendMode);
/**
* \brief Set the scale mode used for blit operations.
*
* \param surface The surface to update.
* \param scaleMode ::SDL_TextureScaleMode to use for blit scaling.
* \param scaleMode ::SDL_ScaleMode to use for blit scaling.
*
* \return 0 on success, or -1 if the surface is not valid or the scale mode is
* not supported.
@@ -331,7 +333,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
* \sa SDL_GetSurfaceScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
int scaleMode);
SDL_ScaleMode scaleMode);
/**
* \brief Get the scale mode used for blit operations.
@@ -344,7 +346,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
* \sa SDL_SetSurfaceScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface,
int *scaleMode);
SDL_ScaleMode *scaleMode);
/**
* Sets the clipping rectangle for the destination surface in a blit.
@@ -413,10 +415,10 @@ extern DECLSPEC int SDLCALL SDL_DrawPoints
*/
extern DECLSPEC int SDLCALL SDL_BlendPoint
(SDL_Surface * dst, int x, int y,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendPoints
(SDL_Surface * dst, const SDL_Point * points, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
/**
* Draws a line with \c color.
@@ -438,10 +440,10 @@ extern DECLSPEC int SDLCALL SDL_DrawLines
*/
extern DECLSPEC int SDLCALL SDL_BlendLine
(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendLines
(SDL_Surface * dst, const SDL_Point * points, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
/**
* Draws the given rectangle with \c color.
@@ -467,10 +469,10 @@ extern DECLSPEC int SDLCALL SDL_DrawRects
*/
extern DECLSPEC int SDLCALL SDL_BlendRect
(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendRects
(SDL_Surface * dst, const SDL_Rect ** rects, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
/**
* Performs a fast fill of the given rectangle with \c color.
@@ -496,92 +498,10 @@ extern DECLSPEC int SDLCALL SDL_FillRects
*/
extern DECLSPEC int SDLCALL SDL_BlendFillRect
(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendFillRects
(SDL_Surface * dst, const SDL_Rect ** rects, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
#if 0
/**
* Draws the given circle with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_DrawCircle
(SDL_Surface * dst, int x, int y, int radius, Uint32 color);
/**
* Blends an RGBA value into the outline of the given circle.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendCircle
(SDL_Surface * dst, int x, int y, int radius,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
/**
* Fills the given circle with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_FillCircle
(SDL_Surface * dst, int x, int y, int radius, Uint32 color);
/**
* Blends an RGBA value into the given circle.
*
* \return This function returns 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendFillCircle
(SDL_Surface * dst, int x, int y, int radius,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
/**
* Draws the given ellipse with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_DrawEllipse
(SDL_Surface * dst, int x, int y, int w, int h, Uint32 color);
/**
* Blends an RGBA value into the outline of the given ellipse.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendEllipse
(SDL_Surface * dst, int x, int y, int w, int h,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
/**
* Fills the given ellipse with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_FillEllipse
(SDL_Surface * dst, int x, int y, int w, int h, Uint32 color);
/**
* Blends an RGBA value into the given ellipse.
*
* \return This function returns 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendFillEllipse
(SDL_Surface * dst, int x, int y, int w, int h,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
#endif // 0
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
/**
* Performs a fast blit from the source surface to the destination surface.
@@ -665,7 +585,7 @@ extern DECLSPEC int SDLCALL SDL_BlendFillEllipse
* rectangle validation and clipping before passing it to SDL_LowerBlit()
*/
extern DECLSPEC int SDLCALL SDL_UpperBlit
(SDL_Surface * src, SDL_Rect * srcrect,
(SDL_Surface * src, const SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect);
/**

View File

@@ -32,6 +32,8 @@
#include "SDL_stdinc.h"
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_blendmode.h"
#include "SDL_scalemode.h"
#include "SDL_surface.h"
#include "begin_code.h"
@@ -213,38 +215,6 @@ typedef enum
SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */
} SDL_TextureModulate;
/**
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
*/
typedef enum
{
SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */
SDL_BLENDMODE_MASK = 0x00000001, /**< dst = A ? src : dst
(alpha is mask) */
SDL_BLENDMODE_BLEND = 0x00000002, /**< dst = (src * A) + (dst * (1-A)) */
SDL_BLENDMODE_ADD = 0x00000004, /**< dst = (src * A) + dst */
SDL_BLENDMODE_MOD = 0x00000008 /**< dst = src * dst */
} SDL_BlendMode;
/**
* \brief The texture scale mode used in SDL_RenderCopy().
*/
typedef enum
{
SDL_TEXTURESCALEMODE_NONE = 0x00000000, /**< No scaling, rectangles must
match dimensions */
SDL_TEXTURESCALEMODE_FAST = 0x00000001, /**< Point sampling or
equivalent algorithm */
SDL_TEXTURESCALEMODE_SLOW = 0x00000002, /**< Linear filtering or
equivalent algorithm */
SDL_TEXTURESCALEMODE_BEST = 0x00000004 /**< Bicubic filtering or
equivalent algorithm */
} SDL_TextureScaleMode;
/**
* \brief An efficient driver-specific representation of pixel data
*/
@@ -915,9 +885,9 @@ extern DECLSPEC int SDLCALL SDL_GetTexturePalette(SDL_Texture * texture,
* \brief Set an additional color value used in render copy operations.
*
* \param texture The texture to update.
* \param r The red source color value multiplied into copy operations.
* \param g The green source color value multiplied into copy operations.
* \param b The blue source color value multiplied into copy operations.
* \param r The red color value multiplied into copy operations.
* \param g The green color value multiplied into copy operations.
* \param b The blue color value multiplied into copy operations.
*
* \return 0 on success, or -1 if the texture is not valid or color modulation
* is not supported.
@@ -932,9 +902,9 @@ extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
* \brief Get the additional color value used in render copy operations.
*
* \param texture The texture to query.
* \param r A pointer filled in with the source red color value.
* \param g A pointer filled in with the source green color value.
* \param b A pointer filled in with the source blue color value.
* \param r A pointer filled in with the current red color value.
* \param g A pointer filled in with the current green color value.
* \param b A pointer filled in with the current blue color value.
*
* \return 0 on success, or -1 if the texture is not valid.
*
@@ -948,7 +918,7 @@ extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
* \brief Set an additional alpha value used in render copy operations.
*
* \param texture The texture to update.
* \param alpha The source alpha value multiplied into copy operations.
* \param alpha The alpha value multiplied into copy operations.
*
* \return 0 on success, or -1 if the texture is not valid or alpha modulation
* is not supported.
@@ -962,7 +932,7 @@ extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
* \brief Get the additional alpha value used in render copy operations.
*
* \param texture The texture to query.
* \param alpha A pointer filled in with the source alpha value.
* \param alpha A pointer filled in with the current alpha value.
*
* \return 0 on success, or -1 if the texture is not valid.
*
@@ -986,7 +956,7 @@ extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
* \sa SDL_GetTextureBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
int blendMode);
SDL_BlendMode blendMode);
/**
* \brief Get the blend mode used for texture copy operations.
@@ -999,13 +969,13 @@ extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
* \sa SDL_SetTextureBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
int *blendMode);
SDL_BlendMode *blendMode);
/**
* \brief Set the scale mode used for texture copy operations.
*
* \param texture The texture to update.
* \param scaleMode ::SDL_TextureScaleMode to use for texture scaling.
* \param scaleMode ::SDL_ScaleMode to use for texture scaling.
*
* \return 0 on success, or -1 if the texture is not valid or the scale mode is
* not supported.
@@ -1016,7 +986,7 @@ extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
* \sa SDL_GetTextureScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
int scaleMode);
SDL_ScaleMode scaleMode);
/**
* \brief Get the scale mode used for texture copy operations.
@@ -1029,7 +999,7 @@ extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
* \sa SDL_SetTextureScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
int *scaleMode);
SDL_ScaleMode *scaleMode);
/**
* \brief Update the given texture rectangle with new pixel data.
@@ -1135,7 +1105,7 @@ extern DECLSPEC int SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b,
*
* \sa SDL_GetRenderDrawBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(int blendMode);
extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
/**
* \brief Get the blend mode used for drawing operations.
@@ -1146,7 +1116,7 @@ extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(int blendMode);
*
* \sa SDL_SetRenderDrawBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(int *blendMode);
extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_BlendMode *blendMode);
/**
* \brief Clear the current rendering target with the drawing color

View File

@@ -117,7 +117,7 @@ SDL_SetError(const char *fmt, ...)
fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
#endif
#ifdef ANDROID
__android_log_print(ANDROID_LOG_ERROR, "libSDL", "SDL_SetError: %s", SDL_GetError());
__android_log_print(ANDROID_LOG_ERROR, "libSDL", "ERROR: %s", SDL_GetError());
#endif
}

View File

@@ -24,7 +24,7 @@
#include <CoreAudio/CoreAudio.h>
#include <CoreServices/CoreServices.h>
#include <AudioUnit/AudioUnit.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
#include <AudioUnit/AUNTComponent.h>
#endif

View File

@@ -97,7 +97,7 @@ int SDL_RecordGesture(SDL_TouchID touchId) {
if((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) {
SDL_gestureTouch[i].recording = SDL_TRUE;
if(touchId >= 0)
return 1;
return 1;
}
}
return (touchId < 0);
@@ -122,7 +122,7 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) {
//if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0;
if(SDL_RWwrite(src,templ->path,
sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS)
sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS)
return 0;
return 1;
@@ -134,7 +134,7 @@ int SDL_SaveAllDollarTemplates(SDL_RWops *src) {
for(i = 0; i < SDL_numGestureTouches; i++) {
SDL_GestureTouch* touch = &SDL_gestureTouch[i];
for(j = 0;j < touch->numDollarTemplates; j++) {
rtrn += SaveTemplate(&touch->dollarTemplate[i],src);
rtrn += SaveTemplate(&touch->dollarTemplate[i],src);
}
}
return rtrn;
@@ -146,7 +146,7 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) {
SDL_GestureTouch* touch = &SDL_gestureTouch[i];
for(j = 0;j < touch->numDollarTemplates; j++) {
if(touch->dollarTemplate[i].hash == gestureId) {
return SaveTemplate(&touch->dollarTemplate[i],src);
return SaveTemplate(&touch->dollarTemplate[i],src);
}
}
}
@@ -166,18 +166,18 @@ static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch,SDL_FloatPoint* path)
inTouch = &SDL_gestureTouch[i];
dollarTemplate =
(SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
(inTouch->numDollarTemplates + 1) *
sizeof(SDL_DollarTemplate));
(SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
(inTouch->numDollarTemplates + 1) *
sizeof(SDL_DollarTemplate));
if(!dollarTemplate) {
SDL_OutOfMemory();
return -1;
SDL_OutOfMemory();
return -1;
}
inTouch->dollarTemplate = dollarTemplate;
templ =
&inTouch->dollarTemplate[inTouch->numDollarTemplates];
&inTouch->dollarTemplate[inTouch->numDollarTemplates];
SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
templ->hash = SDL_HashDollar(templ->path);
inTouch->numDollarTemplates++;
@@ -186,8 +186,8 @@ static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch,SDL_FloatPoint* path)
} else {
SDL_DollarTemplate* dollarTemplate =
( SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
(inTouch->numDollarTemplates + 1) *
sizeof(SDL_DollarTemplate));
(inTouch->numDollarTemplates + 1) *
sizeof(SDL_DollarTemplate));
if(!dollarTemplate) {
SDL_OutOfMemory();
return -1;
@@ -212,7 +212,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) {
if(touchId >= 0) {
for(i = 0;i < SDL_numGestureTouches; i++)
if(SDL_gestureTouch[i].id == touchId)
touch = &SDL_gestureTouch[i];
touch = &SDL_gestureTouch[i];
if(touch == NULL) return -1;
}
@@ -229,10 +229,10 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) {
else {
//printf("Adding to: %i touches\n",SDL_numGestureTouches);
for(i = 0;i < SDL_numGestureTouches; i++) {
touch = &SDL_gestureTouch[i];
//printf("Adding loaded gesture to + touches\n");
//TODO: What if this fails?
SDL_AddDollarGesture(touch,templ.path);
touch = &SDL_gestureTouch[i];
//printf("Adding loaded gesture to + touches\n");
//TODO: What if this fails?
SDL_AddDollarGesture(touch,templ.path);
}
loaded++;
}
@@ -251,7 +251,7 @@ float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) {
p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang));
p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang));
dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
(p.y-templ[i].y)*(p.y-templ[i].y)));
(p.y-templ[i].y)*(p.y-templ[i].y)));
}
return dist/DOLLARNPOINTS;
@@ -294,7 +294,7 @@ float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) {
}
//DollarPath contains raw points, plus (possibly) the calculated length
int dollarNormalize(SDL_DollarPath path,SDL_FloatPoint *points) {
int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) {
int i;
float interval;
float dist;
@@ -303,34 +303,35 @@ int dollarNormalize(SDL_DollarPath path,SDL_FloatPoint *points) {
float xmin,xmax,ymin,ymax;
float ang;
float w,h;
float length = path->length;
//Calculate length if it hasn't already been done
if(path.length <= 0) {
for(i=1;i<path.numPoints;i++) {
float dx = path.p[i ].x -
path.p[i-1].x;
float dy = path.p[i ].y -
path.p[i-1].y;
path.length += (float)(SDL_sqrt(dx*dx+dy*dy));
if(length <= 0) {
for(i=1;i<path->numPoints;i++) {
float dx = path->p[i ].x -
path->p[i-1].x;
float dy = path->p[i ].y -
path->p[i-1].y;
length += (float)(SDL_sqrt(dx*dx+dy*dy));
}
}
//Resample
interval = path.length/(DOLLARNPOINTS - 1);
interval = length/(DOLLARNPOINTS - 1);
dist = interval;
centroid.x = 0;centroid.y = 0;
//printf("(%f,%f)\n",path.p[path.numPoints-1].x,path.p[path.numPoints-1].y);
for(i = 1;i < path.numPoints;i++) {
float d = (float)(SDL_sqrt((path.p[i-1].x-path.p[i].x)*(path.p[i-1].x-path.p[i].x)+
(path.p[i-1].y-path.p[i].y)*(path.p[i-1].y-path.p[i].y)));
//printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y);
for(i = 1;i < path->numPoints;i++) {
float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+
(path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y)));
//printf("d = %f dist = %f/%f\n",d,dist,interval);
while(dist + d > interval) {
points[numPoints].x = path.p[i-1].x +
((interval-dist)/d)*(path.p[i].x-path.p[i-1].x);
points[numPoints].y = path.p[i-1].y +
((interval-dist)/d)*(path.p[i].y-path.p[i-1].y);
points[numPoints].x = path->p[i-1].x +
((interval-dist)/d)*(path->p[i].x-path->p[i-1].x);
points[numPoints].y = path->p[i-1].y +
((interval-dist)/d)*(path->p[i].y-path->p[i-1].y);
centroid.x += points[numPoints].x;
centroid.y += points[numPoints].y;
numPoints++;
@@ -344,7 +345,7 @@ int dollarNormalize(SDL_DollarPath path,SDL_FloatPoint *points) {
return 0;
}
//copy the last point
points[DOLLARNPOINTS-1] = path.p[path.numPoints-1];
points[DOLLARNPOINTS-1] = path->p[path->numPoints-1];
numPoints = DOLLARNPOINTS;
centroid.x /= numPoints;
@@ -358,9 +359,9 @@ int dollarNormalize(SDL_DollarPath path,SDL_FloatPoint *points) {
ymax = centroid.y;
ang = (float)(SDL_atan2(centroid.y - points[0].y,
centroid.x - points[0].x));
centroid.x - points[0].x));
for(i = 0;i<numPoints;i++) {
for(i = 0;i<numPoints;i++) {
float px = points[i].x;
float py = points[i].y;
points[i].x = (float)((px - centroid.x)*SDL_cos(ang) -
@@ -386,26 +387,26 @@ int dollarNormalize(SDL_DollarPath path,SDL_FloatPoint *points) {
return numPoints;
}
float dollarRecognize(SDL_DollarPath path,int *bestTempl,SDL_GestureTouch* touch) {
SDL_FloatPoint points[DOLLARNPOINTS];
int numPoints = dollarNormalize(path,points);
int i;
float bestDiff = 10000;
float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch) {
SDL_FloatPoint points[DOLLARNPOINTS];
int numPoints = dollarNormalize(path,points);
int i;
float bestDiff = 10000;
//PrintPath(points);
*bestTempl = -1;
for(i = 0;i < touch->numDollarTemplates;i++) {
float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
if(diff < bestDiff) {bestDiff = diff; *bestTempl = i;}
}
return bestDiff;
//PrintPath(points);
*bestTempl = -1;
for(i = 0;i < touch->numDollarTemplates;i++) {
float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
if(diff < bestDiff) {bestDiff = diff; *bestTempl = i;}
}
return bestDiff;
}
int SDL_GestureAddTouch(SDL_Touch* touch) {
SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch,
(SDL_numGestureTouches + 1) *
sizeof(SDL_GestureTouch));
(SDL_numGestureTouches + 1) *
sizeof(SDL_GestureTouch));
if(!gestureTouch) {
SDL_OutOfMemory();
@@ -464,7 +465,7 @@ int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) {
}
int SDL_SendGestureDollar(SDL_GestureTouch* touch,
SDL_GestureID gestureId,float error) {
SDL_GestureID gestureId,float error) {
SDL_Event event;
event.dgesture.type = SDL_DOLLARGESTURE;
event.dgesture.touchId = touch->id;
@@ -513,7 +514,7 @@ void SDL_GestureProcessEvent(SDL_Event* event)
if(inTouch == NULL) return;
//printf("@ (%i,%i) with res: (%i,%i)\n",(int)event->tfinger.x,
// (int)event->tfinger.y,
// (int)event->tfinger.y,
// (int)inTouch->res.x,(int)inTouch->res.y);
@@ -527,44 +528,44 @@ void SDL_GestureProcessEvent(SDL_Event* event)
#ifdef ENABLE_DOLLAR
if(inTouch->recording) {
inTouch->recording = SDL_FALSE;
dollarNormalize(inTouch->dollarPath,path);
//PrintPath(path);
if(recordAll) {
index = SDL_AddDollarGesture(NULL,path);
for(i = 0;i < SDL_numGestureTouches; i++)
SDL_gestureTouch[i].recording = SDL_FALSE;
}
else {
index = SDL_AddDollarGesture(inTouch,path);
}
if(index >= 0) {
SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash);
}
else {
SDL_SendDollarRecord(inTouch,-1);
}
inTouch->recording = SDL_FALSE;
dollarNormalize(&inTouch->dollarPath,path);
//PrintPath(path);
if(recordAll) {
index = SDL_AddDollarGesture(NULL,path);
for(i = 0;i < SDL_numGestureTouches; i++)
SDL_gestureTouch[i].recording = SDL_FALSE;
}
else {
index = SDL_AddDollarGesture(inTouch,path);
}
if(index >= 0) {
SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash);
}
else {
SDL_SendDollarRecord(inTouch,-1);
}
}
else {
int bestTempl;
float error;
error = dollarRecognize(inTouch->dollarPath,
&bestTempl,inTouch);
if(bestTempl >= 0){
//Send Event
unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
SDL_SendGestureDollar(inTouch,gestureId,error);
//printf ("%s\n",);("Dollar error: %f\n",error);
}
else {
int bestTempl;
float error;
error = dollarRecognize(&inTouch->dollarPath,
&bestTempl,inTouch);
if(bestTempl >= 0){
//Send Event
unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
SDL_SendGestureDollar(inTouch,gestureId,error);
//printf ("%s\n",);("Dollar error: %f\n",error);
}
}
#endif
//inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers];
if(inTouch->numDownFingers > 0) {
inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)-
x)/inTouch->numDownFingers;
inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)-
y)/inTouch->numDownFingers;
inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)-
x)/inTouch->numDownFingers;
inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)-
y)/inTouch->numDownFingers;
}
}
else if(event->type == SDL_FINGERMOTION) {
@@ -574,14 +575,14 @@ void SDL_GestureProcessEvent(SDL_Event* event)
#ifdef ENABLE_DOLLAR
SDL_DollarPath* path = &inTouch->dollarPath;
if(path->numPoints < MAXPATHSIZE) {
path->p[path->numPoints].x = inTouch->centroid.x;
path->p[path->numPoints].y = inTouch->centroid.y;
pathDx =
(path->p[path->numPoints].x-path->p[path->numPoints-1].x);
pathDy =
(path->p[path->numPoints].y-path->p[path->numPoints-1].y);
path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
path->numPoints++;
path->p[path->numPoints].x = inTouch->centroid.x;
path->p[path->numPoints].y = inTouch->centroid.y;
pathDx =
(path->p[path->numPoints].x-path->p[path->numPoints-1].x);
pathDy =
(path->p[path->numPoints].y-path->p[path->numPoints-1].y);
path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
path->numPoints++;
}
#endif
lastP.x = x - dx;
@@ -592,46 +593,46 @@ void SDL_GestureProcessEvent(SDL_Event* event)
inTouch->centroid.y += dy/inTouch->numDownFingers;
//printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y);
if(inTouch->numDownFingers > 1) {
SDL_FloatPoint lv; //Vector from centroid to last x,y position
SDL_FloatPoint v; //Vector from centroid to current x,y position
//lv = inTouch->gestureLast[j].cv;
lv.x = lastP.x - lastCentroid.x;
lv.y = lastP.y - lastCentroid.y;
lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y);
//printf("lDist = %f\n",lDist);
v.x = x - inTouch->centroid.x;
v.y = y - inTouch->centroid.y;
//inTouch->gestureLast[j].cv = v;
Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y);
// SDL_cos(dTheta) = (v . lv)/(|v| * |lv|)
//Normalize Vectors to simplify angle calculation
lv.x/=lDist;
lv.y/=lDist;
v.x/=Dist;
v.y/=Dist;
dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
dDist = (Dist - lDist);
if(lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values
//inTouch->gestureLast[j].dDist = dDist;
//inTouch->gestureLast[j].dtheta = dtheta;
//printf("dDist = %f, dTheta = %f\n",dDist,dtheta);
//gdtheta = gdtheta*.9 + dtheta*.1;
//gdDist = gdDist*.9 + dDist*.1
//knob.r += dDist/numDownFingers;
//knob.ang += dtheta;
//printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist);
//printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist);
SDL_SendGestureMulti(inTouch,dtheta,dDist);
SDL_FloatPoint lv; //Vector from centroid to last x,y position
SDL_FloatPoint v; //Vector from centroid to current x,y position
//lv = inTouch->gestureLast[j].cv;
lv.x = lastP.x - lastCentroid.x;
lv.y = lastP.y - lastCentroid.y;
lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y);
//printf("lDist = %f\n",lDist);
v.x = x - inTouch->centroid.x;
v.y = y - inTouch->centroid.y;
//inTouch->gestureLast[j].cv = v;
Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y);
// SDL_cos(dTheta) = (v . lv)/(|v| * |lv|)
//Normalize Vectors to simplify angle calculation
lv.x/=lDist;
lv.y/=lDist;
v.x/=Dist;
v.y/=Dist;
dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
dDist = (Dist - lDist);
if(lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values
//inTouch->gestureLast[j].dDist = dDist;
//inTouch->gestureLast[j].dtheta = dtheta;
//printf("dDist = %f, dTheta = %f\n",dDist,dtheta);
//gdtheta = gdtheta*.9 + dtheta*.1;
//gdDist = gdDist*.9 + dDist*.1
//knob.r += dDist/numDownFingers;
//knob.ang += dtheta;
//printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist);
//printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist);
SDL_SendGestureMulti(inTouch,dtheta,dDist);
}
else {
//inTouch->gestureLast[j].dDist = 0;
//inTouch->gestureLast[j].dtheta = 0;
//inTouch->gestureLast[j].cv.x = 0;
//inTouch->gestureLast[j].cv.y = 0;
//inTouch->gestureLast[j].dDist = 0;
//inTouch->gestureLast[j].dtheta = 0;
//inTouch->gestureLast[j].cv.x = 0;
//inTouch->gestureLast[j].cv.y = 0;
}
//inTouch->gestureLast[j].f.p.x = x;
//inTouch->gestureLast[j].f.p.y = y;
@@ -643,9 +644,9 @@ void SDL_GestureProcessEvent(SDL_Event* event)
inTouch->numDownFingers++;
inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+
x)/inTouch->numDownFingers;
x)/inTouch->numDownFingers;
inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+
y)/inTouch->numDownFingers;
y)/inTouch->numDownFingers;
//printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
// inTouch->centroid.x,inTouch->centroid.y);

View File

@@ -26,7 +26,7 @@
struct SDL_Cursor
{
SDL_Cursor *next;
struct SDL_Cursor *next;
void *driverdata;
};

View File

@@ -65,8 +65,8 @@ SDL_GetFingerIndexId(SDL_Touch* touch,SDL_FingerID fingerid)
{
int i;
for(i = 0;i < touch->num_fingers;i++)
if(touch->fingers[i]->id == fingerid)
return i;
if(touch->fingers[i]->id == fingerid)
return i;
return -1;
}
@@ -76,7 +76,7 @@ SDL_GetFinger(SDL_Touch* touch,SDL_FingerID id)
{
int index = SDL_GetFingerIndexId(touch,id);
if(index < 0 || index >= touch->num_fingers)
return NULL;
return NULL;
return touch->fingers[index];
}
@@ -259,22 +259,22 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger *finger)
//printf("Adding Finger...\n");
if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
SDL_SetError("Finger ID already in use");
}
}
/* Add the touch to the list of touch */
if(touch->num_fingers >= touch->max_fingers){
//printf("Making room for it!\n");
fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
(touch->num_fingers + 1) * sizeof(SDL_Finger *));
touch->max_fingers = touch->num_fingers+1;
if (!fingers) {
SDL_OutOfMemory();
return -1;
} else {
touch->max_fingers = touch->num_fingers+1;
touch->fingers = fingers;
}
}
//printf("Making room for it!\n");
fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
(touch->num_fingers + 1) * sizeof(SDL_Finger *));
touch->max_fingers = touch->num_fingers+1;
if (!fingers) {
SDL_OutOfMemory();
return -1;
} else {
touch->max_fingers = touch->num_fingers+1;
touch->fingers = fingers;
}
}
index = touch->num_fingers;
//printf("Max_Fingers: %i Index: %i\n",touch->max_fingers,index);
@@ -310,13 +310,13 @@ SDL_DelFinger(SDL_Touch* touch,SDL_FingerID fingerid)
int
SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down,
float xin, float yin, float pressurein)
float xin, float yin, float pressurein)
{
int posted;
Uint16 x;
Uint16 y;
Uint16 pressure;
SDL_Finger *finger;
Uint16 x;
Uint16 y;
Uint16 pressure;
SDL_Finger *finger;
SDL_Touch* touch = SDL_GetTouch(id);
@@ -332,68 +332,68 @@ SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down,
finger = SDL_GetFinger(touch,fingerid);
if(down) {
if(finger == NULL) {
SDL_Finger nf;
nf.id = fingerid;
nf.x = x;
nf.y = y;
nf.pressure = pressure;
nf.xdelta = 0;
nf.ydelta = 0;
nf.last_x = x;
nf.last_y = y;
nf.last_pressure = pressure;
nf.down = SDL_FALSE;
if(SDL_AddFinger(touch,&nf) < 0) return 0;
finger = SDL_GetFinger(touch,fingerid);
}
else if(finger->down) return 0;
if(xin < touch->x_min || yin < touch->y_min) return 0; //should defer if only a partial input
posted = 0;
if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERDOWN;
event.tfinger.touchId = id;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.tfinger.fingerId = fingerid;
posted = (SDL_PushEvent(&event) > 0);
}
if(posted) finger->down = SDL_TRUE;
return posted;
if(finger == NULL) {
SDL_Finger nf;
nf.id = fingerid;
nf.x = x;
nf.y = y;
nf.pressure = pressure;
nf.xdelta = 0;
nf.ydelta = 0;
nf.last_x = x;
nf.last_y = y;
nf.last_pressure = pressure;
nf.down = SDL_FALSE;
if(SDL_AddFinger(touch,&nf) < 0) return 0;
finger = SDL_GetFinger(touch,fingerid);
}
else if(finger->down) return 0;
if(xin < touch->x_min || yin < touch->y_min) return 0; //should defer if only a partial input
posted = 0;
if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERDOWN;
event.tfinger.touchId = id;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.tfinger.fingerId = fingerid;
posted = (SDL_PushEvent(&event) > 0);
}
if(posted) finger->down = SDL_TRUE;
return posted;
}
else {
if(finger == NULL) {
SDL_SetError("Finger not found.");
return 0;
}
posted = 0;
if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERUP;
event.tfinger.touchId = id;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.tfinger.fingerId = fingerid;
//I don't trust the coordinates passed on fingerUp
event.tfinger.x = finger->x;
event.tfinger.y = finger->y;
event.tfinger.dx = 0;
event.tfinger.dy = 0;
posted = 0;
if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERUP;
event.tfinger.touchId = id;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.tfinger.fingerId = fingerid;
//I don't trust the coordinates passed on fingerUp
event.tfinger.x = finger->x;
event.tfinger.y = finger->y;
event.tfinger.dx = 0;
event.tfinger.dy = 0;
if(SDL_DelFinger(touch,fingerid) < 0) return 0;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
if(SDL_DelFinger(touch,fingerid) < 0) return 0;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
}
int
SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative,
float xin, float yin, float pressurein)
float xin, float yin, float pressurein)
{
int index = SDL_GetTouchIndexId(id);
SDL_Touch *touch = SDL_GetTouch(id);
@@ -401,9 +401,9 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative,
int posted;
Sint16 xrel, yrel;
float x_max = 0, y_max = 0;
Uint16 x;
Uint16 y;
Uint16 pressure;
Uint16 x;
Uint16 y;
Uint16 pressure;
if (!touch) {
return SDL_TouchNotFoundError(id);
@@ -414,85 +414,85 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative,
y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
if(touch->flush_motion) {
return 0;
return 0;
}
if(finger == NULL || !finger->down) {
return SDL_SendFingerDown(id,fingerid,SDL_TRUE,xin,yin,pressurein);
return SDL_SendFingerDown(id,fingerid,SDL_TRUE,xin,yin,pressurein);
} else {
/* the relative motion is calculated regarding the last position */
if (relative) {
xrel = x;
yrel = y;
x = (finger->last_x + x);
y = (finger->last_y + y);
} else {
if(xin < touch->x_min) x = finger->last_x; /*If movement is only in one axis,*/
if(yin < touch->y_min) y = finger->last_y; /*The other is marked as -1*/
if(pressurein < touch->pressure_min) pressure = finger->last_pressure;
xrel = x - finger->last_x;
yrel = y - finger->last_y;
//printf("xrel,yrel (%i,%i)\n",(int)xrel,(int)yrel);
}
/* Drop events that don't change state */
if (!xrel && !yrel) {
/* the relative motion is calculated regarding the last position */
if (relative) {
xrel = x;
yrel = y;
x = (finger->last_x + x);
y = (finger->last_y + y);
} else {
if(xin < touch->x_min) x = finger->last_x; /*If movement is only in one axis,*/
if(yin < touch->y_min) y = finger->last_y; /*The other is marked as -1*/
if(pressurein < touch->pressure_min) pressure = finger->last_pressure;
xrel = x - finger->last_x;
yrel = y - finger->last_y;
//printf("xrel,yrel (%i,%i)\n",(int)xrel,(int)yrel);
}
/* Drop events that don't change state */
if (!xrel && !yrel) {
#if 0
printf("Touch event didn't change state - dropped!\n");
printf("Touch event didn't change state - dropped!\n");
#endif
return 0;
}
/* Update internal touch coordinates */
finger->x = x;
finger->y = y;
/*Should scale to window? Normalize? Maintain Aspect?*/
//SDL_GetWindowSize(touch->focus, &x_max, &y_max);
/* make sure that the pointers find themselves inside the windows */
/* only check if touch->xmax is set ! */
/*
if (x_max && touch->x > x_max) {
touch->x = x_max;
} else if (touch->x < 0) {
touch->x = 0;
}
if (y_max && touch->y > y_max) {
touch->y = y_max;
} else if (touch->y < 0) {
touch->y = 0;
}
*/
finger->xdelta = xrel;
finger->ydelta = yrel;
finger->pressure = pressure;
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERMOTION;
event.tfinger.touchId = id;
event.tfinger.fingerId = fingerid;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.dx = xrel;
event.tfinger.dy = yrel;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
finger->last_x = finger->x;
finger->last_y = finger->y;
finger->last_pressure = finger->pressure;
return posted;
return 0;
}
/* Update internal touch coordinates */
finger->x = x;
finger->y = y;
/*Should scale to window? Normalize? Maintain Aspect?*/
//SDL_GetWindowSize(touch->focus, &x_max, &y_max);
/* make sure that the pointers find themselves inside the windows */
/* only check if touch->xmax is set ! */
/*
if (x_max && touch->x > x_max) {
touch->x = x_max;
} else if (touch->x < 0) {
touch->x = 0;
}
if (y_max && touch->y > y_max) {
touch->y = y_max;
} else if (touch->y < 0) {
touch->y = 0;
}
*/
finger->xdelta = xrel;
finger->ydelta = yrel;
finger->pressure = pressure;
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERMOTION;
event.tfinger.touchId = id;
event.tfinger.fingerId = fingerid;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.dx = xrel;
event.tfinger.dy = yrel;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
finger->last_x = finger->x;
finger->last_y = finger->y;
finger->last_pressure = finger->pressure;
return posted;
}
}
int

View File

@@ -59,7 +59,7 @@
#include <libusbhid.h>
#endif
#ifdef defined(__FREEBSD__) || defined(__FreeBSD_kernel__)
#if defined(__FREEBSD__) || defined(__FreeBSD_kernel__)
#ifndef __DragonFly__
#include <osreldate.h>
#endif

View File

@@ -1,874 +0,0 @@
/* *INDENT-OFF* */
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_HID_IOHIDLIB_H_
#define _IOKIT_HID_IOHIDLIB_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
#include <CoreFoundation/CoreFoundation.h>
#if COREFOUNDATION_CFPLUGINCOM_SEPARATE
#include <CoreFoundation/CFPlugInCOM.h>
#endif
#include <IOKit/IOTypes.h>
#include <IOKit/IOReturn.h>
#include <IOKit/hid/IOHIDKeys.h>
struct IOHIDEventStruct
{
IOHIDElementType type;
IOHIDElementCookie elementCookie;
SInt32 value;
AbsoluteTime timestamp;
UInt32 longValueSize;
void * longValue;
};
typedef struct IOHIDEventStruct IOHIDEventStruct;
/* FA12FA38-6F1A-11D4-BA0C-0005028F18D5 */
#define kIOHIDDeviceUserClientTypeID CFUUIDGetConstantUUIDWithBytes(NULL, \
0xFA, 0x12, 0xFA, 0x38, 0x6F, 0x1A, 0x11, 0xD4, \
0xBA, 0x0C, 0x00, 0x05, 0x02, 0x8F, 0x18, 0xD5)
/* 13AA9C44-6F1B-11D4-907C-0005028F18D5 */
#define kIOHIDDeviceFactoryID CFUUIDGetConstantUUIDWithBytes(NULL, \
0x13, 0xAA, 0x9C, 0x44, 0x6F, 0x1B, 0x11, 0xD4, \
0x90, 0x7C, 0x00, 0x05, 0x02, 0x8F, 0x18, 0xD5)
/* 78BD420C-6F14-11D4-9474-0005028F18D5 */
/*! @defined kIOHIDDeviceInterfaceID
@discussion Interface ID for the IOHIDDeviceInterface. Corresponds to an
available HID device. */
#define kIOHIDDeviceInterfaceID CFUUIDGetConstantUUIDWithBytes(NULL, \
0x78, 0xBD, 0x42, 0x0C, 0x6F, 0x14, 0x11, 0xD4, \
0x94, 0x74, 0x00, 0x05, 0x02, 0x8F, 0x18, 0xD5)
/* 7D0B510E-16D5-11D7-9E9B-000393992E38 */
/*! @defined kIOHIDDeviceInterfaceID121
@discussion Interface ID for the IOHIDDeviceInterface121. Corresponds to
an available HID device that includes methods from
IOHIDDeviceInterface. This interface is available on
IOHIDLib 1.2.1 and Mac OS X 10.2.3 or later.*/
#define kIOHIDDeviceInterfaceID121 CFUUIDGetConstantUUIDWithBytes(NULL, \
0x7d, 0xb, 0x51, 0xe, 0x16, 0xd5, 0x11, 0xd7, \
0x9e, 0x9b, 0x0, 0x3, 0x93, 0x99, 0x2e, 0x38)
/* B70ABF31-16D5-11D7-AB35-000393992E38 */
/*! @defined kIOHIDDeviceInterfaceID122
@discussion Interface ID for the IOHIDDeviceInterface122. Corresponds to
an available HID device that includes methods from
IOHIDDeviceInterface and IOHIDDeviceInterface121. This
interface is available on IOHIDLib 1.2.2 and Mac OS X 10.3
or later.*/
#define kIOHIDDeviceInterfaceID122 CFUUIDGetConstantUUIDWithBytes(NULL, \
0xb7, 0xa, 0xbf, 0x31, 0x16, 0xd5, 0x11, 0xd7, \
0xab, 0x35, 0x0, 0x3, 0x93, 0x99, 0x2e, 0x38)
/* 8138629E-6F14-11D4-970E-0005028F18D5 */
/*! @defined kIOHIDQueueInterfaceID
@discussion Interface ID for the kIOHIDQueueInterfaceID. Corresponds to a
queue for a specific HID device. */
#define kIOHIDQueueInterfaceID CFUUIDGetConstantUUIDWithBytes(NULL, \
0x81, 0x38, 0x62, 0x9E, 0x6F, 0x14, 0x11, 0xD4, \
0x97, 0x0E, 0x00, 0x05, 0x02, 0x8F, 0x18, 0xD5)
/* 80CDCC00-755D-11D4-8E0F-0005028F18D5 */
/*! @defined kIOHIDOutputTransactionInterfaceID
@discussion Interface ID for the kIOHIDOutputTransactionInterfaceID.
Corresponds to an output transaction for one or more report IDs
on a specific device. */
#define kIOHIDOutputTransactionInterfaceID CFUUIDGetConstantUUIDWithBytes(NULL,\
0x80, 0xCD, 0xCC, 0x00, 0x75, 0x5D, 0x11, 0xD4, \
0x80, 0xEF, 0x00, 0x05, 0x02, 0x8F, 0x18, 0xD5)
/*! @typedef IOHIDCallbackFunction
@discussion Type and arguments of callout C function that is used when a
completion routine is called, see
IOHIDLib.h:setRemovalCallback().
@param target void * pointer to your data, often a pointer to an object.
@param result Completion result of desired operation.
@param refcon void * pointer to more data.
@param sender Interface instance sending the completion routine.
*/
typedef void (*IOHIDCallbackFunction)
(void * target, IOReturn result, void * refcon, void * sender);
/*! @typedef IOHIDElementCallbackFunction
@discussion Type and arguments of callout C function that is used when a
completion routine is called, see IOHIDLib.h:setElementValue().
@param target void * pointer to your data, often a pointer to an object.
@param result Completion result of desired operation.
@param refcon void * pointer to more data.
@param sender Interface instance sending the completion routine.
@param elementCookie Element within interface instance sending completion.
*/
typedef void (*IOHIDElementCallbackFunction)
(void * target,
IOReturn result,
void * refcon,
void * sender,
IOHIDElementCookie elementCookie);
/*! @typedef IOHIDReportCallbackFunction
@discussion Type and arguments of callout C function that is used when a
completion routine is called, see IOHIDLib.h:setReport().
@param target void * pointer to your data, often a pointer to an object.
@param result Completion result of desired operation.
@param refcon void * pointer to more data.
@param sender Interface instance sending the completion routine.
@param bufferSize Size of the buffer received upon completion.
*/
typedef void (*IOHIDReportCallbackFunction)
(void * target,
IOReturn result,
void * refcon,
void * sender,
UInt32 bufferSize);
/* Forward declarations of the queue and output transaction interfaces */
struct IOHIDQueueInterface;
struct IOHIDOutputTransactionInterface;
typedef struct IOHIDQueueInterface IOHIDQueueInterface;
typedef struct IOHIDOutputTransactionInterface IOHIDOutputTransactionInterface;
//
// IOHIDDeviceInterface Functions available in version 1.0 (10.0) and higher of Mac OS X
//
#define IOHIDDEVICEINTERFACE_FUNCS_100 \
IOReturn (*createAsyncEventSource)(void * self, CFRunLoopSourceRef * source); \
CFRunLoopSourceRef (*getAsyncEventSource)(void * self); \
IOReturn (*createAsyncPort)(void * self, mach_port_t * port); \
mach_port_t (*getAsyncPort)(void * self); \
IOReturn (*open)(void * self, UInt32 flags); \
IOReturn (*close)(void * self); \
IOReturn (*setRemovalCallback)(void * self, IOHIDCallbackFunction removalCallback, \
void * removalTarget, void * removalRefcon); \
IOReturn (*getElementValue)(void * self, IOHIDElementCookie elementCookie, \
IOHIDEventStruct * valueEvent); \
IOReturn (*setElementValue)(void * self, IOHIDElementCookie elementCookie, \
IOHIDEventStruct * valueEvent, UInt32 timeoutMS, \
IOHIDElementCallbackFunction callback, \
void * callbackTarget, void * callbackRefcon); \
IOReturn (*queryElementValue)(void * self, IOHIDElementCookie elementCookie, \
IOHIDEventStruct * valueEvent, UInt32 timeoutMS, \
IOHIDElementCallbackFunction callback, \
void * callbackTarget, void * callbackRefcon); \
IOReturn (*startAllQueues)(void * self); \
IOReturn (*stopAllQueues)(void * self); \
IOHIDQueueInterface ** (*allocQueue) (void *self); \
IOHIDOutputTransactionInterface ** (*allocOutputTransaction) (void *self)
//
// IOHIDDeviceInterface Functions available in version 1.2.1 (10.2.3) and higher of Mac OS X
//
#define IOHIDDEVICEINTERFACE_FUNCS_121 \
IOReturn (*setReport)(void * self, IOHIDReportType reportType, UInt32 reportID, \
void * reportBuffer, UInt32 reportBufferSize, \
UInt32 timeoutMS, IOHIDReportCallbackFunction callback, \
void * callbackTarget, void * callbackRefcon); \
IOReturn (*getReport)(void * self, IOHIDReportType reportType, \
UInt32 reportID, void * reportBuffer, \
UInt32 * reportBufferSize, UInt32 timeoutMS, \
IOHIDReportCallbackFunction callback, \
void * callbackTarget, void * callbackRefcon)
//
// IOHIDDeviceInterface Functions available in version 1.2.2 (10.3) and higher of Mac OS X
//
#define IOHIDDEVICEINTERFACE_FUNCS_122 \
IOReturn (*copyMatchingElements)(void * self, CFDictionaryRef matchingDict, \
CFArrayRef * elements); \
IOReturn (*setInterruptReportHandlerCallback)(void * self, void * reportBuffer, \
UInt32 reportBufferSize, \
IOHIDReportCallbackFunction callback, \
void * callbackTarget, void * callbackRefcon)
typedef struct IOHIDDeviceInterface
{
IUNKNOWN_C_GUTS;
IOHIDDEVICEINTERFACE_FUNCS_100;
IOHIDDEVICEINTERFACE_FUNCS_121;
} IOHIDDeviceInterface;
typedef struct IOHIDDeviceInterface121
{
IUNKNOWN_C_GUTS;
IOHIDDEVICEINTERFACE_FUNCS_100;
IOHIDDEVICEINTERFACE_FUNCS_121;
} IOHIDDeviceInterface121;
typedef struct IOHIDDeviceInterface122
{
IUNKNOWN_C_GUTS;
IOHIDDEVICEINTERFACE_FUNCS_100;
IOHIDDEVICEINTERFACE_FUNCS_121;
IOHIDDEVICEINTERFACE_FUNCS_122;
} IOHIDDeviceInterface122;
//
// IOHIDQueueInterface Functions available in version 1.0 (10.0) and higher of Mac OS X
//
#define IOHIDQUEUEINTERFACE_FUNCS_100 \
IOReturn (*createAsyncEventSource)(void * self, CFRunLoopSourceRef * source); \
CFRunLoopSourceRef (*getAsyncEventSource)(void * self); \
IOReturn (*createAsyncPort)(void * self, mach_port_t * port); \
mach_port_t (*getAsyncPort)(void * self); \
IOReturn (*create)(void * self, UInt32 flags, UInt32 depth); \
IOReturn (*dispose)(void * self); \
IOReturn (*addElement)(void * self, IOHIDElementCookie elementCookie, UInt32 flags);\
IOReturn (*removeElement)(void * self, IOHIDElementCookie elementCookie); \
Boolean (*hasElement)(void * self, IOHIDElementCookie elementCookie); \
IOReturn (*start)(void * self); \
IOReturn (*stop)(void * self); \
IOReturn (*getNextEvent)(void * self, IOHIDEventStruct * event, \
AbsoluteTime maxTime, UInt32 timeoutMS); \
IOReturn (*setEventCallout)(void * self, IOHIDCallbackFunction callback, \
void * callbackTarget, void * callbackRefcon); \
IOReturn (*getEventCallout)(void * self, IOHIDCallbackFunction * outCallback, \
void ** outCallbackTarget, void ** outCallbackRefcon)
struct IOHIDQueueInterface
{
IUNKNOWN_C_GUTS;
IOHIDQUEUEINTERFACE_FUNCS_100;
};
//
// IOHIDOutputTransactionInterface Functions available in version 1.2 (10.2) and higher of Mac OS X
//
#define IOHIDOUTPUTTRANSACTIONINTERFACE_FUNCS_120 \
IOReturn (*createAsyncEventSource)(void * self, CFRunLoopSourceRef * source); \
CFRunLoopSourceRef (*getAsyncEventSource)(void * self); \
IOReturn (*createAsyncPort)(void * self, mach_port_t * port); \
mach_port_t (*getAsyncPort)(void * self); \
IOReturn (*create)(void * self); \
IOReturn (*dispose)(void * self); \
IOReturn (*addElement)(void * self, IOHIDElementCookie elementCookie); \
IOReturn (*removeElement)(void * self, IOHIDElementCookie elementCookie); \
Boolean (*hasElement)(void * self, IOHIDElementCookie elementCookie); \
IOReturn (*setElementDefault)(void *self, IOHIDElementCookie elementCookie, \
IOHIDEventStruct * valueEvent); \
IOReturn (*getElementDefault)(void * self, IOHIDElementCookie elementCookie, \
IOHIDEventStruct * outValueEvent); \
IOReturn (*setElementValue)(void * self, IOHIDElementCookie elementCookie, \
IOHIDEventStruct * valueEvent); \
IOReturn (*getElementValue)(void * self, IOHIDElementCookie elementCookie, \
IOHIDEventStruct * outValueEvent); \
IOReturn (*commit)(void * self, UInt32 timeoutMS, IOHIDCallbackFunction callback, \
void * callbackTarget, void * callbackRefcon); \
IOReturn (*clear)(void * self)
struct IOHIDOutputTransactionInterface
{
IUNKNOWN_C_GUTS;
IOHIDOUTPUTTRANSACTIONINTERFACE_FUNCS_120;
};
//
// BEGIN READABLE STRUCTURE DEFINITIONS
//
// This portion of uncompiled code provides a more reader friendly representation of
// the CFPlugin methods defined above.
#if 0
/*! @class IOHIDDeviceInterface
@discussion CFPlugin object subclass which provides the primary interface to
HID devices.
*/
typedef struct IOHIDDeviceInterface
{
IUNKNOWN_C_GUTS;
/*! @function createAsyncEventSource
@abstract Creates async eventsource.
@discussion This method will create an async mach port, if one
has not already been created.
@param source Reference to CFRunLoopSourceRef that is created.
@result Returns an IOReturn code.
*/
IOReturn (*createAsyncEventSource)(void * self,
CFRunLoopSourceRef * source);
/*! @function getAsyncEventSource
@abstract Gets the created async event source.
@result Returns a CFRunLoopSourceRef.
*/
CFRunLoopSourceRef (*getAsyncEventSource)(void * self);
/*! @function createAsyncPort
@abstract Creates an async port.
@discussion The port must be created before any callbacks can be used.
@param port Reference to mach port that is created.
@result Returns an IOReturn code.
*/
IOReturn (*createAsyncPort)(void * self, mach_port_t * port);
/*! @function getAsyncPort
@abstract Gets the current async port.
@result Returns a mach_port_t.
*/
mach_port_t (*getAsyncPort)(void * self);
/*! @function open
@abstract Opens the device.
@param flags Flags to be passed down to the user client.
@result Returns an IOReturn code.
*/
IOReturn (*open)(void * self, UInt32 flags);
/*! @function close
@abstract Closes the device.
@result Returns an IOReturn code.
*/
IOReturn (*close)(void * self);
/*! @function setRemovalCallback
@abstract Sets callback to be used when device is removed.
@param removalCallback Called when the device is removed.
@param removeTarget Passed to the callback.
@param removalRefcon Passed to the callback.
@result Returns an IOReturn code.
*/
IOReturn (*setRemovalCallback)(void * self,
IOHIDCallbackFunction removalCallback,
void * removalTarget,
void * removalRefcon);
/*! @function getElementValue
@abstract Obtains the most recent value of an element.
@discussion This call is most useful for interrupt driven elements,
such as input type elements. Since feature type element values
need to be polled from the device, it is recommended to use the
queryElementValue method to obtain the current value. The
timestamp field in the event details the last time the element
value was altered.
@param elementCookie The element of interest.
@param valueEvent The event that will be filled. If a long value is
present, it is up to the caller to deallocate it.
@result Returns an IOReturn code.
*/
IOReturn (*getElementValue)(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent);
/*! @function setElementValue
@abstract Sets an element value on the device.
@discussion This call is most useful for feature type elements. It is
recommended to use IOOutputTransaction for output type elements.
@param elementCookie The element of interest.
@param valueEvent The event that will be filled. If a long value is
present, it will be copied.
@param timeoutMS UNSUPPORTED.
@param callback UNSUPPORTED.
@param callbackTarget UNSUPPORTED.
@param callbackRefcon UNSUPPORTED.
@result Returns an IOReturn code.
*/
IOReturn (*setElementValue)(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent,
UInt32 timeoutMS,
IOHIDElementCallbackFunction callback,
void * callbackTarget,
void * callbackRefcon);
/*! @function queryElementValue
@abstract Obtains the current value of an element.
@discussion This call is most useful for feature type elements. This
method will poll the device for the current element value.
@param elementCookie The element of interest.
@param valueEvent The event that will be filled. If a long value is
present, it is up to the caller to deallocate it.
@param timeoutMS UNSUPPORTED.
@param callback UNSUPPORTED.
@param callbackTarget UNSUPPORTED.
@param callbackRefcon UNSUPPORTED.
@result Returns an IOReturn code.
*/
IOReturn (*queryElementValue)(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent,
UInt32 timeoutMS,
IOHIDElementCallbackFunction callback,
void * callbackTarget,
void * callbackRefcon);
/*! @function startAllQueues
@abstract Starts data delivery on all queues for this device.
@result Returns an IOReturn code.
*/
IOReturn (*startAllQueues)(void * self);
/*! @function stopAllQueues
@abstract Stops data delivery on all queues for this device.
@result Returns an IOReturn code.
*/
IOReturn (*stopAllQueues)(void * self);
/*! @function allocQueue
@abstract Wrapper to return instances of the IOHIDQueueInterface.
@result Returns the created IOHIDQueueInterface.
*/
IOHIDQueueInterface ** (*allocQueue) (void *self);
/*! @function allocOutputTransaction
@abstract Wrapper to return instances of the IOHIDOutputTransactionInterface.
@result Returns the created IOHIDOutputTransactionInterface.
*/
IOHIDOutputTransactionInterface ** (*allocOutputTransaction) (void *self);
} IOHIDDeviceInterface;
/*! @class IOHIDDeviceInterface121
@discussion CFPlugin object subclass which provides the primary interface to
HID devices. This class is a subclass of IOHIDDeviceInterface.
*/
typedef struct IOHIDDeviceInterface121
{
IUNKNOWN_C_GUTS;
IOHIDDEVICEINTERFACE_FUNCS_100;
/*! @function setReport
@abstract Sends a report to the device.
@param reportType The report type.
@param reportID The report id.
@param reportBuffer Pointer to a preallocated buffer.
@param reportBufferSize Size of the reportBuffer in bytes.
@param timeoutMS
@param callback If null, this method will behave synchronously.
@param callbackTarget The callback target passed to the callback.
@param callbackRefcon The callback refcon passed to the callback.
@result Returns an IOReturn code.
*/
IOReturn (*setReport) (void * self,
IOHIDReportType reportType,
UInt32 reportID,
void * reportBuffer,
UInt32 reportBufferSize,
UInt32 timeoutMS,
IOHIDReportCallbackFunction callback,
void * callbackTarget,
void * callbackRefcon);
/*! @function getReport
@abstract Obtains a report from the device.
@param reportType The report type.
@param reportID The report ID.
@param reportBuffer Pointer to a preallocated buffer.
@param reportBufferSize Size of the reportBuffer in bytes.
When finished, will contain the actual size of the report.
@param timeoutMS
@param callback If null, this method will behave synchronously.
@param callbackTarget The callback target passed to the callback.
@param callbackRefcon The callback refcon passed to the callback.
@result Returns an IOReturn code.
*/
IOReturn (*getReport) (void * self,
IOHIDReportType reportType,
UInt32 reportID,
void * reportBuffer,
UInt32 * reportBufferSize,
UInt32 timeoutMS,
IOHIDReportCallbackFunction callback,
void * callbackTarget,
void * callbackRefcon);
}IOHIDDeviceInterface121;
/*! @class IOHIDDeviceInterface122
@discussion CFPlugin object subclass which provides the primary interface to
HID devices. This class is a subclass of IOHIDDeviceInterface121.
*/
typedef struct IOHIDDeviceInterface122
{
IUNKNOWN_C_GUTS;
IOHIDDEVICEINTERFACE_FUNCS_100;
IOHIDDEVICEINTERFACE_FUNCS_121;
/*! @function copyMatchingElements
@abstract Obtains specific elements defined by the device.
@discussion Using keys defined in IOHIDKeys.h for elements, create a
matching dictonary containing items that you wish to search for.
A null array indicates that no elements matching that criteria
were found. Each item in the array is a reference to the same
dictionary item that represents each element in the I/O Registry.
It is up to the caller to release the returned array of elements.
@param matchingDict Dictionary containg key/value pairs to match on. Pass
a null value to match on all elements.
@param elements Pointer to a CFArrayRef that will be returned by this
method. It is up to the caller to release it when finished.
@result Returns an IOReturn code.
*/
IOReturn (*copyMatchingElements)(void * self,
CFDictionaryRef matchingDict,
CFArrayRef * elements);
/*! @function setInterruptReportHandlerCallback
@abstract Sets the report handler callout to be called when the data
is received from the Interrupt-In pipe.
@discussion In order for this to work correctly, you must call
createAsyncPort and createAsyncEventSource.
@param reportBuffer Pointer to a preallocated buffer.
@param reportBufferSize Size of the reportBuffer in bytes.
@param callback If non-NULL, is a callback to be called when data
is received from the device.
@param callbackTarget The callback target passed to the callback
@param callbackRefcon The callback refcon passed to the callback.
@result Returns an IOReturn code.
*/
IOReturn (*setInterruptReportHandlerCallback)(
void * self,
void * reportBuffer,
UInt32 reportBufferSize,
IOHIDReportCallbackFunction callback,
void * callbackTarget,
void * callbackRefcon);
}IOHIDDeviceInterface122;
/*! @class IOHIDQueueInterface
@discussion CFPlugin object subclass which provides an interface for input
queues from HID devices. Created by an IOHIDDeviceInterface
object.
*/
typedef struct IOHIDQueueInterface
{
IUNKNOWN_C_GUTS;
/*! @function createAsyncEventSource
@abstract Creates an async event source.
@discussion This will be used with setEventCallout.
@param source The newly created event source.
@result Returns an IOReturn code.
*/
IOReturn (*createAsyncEventSource)(void * self,
CFRunLoopSourceRef * source);
/*! @function getAsyncEventSource
@abstract Obtains the current event source.
@result Returns a CFRunLoopSourceRef.
*/
CFRunLoopSourceRef (*getAsyncEventSource)(void * self);
/*! @function createAsyncPort
@abstract Creates an async port.
@discussion This will be used with createAsyncEventSource.
@param port The newly created async port.
@result Returns an IOReturn code.
*/
IOReturn (*createAsyncPort)(void * self, mach_port_t * port);
/*! @function getAsyncPort
@abstract Obtains the current async port.
@result Returns a mach_port_t.
*/
mach_port_t (*getAsyncPort)(void * self);
/*! @function create
@abstract Creates the current queue.
@param flags
@param depth The maximum number of elements in the queue
before the oldest elements in the queue begin to be lost.
@result Returns an IOReturn code.
*/
IOReturn (*create)(void * self,
UInt32 flags,
UInt32 depth);
/*! @function create
@abstract Disposes of the current queue.
@result Returns an IOReturn code.
*/
IOReturn (*dispose)(void * self);
/*! @function addElement
@abstract Adds an element to the queue.
@discussion If the element has already been added to queue,
an error will be returned.
@param elementCookie The element of interest.
@param flags
@result Returns an IOReturn code.
*/
IOReturn (*addElement)(void * self,
IOHIDElementCookie elementCookie,
UInt32 flags);
/*! @function removeElement
@abstract Removes an element from the queue.
@discussion If the element has not been added to queue,
an error will be returned.
@param elementCookie The element of interest.
@result Returns an IOReturn code.
*/
IOReturn (*removeElement)(void * self, IOHIDElementCookie elementCookie);
/*! @function hasElement
@abstract Checks whether an element has been added to
the queue.
@discussion Will return true if present, otherwise will return false.
@param elementCookie The element of interest.
@result Returns a Boolean value.
*/
Boolean (*hasElement)(void * self, IOHIDElementCookie elementCookie);
/*! @function start
@abstract Starts event delivery to the queue.
@result Returns an IOReturn code.
*/
IOReturn (*start)(void * self);
/*! @function stop
@abstract Stops event delivery to the queue.
@result Returns an IOReturn code.
*/
IOReturn (*stop)(void * self);
/*! @function getNextEvent
@abstract Reads next event from the queue.
@param event The event that will be filled. If a long value is
present, it is up to the caller to deallocate it.
@param maxtime UNSUPPORTED. If non-zero, limits read events to
those that occured on or before maxTime.
@param timoutMS UNSUPPORTED. The timeout in milliseconds, a zero
timeout will cause this call to be non-blocking (returning
queue empty) if there is a NULL callback, and blocking forever
until the queue is non-empty if there is a valid callback.
@result Returns an IOReturn code.
*/
IOReturn (*getNextEvent)(void * self,
IOHIDEventStruct * event,
AbsoluteTime maxTime,
UInt32 timeoutMS);
/*! @function setEventCallout
@abstract Sets the event callout to be called when the queue
transitions to non-empty.
@discussion In order for this to work correctly, you must call
createAsyncPort and createAsyncEventSource.
@param callback if non-NULL is a callback to be called when data
is inserted to the queue
@param callbackTarget The callback target passed to the callback
@param callbackRefcon The callback refcon passed to the callback.
@result Returns an IOReturn code.
*/
IOReturn (*setEventCallout)(void * self,
IOHIDCallbackFunction callback,
void * callbackTarget,
void * callbackRefcon);
/*! @function getEventCallout
@abstract Gets the event callout.
@discussion This callback will be called the queue transitions
to non-empty.
@param callback if non-NULL is a callback to be called when data
is inserted to the queue
@param callbackTarget The callback target passed to the callback
@param callbackRefcon The callback refcon passed to the callback
@result Returns an IOReturn code.
*/
IOReturn (*getEventCallout)(void * self,
IOHIDCallbackFunction * outCallback,
void ** outCallbackTarget,
void ** outCallbackRefcon);
} IOHIDQueueInterface;
/*! @class IOHIDOutputTransactionInterface
@discussion CFPlugin object subclass which privides interface for output
transactions to HID devices. Created by a IOHIDDeviceInterface
object. */
typedef struct IOHIDOutputTransactionInterface
{
IUNKNOWN_C_GUTS;
/*! @function createAsyncEventSource
@abstract Creates an async event source.
@discussion This will be used with setEventCallout.
@param source The newly created event source
@result Returns an IOReturn code.
*/
IOReturn (*createAsyncEventSource)(void * self,
CFRunLoopSourceRef * source);
/*! @function getAsyncEventSource
@abstract Obtains the current event source.
@result Returns a CFRunLoopSourceRef.
*/
CFRunLoopSourceRef (*getAsyncEventSource)(void * self);
/*! @function createAsyncPort
@abstract Creates an async port.
@discussion This will be used with createAsyncEventSource.
@param port The newly created async port.
@result Returns an IOReturn code.
*/
IOReturn (*createAsyncPort)(void * self, mach_port_t * port);
/*! @function getAsyncPort
@abstract Obtains the current async port.
@result Returns a mach_port_t.
*/
mach_port_t (*getAsyncPort)(void * self);
/*! @function create
@abstract Creates the current transaction.
@discussion This method will free any memory that has been
allocated for this transaction.
@result Returns an IOReturn code.
*/
IOReturn (*create)(void * self);
/*! @function dispose
@abstract Disposes of the current transaction.
@discussion The transaction will have to be recreated, in order
to perform any operations on the transaction.
@result Returns an IOReturn code.
*/
IOReturn (*dispose)(void * self);
/*! @function addElement
@abstract Adds an element to the transaction.
@discussion If the element has already been added to transaction,
an error will be returned.
@param elementCookie The element of interest.
@result Returns an IOReturn code.
*/
IOReturn (*addElement) (void * self, IOHIDElementCookie elementCookie);
/*! @function removeElement
@abstract Removes an element from the transaction.
@discussion If the element has not been added to transaction,
an error will be returned.
@param elementCookie The element of interest.
@result Returns an IOReturn code.
*/
IOReturn (*removeElement) (void * self, IOHIDElementCookie elementCookie);
/*! @function hasElement
@abstract Checks whether an element has been added to
the transaction.
@discussion Will return true if present, otherwise will return false.
@param elementCookie The element of interest.
@result Returns a Boolean value.
*/
Boolean (*hasElement) (void * self, IOHIDElementCookie elementCookie);
/*! @function setElementDefault
@abstract Sets the default value of an element in a
transaction.
@discussion An error will be returned if the element has not been
added to the transaction.
@param elementCookie The element of interest.
@param valueEvent The event that will be filled. If a long value is
present, it will be copied.
@result Returns an IOReturn code.
*/
IOReturn (*setElementDefault)(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent);
/*! @function getElementDefault
@abstract Obtains the default value of an element in a
transaction.
@discussion An error will be returned if the element has not been
added to the transaction.
@param elementCookie The element of interest.
@param outValueEvent The event that will be filled. If a long value is
present, it is up to the caller to deallocate it.
@result Returns an IOReturn code.
*/
IOReturn (*getElementDefault)(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * outValueEvent);
/*! @function setElementValue
@abstract Sets the value of an element in a transaction.
@discussion An error will be returned if the element has not been
added to the transaction.
@param elementCookie The element of interest.
@param valueEvent The event that will be filled. If a long value is
present, it will be copied.
@result Returns an IOReturn code.
*/
IOReturn (*setElementValue)(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent);
/*! @function getElementValue
@abstract Obtains the value of an element in a transaction.
@discussion An error will be returned if the element has not been
added to the transaction.
@param elementCookie The element of interest.
@param outValueEvent The event that will be filled. If a long value is
present, it is up to the caller to deallocate it.
@result Returns an IOReturn code.
*/
IOReturn (*getElementValue)(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * outValueEvent);
/*! @function commit
@abstract Commits the transaction.
@discussion Transaction element values, if set, will be sent to the
device. Otherwise, the default element value will be used. If
neither are set, that element will be omitted from the commit.
After a transaction is committed, transaction element values
will be cleared. Default values will be preserved.
@param timeoutMS UNSUPPORTED
@param callback UNSUPPORTED
@param callbackTarget UNSUPPORTED
@param callbackRefcon UNSUPPORTED
@result Returns an IOReturn code.
*/
IOReturn (*commit)(void * self,
UInt32 timeoutMS,
IOHIDCallbackFunction callback,
void * callbackTarget,
void * callbackRefcon);
/*! @function clear
@abstract Clears the transaction.
@discussion Transaction element values will cleared. Default
values will be preserved.
@result Returns an IOReturn code.
*/
IOReturn (*clear)(void * self);
} IOHIDOutputTransactionInterface;
#endif
__END_DECLS
#endif /* !_IOKIT_HID_IOHIDLIB_H_ */

View File

@@ -39,11 +39,7 @@
/* The header was moved here in Mac OS X 10.1 */
#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
#endif
#if MAC_OS_X_VERSION_MIN_REQUIRED == 1030
#include "10.3.9-FIX/IOHIDLib.h"
#else
#include <IOKit/hid/IOHIDLib.h>
#endif
#include <IOKit/hid/IOHIDKeys.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h> /* for NewPtrClear, DisposePtr */

View File

@@ -24,11 +24,7 @@
#ifndef SDL_JOYSTICK_IOKIT_H
#if MAC_OS_X_VERSION_MIN_REQUIRED == 1030
#include "10.3.9-FIX/IOHIDLib.h"
#else
#include <IOKit/hid/IOHIDLib.h>
#endif
#include <IOKit/hid/IOHIDKeys.h>

View File

@@ -18,6 +18,7 @@
#define _MATH_PRIVATE_H_
/*#include <endian.h>*/
#include "SDL_endian.h"
#include <sys/types.h>
#define attribute_hidden
@@ -46,8 +47,7 @@ typedef unsigned int u_int32_t;
* For VFP, floats words follow the memory system mode.
*/
#if (__BYTE_ORDER == __BIG_ENDIAN) || \
(!defined(__VFP_FP__) && (defined(__arm__) || defined(__thumb__)))
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
typedef union
{

View File

@@ -26,7 +26,7 @@
static int
SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;
@@ -49,7 +49,7 @@ SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
static int
SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;
@@ -72,7 +72,7 @@ SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
static int
SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;
@@ -95,7 +95,7 @@ SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
static int
SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;
@@ -118,7 +118,7 @@ SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
static int
SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
SDL_PixelFormat *fmt = dst->format;
unsigned inva = 0xff - a;
@@ -164,7 +164,7 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
static int
SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
SDL_PixelFormat *fmt = dst->format;
unsigned inva = 0xff - a;
@@ -194,7 +194,7 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
int
SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
SDL_Rect clipped;
@@ -263,12 +263,12 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
int
SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
SDL_Rect clipped;
int i;
int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
int status = 0;
if (!dst) {

View File

@@ -26,7 +26,7 @@
static void
SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
@@ -118,7 +118,7 @@ SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
static void
SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
@@ -210,7 +210,7 @@ SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
static void
SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
@@ -302,7 +302,7 @@ SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
static void
SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
@@ -394,7 +394,7 @@ SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
static void
SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
@@ -486,7 +486,7 @@ SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
static void
SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
@@ -578,7 +578,7 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
static void
SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
{
const SDL_PixelFormat *fmt = dst->format;
@@ -670,7 +670,7 @@ SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
typedef void (*BlendLineFunc) (SDL_Surface * dst,
int x1, int y1, int x2, int y2,
int blendMode,
SDL_BlendMode blendMode,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SDL_bool draw_end);
@@ -707,7 +707,7 @@ SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
int
SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
BlendLineFunc func;
@@ -734,7 +734,7 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int
SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
int i;
int x1, y1;

View File

@@ -24,7 +24,7 @@
#include "SDL_draw.h"
static int
SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;
@@ -47,7 +47,7 @@ SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
}
static int
SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;
@@ -70,7 +70,7 @@ SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
}
static int
SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;
@@ -93,7 +93,7 @@ SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
}
static int
SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, int blendMode,
SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;
@@ -116,7 +116,7 @@ SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, int blendMode,
}
static int
SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
Uint8 g, Uint8 b, Uint8 a)
{
SDL_PixelFormat *fmt = dst->format;
@@ -162,7 +162,7 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
}
static int
SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
Uint8 g, Uint8 b, Uint8 a)
{
SDL_PixelFormat *fmt = dst->format;
@@ -192,7 +192,7 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
}
int
SDL_BlendPoint(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
Uint8 g, Uint8 b, Uint8 a)
{
if (!dst) {
@@ -258,14 +258,14 @@ SDL_BlendPoint(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
int
SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
int minx, miny;
int maxx, maxy;
int i;
int x, y;
int (*func)(SDL_Surface * dst, int x, int y,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
int status = 0;
if (!dst) {

View File

@@ -26,7 +26,7 @@
int
SDL_BlendRect(SDL_Surface * dst, const SDL_Rect * rect,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
SDL_Rect full_rect;
SDL_Point points[5];
@@ -60,7 +60,7 @@ SDL_BlendRect(SDL_Surface * dst, const SDL_Rect * rect,
int
SDL_BlendRects(SDL_Surface * dst, const SDL_Rect ** rects, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
int i;

View File

@@ -39,6 +39,50 @@ struct SDL_PaletteWatch
/* Helper functions */
const char*
SDL_GetPixelFormatName(Uint32 format)
{
switch (format) {
#define CASE(X) case X: return #X;
CASE(SDL_PIXELFORMAT_INDEX1LSB)
CASE(SDL_PIXELFORMAT_INDEX1MSB)
CASE(SDL_PIXELFORMAT_INDEX4LSB)
CASE(SDL_PIXELFORMAT_INDEX4MSB)
CASE(SDL_PIXELFORMAT_INDEX8)
CASE(SDL_PIXELFORMAT_RGB332)
CASE(SDL_PIXELFORMAT_RGB444)
CASE(SDL_PIXELFORMAT_RGB555)
CASE(SDL_PIXELFORMAT_BGR555)
CASE(SDL_PIXELFORMAT_ARGB4444)
CASE(SDL_PIXELFORMAT_RGBA4444)
CASE(SDL_PIXELFORMAT_ABGR4444)
CASE(SDL_PIXELFORMAT_BGRA4444)
CASE(SDL_PIXELFORMAT_ARGB1555)
CASE(SDL_PIXELFORMAT_RGBA5551)
CASE(SDL_PIXELFORMAT_ABGR1555)
CASE(SDL_PIXELFORMAT_BGRA5551)
CASE(SDL_PIXELFORMAT_RGB565)
CASE(SDL_PIXELFORMAT_BGR565)
CASE(SDL_PIXELFORMAT_RGB24)
CASE(SDL_PIXELFORMAT_BGR24)
CASE(SDL_PIXELFORMAT_RGB888)
CASE(SDL_PIXELFORMAT_BGR888)
CASE(SDL_PIXELFORMAT_ARGB8888)
CASE(SDL_PIXELFORMAT_RGBA8888)
CASE(SDL_PIXELFORMAT_ABGR8888)
CASE(SDL_PIXELFORMAT_BGRA8888)
CASE(SDL_PIXELFORMAT_ARGB2101010)
CASE(SDL_PIXELFORMAT_YV12)
CASE(SDL_PIXELFORMAT_IYUV)
CASE(SDL_PIXELFORMAT_YUY2)
CASE(SDL_PIXELFORMAT_UYVY)
CASE(SDL_PIXELFORMAT_YVYU)
#undef CASE
default:
return "SDL_PIXELFORMAT_UNKNOWN";
}
}
SDL_bool
SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask,
Uint32 * Gmask, Uint32 * Bmask, Uint32 * Amask)
@@ -221,6 +265,12 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
break;
case 16:
switch (Rmask) {
case 0xF000:
return SDL_PIXELFORMAT_RGBA4444;
case 0x0F00:
return SDL_PIXELFORMAT_ARGB4444;
case 0x00F0:
return SDL_PIXELFORMAT_BGRA4444;
case 0x000F:
return SDL_PIXELFORMAT_ABGR4444;
case 0x001F:
@@ -228,12 +278,13 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
return SDL_PIXELFORMAT_BGR565;
}
return SDL_PIXELFORMAT_ABGR1555;
case 0x0F00:
return SDL_PIXELFORMAT_ARGB4444;
case 0x7C00:
return SDL_PIXELFORMAT_ARGB1555;
case 0xF800:
return SDL_PIXELFORMAT_RGB565;
if (Gmask == 0x07E0) {
return SDL_PIXELFORMAT_RGB565;
}
return SDL_PIXELFORMAT_RGBA5551;
}
break;
case 24:

View File

@@ -126,8 +126,7 @@ SDL_RenderDriver GL_RenderDriver = {
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
SDL_TEXTURESCALEMODE_SLOW),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW),
15,
{
SDL_PIXELFORMAT_INDEX1LSB,
@@ -761,7 +760,8 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
if (!convert_format(renderdata, texture->format, &internalFormat,
&format, &type)) {
SDL_SetError("Unsupported texture format");
SDL_SetError("Texture format %s not supported by OpenGL",
SDL_GetPixelFormatName(texture->format));
return -1;
}
if (texture->format == SDL_PIXELFORMAT_UYVY &&
@@ -1004,17 +1004,17 @@ static int
GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
case SDL_SCALEMODE_SLOW:
return 0;
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_BEST:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_SLOW;
texture->scaleMode = SDL_SCALEMODE_SLOW;
return -1;
default:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
}
@@ -1181,6 +1181,11 @@ GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
}
data->glEnd();
} else {
#if defined(__APPLE__) || defined(__WIN32__)
#else
int x1, y1, x2, y2;
#endif
data->glBegin(GL_LINE_STRIP);
for (i = 0; i < count; ++i) {
data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
@@ -1200,10 +1205,10 @@ GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y);
#else
/* Linux seems to leave the right-most or bottom-most point open */
int x1 = points[0].x;
int y1 = points[0].y;
int x2 = points[count-1].x;
int y2 = points[count-1].y;
x1 = points[0].x;
y1 = points[0].y;
x2 = points[count-1].x;
y2 = points[count-1].y;
if (x1 > x2) {
data->glVertex2f(0.5f + x1, 0.5f + y1);
@@ -1360,15 +1365,15 @@ GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
if (texture->scaleMode != data->scaleMode) {
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
break;
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_SLOW:
case SDL_SCALEMODE_BEST:
data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,

View File

@@ -126,19 +126,14 @@ SDL_RenderDriver GL_ES_RenderDriver = {
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
SDL_TEXTURESCALEMODE_SLOW), 5,
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), 6,
{
/* OpenGL ES 1.x supported formats list */
SDL_PIXELFORMAT_ABGR4444,
SDL_PIXELFORMAT_ABGR1555,
SDL_PIXELFORMAT_BGR565,
#ifdef ANDROID
SDL_PIXELFORMAT_RGB565, // Android is special, GL pixelformat has R and B channels not swapped
SDL_PIXELFORMAT_RGBA5551,
SDL_PIXELFORMAT_RGBA4444,
#endif
SDL_PIXELFORMAT_BGR24,
SDL_PIXELFORMAT_RGBA5551,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_RGB24,
SDL_PIXELFORMAT_BGR888,
SDL_PIXELFORMAT_ABGR8888},
0,
0}
@@ -423,32 +418,17 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
GLenum result;
switch (texture->format) {
case SDL_PIXELFORMAT_BGR24:
case SDL_PIXELFORMAT_RGB24:
internalFormat = GL_RGB;
format = GL_RGB;
type = GL_UNSIGNED_BYTE;
break;
case SDL_PIXELFORMAT_BGR888:
case SDL_PIXELFORMAT_ABGR8888:
internalFormat = GL_RGBA;
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
break;
case SDL_PIXELFORMAT_BGR565:
internalFormat = GL_RGB;
format = GL_RGB;
type = GL_UNSIGNED_SHORT_5_6_5;
break;
case SDL_PIXELFORMAT_ABGR1555:
internalFormat = GL_RGBA;
format = GL_RGBA;
type = GL_UNSIGNED_SHORT_5_5_5_1;
break;
case SDL_PIXELFORMAT_ABGR4444:
internalFormat = GL_RGBA;
format = GL_RGBA;
type = GL_UNSIGNED_SHORT_4_4_4_4;
break;
#ifdef ANDROID
case SDL_PIXELFORMAT_RGB565:
internalFormat = GL_RGB;
format = GL_RGB;
@@ -464,9 +444,9 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
format = GL_RGBA;
type = GL_UNSIGNED_SHORT_4_4_4_4;
break;
#endif
default:
SDL_SetError("Unsupported by OpenGL ES texture format");
SDL_SetError("Texture format %s not supported by OpenGL ES",
SDL_GetPixelFormatName(texture->format));
return -1;
}
@@ -598,17 +578,17 @@ static int
GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
case SDL_SCALEMODE_SLOW:
return 0;
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_BEST:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_SLOW;
texture->scaleMode = SDL_SCALEMODE_SLOW;
return -1;
default:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
}
@@ -947,15 +927,15 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
GLES_SetBlendMode(data, texture->blendMode, 0);
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
break;
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_SLOW:
case SDL_SCALEMODE_BEST:
data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,

View File

@@ -90,7 +90,7 @@ SDL_RenderDriver SW_RenderDriver = {
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST),
14,
{
SDL_PIXELFORMAT_INDEX8,

View File

@@ -438,7 +438,7 @@ SDL_GetSurfaceAlphaMod(SDL_Surface * surface, Uint8 * alpha)
}
int
SDL_SetSurfaceBlendMode(SDL_Surface * surface, int blendMode)
SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode)
{
int flags, status;
@@ -486,7 +486,7 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, int blendMode)
}
int
SDL_GetSurfaceBlendMode(SDL_Surface * surface, int *blendMode)
SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode)
{
if (!surface) {
return -1;
@@ -519,7 +519,7 @@ SDL_GetSurfaceBlendMode(SDL_Surface * surface, int *blendMode)
}
int
SDL_SetSurfaceScaleMode(SDL_Surface * surface, int scaleMode)
SDL_SetSurfaceScaleMode(SDL_Surface * surface, SDL_ScaleMode scaleMode)
{
int flags, status;
@@ -531,13 +531,13 @@ SDL_SetSurfaceScaleMode(SDL_Surface * surface, int scaleMode)
flags = surface->map->info.flags;
surface->map->info.flags &= ~(SDL_COPY_NEAREST);
switch (scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_SCALEMODE_NONE:
break;
case SDL_TEXTURESCALEMODE_FAST:
case SDL_SCALEMODE_FAST:
surface->map->info.flags |= SDL_COPY_NEAREST;
break;
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_SLOW:
case SDL_SCALEMODE_BEST:
SDL_Unsupported();
surface->map->info.flags |= SDL_COPY_NEAREST;
status = -1;
@@ -555,7 +555,7 @@ SDL_SetSurfaceScaleMode(SDL_Surface * surface, int scaleMode)
}
int
SDL_GetSurfaceScaleMode(SDL_Surface * surface, int *scaleMode)
SDL_GetSurfaceScaleMode(SDL_Surface * surface, SDL_ScaleMode *scaleMode)
{
if (!surface) {
return -1;
@@ -567,10 +567,10 @@ SDL_GetSurfaceScaleMode(SDL_Surface * surface, int *scaleMode)
switch (surface->map->info.flags & SDL_COPY_NEAREST) {
case SDL_COPY_NEAREST:
*scaleMode = SDL_TEXTURESCALEMODE_FAST;
*scaleMode = SDL_SCALEMODE_FAST;
break;
default:
*scaleMode = SDL_TEXTURESCALEMODE_NONE;
*scaleMode = SDL_SCALEMODE_NONE;
break;
}
return 0;
@@ -595,7 +595,7 @@ SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect)
/* Set the clipping rectangle */
if (!rect) {
surface->clip_rect = full_rect;
return 1;
return SDL_TRUE;
}
return SDL_IntersectRect(rect, &full_rect, &surface->clip_rect);
}
@@ -640,7 +640,7 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect,
int
SDL_UpperBlit(SDL_Surface * src, SDL_Rect * srcrect,
SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect)
{
SDL_Rect fulldst;

View File

@@ -46,8 +46,8 @@ struct SDL_Texture
int w; /**< The width of the texture */
int h; /**< The height of the texture */
int modMode; /**< The texture modulation mode */
int blendMode; /**< The texture blend mode */
int scaleMode; /**< The texture scale mode */
SDL_BlendMode blendMode; /**< The texture blend mode */
SDL_ScaleMode scaleMode; /**< The texture scale mode */
Uint8 r, g, b, a; /**< Texture modulation values */
SDL_Renderer *renderer;
@@ -121,7 +121,7 @@ struct SDL_Renderer
SDL_Texture *textures;
Uint8 r, g, b, a; /**< Color for drawing operations values */
int blendMode; /**< The drawing blend mode */
SDL_BlendMode blendMode; /**< The drawing blend mode */
void *driverdata;
};

View File

@@ -37,6 +37,11 @@
#include <android/log.h>
#endif
#if SDL_VIDEO_DRIVER_WIN32
#include "win32/SDL_win32video.h"
extern void IME_Present(SDL_VideoData *videodata);
#endif
#if SDL_VIDEO_OPENGL_ES
#include "SDL_opengles.h"
#endif /* SDL_VIDEO_OPENGL_ES */
@@ -692,6 +697,10 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
}
/* Actually change the display mode */
if (!_this->SetDisplayMode) {
SDL_SetError("Video driver doesn't support changing display mode");
return -1;
}
if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
return -1;
}
@@ -1044,11 +1053,19 @@ SDL_GetCurrentRenderer(SDL_bool create)
return NULL;
}
if (!SDL_CurrentRenderer) {
SDL_Window *window = NULL;
if (!create) {
SDL_SetError("Use SDL_CreateRenderer() to create a renderer");
return NULL;
}
if (SDL_CreateRenderer(0, -1, 0) < 0) {
/* Get the first window on the first display */
if (_this->num_displays > 0) {
window = _this->displays[0].windows;
}
if (SDL_CreateRenderer(window, -1, 0) < 0) {
return NULL;
}
}
@@ -1725,13 +1742,15 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_BGR565,
SDL_PIXELFORMAT_ARGB1555,
SDL_PIXELFORMAT_ABGR1555,
SDL_PIXELFORMAT_RGBA5551,
SDL_PIXELFORMAT_ABGR1555,
SDL_PIXELFORMAT_BGRA5551,
SDL_PIXELFORMAT_RGB555,
SDL_PIXELFORMAT_BGR555,
SDL_PIXELFORMAT_ARGB4444,
SDL_PIXELFORMAT_ABGR4444,
SDL_PIXELFORMAT_RGBA4444,
SDL_PIXELFORMAT_ABGR4444,
SDL_PIXELFORMAT_BGRA4444,
SDL_PIXELFORMAT_RGB444,
SDL_PIXELFORMAT_ARGB2101010,
SDL_PIXELFORMAT_INDEX8,
@@ -1815,11 +1834,13 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_ARGB1555,
SDL_PIXELFORMAT_ABGR1555,
SDL_PIXELFORMAT_RGBA5551,
SDL_PIXELFORMAT_ABGR1555,
SDL_PIXELFORMAT_BGRA5551,
SDL_PIXELFORMAT_ARGB4444,
SDL_PIXELFORMAT_ABGR4444,
SDL_PIXELFORMAT_RGBA4444,
SDL_PIXELFORMAT_ABGR4444,
SDL_PIXELFORMAT_BGRA4444,
SDL_PIXELFORMAT_ARGB2101010,
SDL_PIXELFORMAT_UNKNOWN
};
@@ -1961,8 +1982,8 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
{
Uint8 r, g, b, a;
int blendMode;
int scaleMode;
SDL_BlendMode blendMode;
SDL_ScaleMode scaleMode;
SDL_GetSurfaceColorMod(surface, &r, &g, &b);
SDL_SetTextureColorMod(texture, r, g, b);
@@ -1970,8 +1991,13 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
SDL_GetSurfaceAlphaMod(surface, &a);
SDL_SetTextureAlphaMod(texture, a);
SDL_GetSurfaceBlendMode(surface, &blendMode);
SDL_SetTextureBlendMode(texture, blendMode);
if (surface->map->info.flags & SDL_COPY_COLORKEY) {
/* We converted to a texture with alpha format */
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
} else {
SDL_GetSurfaceBlendMode(surface, &blendMode);
SDL_SetTextureBlendMode(texture, blendMode);
}
SDL_GetSurfaceScaleMode(surface, &scaleMode);
SDL_SetTextureScaleMode(texture, scaleMode);
@@ -2131,7 +2157,7 @@ SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha)
}
int
SDL_SetTextureBlendMode(SDL_Texture * texture, int blendMode)
SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode)
{
SDL_Renderer *renderer;
@@ -2147,7 +2173,7 @@ SDL_SetTextureBlendMode(SDL_Texture * texture, int blendMode)
}
int
SDL_GetTextureBlendMode(SDL_Texture * texture, int *blendMode)
SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode)
{
CHECK_TEXTURE_MAGIC(texture, -1);
@@ -2158,7 +2184,7 @@ SDL_GetTextureBlendMode(SDL_Texture * texture, int *blendMode)
}
int
SDL_SetTextureScaleMode(SDL_Texture * texture, int scaleMode)
SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode)
{
SDL_Renderer *renderer;
@@ -2174,7 +2200,7 @@ SDL_SetTextureScaleMode(SDL_Texture * texture, int scaleMode)
}
int
SDL_GetTextureScaleMode(SDL_Texture * texture, int *scaleMode)
SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode)
{
CHECK_TEXTURE_MAGIC(texture, -1);
@@ -2317,7 +2343,7 @@ SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
}
int
SDL_SetRenderDrawBlendMode(int blendMode)
SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode)
{
SDL_Renderer *renderer;
@@ -2334,7 +2360,7 @@ SDL_SetRenderDrawBlendMode(int blendMode)
}
int
SDL_GetRenderDrawBlendMode(int *blendMode)
SDL_GetRenderDrawBlendMode(SDL_BlendMode *blendMode)
{
SDL_Renderer *renderer;
@@ -2356,7 +2382,7 @@ SDL_RenderClear()
return -1;
}
if (!renderer->RenderClear) {
int blendMode = renderer->blendMode;
SDL_BlendMode blendMode = renderer->blendMode;
int status;
if (blendMode >= SDL_BLENDMODE_BLEND) {
@@ -2864,6 +2890,9 @@ SDL_RenderPresent(void)
if (!renderer || !renderer->RenderPresent) {
return;
}
#if SDL_VIDEO_DRIVER_WIN32
IME_Present((SDL_VideoData *)_this->driverdata);
#endif
renderer->RenderPresent(renderer);
}

View File

@@ -103,8 +103,8 @@ class SDL_BWin:public BDirectWindow
keymap[B_F10_KEY] = SDLK_F10;
keymap[B_F11_KEY] = SDLK_F11;
keymap[B_F12_KEY] = SDLK_F12;
keymap[B_PRINT_KEY] = SDLK_PRINT;
keymap[B_SCROLL_KEY] = SDLK_SCROLLOCK;
keymap[B_PRINT_KEY] = SDLK_PRINTSCREEN;
keymap[B_SCROLL_KEY] = SDLK_SCROLLLOCK;
keymap[B_PAUSE_KEY] = SDLK_PAUSE;
keymap[0x11] = SDLK_BACKQUOTE;
keymap[0x12] = SDLK_1;
@@ -123,7 +123,7 @@ class SDL_BWin:public BDirectWindow
keymap[0x1f] = SDLK_INSERT;
keymap[0x20] = SDLK_HOME;
keymap[0x21] = SDLK_PAGEUP;
keymap[0x22] = SDLK_NUMLOCK;
keymap[0x22] = SDLK_NUMLOCKCLEAR;
keymap[0x23] = SDLK_KP_DIVIDE;
keymap[0x24] = SDLK_KP_MULTIPLY;
keymap[0x25] = SDLK_KP_MINUS;
@@ -144,9 +144,9 @@ class SDL_BWin:public BDirectWindow
keymap[0x34] = SDLK_DELETE;
keymap[0x35] = SDLK_END;
keymap[0x36] = SDLK_PAGEDOWN;
keymap[0x37] = SDLK_KP7;
keymap[0x38] = SDLK_KP8;
keymap[0x39] = SDLK_KP9;
keymap[0x37] = SDLK_KP_7;
keymap[0x38] = SDLK_KP_8;
keymap[0x39] = SDLK_KP_9;
keymap[0x3a] = SDLK_KP_PLUS;
keymap[0x3b] = SDLK_CAPSLOCK;
keymap[0x3c] = SDLK_a;
@@ -161,9 +161,9 @@ class SDL_BWin:public BDirectWindow
keymap[0x45] = SDLK_SEMICOLON;
keymap[0x46] = SDLK_QUOTE;
keymap[0x47] = SDLK_RETURN;
keymap[0x48] = SDLK_KP4;
keymap[0x49] = SDLK_KP5;
keymap[0x4a] = SDLK_KP6;
keymap[0x48] = SDLK_KP_4;
keymap[0x49] = SDLK_KP_5;
keymap[0x4a] = SDLK_KP_6;
keymap[0x4b] = SDLK_LSHIFT;
keymap[0x4c] = SDLK_z;
keymap[0x4d] = SDLK_x;
@@ -177,9 +177,9 @@ class SDL_BWin:public BDirectWindow
keymap[0x55] = SDLK_SLASH;
keymap[0x56] = SDLK_RSHIFT;
keymap[0x57] = SDLK_UP;
keymap[0x58] = SDLK_KP1;
keymap[0x59] = SDLK_KP2;
keymap[0x5a] = SDLK_KP3;
keymap[0x58] = SDLK_KP_1;
keymap[0x59] = SDLK_KP_2;
keymap[0x5a] = SDLK_KP_3;
keymap[0x5b] = SDLK_KP_ENTER;
keymap[0x5c] = SDLK_LCTRL;
keymap[0x5d] = SDLK_LALT;
@@ -189,12 +189,12 @@ class SDL_BWin:public BDirectWindow
keymap[0x61] = SDLK_LEFT;
keymap[0x62] = SDLK_DOWN;
keymap[0x63] = SDLK_RIGHT;
keymap[0x64] = SDLK_KP0;
keymap[0x64] = SDLK_KP_0;
keymap[0x65] = SDLK_KP_PERIOD;
keymap[0x66] = SDLK_LMETA;
keymap[0x67] = SDLK_RMETA;
keymap[0x66] = SDLK_LGUI;
keymap[0x67] = SDLK_RGUI;
keymap[0x68] = SDLK_MENU;
keymap[0x69] = SDLK_EURO;
keymap[0x69] = SDLK_2; //SDLK_EURO;
keymap[0x6a] = SDLK_KP_EQUALS;
keymap[0x6b] = SDLK_POWER;
}

View File

@@ -27,9 +27,7 @@
static NSString *
GetTextFormat(_THIS)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
return NSStringPboardType;
#else
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
if (data->osversion >= 0x1060) {
@@ -37,6 +35,8 @@ GetTextFormat(_THIS)
} else {
return NSStringPboardType;
}
#else
return NSStringPboardType;
#endif
}

View File

@@ -36,11 +36,9 @@
#endif
/* setAppleMenu disappeared from the headers in 10.4 */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
@interface NSApplication(NSAppleMenu)
- (void)setAppleMenu:(NSMenu *)menu;
@end
#endif
@implementation NSApplication(SDL)
- (void)setRunning

View File

@@ -171,7 +171,11 @@
}
/* Needs long instead of NSInteger for compilation on Mac OS X 10.4 */
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
- (long) conversationIdentifier
#else
- (NSInteger) conversationIdentifier
#endif
{
return (long) self;
}
@@ -478,7 +482,7 @@ HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags)
static void
UpdateKeymap(SDL_VideoData *data)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
TISInputSourceRef key_layout;
#else
KeyboardLayoutRef key_layout;
@@ -489,7 +493,7 @@ UpdateKeymap(SDL_VideoData *data)
SDLKey keymap[SDL_NUM_SCANCODES];
/* See if the keymap needs to be updated */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
key_layout = TISCopyCurrentKeyboardLayoutInputSource();
#else
KLGetCurrentKeyboardLayout(&key_layout);
@@ -502,7 +506,7 @@ UpdateKeymap(SDL_VideoData *data)
SDL_GetDefaultKeymap(keymap);
/* Try Unicode data first (preferred as of Mac OS X 10.5) */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
CFDataRef uchrDataRef = TISGetInputSourceProperty(key_layout, kTISPropertyUnicodeKeyLayoutData);
if (uchrDataRef)
chr_data = CFDataGetBytePtr(uchrDataRef);
@@ -544,7 +548,7 @@ UpdateKeymap(SDL_VideoData *data)
return;
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
cleanup:
CFRelease(key_layout);
#else

View File

@@ -23,7 +23,7 @@
#include "SDL_cocoavideo.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
/*
Add methods to get at private members of NSScreen.
Since there is a bug in Apple's screen switching code
@@ -248,27 +248,29 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
CGError result;
/* Fade to black to hide resolution-switching flicker */
if (CGAcquireDisplayFadeReservation(5, &fade_token) == kCGErrorSuccess) {
CGDisplayFade(fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE);
}
/* Put up the blanking window (a window above all other windows) */
result = CGDisplayCapture(displaydata->display);
if (result != kCGErrorSuccess) {
CG_SetError("CGDisplayCapture()", result);
goto ERR_NO_CAPTURE;
}
if (data == display->desktop_mode.driverdata) {
/* Restoring desktop mode */
CGDisplaySwitchToMode(displaydata->display, data->moderef);
CGDisplayRelease(displaydata->display);
if (CGDisplayIsMain(displaydata->display)) {
ShowMenuBar();
}
} else {
/* Put up the blanking window (a window above all other windows) */
result = CGDisplayCapture(displaydata->display);
if (result != kCGErrorSuccess) {
CG_SetError("CGDisplayCapture()", result);
goto ERR_NO_CAPTURE;
}
/* Do the physical switch */
result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
if (result != kCGErrorSuccess) {
@@ -290,7 +292,7 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
[[NSApp mainWindow] makeKeyAndOrderFront: nil];
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
/*
There is a bug in Cocoa where NSScreen doesn't synchronize
with CGDirectDisplay, so the main screen's frame is wrong.
@@ -326,7 +328,6 @@ Cocoa_QuitModes(_THIS)
Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
}
}
CGReleaseAllDisplays();
ShowMenuBar();
}

View File

@@ -36,16 +36,6 @@
#define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
/* This is implemented in Mac OS X 10.3 and above */
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
@implementation NSOpenGLContext(CGLContextAccess)
- (CGLContextObj)CGLContextObj;
{
return _contextAuxiliary;
}
@end
#endif /* < 10.3 */
int
Cocoa_GL_LoadLibrary(_THIS, const char *path)
{
@@ -180,7 +170,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
#endif
{
long cache_max = 64;
GLint cache_max = 64;
CGLContextObj ctx = [context CGLContextObj];
CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max);
CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max);

View File

@@ -23,13 +23,15 @@
#include "SDL_cocoavideo.h"
#include "SDL_shape.h"
#include "SDL_cocoashape.h"
#include "../src/video/SDL_sysvideo.h"
#include "../SDL_sysvideo.h"
SDL_WindowShaper*
Cocoa_CreateShaper(SDL_Window* window) {
SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
[windata->nswindow setOpaque:NO];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
[windata->nswindow setStyleMask:NSBorderlessWindowMask];
#endif
SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper));
result->window = window;
result->mode.mode = ShapeModeDefault;

View File

@@ -40,7 +40,7 @@
#include "SDL_cocoaopengl.h"
#include "SDL_cocoawindow.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
#if __LP64__
typedef long NSInteger;
typedef unsigned long NSUInteger;

View File

@@ -29,7 +29,7 @@
typedef struct SDL_WindowData SDL_WindowData;
/* *INDENT-OFF* */
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
#else
@interface Cocoa_WindowListener : NSResponder {

View File

@@ -57,11 +57,15 @@ static __inline__ void ConvertNSRect(NSRect *r)
} else {
[_data->nswindow setDelegate:self];
}
// FIXME: Why doesn't this work?
// [center addObserver:self selector:@selector(rightMouseDown:) name:[NSString stringWithCString:"rightMouseDown" encoding:NSUTF8StringEncoding] object:[_data->nswindow contentView]];
[center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp];
[center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp];
[_data->nswindow setAcceptsMouseMovedEvents:YES];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[[_data->nswindow contentView] setAcceptsTouchEvents:YES];
#endif
}
- (void)close
@@ -113,7 +117,8 @@ static __inline__ void ConvertNSRect(NSRect *r)
NSRect rect = [_data->nswindow contentRectForFrameRect:[_data->nswindow frame]];
w = (int)rect.size.width;
h = (int)rect.size.height;
Cocoa_ResizeWindowShape(_data->window);
if (SDL_IsShapedWindow(_data->window))
Cocoa_ResizeWindowShape(_data->window);
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
}
@@ -293,6 +298,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
NSSet *touches = 0;
NSEnumerator *enumerator;
NSTouch *touch;
@@ -354,6 +360,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
touch = (NSTouch*)[enumerator nextObject];
}
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 */
}
@end
@@ -376,6 +383,30 @@ static __inline__ void ConvertNSRect(NSRect *r)
}
@end
@interface SDLView : NSView {
Cocoa_WindowListener *listener;
}
@end
@implementation SDLView
- (id) initWithFrame: (NSRect) rect
listener: (Cocoa_WindowListener *) theListener
{
if (self = [super initWithFrame:rect]) {
listener = theListener;
}
return self;
}
- (void)rightMouseDown:(NSEvent *)theEvent
{
[listener mouseDown:theEvent];
}
@end
static int
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
{
@@ -407,6 +438,14 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
{
SDL_Rect bounds;
NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
NSView *contentView = [[SDLView alloc] initWithFrame: rect
listener: data->listener];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[contentView setAcceptsTouchEvents:YES];
#endif
[nswindow setContentView: contentView];
[contentView release];
ConvertNSRect(&rect);
Cocoa_GetDisplayBounds(_this, display, &bounds);
window->x = (int)rect.origin.x - bounds.x;

View File

@@ -104,8 +104,8 @@ SDL_RenderDriver DirectFB_RenderDriver = {
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST |
SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),
14,
{
SDL_PIXELFORMAT_INDEX4LSB,
@@ -711,21 +711,21 @@ DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
data->render_options = DSRO_NONE;
break;
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_SCALEMODE_SLOW:
data->render_options = DSRO_SMOOTH_UPSCALE | DSRO_SMOOTH_DOWNSCALE;
break;
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_BEST:
data->render_options =
DSRO_SMOOTH_UPSCALE | DSRO_SMOOTH_DOWNSCALE | DSRO_ANTIALIAS;
break;
default:
SDL_Unsupported();
data->render_options = DSRO_NONE;
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
#endif

View File

@@ -82,7 +82,7 @@ SDL_RenderDriver NDS_RenderDriver = {
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), /* u32 flags */
(SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
(SDL_BLENDMODE_MASK), /* u32 blend_modes */
(SDL_TEXTURESCALEMODE_FAST), /* u32 scale_modes */
(SDL_SCALEMODE_FAST), /* u32 scale_modes */
3, /* u32 num_texture_formats */
{
SDL_PIXELFORMAT_INDEX8,

View File

@@ -104,8 +104,7 @@ SDL_RenderDriver photon_renderdriver = {
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW |
SDL_TEXTURESCALEMODE_FAST),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW | SDL_SCALEMODE_FAST),
10,
{SDL_PIXELFORMAT_INDEX8,
SDL_PIXELFORMAT_RGB555,
@@ -254,17 +253,17 @@ photon_createrenderer(SDL_Window * window, Uint32 flags)
/* Set current scale blitting capabilities */
if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
{
renderer->info.scale_modes=SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW;
renderer->info.scale_modes=SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW;
if ((didata->mode_2dcaps & SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)==SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)
{
/* This video mode supports hardware scaling */
renderer->info.scale_modes|=SDL_TEXTURESCALEMODE_FAST;
renderer->info.scale_modes|=SDL_SCALEMODE_FAST;
}
}
else
{
/* PhImage blit functions do not support scaling */
renderer->info.scale_modes=SDL_TEXTURESCALEMODE_NONE;
renderer->info.scale_modes=SDL_SCALEMODE_NONE;
}
return renderer;
@@ -984,39 +983,39 @@ photon_settexturescalemode(SDL_Renderer * renderer, SDL_Texture * texture)
switch (texture->scaleMode)
{
case SDL_TEXTURESCALEMODE_NONE:
case SDL_SCALEMODE_NONE:
return 0;
case SDL_TEXTURESCALEMODE_FAST:
if ((renderer->info.scale_modes & SDL_TEXTURESCALEMODE_FAST)==SDL_TEXTURESCALEMODE_FAST)
case SDL_SCALEMODE_FAST:
if ((renderer->info.scale_modes & SDL_SCALEMODE_FAST)==SDL_SCALEMODE_FAST)
{
return 0;
}
else
{
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
texture->scaleMode = SDL_SCALEMODE_FAST;
return -1;
}
break;
case SDL_TEXTURESCALEMODE_SLOW:
if ((renderer->info.scale_modes & SDL_TEXTURESCALEMODE_SLOW)==SDL_TEXTURESCALEMODE_SLOW)
case SDL_SCALEMODE_SLOW:
if ((renderer->info.scale_modes & SDL_SCALEMODE_SLOW)==SDL_SCALEMODE_SLOW)
{
return 0;
}
else
{
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_SLOW;
texture->scaleMode = SDL_SCALEMODE_SLOW;
return -1;
}
break;
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_BEST:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_SLOW;
texture->scaleMode = SDL_SCALEMODE_SLOW;
return -1;
default:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}

View File

@@ -79,7 +79,7 @@ SDL_RenderDriver SDL_PS3_RenderDriver = {
(SDL_BLENDMODE_NONE),
/* We use bilinear scaling on the SPE for YV12 & IYUV
* (width and height % 8 = 0) */
(SDL_TEXTURESCALEMODE_SLOW)
(SDL_SCALEMODE_SLOW)
}
};

View File

@@ -87,7 +87,7 @@ SDL_RenderDriver gf_renderdriver = {
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW),
13,
{
SDL_PIXELFORMAT_INDEX8,

View File

@@ -85,7 +85,7 @@ SDL_RenderDriver DDRAW_RenderDriver = {
SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE),
(SDL_BLENDMODE_NONE),
(SDL_TEXTURESCALEMODE_NONE),
(SDL_SCALEMODE_NONE),
0,
{0},
0,
@@ -666,10 +666,10 @@ static int
DDRAW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_SCALEMODE_NONE:
default:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
return 0;

View File

@@ -150,8 +150,8 @@ SDL_RenderDriver D3D_RenderDriver = {
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST |
SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),
0,
{0},
0,
@@ -807,14 +807,14 @@ static int
D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
case SDL_SCALEMODE_SLOW:
case SDL_SCALEMODE_BEST:
return 0;
default:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
return 0;
@@ -1343,20 +1343,20 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
}
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
D3DTEXF_POINT);
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
D3DTEXF_POINT);
break;
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_SCALEMODE_SLOW:
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
D3DTEXF_LINEAR);
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
D3DTEXF_LINEAR);
break;
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_BEST:
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
D3DTEXF_GAUSSIANQUAD);
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,

View File

@@ -210,7 +210,7 @@ SDL_RenderDriver GAPI_RenderDriver = {
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
(SDL_TEXTUREMODULATE_NONE),
(SDL_BLENDMODE_NONE),
(SDL_TEXTURESCALEMODE_NONE),
(SDL_SCALEMODE_NONE),
7,
{
SDL_PIXELFORMAT_RGB555,
@@ -233,7 +233,7 @@ SDL_RenderDriver RAW_RenderDriver = {
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
(SDL_TEXTUREMODULATE_NONE),
(SDL_BLENDMODE_NONE),
(SDL_TEXTURESCALEMODE_NONE),
(SDL_SCALEMODE_NONE),
7,
{
SDL_PIXELFORMAT_RGB555,

View File

@@ -90,7 +90,7 @@ SDL_RenderDriver GDI_RenderDriver = {
SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST),
14,
{
SDL_PIXELFORMAT_INDEX8,
@@ -580,17 +580,17 @@ static int
GDI_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
return 0;
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_SLOW:
case SDL_SCALEMODE_BEST:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
texture->scaleMode = SDL_SCALEMODE_FAST;
return -1;
default:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
return 0;

View File

@@ -22,6 +22,7 @@ typedef struct ITfUIElement ITfUIElement;
typedef struct ITfUIElementMgr ITfUIElementMgr;
typedef struct IEnumTfUIElements IEnumTfUIElements;
typedef struct ITfThreadMgrEx ITfThreadMgrEx;
typedef struct ITfCandidateListUIElement ITfCandidateListUIElement;
typedef struct ITfReadingInformationUIElement ITfReadingInformationUIElement;
typedef struct ITfInputProcessorProfileActivationSink ITfInputProcessorProfileActivationSink;
typedef struct ITfSource ITfSource;
@@ -127,6 +128,30 @@ struct ITfUIElementMgr
const struct ITfUIElementMgrVtbl *lpVtbl;
};
typedef struct ITfCandidateListUIElementVtbl
{
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfCandidateListUIElement *, REFIID, void **);
ULONG (STDMETHODCALLTYPE *AddRef)(ITfCandidateListUIElement *);
ULONG (STDMETHODCALLTYPE *Release)(ITfCandidateListUIElement *);
HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfCandidateListUIElement *, BSTR *);
HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfCandidateListUIElement *, GUID *);
HRESULT (STDMETHODCALLTYPE *Show)(ITfCandidateListUIElement *, BOOL);
HRESULT (STDMETHODCALLTYPE *IsShown)(ITfCandidateListUIElement *, BOOL *);
HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfCandidateListUIElement *, DWORD *);
HRESULT (STDMETHODCALLTYPE *GetDocumentMgr)(ITfCandidateListUIElement *, ITfDocumentMgr **);
HRESULT (STDMETHODCALLTYPE *GetCount)(ITfCandidateListUIElement *, UINT *);
HRESULT (STDMETHODCALLTYPE *GetSelection)(ITfCandidateListUIElement *, UINT *);
HRESULT (STDMETHODCALLTYPE *GetString)(ITfCandidateListUIElement *, UINT, BSTR *);
HRESULT (STDMETHODCALLTYPE *GetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT, UINT *);
HRESULT (STDMETHODCALLTYPE *SetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT);
HRESULT (STDMETHODCALLTYPE *GetCurrentPage)(ITfCandidateListUIElement *, UINT *);
} ITfCandidateListUIElementVtbl;
struct ITfCandidateListUIElement
{
const struct ITfCandidateListUIElementVtbl *lpVtbl;
};
typedef struct ITfReadingInformationUIElementVtbl
{
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfReadingInformationUIElement *, REFIID, void **);

View File

@@ -27,6 +27,7 @@
#include "SDL_syswm.h"
#include "SDL_vkeys.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_touch_c.h"
@@ -55,13 +56,11 @@
#ifndef WM_INPUT
#define WM_INPUT 0x00ff
#endif
#ifndef WM_GESTURE
#define WM_GESTURE 0x0119
#endif
#ifndef WM_TOUCH
#ifndef WM_TOUCH
#define WM_TOUCH 0x0240
#endif
static WPARAM
RemapVKEY(WPARAM wParam, LPARAM lParam)
{
@@ -519,41 +518,70 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
returnCode = 0;
break;
case WM_TOUCH:
{
//printf("Got Touch Event!\n");
#ifdef WMMSG_DEBUG
FILE *log = fopen("wmmsg.txt", "a");
fprintf(log, "Received Touch Message: %p ", hwnd);
if (msg > MAX_WMMSG) {
fprintf(log, "%d", msg);
} else {
fprintf(log, "%s", wmtab[msg]);
UINT i, num_inputs = LOWORD(wParam);
PTOUCHINPUT inputs = SDL_stack_alloc(TOUCHINPUT, num_inputs);
if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) {
RECT rect;
float x, y;
if (!GetClientRect(hwnd, &rect) ||
(rect.right == rect.left && rect.bottom == rect.top)) {
break;
}
ClientToScreen(hwnd, (LPPOINT) & rect);
ClientToScreen(hwnd, (LPPOINT) & rect + 1);
rect.top *= 100;
rect.left *= 100;
rect.bottom *= 100;
rect.right *= 100;
for (i = 0; i < num_inputs; ++i) {
PTOUCHINPUT input = &inputs[i];
SDL_TouchID touchId = (SDL_TouchID)input->hSource;
if (!SDL_GetTouch(touchId)) {
SDL_Touch touch;
touch.id = touchId;
touch.x_min = 0;
touch.x_max = 1;
touch.native_xres = touch.x_max - touch.x_min;
touch.y_min = 0;
touch.y_max = 1;
touch.native_yres = touch.y_max - touch.y_min;
touch.pressure_min = 0;
touch.pressure_max = 1;
touch.native_pressureres = touch.pressure_max - touch.pressure_min;
if (SDL_AddTouch(&touch, "") < 0) {
continue;
}
}
// Get the normalized coordinates for the window
x = (float)(input->x - rect.left)/(rect.right - rect.left);
y = (float)(input->y - rect.top)/(rect.bottom - rect.top);
if (input->dwFlags & TOUCHEVENTF_DOWN) {
SDL_SendFingerDown(touchId, input->dwID, SDL_TRUE, x, y, 1);
}
if (input->dwFlags & TOUCHEVENTF_MOVE) {
SDL_SendTouchMotion(touchId, input->dwID, SDL_FALSE, x, y, 1);
}
if (input->dwFlags & TOUCHEVENTF_UP) {
SDL_SendFingerDown(touchId, input->dwID, SDL_FALSE, x, y, 1);
}
}
}
fprintf(log, "WM_TOUCH = %d -- 0x%X, 0x%X\n",msg, wParam, lParam);
fclose(log);
#endif
SDL_stack_free(inputs);
data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam);
return 0;
}
break;
case WM_GESTURE:
{
//printf("Got Touch Event!\n");
#ifdef WMMSG_DEBUG
FILE *log = fopen("wmmsg.txt", "a");
fprintf(log, "Received Gesture Message: %p ", hwnd);
if (msg > MAX_WMMSG) {
fprintf(log, "%d", msg);
} else {
fprintf(log, "%s", wmtab[msg]);
}
fprintf(log, "WM_GESTURE = %d -- 0x%X, 0x%X\n",msg, wParam, lParam);
fclose(log);
#endif
}
break;
}
/* If there's a window proc, assume it's going to handle messages */

View File

@@ -100,6 +100,23 @@ WIN_InitKeyboard(_THIS)
data->ime_composition[0] = 0;
data->ime_readingstring[0] = 0;
data->ime_cursor = 0;
data->ime_candlist = SDL_FALSE;
SDL_memset(data->ime_candidates, 0, sizeof(data->ime_candidates));
data->ime_candcount = 0;
data->ime_candref = 0;
data->ime_candsel = 0;
data->ime_candpgsize = 0;
data->ime_candlistindexbase = 0;
data->ime_candvertical = SDL_TRUE;
data->ime_candtex = NULL;
data->ime_dirty = SDL_FALSE;
SDL_memset(&data->ime_rect, 0, sizeof(data->ime_rect));
SDL_memset(&data->ime_candlistrect, 0, sizeof(data->ime_candlistrect));
data->ime_winwidth = 0;
data->ime_winheight = 0;
data->ime_hkl = 0;
data->ime_himm32 = 0;
data->GetReadingString = 0;
@@ -165,6 +182,7 @@ WIN_StartTextInput(_THIS)
if (window) {
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_GetWindowSize(window, &videodata->ime_winwidth, &videodata->ime_winheight);
IME_Init(videodata, hwnd);
IME_Enable(videodata, hwnd);
}
@@ -185,7 +203,8 @@ WIN_StopTextInput(_THIS)
void
WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
videodata->ime_rect = *rect;
}
#ifdef __GNUC__
@@ -196,6 +215,7 @@ DEFINE_GUID(IID_ITfUIElementSink, 0xEA1EA136,0x19DF
DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD, 0x34745C63,0xB2F0,0x4784,0x8B,0x67,0x5E,0x12,0xC8,0x70,0x1A,0x31);
DEFINE_GUID(IID_ITfSource, 0x4EA48A35,0x60AE,0x446F,0x8F,0xD6,0xE6,0xA8,0xD8,0x24,0x59,0xF7);
DEFINE_GUID(IID_ITfUIElementMgr, 0xEA1EA135,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
DEFINE_GUID(IID_ITfCandidateListUIElement, 0xEA1EA138,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
DEFINE_GUID(IID_ITfReadingInformationUIElement, 0xEA1EA139,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
DEFINE_GUID(IID_ITfThreadMgr, 0xAA80E801,0x2021,0x11D2,0x93,0xE0,0x00,0x60,0xB0,0x67,0xB8,0x6E);
DEFINE_GUID(CLSID_TF_ThreadMgr, 0x529A9E6B,0x6587,0x4F23,0xAB,0x9E,0x9C,0x7D,0x68,0x3E,0x3C,0x50);
@@ -243,6 +263,8 @@ static void IME_SetWindow(SDL_VideoData* videodata, HWND hwnd);
static void IME_SetupAPI(SDL_VideoData *videodata);
static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex);
static void IME_SendEditingEvent(SDL_VideoData *videodata);
static void IME_DestroyTextures(SDL_VideoData *videodata);
#define SDL_IsEqualIID(riid1, riid2) SDL_IsEqualGUID(riid1, riid2)
#define SDL_IsEqualGUID(rguid1, rguid2) (!SDL_memcmp(rguid1, rguid2, sizeof(GUID)))
@@ -345,6 +367,7 @@ IME_Quit(SDL_VideoData *videodata)
CoUninitialize();
videodata->ime_com_initialized = SDL_FALSE;
}
IME_DestroyTextures(videodata);
videodata->ime_initialized = SDL_FALSE;
}
@@ -453,17 +476,14 @@ static void
IME_InputLangChanged(SDL_VideoData *videodata)
{
UINT lang = PRIMLANG();
HWND hwndime = 0;
IME_UpdateInputLocale(videodata);
if (!videodata->ime_uiless)
videodata->ime_candlistindexbase = (videodata->ime_hkl == CHT_HKL_DAYI) ? 0 : 1;
IME_SetupAPI(videodata);
if (lang != PRIMLANG()) {
IME_ClearComposition(videodata);
}
hwndime = ImmGetDefaultIMEWnd(videodata->ime_hwnd_current);
if (hwndime) {
SendMessageA(hwndime, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0);
SendMessageA(hwndime, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0);
}
}
static DWORD
@@ -610,6 +630,20 @@ IME_UpdateInputLocale(SDL_VideoData *videodata)
return;
hklprev = videodata->ime_hkl;
switch (PRIMLANG()) {
case LANG_CHINESE:
videodata->ime_candvertical = SDL_TRUE;
if (SUBLANG() == SUBLANG_CHINESE_SIMPLIFIED)
videodata->ime_candvertical = SDL_FALSE;
break;
case LANG_JAPANESE:
videodata->ime_candvertical = SDL_TRUE;
break;
case LANG_KOREAN:
videodata->ime_candvertical = SDL_FALSE;
break;
}
}
static void
@@ -632,12 +666,6 @@ IME_ClearComposition(SDL_VideoData *videodata)
SDL_SendEditingText("", 0, 0);
}
static void
IME_ClearEditing(SDL_VideoData *videodata)
{
}
static void
IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)
{
@@ -690,6 +718,92 @@ IME_SendEditingEvent(SDL_VideoData *videodata)
SDL_free(s);
}
static void
IME_AddCandidate(SDL_VideoData *videodata, UINT i, LPCWSTR candidate)
{
LPWSTR dst = videodata->ime_candidates[i];
*dst++ = (WCHAR)(TEXT('0') + ((i + videodata->ime_candlistindexbase) % 10));
if (videodata->ime_candvertical)
*dst++ = TEXT(' ');
while (*candidate && (SDL_arraysize(videodata->ime_candidates[i]) > (dst - videodata->ime_candidates[i])))
*dst++ = *candidate++;
*dst = (WCHAR)'\0';
}
static void
IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata)
{
LPCANDIDATELIST cand_list = 0;
DWORD size = ImmGetCandidateListW(himc, 0, 0, 0);
if (size) {
cand_list = (LPCANDIDATELIST)SDL_malloc(size);
if (cand_list) {
size = ImmGetCandidateListW(himc, 0, cand_list, size);
if (size) {
int i = 0;
int j = 0;
int page_start = 0;
videodata->ime_candsel = cand_list->dwSelection;
videodata->ime_candcount = cand_list->dwCount;
if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) {
const UINT maxcandchar = 18;
UINT i = 0;
UINT cchars = 0;
for (; i < videodata->ime_candcount; ++i) {
UINT len = SDL_wcslen((LPWSTR)((DWORD)cand_list + cand_list->dwOffset[i])) + 1;
if (len + cchars > maxcandchar) {
if (i > cand_list->dwSelection)
break;
page_start = i;
cchars = len;
}
else {
cchars += len;
}
}
videodata->ime_candpgsize = i - page_start;
}
else {
videodata->ime_candpgsize = SDL_min(cand_list->dwPageSize, MAX_CANDLIST);
page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
}
SDL_memset(&videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++) {
LPCWSTR candidate = (LPCWSTR)((DWORD)cand_list + cand_list->dwOffset[i]);
IME_AddCandidate(videodata, j, candidate);
}
if (PRIMLANG() == LANG_KOREAN || (PRIMLANG() == LANG_CHT && !IME_GetId(videodata, 0)))
videodata->ime_candsel = -1;
}
SDL_free(cand_list);
}
}
}
static void
IME_ShowCandidateList(SDL_VideoData *videodata)
{
videodata->ime_dirty = SDL_TRUE;
videodata->ime_candlist = SDL_TRUE;
IME_DestroyTextures(videodata);
IME_SendEditingEvent(videodata);
}
static void
IME_HideCandidateList(SDL_VideoData *videodata)
{
videodata->ime_dirty = SDL_FALSE;
videodata->ime_candlist = SDL_FALSE;
IME_DestroyTextures(videodata);
IME_SendEditingEvent(videodata);
}
SDL_bool
IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata)
{
@@ -698,10 +812,9 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled)
return SDL_FALSE;
switch (msg)
{
switch (msg) {
case WM_INPUTLANGCHANGE:
//IME_InputLangChanged(videodata);
IME_InputLangChanged(videodata);
break;
case WM_IME_SETCONTEXT:
*lParam = 0;
@@ -732,18 +845,28 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
SDL_SendEditingText("", 0, 0);
break;
case WM_IME_NOTIFY:
switch (wParam)
{
switch (wParam) {
case IMN_SETCONVERSIONMODE:
case IMN_SETOPENSTATUS:
IME_UpdateInputLocale(videodata);
break;
case IMN_OPENCANDIDATE:
case IMN_CHANGECANDIDATE:
if (videodata->ime_uiless)
break;
trap = SDL_TRUE;
IME_ShowCandidateList(videodata);
himc = ImmGetContext(hwnd);
if (!himc)
break;
IME_GetCandidateList(himc, videodata);
ImmReleaseContext(hwnd, himc);
break;
case IMN_CLOSECANDIDATE:
trap = SDL_TRUE;
IME_HideCandidateList(videodata);
break;
case IMN_PRIVATE:
{
@@ -784,6 +907,63 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
return trap;
}
static void
IME_CloseCandidateList(SDL_VideoData *videodata)
{
IME_HideCandidateList(videodata);
videodata->ime_candcount = 0;
SDL_memset(videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
}
static void
UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pcandlist)
{
UINT selection = 0;
UINT count = 0;
UINT page = 0;
UINT pgcount = 0;
DWORD pgstart = 0;
DWORD pgsize = 0;
UINT i, j;
pcandlist->lpVtbl->GetSelection(pcandlist, &selection);
pcandlist->lpVtbl->GetCount(pcandlist, &count);
pcandlist->lpVtbl->GetCurrentPage(pcandlist, &page);
videodata->ime_candsel = selection;
videodata->ime_candcount = count;
IME_ShowCandidateList(videodata);
pcandlist->lpVtbl->GetPageIndex(pcandlist, 0, 0, &pgcount);
if (pgcount > 0) {
UINT *idxlist = SDL_malloc(sizeof(UINT) * pgcount);
if (idxlist) {
pcandlist->lpVtbl->GetPageIndex(pcandlist, idxlist, pgcount, &pgcount);
pgstart = idxlist[page];
if (page < pgcount - 1)
pgsize = SDL_min(count, idxlist[page + 1]) - pgstart;
else
pgsize = count - pgstart;
SDL_free(idxlist);
}
}
videodata->ime_candpgsize = SDL_min(pgsize, MAX_CANDLIST);
videodata->ime_candsel = videodata->ime_candsel - pgstart;
SDL_memset(videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
for (i = pgstart, j = 0; (DWORD)i < count && j < videodata->ime_candpgsize; i++, j++) {
BSTR bstr;
if (SUCCEEDED(pcandlist->lpVtbl->GetString(pcandlist, i, &bstr))) {
if (bstr) {
IME_AddCandidate(videodata, j, bstr);
SysFreeString(bstr);
}
}
}
if (PRIMLANG() == LANG_KOREAN)
videodata->ime_candsel = -1;
}
STDMETHODIMP_(ULONG) TSFSink_AddRef(TSFSink *sink)
{
return ++sink->refcount;
@@ -792,8 +972,7 @@ STDMETHODIMP_(ULONG) TSFSink_AddRef(TSFSink *sink)
STDMETHODIMP_(ULONG)TSFSink_Release(TSFSink *sink)
{
--sink->refcount;
if (sink->refcount == 0)
{
if (sink->refcount == 0) {
SDL_free(sink);
return 0;
}
@@ -835,6 +1014,7 @@ STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BO
{
ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
ITfReadingInformationUIElement *preading = 0;
ITfCandidateListUIElement *pcandlist = 0;
SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
if (!element)
return E_INVALIDARG;
@@ -848,6 +1028,11 @@ STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BO
}
preading->lpVtbl->Release(preading);
}
else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) {
videodata->ime_candref++;
UILess_GetCandidateList(videodata, pcandlist);
pcandlist->lpVtbl->Release(pcandlist);
}
return S_OK;
}
@@ -855,6 +1040,7 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId)
{
ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
ITfReadingInformationUIElement *preading = 0;
ITfCandidateListUIElement *pcandlist = 0;
SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
if (!element)
return E_INVALIDARG;
@@ -869,6 +1055,10 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId)
}
preading->lpVtbl->Release(preading);
}
else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) {
UILess_GetCandidateList(videodata, pcandlist);
pcandlist->lpVtbl->Release(pcandlist);
}
return S_OK;
}
@@ -876,6 +1066,7 @@ STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId)
{
ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
ITfReadingInformationUIElement *preading = 0;
ITfCandidateListUIElement *pcandlist = 0;
SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
if (!element)
return E_INVALIDARG;
@@ -885,6 +1076,13 @@ STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId)
IME_SendEditingEvent(videodata);
preading->lpVtbl->Release(preading);
}
if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) {
videodata->ime_candref--;
if (videodata->ime_candref == 0)
IME_CloseCandidateList(videodata);
pcandlist->lpVtbl->Release(pcandlist);
}
return S_OK;
}
@@ -908,9 +1106,13 @@ STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv)
STDMETHODIMP IPPASink_OnActivated(TSFSink *sink, DWORD dwProfileType, LANGID langid, REFCLSID clsid, REFGUID catid, REFGUID guidProfile, HKL hkl, DWORD dwFlags)
{
static GUID TF_PROFILE_DAYI = {0x037B2C25, 0x480C, 0x4D7F, 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A};
SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
videodata->ime_candlistindexbase = SDL_IsEqualGUID(&TF_PROFILE_DAYI, guidProfile) ? 0 : 1;
if (SDL_IsEqualIID(catid, &GUID_TFCAT_TIP_KEYBOARD) && (dwFlags & TF_IPSINK_FLAG_ACTIVE))
IME_InputLangChanged((SDL_VideoData *)sink->data);
IME_HideCandidateList(videodata);
return S_OK;
}
@@ -1016,4 +1218,338 @@ UILess_ReleaseSinks(SDL_VideoData *videodata)
}
}
static void *
StartDrawToBitmap(HDC hdc, HBITMAP *hhbm, int width, int height)
{
BITMAPINFO info = {0};
BITMAPINFOHEADER *infoHeader = &info.bmiHeader;
BYTE *bits = NULL;
if (hhbm) {
infoHeader->biSize = sizeof(BITMAPINFOHEADER);
infoHeader->biWidth = width;
infoHeader->biHeight = -1 * SDL_abs(height);
infoHeader->biPlanes = 1;
infoHeader->biBitCount = 32;
infoHeader->biCompression = BI_RGB;
*hhbm = CreateDIBSection(hdc, &info, DIB_RGB_COLORS, (void **)&bits, 0, 0);
if (*hhbm)
SelectObject(hdc, *hhbm);
}
return bits;
}
static void
StopDrawToBitmap(HDC hdc, HBITMAP *hhbm)
{
if (hhbm && *hhbm) {
DeleteObject(*hhbm);
*hhbm = NULL;
}
}
static void
BitmapToTexture(HBITMAP hbm, BYTE *bits, int width, int height, SDL_Texture **texture)
{
SDL_Surface *surface = NULL;
BITMAP bm = {0};
if (GetObject(hbm, sizeof(bm), &bm) == 0)
return;
if (bits && texture) {
/*
For transparency:
const Uint8 alpha = 130;
unsigned long *p = (unsigned long *)bits;
unsigned long *end = (unsigned long *)(bits + (bm.bmWidthBytes * bm.bmHeight));
while (p < end) {
*p = RGB(GetRValue(*p), GetGValue(*p), GetBValue(*p)) | (alpha << 24);
++p;
}
surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
*/
surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0);
if (surface) {
*texture = SDL_CreateTextureFromSurface(0, surface);
SDL_FreeSurface(surface);
}
}
}
/* This draws only within the specified area and fills the entire region. */
static void
DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize)
{
/* The case of no pen (PenSize = 0) is automatically taken care of. */
const int penadjust = (int)SDL_floor(pensize / 2.0f - 0.5f);
left += pensize / 2;
top += pensize / 2;
right -= penadjust;
bottom -= penadjust;
Rectangle(hdc, left, top, right, bottom);
}
static void
DestroyTexture(SDL_Texture **texture)
{
if (texture && *texture) {
SDL_DestroyTexture(*texture);
*texture = NULL;
}
}
static void
IME_DestroyTextures(SDL_VideoData *videodata)
{
DestroyTexture(&videodata->ime_candtex);
}
#define SDL_swap(a,b) { \
int c = (a); \
(a) = (b); \
(b) = c; \
}
static void
IME_PositionCandidateList(SDL_VideoData *videodata, SIZE size)
{
int left, top, right, bottom;
SDL_bool ok = SDL_FALSE;
int winw = videodata->ime_winwidth;
int winh = videodata->ime_winheight;
/* Bottom */
left = videodata->ime_rect.x;
top = videodata->ime_rect.y + videodata->ime_rect.h;
right = left + size.cx;
bottom = top + size.cy;
if (right >= winw) {
left -= right - winw;
right = winw;
}
if (bottom < winh)
ok = SDL_TRUE;
/* Top */
if (!ok) {
left = videodata->ime_rect.x;
top = videodata->ime_rect.y - size.cy;
right = left + size.cx;
bottom = videodata->ime_rect.y;
if (right >= winw) {
left -= right - winw;
right = winw;
}
if (top >= 0)
ok = SDL_TRUE;
}
/* Right */
if (!ok) {
left = videodata->ime_rect.x + size.cx;
top = 0;
right = left + size.cx;
bottom = size.cy;
if (right < winw)
ok = SDL_TRUE;
}
/* Left */
if (!ok) {
left = videodata->ime_rect.x - size.cx;
top = 0;
right = videodata->ime_rect.x;
bottom = size.cy;
if (right >= 0)
ok = SDL_TRUE;
}
/* Window too small, show at (0,0) */
if (!ok) {
left = 0;
top = 0;
right = size.cx;
bottom = size.cy;
}
videodata->ime_candlistrect.x = left;
videodata->ime_candlistrect.y = top;
videodata->ime_candlistrect.w = right - left;
videodata->ime_candlistrect.h = bottom - top;
}
static void
IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
{
int i, j;
SIZE size = {0};
SIZE candsizes[MAX_CANDLIST];
SIZE maxcandsize = {0};
HBITMAP hbm = NULL;
BYTE *bits = NULL;
const int candcount = SDL_min(SDL_min(MAX_CANDLIST, videodata->ime_candcount), videodata->ime_candpgsize);
SDL_bool vertical = videodata->ime_candvertical;
const int listborder = 1;
const int listpadding = 0;
const int listbordercolor = RGB(0xB4, 0xC7, 0xAA);
const int listfillcolor = RGB(255, 255, 255);
const int candborder = 1;
const int candpadding = 0;
const int candmargin = 1;
const COLORREF candbordercolor = RGB(255, 255, 255);
const COLORREF candfillcolor = RGB(255, 255, 255);
const COLORREF candtextcolor = RGB(0, 0, 0);
const COLORREF selbordercolor = RGB(0x84, 0xAC, 0xDD);
const COLORREF selfillcolor = RGB(0xD2, 0xE6, 0xFF);
const COLORREF seltextcolor = RGB(0, 0, 0);
const int horzcandspacing = 5;
HPEN listpen = listborder != 0 ? CreatePen(PS_SOLID, listborder, listbordercolor) : (HPEN)GetStockObject(NULL_PEN);
HBRUSH listbrush = CreateSolidBrush(listfillcolor);
HPEN candpen = candborder != 0 ? CreatePen(PS_SOLID, candborder, candbordercolor) : (HPEN)GetStockObject(NULL_PEN);
HBRUSH candbrush = CreateSolidBrush(candfillcolor);
HPEN selpen = candborder != 0 ? CreatePen(PS_DOT, candborder, selbordercolor) : (HPEN)GetStockObject(NULL_PEN);
HBRUSH selbrush = CreateSolidBrush(selfillcolor);
HFONT font = CreateFont((int)(1 + videodata->ime_rect.h * 0.75f), 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH | FF_SWISS, TEXT("Microsoft Sans Serif"));
SetBkMode(hdc, TRANSPARENT);
SelectObject(hdc, font);
for (i = 0; i < candcount; ++i) {
const WCHAR *s = videodata->ime_candidates[i];
if (!*s)
break;
GetTextExtentPoint32W(hdc, s, SDL_wcslen(s), &candsizes[i]);
maxcandsize.cx = SDL_max(maxcandsize.cx, candsizes[i].cx);
maxcandsize.cy = SDL_max(maxcandsize.cy, candsizes[i].cy);
}
if (vertical) {
size.cx =
(listborder * 2) +
(listpadding * 2) +
(candmargin * 2) +
(candborder * 2) +
(candpadding * 2) +
(maxcandsize.cx)
;
size.cy =
(listborder * 2) +
(listpadding * 2) +
((candcount + 1) * candmargin) +
(candcount * candborder * 2) +
(candcount * candpadding * 2) +
(candcount * maxcandsize.cy)
;
}
else {
size.cx =
(listborder * 2) +
(listpadding * 2) +
((candcount + 1) * candmargin) +
(candcount * candborder * 2) +
(candcount * candpadding * 2) +
((candcount - 1) * horzcandspacing);
;
for (i = 0; i < candcount; ++i)
size.cx += candsizes[i].cx;
size.cy =
(listborder * 2) +
(listpadding * 2) +
(candmargin * 2) +
(candborder * 2) +
(candpadding * 2) +
(maxcandsize.cy)
;
}
bits = StartDrawToBitmap(hdc, &hbm, size.cx, size.cy);
SelectObject(hdc, listpen);
SelectObject(hdc, listbrush);
DrawRect(hdc, 0, 0, size.cx, size.cy, listborder);
SelectObject(hdc, candpen);
SelectObject(hdc, candbrush);
SetTextColor(hdc, candtextcolor);
SetBkMode(hdc, TRANSPARENT);
for (i = 0; i < candcount; ++i) {
const WCHAR *s = videodata->ime_candidates[i];
int left, top, right, bottom;
if (!*s)
break;
if (vertical) {
left = listborder + listpadding + candmargin;
top = listborder + listpadding + (i * candborder * 2) + (i * candpadding * 2) + ((i + 1) * candmargin) + (i * maxcandsize.cy);
right = size.cx - listborder - listpadding - candmargin;
bottom = top + maxcandsize.cy + (candpadding * 2) + (candborder * 2);
}
else {
left = listborder + listpadding + (i * candborder * 2) + (i * candpadding * 2) + ((i + 1) * candmargin) + (i * horzcandspacing);
for (j = 0; j < i; ++j)
left += candsizes[j].cx;
top = listborder + listpadding + candmargin;
right = left + candsizes[i].cx + (candpadding * 2) + (candborder * 2);
bottom = size.cy - listborder - listpadding - candmargin;
}
if (i == videodata->ime_candsel) {
SelectObject(hdc, selpen);
SelectObject(hdc, selbrush);
SetTextColor(hdc, seltextcolor);
}
else {
SelectObject(hdc, candpen);
SelectObject(hdc, candbrush);
SetTextColor(hdc, candtextcolor);
}
DrawRect(hdc, left, top, right, bottom, candborder);
ExtTextOutW(hdc, left + candborder + candpadding, top + candborder + candpadding, 0, NULL, s, SDL_wcslen(s), NULL);
}
BitmapToTexture(hbm, bits, size.cx, size.cy, &videodata->ime_candtex);
StopDrawToBitmap(hdc, &hbm);
DeleteObject(listpen);
DeleteObject(listbrush);
DeleteObject(candpen);
DeleteObject(candbrush);
DeleteObject(selpen);
DeleteObject(selbrush);
DeleteObject(font);
IME_PositionCandidateList(videodata, size);
}
static void
IME_Render(SDL_VideoData *videodata)
{
HDC hdc = CreateCompatibleDC(NULL);
if (videodata->ime_candlist)
IME_RenderCandidateList(videodata, hdc);
DeleteDC(hdc);
videodata->ime_dirty = SDL_FALSE;
}
void IME_Present(SDL_VideoData *videodata)
{
if (videodata->ime_dirty)
IME_Render(videodata);
SDL_RenderCopy(videodata->ime_candtex, NULL, &videodata->ime_candlistrect);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -82,6 +82,10 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
FreeLibrary(data->hAygShell);
}
#endif
if (data->userDLL) {
FreeLibrary(data->userDLL);
}
SDL_free(device->driverdata);
SDL_free(device);
}
@@ -155,6 +159,13 @@ WIN_CreateDevice(int devindex)
data->CoordTransform = NULL;
#endif
data->userDLL = LoadLibrary(TEXT("USER32.DLL"));
if (data->userDLL) {
data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) GetProcAddress(data->userDLL, "CloseTouchInputHandle");
data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) GetProcAddress(data->userDLL, "GetTouchInputInfo");
data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) GetProcAddress(data->userDLL, "RegisterTouchWindow");
}
/* Set the function pointers */
device->VideoInit = WIN_VideoInit;
device->VideoQuit = WIN_VideoQuit;

View File

@@ -44,6 +44,9 @@
#include <imm.h>
#define MAX_CANDLIST 10
#define MAX_CANDLENGTH 256
#if SDL_VIDEO_RENDER_D3D
//#include <d3d9.h>
#define D3D_DEBUG_INFO
@@ -77,6 +80,32 @@ extern void WIN_SetError(const char *prefix);
enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW };
#if WINVER < 0x0601
/* Touch input definitions */
#define TWF_FINETOUCH 1
#define TWF_WANTPALM 2
#define TOUCHEVENTF_MOVE 0x0001
#define TOUCHEVENTF_DOWN 0x0002
#define TOUCHEVENTF_UP 0x0004
DECLARE_HANDLE(HTOUCHINPUT);
typedef struct _TOUCHINPUT {
LONG x;
LONG y;
HANDLE hSource;
DWORD dwID;
DWORD dwFlags;
DWORD dwMask;
DWORD dwTime;
ULONG_PTR dwExtraInfo;
DWORD cxContact;
DWORD cyContact;
} TOUCHINPUT, *PTOUCHINPUT;
#endif /* WINVER < 0x0601 */
typedef BOOL (*PFNSHFullScreen)(HWND, DWORD);
typedef void (*PFCoordTransform)(SDL_Window*, POINT*);
@@ -89,26 +118,26 @@ typedef struct
/* Definition from Win98DDK version of IMM.H */
typedef struct tagINPUTCONTEXT2 {
HWND hWnd;
BOOL fOpen;
POINT ptStatusWndPos;
POINT ptSoftKbdPos;
DWORD fdwConversion;
DWORD fdwSentence;
union {
LOGFONTA A;
LOGFONTW W;
HWND hWnd;
BOOL fOpen;
POINT ptStatusWndPos;
POINT ptSoftKbdPos;
DWORD fdwConversion;
DWORD fdwSentence;
union {
LOGFONTA A;
LOGFONTW W;
} lfFont;
COMPOSITIONFORM cfCompForm;
CANDIDATEFORM cfCandForm[4];
HIMCC hCompStr;
HIMCC hCandInfo;
HIMCC hGuideLine;
HIMCC hPrivate;
DWORD dwNumMsgBuf;
HIMCC hMsgBuf;
DWORD fdwInit;
DWORD dwReserve[3];
COMPOSITIONFORM cfCompForm;
CANDIDATEFORM cfCandForm[4];
HIMCC hCompStr;
HIMCC hCandInfo;
HIMCC hGuideLine;
HIMCC hPrivate;
DWORD dwNumMsgBuf;
HIMCC hMsgBuf;
DWORD fdwInit;
DWORD dwReserve[3];
} INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2;
/* Private display data */
@@ -132,7 +161,13 @@ typedef struct SDL_VideoData
#endif
const SDL_scancode *key_layout;
DWORD clipboard_count;
DWORD clipboard_count;
/* Touch input functions */
HANDLE userDLL;
BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
SDL_bool ime_com_initialized;
struct ITfThreadMgr *ime_threadmgr;
@@ -147,6 +182,22 @@ typedef struct SDL_VideoData
WCHAR ime_readingstring[16];
int ime_cursor;
SDL_bool ime_candlist;
WCHAR ime_candidates[MAX_CANDLIST][MAX_CANDLENGTH];
DWORD ime_candcount;
DWORD ime_candref;
DWORD ime_candsel;
UINT ime_candpgsize;
int ime_candlistindexbase;
SDL_bool ime_candvertical;
SDL_Texture *ime_candtex;
SDL_bool ime_dirty;
SDL_Rect ime_rect;
SDL_Rect ime_candlistrect;
int ime_winwidth;
int ime_winheight;
HKL ime_hkl;
HMODULE ime_himm32;
UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen);

View File

@@ -144,6 +144,11 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
}
}
/* Enable multi-touch */
if (videodata->RegisterTouchWindow) {
videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM));
}
/* All done! */
window->driverdata = data;
return 0;
@@ -639,5 +644,4 @@ SDL_HelperWindowDestroy(void)
}
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -28,6 +28,7 @@
#include <limits.h> /* For INT_MAX */
#include "SDL_x11video.h"
#include "SDL_x11touch.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_touch_c.h"

View File

@@ -83,7 +83,7 @@ SDL_RenderDriver X11_RenderDriver = {
SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
SDL_TEXTUREMODULATE_NONE,
SDL_BLENDMODE_NONE,
SDL_TEXTURESCALEMODE_NONE,
SDL_SCALEMODE_NONE,
0,
{0},
0,
@@ -331,8 +331,8 @@ X11_AddRenderDriver(_THIS)
/* Update the capabilities of the renderer. */
info->blend_modes |= (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD |
SDL_BLENDMODE_MOD | SDL_BLENDMODE_MASK);
info->scale_modes |= (SDL_TEXTURESCALEMODE_FAST | SDL_TEXTURESCALEMODE_SLOW |
SDL_TEXTURESCALEMODE_BEST);
info->scale_modes |= (SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW |
SDL_SCALEMODE_BEST);
info->mod_modes |= (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA);
}
#endif
@@ -1010,8 +1010,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
return -1;
}
}
}
else {
} else {
data->image =
XCreateImage(renderdata->display, data->visual,
data->depth, ZPixmap, 0, NULL,
@@ -1036,7 +1035,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
data->pitch = data->image->bytes_per_line;
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
if(renderdata->use_xrender) {
if(renderdata->use_xrender && !data->yuv) {
gcv.graphics_exposures = False;
data->gc =
XCreateGC(renderdata->display, data->pixmap, GCGraphicsExposures, &gcv);
@@ -1078,7 +1077,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
// FIXME: Is the following required?
/* Set the default blending and scaling modes. */
texture->blendMode = SDL_BLENDMODE_NONE;
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
data->blend_op = PictOpSrc;
data->filter = NULL;
}
@@ -1216,14 +1215,14 @@ X11_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata;
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_SCALEMODE_NONE:
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
if (renderdata->use_xrender) {
data->filter = NULL;
}
#endif
return 0;
case SDL_TEXTURESCALEMODE_FAST:
case SDL_SCALEMODE_FAST:
/* We can sort of fake it for streaming textures */
if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) {
return 0;
@@ -1233,12 +1232,12 @@ X11_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
data->filter = FilterFast;
return 0;
}
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_SCALEMODE_SLOW:
if (renderdata->use_xrender) {
data->filter = FilterGood;
return 0;
}
case SDL_TEXTURESCALEMODE_BEST:
case SDL_SCALEMODE_BEST:
if (renderdata->use_xrender) {
data->filter = FilterBest;
return 0;
@@ -1249,12 +1248,12 @@ X11_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
SDL_Unsupported();
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
if (renderdata->use_xrender) {
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
data->filter = NULL;
}
else
#endif
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
return 0;
@@ -1922,7 +1921,7 @@ X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_AddDirtyRect(&data->dirty, dstrect);
}
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
if (data->use_xrender) {
if (data->use_xrender && !texturedata->yuv) {
if(texture->access == SDL_TEXTUREACCESS_STREAMING) {
#ifndef NO_SHARED_MEMORY
if(texturedata->shminfo.shmaddr) {
@@ -2012,7 +2011,7 @@ X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
}
/* Set the picture filter only if a scaling mode is set. */
if (texture->scaleMode != SDL_TEXTURESCALEMODE_NONE) {
if (texture->scaleMode != SDL_SCALEMODE_NONE) {
XRenderSetPictureFilter(data->display, src,
texturedata->filter, 0, 0);
}

View File

@@ -21,7 +21,7 @@
*/
#include "SDL_config.h"
#include "SDL_x11video.h"
#include "SDL_eventtouch.h"
#include "SDL_x11touch.h"
#include "../../events/SDL_touch_c.h"

View File

@@ -21,12 +21,12 @@
*/
#include "SDL_config.h"
#ifndef _SDL_eventtouch_h
#define _SDL_eventtouch_h
#ifndef _SDL_x11touch_h
#define _SDL_x11touch_h
//What should this be?
#if SDL_VIDEO_DRIVER_X11_XINPUT
#ifdef SDL_INPUT_LINUXEV
typedef struct EventTouchData
{
int x,y,pressure,finger; //Temporary Variables until sync
@@ -38,6 +38,6 @@ typedef struct EventTouchData
extern void X11_InitTouch(_THIS);
extern void X11_QuitTouch(_THIS);
#endif /* _SDL_eventtouch_h */
#endif /* _SDL_x11touch_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -25,13 +25,13 @@
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_eventtouch.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "SDL_x11video.h"
#include "SDL_x11render.h"
#include "SDL_x11shape.h"
#include "SDL_x11touch.h"
#if SDL_VIDEO_DRIVER_PANDORA
#include "SDL_x11opengles.h"

View File

@@ -66,7 +66,6 @@
#include "SDL_x11keyboard.h"
#include "SDL_x11modes.h"
#include "SDL_x11mouse.h"
#include "SDL_eventtouch.h"
#include "SDL_x11opengl.h"
#include "SDL_x11window.h"

View File

@@ -942,7 +942,7 @@ X11_SetWindowSize(_THIS, SDL_Window * window)
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
Display *display = data->videodata->display;
if(SDL_IsShapedWindow(window))
if (SDL_IsShapedWindow(window))
X11_ResizeWindowShape(window);
XResizeWindow(display, data->xwindow, window->w, window->h);
}