Updated SDL 1.3 to latest HG head.
This commit is contained in:
72
project/sdl/sdl-1.3/README.gesture
Normal file
72
project/sdl/sdl-1.3/README.gesture
Normal file
@@ -0,0 +1,72 @@
|
||||
===========================================================================
|
||||
Dollar Gestures
|
||||
===========================================================================
|
||||
SDL Provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
||||
|
||||
Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up.
|
||||
|
||||
Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID.
|
||||
|
||||
Recording:
|
||||
----------
|
||||
To begin recording on a touch device call:
|
||||
SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices.
|
||||
|
||||
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
||||
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
||||
|
||||
event.dgesture.touchId - the Id of the touch used to record the gesture.
|
||||
event.dgesture.gestureId - the unique id of the recoreded gesture.
|
||||
|
||||
|
||||
Performing:
|
||||
-----------
|
||||
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
||||
|
||||
event.dgesture.touchId - the Id of the touch which performed the gesture.
|
||||
event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
||||
event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
||||
event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
||||
|
||||
Most programs will want to define an appropriate error threshold and check to be sure taht the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
||||
|
||||
|
||||
|
||||
Saving:
|
||||
-------
|
||||
To save a template, call SDL_SaveDollarTemplate(gestureId, src) where gestureId is the id of the gesture you want to save, and src is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(src) where source is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
Both functions return the number of gestures sucessfully saved.
|
||||
|
||||
|
||||
Loading:
|
||||
--------
|
||||
To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file.
|
||||
|
||||
SDL_LoadDollarTemplates returns the number of templates sucessfully loaded.
|
||||
|
||||
|
||||
|
||||
===========================================================================
|
||||
Multi Gestures
|
||||
===========================================================================
|
||||
SDL provides simple support for pinch/rotate/swipe gestures.
|
||||
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
||||
|
||||
event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
||||
event.mgesture.x - the normalized x cooridinate of the gesture. (0..1)
|
||||
event.mgesture.y - the normalized y cooridinate of the gesture. (0..1)
|
||||
event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
||||
event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
||||
event.mgesture.numFingers - the number of fingers used in the gesture.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
101
project/sdl/sdl-1.3/README.touch
Normal file
101
project/sdl/sdl-1.3/README.touch
Normal file
@@ -0,0 +1,101 @@
|
||||
===========================================================================
|
||||
System Specific Notes
|
||||
===========================================================================
|
||||
Linux:
|
||||
The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it.
|
||||
|
||||
Mac:
|
||||
The Mac and Iphone API's are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
|
||||
|
||||
iPhone:
|
||||
Works out of box.
|
||||
|
||||
Windows:
|
||||
Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com
|
||||
|
||||
===========================================================================
|
||||
Events
|
||||
===========================================================================
|
||||
SDL_FINGERDOWN:
|
||||
Sent when a finger (or stylus) is placed on a touch device.
|
||||
Fields:
|
||||
event.tfinger.touchId - the Id of the touch device.
|
||||
event.tfinger.fingerId - the Id of the finger which just went down.
|
||||
event.tfinger.x - the x coordinate of the touch (0..touch.xres)
|
||||
event.tfinger.y - the y coordinate of the touch (0..touch.yres)
|
||||
event.tfinger.pressure - the pressure of the touch (0..touch.pressureres)
|
||||
|
||||
SDL_FINGERMOTION:
|
||||
Sent when a finger (or stylus) is moved on the touch device.
|
||||
Fields:
|
||||
Same as FINGERDOWN but with additional:
|
||||
event.tfginer.dx - change in x coordinate during this motion event.
|
||||
event.tfginer.dy - change in y coordinate during this motion event.
|
||||
|
||||
SDL_FINGERMOTION:
|
||||
Sent when a finger (or stylus) is lifted from the touch device.
|
||||
Fields:
|
||||
Same as FINGERDOWN.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Functions
|
||||
===========================================================================
|
||||
SDL provides the ability to access the underlying Touch and Finger structures.
|
||||
These structures should _never_ be modified.
|
||||
|
||||
The following functions are included from SDL_Touch.h
|
||||
|
||||
To get a SDL_Touch device call SDL_GetTouch(touchId).
|
||||
This returns an SDL_Touch*.
|
||||
IMPORTANT: If the touch has been removed, or there is no touch with the given ID, SDL_GetTouch will return null. Be sure to check for this!
|
||||
|
||||
An SDL_Touch has the following fields:
|
||||
>xres,yres,pressures:
|
||||
The resolution at which x,y, and pressure values are reported. Currently these will always be equal to 2^15, but this may not always be the case.
|
||||
|
||||
>pressure_max, pressure_min, x_max, x_min, y_max, y_min
|
||||
Which give, respectively, the maximum and minumum values that the touch digitizer can return for pressure, x coordiniate, and y coordinate AS REPORTED BY THE OPERATING SYSTEM.
|
||||
On Mac/iPhone systems _max will always be 0, and _min will always be 1.
|
||||
|
||||
>native_xres,native_yres,native_pressureres:
|
||||
The native resolution of the touch device AS REPORTED BY THE OPERATING SYSTEM.
|
||||
On Mac/iPhone systems these will always be 1.
|
||||
|
||||
>num_fingers:
|
||||
The number of fingers currently down on the device.
|
||||
|
||||
>fingers:
|
||||
An array of pointers to the fingers which are on the device.
|
||||
|
||||
|
||||
The most common reason to access a touch device is to normalize inputs. This would be accomplished by code like the following:
|
||||
|
||||
SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId);
|
||||
if(inTouch == NULL) continue; //The touch has been removed
|
||||
|
||||
float x = ((float)event.tfinger.x)/inTouch->xres;
|
||||
float y = ((float)event.tfinger.y)/inTouch->yres;
|
||||
|
||||
|
||||
|
||||
To get an SDL_Finger, call SDL_GetFinger(touch,fingerId), where touch is a pointer to an SDL_Touch device, and fingerId is the id of the requested finger.
|
||||
This returns an SDL_Finger*, or null if the finger does not exist, or has been removed.
|
||||
An SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the FINGERUP event is polled.
|
||||
As a result, be very careful to check for null return values.
|
||||
|
||||
An SDL_Finger has the following fields:
|
||||
>x,y,pressure:
|
||||
The current coordinates of the touch.
|
||||
>xdelta,ydelta:
|
||||
The change in position resulting from the last finger motion.
|
||||
>last_x, last_y, last_pressure:
|
||||
The previous coordinates of the touch.
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
@@ -1,3 +1,26 @@
|
||||
Eli Gottlieb's checklist for the GSOC shaped windows project. Dated July 9, 2010.
|
||||
1. Enable proper linking of the X11 implementation and test it.
|
||||
--> Find the place in the build system for platform-specific linking flags. STATUS: DONE
|
||||
--> Add a linker flag to bring in libXext.a. STATUS: DONE.
|
||||
2. Build the Win32 implementation of shaped-windows functionality.
|
||||
--> Add driver functions to the SDL_ShapeDriver in the Win32 driver's SDL_DisplayDevice at the proper point in the code. STATUS: CHECK.
|
||||
--> Add a hook in the Windows resize-window code to call Win32_ResizeWindowShape(). STATUS: CHECK.
|
||||
--> Get the Windows code to build and run properly. STATUS: IN PROGRESS.
|
||||
3. Enable building the testeyes program.
|
||||
--> Reprogram it to use the latest shaped-windows API. STATUS: CHECK.
|
||||
--> Get it, along with the rest of the test suite in my branch, building successfully. STATUS: DONE.
|
||||
--> Debug testeyes and the platform-specific shaped-window implementations in tandem. STATUS: IN PROGRESS.
|
||||
4. Implement the SDL shaped-windows API for Mac OS X using Cocoa. STATUS: IN PROGRESS
|
||||
--> Locate (once more) the API documentation for shaped windows under Cocoa. STATUS: NEARLY FINISHED.
|
||||
--> Design and encode a version of SDL_ShapeData for Cocoa. STATUS: IN PROGRESS.
|
||||
--> Write Cocoa_CreateShaper(). STATUS: MOSTLY DONE, AFAIK.
|
||||
--> Write Cocoa_ResizeWindowShape(). STATUS: DONE, AFAIK.
|
||||
--> Write Cocoa_SetWindowShape(). STATUS: IN PROGRESS.
|
||||
--> If necessary, implement functionality adjunct to SDL_CalculateShapeBitmap() for Cocoa usage.
|
||||
5. Use testeyes to debug all implementations. STATUS: SPRINT + 2.
|
||||
--> Debug Cocoa implementation.
|
||||
--> Debug Win32 implementation.
|
||||
--> Debug X11 implementation (again).
|
||||
|
||||
1.3 release checklist:
|
||||
* http://wiki.libsdl.org/moin.cgi/Roadmap
|
||||
|
||||
@@ -121,8 +121,7 @@ extern "C" {
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* This function loads the SDL dynamically linked library and initializes
|
||||
* the subsystems specified by \c flags (and those satisfying dependencies).
|
||||
* This function initializes the subsystems specified by \c flags
|
||||
* Unless the ::SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
|
||||
* signal handlers for some commonly ignored fatal signals (like SIGSEGV).
|
||||
*/
|
||||
@@ -139,16 +138,16 @@ extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
|
||||
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function returns mask of the specified subsystems which have
|
||||
* been initialized.
|
||||
* This function returns a mask of the specified subsystems which have
|
||||
* previously been initialized.
|
||||
*
|
||||
* If \c flags is 0, it returns a mask of all initialized subsystems.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
|
||||
|
||||
/**
|
||||
* This function cleans up all initialized subsystems and unloads the
|
||||
* dynamically linked library. You should call it upon all exit conditions.
|
||||
* This function cleans up all initialized subsystems. You should
|
||||
* call it upon all exit conditions.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_Quit(void);
|
||||
|
||||
|
||||
@@ -136,6 +136,8 @@
|
||||
#undef HAVE_SNPRINTF
|
||||
#undef HAVE_VSNPRINTF
|
||||
#undef HAVE_M_PI
|
||||
#undef HAVE_ATAN
|
||||
#undef HAVE_ATAN2
|
||||
#undef HAVE_CEIL
|
||||
#undef HAVE_COPYSIGN
|
||||
#undef HAVE_COS
|
||||
@@ -272,12 +274,18 @@
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XDAMAGE
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES
|
||||
#undef SDL_VIDEO_DRIVER_X11_VIDMODE
|
||||
#undef SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
#undef SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
#undef SDL_VIDEO_DRIVER_X11_XINPUT
|
||||
#undef SDL_VIDEO_DRIVER_X11_SCRNSAVER
|
||||
#undef SDL_VIDEO_DRIVER_X11_XV
|
||||
#undef SDL_VIDEO_DRIVER_X11_XRENDER
|
||||
#undef SDL_VIDEO_DRIVER_X11_XDAMAGE
|
||||
#undef SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
#undef SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
|
||||
#undef SDL_VIDEO_RENDER_D3D
|
||||
#undef SDL_VIDEO_RENDER_GDI
|
||||
|
||||
@@ -144,6 +144,7 @@
|
||||
#define SDL_VIDEO_DRIVER_X11_XINPUT 1
|
||||
#define SDL_VIDEO_DRIVER_X11_SCRNSAVER 1
|
||||
#define SDL_VIDEO_DRIVER_X11_XV 1
|
||||
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
|
||||
|
||||
#define SDL_VIDEO_RENDER_OGL 1
|
||||
#define SDL_VIDEO_RENDER_X11 1
|
||||
|
||||
@@ -125,6 +125,8 @@ typedef unsigned int uintptr_t;
|
||||
#define HAVE__STRNICMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_M_PI 1
|
||||
#define HAVE_ATAN 1
|
||||
#define HAVE_ATAN2 1
|
||||
#define HAVE_CEIL 1
|
||||
#define HAVE_COPYSIGN 1
|
||||
#define HAVE_COS 1
|
||||
|
||||
@@ -41,7 +41,7 @@ extern "C" {
|
||||
|
||||
/* Public functions */
|
||||
extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...);
|
||||
extern DECLSPEC char *SDLCALL SDL_GetError(void);
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetError(void);
|
||||
extern DECLSPEC void SDLCALL SDL_ClearError(void);
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_quit.h"
|
||||
#include "SDL_gesture.h"
|
||||
#include "SDL_touch.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
@@ -90,14 +92,28 @@ typedef enum
|
||||
SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
|
||||
SDL_JOYBUTTONUP, /**< Joystick button released */
|
||||
|
||||
/* Touch events */
|
||||
SDL_FINGERDOWN = 0x700,
|
||||
SDL_FINGERUP,
|
||||
SDL_FINGERMOTION,
|
||||
SDL_TOUCHBUTTONDOWN,
|
||||
SDL_TOUCHBUTTONUP,
|
||||
|
||||
/* Gesture events */
|
||||
SDL_DOLLARGESTURE = 0x800,
|
||||
SDL_DOLLARRECORD,
|
||||
SDL_MULTIGESTURE,
|
||||
|
||||
/* Clipboard events */
|
||||
SDL_CLIPBOARDUPDATE = 0x700, /**< The clipboard changed */
|
||||
|
||||
SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
|
||||
|
||||
/* Obsolete events */
|
||||
SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
|
||||
SDL_EVENT_COMPAT2,
|
||||
SDL_EVENT_COMPAT3,
|
||||
|
||||
|
||||
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
|
||||
* and should be allocated with SDL_RegisterEvents()
|
||||
*/
|
||||
@@ -263,6 +279,79 @@ typedef struct SDL_JoyButtonEvent
|
||||
Uint8 padding1;
|
||||
} SDL_JoyButtonEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Touch finger motion/finger event structure (event.tmotion.*)
|
||||
*/
|
||||
typedef struct SDL_TouchFingerEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_FINGERMOTION OR
|
||||
SDL_FINGERDOWN OR SDL_FINGERUP*/
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device id */
|
||||
SDL_FingerID fingerId;
|
||||
Uint8 state; /**< The current button state */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
Uint16 x;
|
||||
Uint16 y;
|
||||
Sint16 dx;
|
||||
Sint16 dy;
|
||||
Uint16 pressure;
|
||||
} SDL_TouchFingerEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Touch finger motion/finger event structure (event.tmotion.*)
|
||||
*/
|
||||
typedef struct SDL_TouchButtonEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_TOUCHBUTTONUP OR SDL_TOUCHBUTTONDOWN */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device index */
|
||||
Uint8 state; /**< The current button state */
|
||||
Uint8 button; /**< The button changing state */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
} SDL_TouchButtonEvent;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Multiple Finger Gesture Event
|
||||
*/
|
||||
typedef struct SDL_MultiGestureEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_MULTIGESTURE */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device index */
|
||||
float dTheta;
|
||||
float dDist;
|
||||
float x; //currently 0...1. Change to screen coords?
|
||||
float y;
|
||||
Uint16 numFingers;
|
||||
Uint16 padding;
|
||||
} SDL_MultiGestureEvent;
|
||||
|
||||
typedef struct SDL_DollarGestureEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_DOLLARGESTURE */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device index */
|
||||
SDL_GestureID gestureId;
|
||||
Uint32 numFingers;
|
||||
float error;
|
||||
/*
|
||||
//TODO: Enable to give location?
|
||||
float x; //currently 0...1. Change to screen coords?
|
||||
float y;
|
||||
*/
|
||||
} SDL_DollarGestureEvent;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief The "quit requested" event
|
||||
*/
|
||||
@@ -345,6 +434,10 @@ typedef union SDL_Event
|
||||
SDL_QuitEvent quit; /**< Quit request event data */
|
||||
SDL_UserEvent user; /**< Custom event data */
|
||||
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*/
|
||||
|
||||
/** Temporarily here for backwards compatibility */
|
||||
/*@{*/
|
||||
@@ -382,12 +475,12 @@ typedef enum
|
||||
* the back of the event queue.
|
||||
*
|
||||
* If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
|
||||
* of the event queue, matching \c mask, will be returned and will not
|
||||
* be removed from the queue.
|
||||
* of the event queue, within the specified minimum and maximum type,
|
||||
* will be returned and will not be removed from the queue.
|
||||
*
|
||||
* If \c action is ::SDL_GETEVENT, up to \c numevents events at the front
|
||||
* of the event queue, matching \c mask, will be returned and will be
|
||||
* removed from the queue.
|
||||
* of the event queue, within the specified minimum and maximum type,
|
||||
* will be returned and will be removed from the queue.
|
||||
*
|
||||
* \return The number of events actually stored, or -1 if there was an error.
|
||||
*
|
||||
|
||||
92
project/sdl/sdl-1.3/include/SDL_gesture.h
Normal file
92
project/sdl/sdl-1.3/include/SDL_gesture.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
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_gesture.h
|
||||
*
|
||||
* Include file for SDL gesture event handling.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_gesture_h
|
||||
#define _SDL_gesture_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "SDL_touch.h"
|
||||
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
typedef Sint64 SDL_GestureID;
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Begin Recording a gesture on the specified touch, or all touches (-1)
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Save all currently loaded Dollar Gesture templates
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *src);
|
||||
|
||||
/**
|
||||
* \brief Save a currently loaded Dollar Gesture template
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Load Dollar Gesture templates from a file
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_gesture_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -65,6 +65,11 @@
|
||||
#undef __LINUX__
|
||||
#define __LINUX__ 1
|
||||
#endif
|
||||
#if defined(ANDROID)
|
||||
#undef __ANDROID__
|
||||
#undef __LINUX__ /*do we need to do this?*/
|
||||
#define __ANDROID__ 1
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* lets us know what version of Mac OS X we're compiling on */
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define SDL_REVISION "hg-4563:ffd169948438"
|
||||
#define SDL_REVISION "hg-4904:c0021a587dc7"
|
||||
|
||||
@@ -65,7 +65,7 @@ typedef struct SDL_RWops
|
||||
size_t size, size_t maxnum);
|
||||
|
||||
/**
|
||||
* Write exactly \c num objects each of size \c objsize from the area
|
||||
* Write exactly \c num objects each of size \c size from the area
|
||||
* pointed at by \c ptr to data source.
|
||||
*
|
||||
* \return the number of objects written, or 0 at error or end of file.
|
||||
|
||||
148
project/sdl/sdl-1.3/include/SDL_shape.h
Normal file
148
project/sdl/sdl-1.3/include/SDL_shape.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
|
||||
#ifndef _SDL_shape_h
|
||||
#define _SDL_shape_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_surface.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/** \file SDL_shape.h
|
||||
*
|
||||
* Header file for the shaped window API.
|
||||
*/
|
||||
|
||||
#define SDL_NONSHAPEABLE_WINDOW -1
|
||||
#define SDL_INVALID_SHAPE_ARGUMENT -2
|
||||
#define SDL_WINDOW_LACKS_SHAPE -3
|
||||
|
||||
/**
|
||||
* \brief Create a window that can be shaped with the specified position, dimensions, and flags.
|
||||
*
|
||||
* \param title The title of the window, in UTF-8 encoding.
|
||||
* \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
* ::SDL_WINDOWPOS_UNDEFINED.
|
||||
* \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
* ::SDL_WINDOWPOS_UNDEFINED.
|
||||
* \param w The width of the window.
|
||||
* \param h The height of the window.
|
||||
* \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following:
|
||||
* ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED,
|
||||
* ::SDL_WINDOW_SHOWN, ::SDL_WINDOW_RESIZABLE,
|
||||
* ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED,
|
||||
* ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset.
|
||||
*
|
||||
* \return The window created, or NULL if window creation failed.
|
||||
*
|
||||
* \sa SDL_DestroyWindow()
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
|
||||
|
||||
/**
|
||||
* \brief Return whether the given window is a shaped window.
|
||||
*
|
||||
* \param window The window to query for being shaped.
|
||||
*
|
||||
* \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL.
|
||||
* \sa SDL_CreateShapedWindow
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window);
|
||||
|
||||
/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
|
||||
typedef enum {
|
||||
/** \brief The default mode, a binarized alpha cutoff of 1. */
|
||||
ShapeModeDefault,
|
||||
/** \brief A binarized alpha cutoff with a given integer value. */
|
||||
ShapeModeBinarizeAlpha,
|
||||
/** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */
|
||||
ShapeModeReverseBinarizeAlpha,
|
||||
/** \brief A color key is applied. */
|
||||
ShapeModeColorKey
|
||||
} WindowShapeMode;
|
||||
|
||||
#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
|
||||
|
||||
/** \brief A union containing parameters for shaped windows. */
|
||||
typedef union {
|
||||
/** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */
|
||||
Uint8 binarizationCutoff;
|
||||
SDL_Color colorKey;
|
||||
} SDL_WindowShapeParams;
|
||||
|
||||
/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
|
||||
typedef struct SDL_WindowShapeMode {
|
||||
/** \brief The mode of these window-shape parameters. */
|
||||
WindowShapeMode mode;
|
||||
/** \brief Window-shape parameters. */
|
||||
SDL_WindowShapeParams parameters;
|
||||
} SDL_WindowShapeMode;
|
||||
|
||||
/**
|
||||
* \brief Set the shape and parameters of a shaped window.
|
||||
*
|
||||
* \param window The shaped window whose parameters should be set.
|
||||
* \param shape A surface encoding the desired shape for the window.
|
||||
* \param shape_mode The parameters to set for the shaped window.
|
||||
*
|
||||
* \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
|
||||
* if the SDL_Window* given does not reference a valid shaped window.
|
||||
*
|
||||
* \sa SDL_WindowShapeMode
|
||||
* \sa SDL_GetShapedWindowMode.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
|
||||
|
||||
/**
|
||||
* \brief Get the shape parameters of a shaped window.
|
||||
*
|
||||
* \param window The shaped window whose parameters should be retrieved.
|
||||
* \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
|
||||
*
|
||||
* \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
|
||||
* data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
|
||||
* the SDL_Window* given is a shapeable window currently lacking a shape.
|
||||
*
|
||||
* \sa SDL_WindowShapeMode
|
||||
* \sa SDL_SetWindowShape
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_shape_h */
|
||||
@@ -174,9 +174,10 @@ SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
|
||||
SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
|
||||
SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
|
||||
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
|
||||
#ifndef __NINTENDODS__ /* TODO: figure out why the following happens:
|
||||
include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
|
||||
include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
|
||||
#if !defined(__NINTENDODS__) && !defined(__ANDROID__)
|
||||
/* TODO: figure out why the following happens:
|
||||
include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
|
||||
include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
|
||||
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
|
||||
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
||||
#endif
|
||||
@@ -195,7 +196,8 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
||||
|
||||
/** \cond */
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
#ifndef __NINTENDODS__ /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
|
||||
#if !defined(__NINTENDODS__) && !defined(__ANDROID__)
|
||||
/* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
|
||||
typedef enum
|
||||
{
|
||||
DUMMY_ENUM_VALUE
|
||||
@@ -470,6 +472,19 @@ extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WCSLCPY
|
||||
#define SDL_wcslcpy wcslcpy
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WCSLCAT
|
||||
#define SDL_wcslcat wcslcat
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_STRLCPY
|
||||
#define SDL_strlcpy strlcpy
|
||||
#else
|
||||
@@ -477,6 +492,9 @@ extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
|
||||
size_t maxlen);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src,
|
||||
size_t dst_bytes);
|
||||
|
||||
#ifdef HAVE_STRLCAT
|
||||
#define SDL_strlcat strlcat
|
||||
#else
|
||||
@@ -676,6 +694,18 @@ extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
|
||||
#define M_PI 3.14159265358979323846264338327950288 /* pi */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATAN
|
||||
#define SDL_atan atan
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_atan(double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATAN2
|
||||
#define SDL_atan2 atan2
|
||||
#else
|
||||
extern DECLSPEC double SDLCALL SDL_atan2(double y, double x);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CEIL
|
||||
#define SDL_ceil ceil
|
||||
#else
|
||||
|
||||
@@ -54,6 +54,11 @@ extern "C" {
|
||||
struct SDL_SysWMinfo;
|
||||
#else
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* This is the structure for custom window manager events */
|
||||
#if defined(SDL_VIDEO_DRIVER_X11)
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
@@ -69,16 +74,34 @@ struct SDL_SysWMinfo;
|
||||
#undef Cursor
|
||||
#endif
|
||||
|
||||
#endif /* defined(SDL_VIDEO_DRIVER_X11) */
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
|
||||
#include <directfb/directfb.h>
|
||||
#endif
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
#ifdef __OBJC__
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#else
|
||||
typedef struct _NSWindow NSWindow;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* These are the various supported subsystems under UNIX.
|
||||
* These are the various supported windowing subsystems
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_SYSWM_X11
|
||||
SDL_SYSWM_UNKNOWN,
|
||||
SDL_SYSWM_WINDOWS,
|
||||
SDL_SYSWM_X11,
|
||||
SDL_SYSWM_DIRECTFB,
|
||||
SDL_SYSWM_COCOA,
|
||||
} SDL_SYSWM_TYPE;
|
||||
|
||||
/**
|
||||
* The UNIX custom event structure.
|
||||
* The custom event structure.
|
||||
*/
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
@@ -86,12 +109,35 @@ struct SDL_SysWMmsg
|
||||
SDL_SYSWM_TYPE subsystem;
|
||||
union
|
||||
{
|
||||
XEvent xevent;
|
||||
} event;
|
||||
#if defined(SDL_VIDEO_DRIVER_WIN32)
|
||||
struct {
|
||||
HWND hwnd; /**< The window for the message */
|
||||
UINT msg; /**< The type of message */
|
||||
WPARAM wParam; /**< WORD message parameter */
|
||||
LPARAM lParam; /**< LONG message parameter */
|
||||
} win;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_X11)
|
||||
struct {
|
||||
XEvent event;
|
||||
} x11;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
|
||||
struct {
|
||||
DFBEvent event;
|
||||
} dfb;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
struct
|
||||
{
|
||||
/* No Cocoa window events yet */
|
||||
} cocoa;
|
||||
#endif
|
||||
} /*msg*/;
|
||||
};
|
||||
|
||||
/**
|
||||
* The UNIX custom window manager information structure.
|
||||
* The custom window manager information structure.
|
||||
*
|
||||
* When this structure is returned, it holds information about which
|
||||
* low level system it is using, and will be one of SDL_SYSWM_TYPE.
|
||||
@@ -102,109 +148,36 @@ struct SDL_SysWMinfo
|
||||
SDL_SYSWM_TYPE subsystem;
|
||||
union
|
||||
{
|
||||
#if defined(SDL_VIDEO_DRIVER_WIN32)
|
||||
struct
|
||||
{
|
||||
Display *display; /**< The X11 display */
|
||||
Window window; /**< The X11 display window */
|
||||
HWND window; /**< The window handle */
|
||||
} win;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_X11)
|
||||
struct
|
||||
{
|
||||
Display *display; /**< The X11 display */
|
||||
Window window; /**< The X11 window */
|
||||
} x11;
|
||||
} info;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
|
||||
struct
|
||||
{
|
||||
IDirectFB *dfb; /**< The directfb main interface */
|
||||
IDirectFBWindow *window; /**< The directfb window handle */
|
||||
IDirectFBSurface *surface; /**< The directfb client surface */
|
||||
} dfb;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
struct
|
||||
{
|
||||
NSWindow *window; /* The Cocoa window */
|
||||
} cocoa;
|
||||
#endif
|
||||
} /*info*/;
|
||||
};
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
/**
|
||||
* The windows custom event structure.
|
||||
*/
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
HWND hwnd; /**< The window for the message */
|
||||
UINT msg; /**< The type of message */
|
||||
WPARAM wParam; /**< WORD message parameter */
|
||||
LPARAM lParam; /**< LONG message parameter */
|
||||
};
|
||||
|
||||
/**
|
||||
* The windows custom window manager information structure.
|
||||
*/
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
HWND window; /**< The Win32 display window */
|
||||
};
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_RISCOS)
|
||||
|
||||
/**
|
||||
* RISC OS custom event structure.
|
||||
*/
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
int eventCode; /**< The window for the message */
|
||||
int pollBlock[64];
|
||||
};
|
||||
|
||||
/**
|
||||
* The RISC OS custom window manager information structure.
|
||||
*/
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
int wimpVersion; /**< Wimp version running under */
|
||||
int taskHandle; /**< The RISC OS task handle */
|
||||
int window; /**< The RISC OS display window */
|
||||
};
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_PHOTON) || defined(SDL_VIDEO_DRIVER_QNXGF)
|
||||
#include <sys/neutrino.h>
|
||||
#if defined(SDL_VIDEO_OPENGL_ES)
|
||||
#include <gf/gf.h>
|
||||
#endif /* SDL_VIDEO_OPENGL_ES */
|
||||
#include <Ph.h>
|
||||
|
||||
/**
|
||||
* The QNX custom event structure.
|
||||
*/
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
/**
|
||||
* The QNX Photon custom window manager information structure.
|
||||
*/
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* The generic custom event structure.
|
||||
*/
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
/**
|
||||
* The generic custom window manager information structure.
|
||||
*/
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
#endif /* video driver type */
|
||||
|
||||
#endif /* SDL_PROTOTYPES_ONLY */
|
||||
|
||||
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||
@@ -222,7 +195,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||
*
|
||||
* You typically use this function like this:
|
||||
* \code
|
||||
* SDL_SysWMInfo info;
|
||||
* SDL_SysWMinfo info;
|
||||
* SDL_VERSION(&info.version);
|
||||
* if ( SDL_GetWindowWMInfo(&info) ) { ... }
|
||||
* \endcode
|
||||
|
||||
@@ -50,6 +50,11 @@ typedef struct SDL_Thread SDL_Thread;
|
||||
/* The SDL thread ID */
|
||||
typedef unsigned long SDL_threadID;
|
||||
|
||||
/* The function passed to SDL_CreateThread()
|
||||
It is passed a void* user context parameter and returns an int.
|
||||
*/
|
||||
typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
|
||||
|
||||
#if defined(__WIN32__) && !defined(HAVE_LIBC)
|
||||
/**
|
||||
* \file SDL_thread.h
|
||||
@@ -100,7 +105,7 @@ typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
|
||||
* Create a thread.
|
||||
*/
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThread(int (SDLCALL * f) (void *), void *data,
|
||||
SDL_CreateThread(SDL_ThreadFunction fn, void *data,
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||
pfnSDL_CurrentEndThread pfnEndThread);
|
||||
|
||||
@@ -125,7 +130,7 @@ SDL_CreateThread(int (SDLCALL * f) (void *), void *data,
|
||||
* Create a thread.
|
||||
*/
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThread(int (SDLCALL * fn) (void *), void *data);
|
||||
SDL_CreateThread(SDL_ThreadFunction fn, void *data);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
125
project/sdl/sdl-1.3/include/SDL_touch.h
Normal file
125
project/sdl/sdl-1.3/include/SDL_touch.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
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_touch.h
|
||||
*
|
||||
* Include file for SDL touch event handling.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_touch_h
|
||||
#define _SDL_touch_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
|
||||
typedef Sint64 SDL_TouchID;
|
||||
typedef Sint64 SDL_FingerID;
|
||||
|
||||
|
||||
struct SDL_Finger {
|
||||
SDL_FingerID id;
|
||||
Uint16 x;
|
||||
Uint16 y;
|
||||
Uint16 pressure;
|
||||
Uint16 xdelta;
|
||||
Uint16 ydelta;
|
||||
Uint16 last_x, last_y,last_pressure; /* the last reported coordinates */
|
||||
SDL_bool down;
|
||||
};
|
||||
|
||||
typedef struct SDL_Touch SDL_Touch;
|
||||
typedef struct SDL_Finger SDL_Finger;
|
||||
|
||||
|
||||
struct SDL_Touch {
|
||||
|
||||
/* Free the touch when it's time */
|
||||
void (*FreeTouch) (SDL_Touch * touch);
|
||||
|
||||
/* data common for tablets */
|
||||
float pressure_max, pressure_min;
|
||||
float x_max,x_min;
|
||||
float y_max,y_min;
|
||||
Uint16 xres,yres,pressureres;
|
||||
float native_xres,native_yres,native_pressureres;
|
||||
float tilt; /* for future use */
|
||||
float rotation; /* for future use */
|
||||
|
||||
/* Data common to all touch */
|
||||
SDL_TouchID id;
|
||||
SDL_Window *focus;
|
||||
|
||||
char *name;
|
||||
Uint8 buttonstate;
|
||||
SDL_bool relative_mode;
|
||||
SDL_bool flush_motion;
|
||||
|
||||
int num_fingers;
|
||||
int max_fingers;
|
||||
SDL_Finger** fingers;
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Get the touch object at the given id.
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the finger object of the given touch, at the given id.
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern
|
||||
DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mouse_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -112,12 +112,11 @@ typedef struct SDL_version
|
||||
|
||||
/**
|
||||
* \brief Get the version of SDL that is linked against your program.
|
||||
*
|
||||
* If you are using a shared library (DLL) version of SDL, then it is
|
||||
* possible that it will be different than the version you compiled against.
|
||||
*
|
||||
* This is a real function; the macro SDL_VERSION() tells you what version
|
||||
* of SDL you compiled against:
|
||||
* If you are linking to SDL dynamically, then it is possible that the
|
||||
* current version will be different than the version you compiled against.
|
||||
* This function returns the current version, while SDL_VERSION() is a
|
||||
* macro that tells you what version you compiled with.
|
||||
*
|
||||
* \code
|
||||
* SDL_version compiled;
|
||||
@@ -140,8 +139,9 @@ extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
|
||||
/**
|
||||
* \brief Get the code revision of SDL that is linked against your program.
|
||||
*
|
||||
* This is an arbitrary string (a hash value, actually), and is only useful
|
||||
* in comparing against other revisions. It is NOT an incrementing number.
|
||||
* Returns an arbitrary string (a hash value) uniquely identifying the
|
||||
* exact revision of the SDL library in use, and is only useful in comparing
|
||||
* against other revisions. It is NOT an incrementing number.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ typedef struct SDL_RendererInfo
|
||||
Uint32 blend_modes; /**< A mask of supported blend modes */
|
||||
Uint32 scale_modes; /**< A mask of supported scale modes */
|
||||
Uint32 num_texture_formats; /**< The number of available texture formats */
|
||||
Uint32 texture_formats[20]; /**< The available texture formats */
|
||||
Uint32 texture_formats[50]; /**< The available texture formats */
|
||||
int max_texture_width; /**< The maximimum texture width */
|
||||
int max_texture_height; /**< The maximimum texture height */
|
||||
} SDL_RendererInfo;
|
||||
@@ -568,7 +568,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data);
|
||||
|
||||
/**
|
||||
* \brief Get the numeric ID of the window, for logging purposes.
|
||||
* \brief Get the numeric ID of a window, for logging purposes.
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window);
|
||||
|
||||
@@ -583,7 +583,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the title of the window, in UTF-8 format.
|
||||
* \brief Set the title of a window, in UTF-8 format.
|
||||
*
|
||||
* \sa SDL_GetWindowTitle()
|
||||
*/
|
||||
@@ -591,14 +591,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
|
||||
const char *title);
|
||||
|
||||
/**
|
||||
* \brief Get the title of the window, in UTF-8 format.
|
||||
* \brief Get the title of a window, in UTF-8 format.
|
||||
*
|
||||
* \sa SDL_SetWindowTitle()
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the icon of the window.
|
||||
* \brief Set the icon for a window.
|
||||
*
|
||||
* \param icon The icon for the window.
|
||||
*/
|
||||
@@ -606,7 +606,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
|
||||
SDL_Surface * icon);
|
||||
|
||||
/**
|
||||
* \brief Associate an arbitrary pointer with the window.
|
||||
* \brief Associate an arbitrary pointer with a window.
|
||||
*
|
||||
* \sa SDL_GetWindowData()
|
||||
*/
|
||||
@@ -614,14 +614,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowData(SDL_Window * window,
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the data pointer associated with the window.
|
||||
* \brief Retrieve the data pointer associated with a window.
|
||||
*
|
||||
* \sa SDL_SetWindowData()
|
||||
*/
|
||||
extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the position of the window.
|
||||
* \brief Set the position of a window.
|
||||
*
|
||||
* \param window The window to reposition.
|
||||
* \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
|
||||
@@ -637,7 +637,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
|
||||
int x, int y);
|
||||
|
||||
/**
|
||||
* \brief Get the position of the window.
|
||||
* \brief Get the position of a window.
|
||||
*
|
||||
* \sa SDL_SetWindowPosition()
|
||||
*/
|
||||
@@ -645,7 +645,7 @@ extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
|
||||
int *x, int *y);
|
||||
|
||||
/**
|
||||
* \brief Set the size of the window's client area.
|
||||
* \brief Set the size of a window's client area.
|
||||
*
|
||||
* \note You can't change the size of a fullscreen window, it automatically
|
||||
* matches the size of the display mode.
|
||||
@@ -656,7 +656,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
|
||||
int h);
|
||||
|
||||
/**
|
||||
* \brief Get the size of the window's client area.
|
||||
* \brief Get the size of a window's client area.
|
||||
*
|
||||
* \sa SDL_SetWindowSize()
|
||||
*/
|
||||
@@ -664,33 +664,33 @@ extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
|
||||
int *h);
|
||||
|
||||
/**
|
||||
* \brief Show the window.
|
||||
* \brief Show a window.
|
||||
*
|
||||
* \sa SDL_HideWindow()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Hide the window.
|
||||
* \brief Hide a window.
|
||||
*
|
||||
* \sa SDL_ShowWindow()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Raise the window above other windows and set the input focus.
|
||||
* \brief Raise a window above other windows and set the input focus.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Make the window as large as possible.
|
||||
* \brief Make a window as large as possible.
|
||||
*
|
||||
* \sa SDL_RestoreWindow()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Minimize the window to an iconic representation.
|
||||
* \brief Minimize a window to an iconic representation.
|
||||
*
|
||||
* \sa SDL_RestoreWindow()
|
||||
*/
|
||||
@@ -705,7 +705,7 @@ extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window);
|
||||
extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the window's fullscreen state.
|
||||
* \brief Set a window's fullscreen state.
|
||||
*
|
||||
* \return 0 on success, or -1 if setting the display mode failed.
|
||||
*
|
||||
@@ -716,7 +716,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
|
||||
int fullscreen);
|
||||
|
||||
/**
|
||||
* \brief Set the window's input grab mode.
|
||||
* \brief Set a window's input grab mode.
|
||||
*
|
||||
* \param mode This is 1 to grab input, and 0 to release input.
|
||||
*
|
||||
@@ -726,7 +726,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
|
||||
int mode);
|
||||
|
||||
/**
|
||||
* \brief Get the window's input grab mode.
|
||||
* \brief Get a window's input grab mode.
|
||||
*
|
||||
* \return This returns 1 if input is grabbed, and 0 otherwise.
|
||||
*
|
||||
@@ -1164,7 +1164,7 @@ extern DECLSPEC int SDLCALL SDL_RenderClear(void);
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(int x, int y);
|
||||
|
||||
/**
|
||||
* \brief Draw some number of points on the current rendering target.
|
||||
* \brief Draw multiple points on the current rendering target.
|
||||
*
|
||||
* \param points The points to draw
|
||||
* \param count The number of points to draw
|
||||
@@ -1198,7 +1198,7 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawLines(const SDL_Point * points,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* \brief Draw a rectangle on the current rendering target with the drawing color.
|
||||
* \brief Draw a rectangle on the current rendering target.
|
||||
*
|
||||
* \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
|
||||
*
|
||||
@@ -1207,14 +1207,14 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawLines(const SDL_Point * points,
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawRect(const SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Draw some number of rectangles in the current rendering target with the drawing color.
|
||||
* \brief Draw some number of rectangles on the current rendering target.
|
||||
*
|
||||
* \param rects A pointer to an array of destination rectangles.
|
||||
* \param count The number of rectangles.
|
||||
*
|
||||
* \return 0 on success, or -1 if there is no rendering context current.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawRects(const SDL_Rect ** rect, int count);
|
||||
extern DECLSPEC int SDLCALL SDL_RenderDrawRects(const SDL_Rect ** rects, int count);
|
||||
|
||||
/**
|
||||
* \brief Fill a rectangle on the current rendering target with the drawing color.
|
||||
@@ -1227,7 +1227,7 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawRects(const SDL_Rect ** rect, int coun
|
||||
extern DECLSPEC int SDLCALL SDL_RenderFillRect(const SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Fill some number of rectangles in the current rendering target with the drawing color.
|
||||
* \brief Fill some number of rectangles on the current rendering target with the drawing color.
|
||||
*
|
||||
* \param rects A pointer to an array of destination rectangles.
|
||||
* \param count The number of rectangles.
|
||||
@@ -1311,7 +1311,7 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
|
||||
extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Returns whether the screensaver is currently enabled (default off).
|
||||
* \brief Returns whether the screensaver is currently enabled (default on).
|
||||
*
|
||||
* \sa SDL_EnableScreenSaver()
|
||||
* \sa SDL_DisableScreenSaver()
|
||||
@@ -1430,7 +1430,7 @@ extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
|
||||
extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void);
|
||||
|
||||
/**
|
||||
* \brief Swap the OpenGL buffers for the window, if double-buffering is
|
||||
* \brief Swap the OpenGL buffers for a window, if double-buffering is
|
||||
* supported.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window);
|
||||
|
||||
@@ -320,9 +320,9 @@ SDL_VideoPaletteChanged(void *userdata, SDL_Palette * palette)
|
||||
}
|
||||
}
|
||||
if (userdata == SDL_VideoSurface) {
|
||||
if (SDL_SetDisplayPalette(palette->colors, 0, palette->ncolors) < 0) {
|
||||
return -1;
|
||||
}
|
||||
/* The display may not have a palette, but always set texture palette */
|
||||
SDL_SetDisplayPalette(palette->colors, 0, palette->ncolors);
|
||||
|
||||
if (SDL_SetTexturePalette
|
||||
(SDL_VideoTexture, palette->colors, 0, palette->ncolors) < 0) {
|
||||
return -1;
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
/*#define DEBUG_ERROR*/
|
||||
|
||||
/* Routine to get the thread-specific error variable */
|
||||
#if SDL_THREADS_DISABLED
|
||||
/* !!! FIXME: what does this comment mean? Victim of Search and Replace? */
|
||||
/* The SDL_arraysize(The ),default (non-thread-safe) global error variable */
|
||||
/* The default (non-thread-safe) global error variable */
|
||||
static SDL_error SDL_global_error;
|
||||
#define SDL_GetErrBuf() (&SDL_global_error)
|
||||
#else
|
||||
@@ -204,12 +205,12 @@ SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
||||
}
|
||||
|
||||
/* Available for backwards compatibility */
|
||||
char *
|
||||
const char *
|
||||
SDL_GetError(void)
|
||||
{
|
||||
static char errmsg[SDL_ERRBUFIZE];
|
||||
|
||||
return ((char *) SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE));
|
||||
return SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
266
project/sdl/sdl-1.3/src/SDL_error.c.orig
Normal file
266
project/sdl/sdl-1.3/src/SDL_error.c.orig
Normal file
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Simple error handling in SDL */
|
||||
|
||||
#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
|
||||
/* !!! FIXME: what does this comment mean? Victim of Search and Replace? */
|
||||
/* The SDL_arraysize(The ),default (non-thread-safe) global error variable */
|
||||
static SDL_error SDL_global_error;
|
||||
#define SDL_GetErrBuf() (&SDL_global_error)
|
||||
#else
|
||||
extern SDL_error *SDL_GetErrBuf(void);
|
||||
#endif /* SDL_THREADS_DISABLED */
|
||||
|
||||
#define SDL_ERRBUFIZE 1024
|
||||
|
||||
/* Private functions */
|
||||
|
||||
static const char *
|
||||
SDL_LookupString(const char *key)
|
||||
{
|
||||
/* FIXME: Add code to lookup key in language string hash-table */
|
||||
return key;
|
||||
}
|
||||
|
||||
/* Public functions */
|
||||
|
||||
void
|
||||
SDL_SetError(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
SDL_error *error;
|
||||
|
||||
/* Copy in the key, mark error as valid */
|
||||
error = SDL_GetErrBuf();
|
||||
error->error = 1;
|
||||
SDL_strlcpy((char *) error->key, fmt, sizeof(error->key));
|
||||
|
||||
va_start(ap, fmt);
|
||||
error->argc = 0;
|
||||
while (*fmt) {
|
||||
if (*fmt++ == '%') {
|
||||
while (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) {
|
||||
++fmt;
|
||||
}
|
||||
switch (*fmt++) {
|
||||
case 0: /* Malformed format string.. */
|
||||
--fmt;
|
||||
break;
|
||||
case 'c':
|
||||
case 'i':
|
||||
case 'd':
|
||||
case 'u':
|
||||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
error->args[error->argc++].value_i = va_arg(ap, int);
|
||||
break;
|
||||
case 'f':
|
||||
error->args[error->argc++].value_f = va_arg(ap, double);
|
||||
break;
|
||||
case 'p':
|
||||
error->args[error->argc++].value_ptr = va_arg(ap, void *);
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
int i = error->argc;
|
||||
const char *str = va_arg(ap, const char *);
|
||||
if (str == NULL)
|
||||
str = "(null)";
|
||||
SDL_strlcpy((char *) error->args[i].buf, str,
|
||||
ERR_MAX_STRLEN);
|
||||
error->argc++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (error->argc >= ERR_MAX_ARGS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
/* If we are in debug mode, print out an error message */
|
||||
#ifdef DEBUG_ERROR
|
||||
fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_ERROR, "libSDL", "SDL_SetError: %s", SDL_GetError());
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function has a bit more overhead than most error functions
|
||||
so that it supports internationalization and thread-safe errors.
|
||||
*/
|
||||
static char *
|
||||
SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
/* Clear the error string */
|
||||
*errstr = '\0';
|
||||
--maxlen;
|
||||
|
||||
/* Get the thread-safe error, and print it out */
|
||||
error = SDL_GetErrBuf();
|
||||
if (error->error) {
|
||||
const char *fmt;
|
||||
char *msg = errstr;
|
||||
int len;
|
||||
int argi;
|
||||
|
||||
fmt = SDL_LookupString(error->key);
|
||||
argi = 0;
|
||||
while (*fmt && (maxlen > 0)) {
|
||||
if (*fmt == '%') {
|
||||
char tmp[32], *spot = tmp;
|
||||
*spot++ = *fmt++;
|
||||
while ((*fmt == '.' || (*fmt >= '0' && *fmt <= '9'))
|
||||
&& spot < (tmp + SDL_arraysize(tmp) - 2)) {
|
||||
*spot++ = *fmt++;
|
||||
}
|
||||
*spot++ = *fmt++;
|
||||
*spot++ = '\0';
|
||||
switch (spot[-2]) {
|
||||
case '%':
|
||||
*msg++ = '%';
|
||||
maxlen -= 1;
|
||||
break;
|
||||
case 'c':
|
||||
case 'i':
|
||||
case 'd':
|
||||
case 'u':
|
||||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_i);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 'f':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_f);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 'p':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_ptr);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 's':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
SDL_LookupString(error->args[argi++].
|
||||
buf));
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
*msg++ = *fmt++;
|
||||
maxlen -= 1;
|
||||
}
|
||||
}
|
||||
*msg = 0; /* NULL terminate the string */
|
||||
}
|
||||
return (errstr);
|
||||
}
|
||||
|
||||
/* Available for backwards compatibility */
|
||||
char *
|
||||
SDL_GetError(void)
|
||||
{
|
||||
static char errmsg[SDL_ERRBUFIZE];
|
||||
|
||||
return ((char *) SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE));
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ClearError(void)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
error = SDL_GetErrBuf();
|
||||
error->error = 0;
|
||||
}
|
||||
|
||||
/* Very common errors go here */
|
||||
void
|
||||
SDL_Error(SDL_errorcode code)
|
||||
{
|
||||
switch (code) {
|
||||
case SDL_ENOMEM:
|
||||
SDL_SetError("Out of memory");
|
||||
break;
|
||||
case SDL_EFREAD:
|
||||
SDL_SetError("Error reading from datastream");
|
||||
break;
|
||||
case SDL_EFWRITE:
|
||||
SDL_SetError("Error writing to datastream");
|
||||
break;
|
||||
case SDL_EFSEEK:
|
||||
SDL_SetError("Error seeking in datastream");
|
||||
break;
|
||||
case SDL_UNSUPPORTED:
|
||||
SDL_SetError("That operation is not supported");
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown SDL error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST_ERROR
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char buffer[BUFSIZ + 1];
|
||||
|
||||
SDL_SetError("Hi there!");
|
||||
printf("Error 1: %s\n", SDL_GetError());
|
||||
SDL_ClearError();
|
||||
SDL_memset(buffer, '1', BUFSIZ);
|
||||
buffer[BUFSIZ] = 0;
|
||||
SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
|
||||
printf("Error 2: %s\n", SDL_GetError());
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "SDL_audiomem.h"
|
||||
#include "SDL_sysaudio.h"
|
||||
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
#define _THIS SDL_AudioDevice *_this
|
||||
|
||||
static SDL_AudioDriver current_audio;
|
||||
static SDL_AudioDevice *open_devices[16];
|
||||
@@ -321,6 +321,9 @@ SDL_StreamDeinit(SDL_AudioStreamer * stream)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(ANDROID)
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
/* The general mixing thread function */
|
||||
int SDLCALL
|
||||
@@ -336,7 +339,7 @@ SDL_RunAudio(void *devicep)
|
||||
|
||||
/* For streaming when the buffer sizes don't match up */
|
||||
Uint8 *istream;
|
||||
int istream_len;
|
||||
int istream_len = 0;
|
||||
|
||||
/* Perform any thread setup */
|
||||
device->threadid = SDL_ThreadID();
|
||||
@@ -889,7 +892,7 @@ open_audio_device(const char *devname, int iscapture,
|
||||
device->opened = 1;
|
||||
|
||||
/* Allocate a fake audio memory buffer */
|
||||
device->fake_stream = SDL_AllocAudioMem(device->spec.size);
|
||||
device->fake_stream = (Uint8 *)SDL_AllocAudioMem(device->spec.size);
|
||||
if (device->fake_stream == NULL) {
|
||||
close_audio_device(device);
|
||||
SDL_OutOfMemory();
|
||||
|
||||
@@ -2308,7 +2308,7 @@ SDL_Upsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
|
||||
Uint8 sample0 = src[0];
|
||||
Uint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = sample0;
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -2340,7 +2340,7 @@ SDL_Downsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
|
||||
Uint8 sample0 = src[0];
|
||||
Uint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -2374,7 +2374,7 @@ SDL_Upsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint8 sample0 = src[0];
|
||||
Uint8 last_sample1 = sample1;
|
||||
Uint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = sample1;
|
||||
dst[0] = sample0;
|
||||
dst -= 2;
|
||||
@@ -2411,7 +2411,7 @@ SDL_Downsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint8 sample1 = src[1];
|
||||
Uint8 last_sample0 = sample0;
|
||||
Uint8 last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -2452,7 +2452,7 @@ SDL_Upsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint8 last_sample2 = sample2;
|
||||
Uint8 last_sample1 = sample1;
|
||||
Uint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = sample3;
|
||||
dst[2] = sample2;
|
||||
dst[1] = sample1;
|
||||
@@ -2499,7 +2499,7 @@ SDL_Downsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint8 last_sample1 = sample1;
|
||||
Uint8 last_sample2 = sample2;
|
||||
Uint8 last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -2550,7 +2550,7 @@ SDL_Upsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint8 last_sample2 = sample2;
|
||||
Uint8 last_sample1 = sample1;
|
||||
Uint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = sample5;
|
||||
dst[4] = sample4;
|
||||
dst[3] = sample3;
|
||||
@@ -2607,7 +2607,7 @@ SDL_Downsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint8 last_sample3 = sample3;
|
||||
Uint8 last_sample4 = sample4;
|
||||
Uint8 last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -2668,7 +2668,7 @@ SDL_Upsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint8 last_sample2 = sample2;
|
||||
Uint8 last_sample1 = sample1;
|
||||
Uint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = sample7;
|
||||
dst[6] = sample6;
|
||||
dst[5] = sample5;
|
||||
@@ -2735,7 +2735,7 @@ SDL_Downsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint8 last_sample5 = sample5;
|
||||
Uint8 last_sample6 = sample6;
|
||||
Uint8 last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -2788,7 +2788,7 @@ SDL_Upsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
|
||||
Sint8 sample0 = ((Sint8) src[0]);
|
||||
Sint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = ((Sint8) sample0);
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -2820,7 +2820,7 @@ SDL_Downsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
|
||||
Sint8 sample0 = ((Sint8) src[0]);
|
||||
Sint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -2854,7 +2854,7 @@ SDL_Upsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint8 sample0 = ((Sint8) src[0]);
|
||||
Sint8 last_sample1 = sample1;
|
||||
Sint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = ((Sint8) sample1);
|
||||
dst[0] = ((Sint8) sample0);
|
||||
dst -= 2;
|
||||
@@ -2891,7 +2891,7 @@ SDL_Downsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint8 sample1 = ((Sint8) src[1]);
|
||||
Sint8 last_sample0 = sample0;
|
||||
Sint8 last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -2932,7 +2932,7 @@ SDL_Upsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint8 last_sample2 = sample2;
|
||||
Sint8 last_sample1 = sample1;
|
||||
Sint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = ((Sint8) sample3);
|
||||
dst[2] = ((Sint8) sample2);
|
||||
dst[1] = ((Sint8) sample1);
|
||||
@@ -2979,7 +2979,7 @@ SDL_Downsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint8 last_sample1 = sample1;
|
||||
Sint8 last_sample2 = sample2;
|
||||
Sint8 last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3030,7 +3030,7 @@ SDL_Upsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint8 last_sample2 = sample2;
|
||||
Sint8 last_sample1 = sample1;
|
||||
Sint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = ((Sint8) sample5);
|
||||
dst[4] = ((Sint8) sample4);
|
||||
dst[3] = ((Sint8) sample3);
|
||||
@@ -3087,7 +3087,7 @@ SDL_Downsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint8 last_sample3 = sample3;
|
||||
Sint8 last_sample4 = sample4;
|
||||
Sint8 last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3148,7 +3148,7 @@ SDL_Upsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint8 last_sample2 = sample2;
|
||||
Sint8 last_sample1 = sample1;
|
||||
Sint8 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = ((Sint8) sample7);
|
||||
dst[6] = ((Sint8) sample6);
|
||||
dst[5] = ((Sint8) sample5);
|
||||
@@ -3215,7 +3215,7 @@ SDL_Downsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint8 last_sample5 = sample5;
|
||||
Sint8 last_sample6 = sample6;
|
||||
Sint8 last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3268,7 +3268,7 @@ SDL_Upsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
|
||||
Uint16 sample0 = SDL_SwapLE16(src[0]);
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = SDL_SwapLE16(sample0);
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -3300,7 +3300,7 @@ SDL_Downsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
|
||||
Uint16 sample0 = SDL_SwapLE16(src[0]);
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3334,7 +3334,7 @@ SDL_Upsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 sample0 = SDL_SwapLE16(src[0]);
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = SDL_SwapLE16(sample1);
|
||||
dst[0] = SDL_SwapLE16(sample0);
|
||||
dst -= 2;
|
||||
@@ -3371,7 +3371,7 @@ SDL_Downsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 sample1 = SDL_SwapLE16(src[1]);
|
||||
Uint16 last_sample0 = sample0;
|
||||
Uint16 last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3412,7 +3412,7 @@ SDL_Upsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample2 = sample2;
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = SDL_SwapLE16(sample3);
|
||||
dst[2] = SDL_SwapLE16(sample2);
|
||||
dst[1] = SDL_SwapLE16(sample1);
|
||||
@@ -3459,7 +3459,7 @@ SDL_Downsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample2 = sample2;
|
||||
Uint16 last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3510,7 +3510,7 @@ SDL_Upsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample2 = sample2;
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = SDL_SwapLE16(sample5);
|
||||
dst[4] = SDL_SwapLE16(sample4);
|
||||
dst[3] = SDL_SwapLE16(sample3);
|
||||
@@ -3567,7 +3567,7 @@ SDL_Downsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample3 = sample3;
|
||||
Uint16 last_sample4 = sample4;
|
||||
Uint16 last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3628,7 +3628,7 @@ SDL_Upsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample2 = sample2;
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = SDL_SwapLE16(sample7);
|
||||
dst[6] = SDL_SwapLE16(sample6);
|
||||
dst[5] = SDL_SwapLE16(sample5);
|
||||
@@ -3695,7 +3695,7 @@ SDL_Downsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample5 = sample5;
|
||||
Uint16 last_sample6 = sample6;
|
||||
Uint16 last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3748,7 +3748,7 @@ SDL_Upsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
|
||||
Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = ((Sint16) SDL_SwapLE16(sample0));
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -3780,7 +3780,7 @@ SDL_Downsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
|
||||
Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3814,7 +3814,7 @@ SDL_Upsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = ((Sint16) SDL_SwapLE16(sample1));
|
||||
dst[0] = ((Sint16) SDL_SwapLE16(sample0));
|
||||
dst -= 2;
|
||||
@@ -3851,7 +3851,7 @@ SDL_Downsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
|
||||
Sint16 last_sample0 = sample0;
|
||||
Sint16 last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3892,7 +3892,7 @@ SDL_Upsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample2 = sample2;
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = ((Sint16) SDL_SwapLE16(sample3));
|
||||
dst[2] = ((Sint16) SDL_SwapLE16(sample2));
|
||||
dst[1] = ((Sint16) SDL_SwapLE16(sample1));
|
||||
@@ -3939,7 +3939,7 @@ SDL_Downsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample2 = sample2;
|
||||
Sint16 last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -3990,7 +3990,7 @@ SDL_Upsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample2 = sample2;
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = ((Sint16) SDL_SwapLE16(sample5));
|
||||
dst[4] = ((Sint16) SDL_SwapLE16(sample4));
|
||||
dst[3] = ((Sint16) SDL_SwapLE16(sample3));
|
||||
@@ -4047,7 +4047,7 @@ SDL_Downsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample3 = sample3;
|
||||
Sint16 last_sample4 = sample4;
|
||||
Sint16 last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4108,7 +4108,7 @@ SDL_Upsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample2 = sample2;
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = ((Sint16) SDL_SwapLE16(sample7));
|
||||
dst[6] = ((Sint16) SDL_SwapLE16(sample6));
|
||||
dst[5] = ((Sint16) SDL_SwapLE16(sample5));
|
||||
@@ -4175,7 +4175,7 @@ SDL_Downsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample5 = sample5;
|
||||
Sint16 last_sample6 = sample6;
|
||||
Sint16 last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4228,7 +4228,7 @@ SDL_Upsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
|
||||
Uint16 sample0 = SDL_SwapBE16(src[0]);
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = SDL_SwapBE16(sample0);
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -4260,7 +4260,7 @@ SDL_Downsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
|
||||
Uint16 sample0 = SDL_SwapBE16(src[0]);
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4294,7 +4294,7 @@ SDL_Upsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 sample0 = SDL_SwapBE16(src[0]);
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = SDL_SwapBE16(sample1);
|
||||
dst[0] = SDL_SwapBE16(sample0);
|
||||
dst -= 2;
|
||||
@@ -4331,7 +4331,7 @@ SDL_Downsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 sample1 = SDL_SwapBE16(src[1]);
|
||||
Uint16 last_sample0 = sample0;
|
||||
Uint16 last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4372,7 +4372,7 @@ SDL_Upsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample2 = sample2;
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = SDL_SwapBE16(sample3);
|
||||
dst[2] = SDL_SwapBE16(sample2);
|
||||
dst[1] = SDL_SwapBE16(sample1);
|
||||
@@ -4419,7 +4419,7 @@ SDL_Downsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample2 = sample2;
|
||||
Uint16 last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4470,7 +4470,7 @@ SDL_Upsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample2 = sample2;
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = SDL_SwapBE16(sample5);
|
||||
dst[4] = SDL_SwapBE16(sample4);
|
||||
dst[3] = SDL_SwapBE16(sample3);
|
||||
@@ -4527,7 +4527,7 @@ SDL_Downsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample3 = sample3;
|
||||
Uint16 last_sample4 = sample4;
|
||||
Uint16 last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4588,7 +4588,7 @@ SDL_Upsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample2 = sample2;
|
||||
Uint16 last_sample1 = sample1;
|
||||
Uint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = SDL_SwapBE16(sample7);
|
||||
dst[6] = SDL_SwapBE16(sample6);
|
||||
dst[5] = SDL_SwapBE16(sample5);
|
||||
@@ -4655,7 +4655,7 @@ SDL_Downsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Uint16 last_sample5 = sample5;
|
||||
Uint16 last_sample6 = sample6;
|
||||
Uint16 last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4708,7 +4708,7 @@ SDL_Upsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
|
||||
Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = ((Sint16) SDL_SwapBE16(sample0));
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -4740,7 +4740,7 @@ SDL_Downsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
|
||||
Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4774,7 +4774,7 @@ SDL_Upsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = ((Sint16) SDL_SwapBE16(sample1));
|
||||
dst[0] = ((Sint16) SDL_SwapBE16(sample0));
|
||||
dst -= 2;
|
||||
@@ -4811,7 +4811,7 @@ SDL_Downsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
|
||||
Sint16 last_sample0 = sample0;
|
||||
Sint16 last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4852,7 +4852,7 @@ SDL_Upsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample2 = sample2;
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = ((Sint16) SDL_SwapBE16(sample3));
|
||||
dst[2] = ((Sint16) SDL_SwapBE16(sample2));
|
||||
dst[1] = ((Sint16) SDL_SwapBE16(sample1));
|
||||
@@ -4899,7 +4899,7 @@ SDL_Downsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample2 = sample2;
|
||||
Sint16 last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -4950,7 +4950,7 @@ SDL_Upsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample2 = sample2;
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = ((Sint16) SDL_SwapBE16(sample5));
|
||||
dst[4] = ((Sint16) SDL_SwapBE16(sample4));
|
||||
dst[3] = ((Sint16) SDL_SwapBE16(sample3));
|
||||
@@ -5007,7 +5007,7 @@ SDL_Downsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample3 = sample3;
|
||||
Sint16 last_sample4 = sample4;
|
||||
Sint16 last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5068,7 +5068,7 @@ SDL_Upsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample2 = sample2;
|
||||
Sint16 last_sample1 = sample1;
|
||||
Sint16 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = ((Sint16) SDL_SwapBE16(sample7));
|
||||
dst[6] = ((Sint16) SDL_SwapBE16(sample6));
|
||||
dst[5] = ((Sint16) SDL_SwapBE16(sample5));
|
||||
@@ -5135,7 +5135,7 @@ SDL_Downsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint16 last_sample5 = sample5;
|
||||
Sint16 last_sample6 = sample6;
|
||||
Sint16 last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5188,7 +5188,7 @@ SDL_Upsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
|
||||
Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = ((Sint32) SDL_SwapLE32(sample0));
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -5220,7 +5220,7 @@ SDL_Downsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
|
||||
Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5254,7 +5254,7 @@ SDL_Upsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = ((Sint32) SDL_SwapLE32(sample1));
|
||||
dst[0] = ((Sint32) SDL_SwapLE32(sample0));
|
||||
dst -= 2;
|
||||
@@ -5291,7 +5291,7 @@ SDL_Downsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
|
||||
Sint32 last_sample0 = sample0;
|
||||
Sint32 last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5332,7 +5332,7 @@ SDL_Upsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample2 = sample2;
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = ((Sint32) SDL_SwapLE32(sample3));
|
||||
dst[2] = ((Sint32) SDL_SwapLE32(sample2));
|
||||
dst[1] = ((Sint32) SDL_SwapLE32(sample1));
|
||||
@@ -5379,7 +5379,7 @@ SDL_Downsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample2 = sample2;
|
||||
Sint32 last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5430,7 +5430,7 @@ SDL_Upsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample2 = sample2;
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = ((Sint32) SDL_SwapLE32(sample5));
|
||||
dst[4] = ((Sint32) SDL_SwapLE32(sample4));
|
||||
dst[3] = ((Sint32) SDL_SwapLE32(sample3));
|
||||
@@ -5487,7 +5487,7 @@ SDL_Downsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample3 = sample3;
|
||||
Sint32 last_sample4 = sample4;
|
||||
Sint32 last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5548,7 +5548,7 @@ SDL_Upsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample2 = sample2;
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = ((Sint32) SDL_SwapLE32(sample7));
|
||||
dst[6] = ((Sint32) SDL_SwapLE32(sample6));
|
||||
dst[5] = ((Sint32) SDL_SwapLE32(sample5));
|
||||
@@ -5615,7 +5615,7 @@ SDL_Downsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample5 = sample5;
|
||||
Sint32 last_sample6 = sample6;
|
||||
Sint32 last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5668,7 +5668,7 @@ SDL_Upsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
|
||||
Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = ((Sint32) SDL_SwapBE32(sample0));
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -5700,7 +5700,7 @@ SDL_Downsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
|
||||
Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5734,7 +5734,7 @@ SDL_Upsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = ((Sint32) SDL_SwapBE32(sample1));
|
||||
dst[0] = ((Sint32) SDL_SwapBE32(sample0));
|
||||
dst -= 2;
|
||||
@@ -5771,7 +5771,7 @@ SDL_Downsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
|
||||
Sint32 last_sample0 = sample0;
|
||||
Sint32 last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5812,7 +5812,7 @@ SDL_Upsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample2 = sample2;
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = ((Sint32) SDL_SwapBE32(sample3));
|
||||
dst[2] = ((Sint32) SDL_SwapBE32(sample2));
|
||||
dst[1] = ((Sint32) SDL_SwapBE32(sample1));
|
||||
@@ -5859,7 +5859,7 @@ SDL_Downsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample2 = sample2;
|
||||
Sint32 last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -5910,7 +5910,7 @@ SDL_Upsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample2 = sample2;
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = ((Sint32) SDL_SwapBE32(sample5));
|
||||
dst[4] = ((Sint32) SDL_SwapBE32(sample4));
|
||||
dst[3] = ((Sint32) SDL_SwapBE32(sample3));
|
||||
@@ -5967,7 +5967,7 @@ SDL_Downsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample3 = sample3;
|
||||
Sint32 last_sample4 = sample4;
|
||||
Sint32 last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6028,7 +6028,7 @@ SDL_Upsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample2 = sample2;
|
||||
Sint32 last_sample1 = sample1;
|
||||
Sint32 last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = ((Sint32) SDL_SwapBE32(sample7));
|
||||
dst[6] = ((Sint32) SDL_SwapBE32(sample6));
|
||||
dst[5] = ((Sint32) SDL_SwapBE32(sample5));
|
||||
@@ -6095,7 +6095,7 @@ SDL_Downsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
Sint32 last_sample5 = sample5;
|
||||
Sint32 last_sample6 = sample6;
|
||||
Sint32 last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6148,7 +6148,7 @@ SDL_Upsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const float *target = ((const float *) cvt->buf) - 1;
|
||||
float sample0 = SDL_SwapFloatLE(src[0]);
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = SDL_SwapFloatLE(sample0);
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -6180,7 +6180,7 @@ SDL_Downsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const float *target = (const float *) (cvt->buf + dstsize);
|
||||
float sample0 = SDL_SwapFloatLE(src[0]);
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6214,7 +6214,7 @@ SDL_Upsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float sample0 = SDL_SwapFloatLE(src[0]);
|
||||
float last_sample1 = sample1;
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = SDL_SwapFloatLE(sample1);
|
||||
dst[0] = SDL_SwapFloatLE(sample0);
|
||||
dst -= 2;
|
||||
@@ -6251,7 +6251,7 @@ SDL_Downsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float sample1 = SDL_SwapFloatLE(src[1]);
|
||||
float last_sample0 = sample0;
|
||||
float last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6292,7 +6292,7 @@ SDL_Upsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample2 = sample2;
|
||||
float last_sample1 = sample1;
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = SDL_SwapFloatLE(sample3);
|
||||
dst[2] = SDL_SwapFloatLE(sample2);
|
||||
dst[1] = SDL_SwapFloatLE(sample1);
|
||||
@@ -6339,7 +6339,7 @@ SDL_Downsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample1 = sample1;
|
||||
float last_sample2 = sample2;
|
||||
float last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6390,7 +6390,7 @@ SDL_Upsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample2 = sample2;
|
||||
float last_sample1 = sample1;
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = SDL_SwapFloatLE(sample5);
|
||||
dst[4] = SDL_SwapFloatLE(sample4);
|
||||
dst[3] = SDL_SwapFloatLE(sample3);
|
||||
@@ -6447,7 +6447,7 @@ SDL_Downsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample3 = sample3;
|
||||
float last_sample4 = sample4;
|
||||
float last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6508,7 +6508,7 @@ SDL_Upsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample2 = sample2;
|
||||
float last_sample1 = sample1;
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = SDL_SwapFloatLE(sample7);
|
||||
dst[6] = SDL_SwapFloatLE(sample6);
|
||||
dst[5] = SDL_SwapFloatLE(sample5);
|
||||
@@ -6575,7 +6575,7 @@ SDL_Downsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample5 = sample5;
|
||||
float last_sample6 = sample6;
|
||||
float last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6628,7 +6628,7 @@ SDL_Upsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const float *target = ((const float *) cvt->buf) - 1;
|
||||
float sample0 = SDL_SwapFloatBE(src[0]);
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[0] = SDL_SwapFloatBE(sample0);
|
||||
dst--;
|
||||
eps += srcsize;
|
||||
@@ -6660,7 +6660,7 @@ SDL_Downsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
const float *target = (const float *) (cvt->buf + dstsize);
|
||||
float sample0 = SDL_SwapFloatBE(src[0]);
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src++;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6694,7 +6694,7 @@ SDL_Upsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float sample0 = SDL_SwapFloatBE(src[0]);
|
||||
float last_sample1 = sample1;
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[1] = SDL_SwapFloatBE(sample1);
|
||||
dst[0] = SDL_SwapFloatBE(sample0);
|
||||
dst -= 2;
|
||||
@@ -6731,7 +6731,7 @@ SDL_Downsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float sample1 = SDL_SwapFloatBE(src[1]);
|
||||
float last_sample0 = sample0;
|
||||
float last_sample1 = sample1;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 2;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6772,7 +6772,7 @@ SDL_Upsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample2 = sample2;
|
||||
float last_sample1 = sample1;
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[3] = SDL_SwapFloatBE(sample3);
|
||||
dst[2] = SDL_SwapFloatBE(sample2);
|
||||
dst[1] = SDL_SwapFloatBE(sample1);
|
||||
@@ -6819,7 +6819,7 @@ SDL_Downsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample1 = sample1;
|
||||
float last_sample2 = sample2;
|
||||
float last_sample3 = sample3;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 4;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6870,7 +6870,7 @@ SDL_Upsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample2 = sample2;
|
||||
float last_sample1 = sample1;
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[5] = SDL_SwapFloatBE(sample5);
|
||||
dst[4] = SDL_SwapFloatBE(sample4);
|
||||
dst[3] = SDL_SwapFloatBE(sample3);
|
||||
@@ -6927,7 +6927,7 @@ SDL_Downsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample3 = sample3;
|
||||
float last_sample4 = sample4;
|
||||
float last_sample5 = sample5;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 6;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
@@ -6988,7 +6988,7 @@ SDL_Upsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample2 = sample2;
|
||||
float last_sample1 = sample1;
|
||||
float last_sample0 = sample0;
|
||||
while (dst != target) {
|
||||
while (dst > target) {
|
||||
dst[7] = SDL_SwapFloatBE(sample7);
|
||||
dst[6] = SDL_SwapFloatBE(sample6);
|
||||
dst[5] = SDL_SwapFloatBE(sample5);
|
||||
@@ -7055,7 +7055,7 @@ SDL_Downsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
float last_sample5 = sample5;
|
||||
float last_sample6 = sample6;
|
||||
float last_sample7 = sample7;
|
||||
while (dst != target) {
|
||||
while (dst < target) {
|
||||
src += 8;
|
||||
eps += dstsize;
|
||||
if ((eps << 1) >= srcsize) {
|
||||
|
||||
@@ -38,7 +38,7 @@ sub outputHeader {
|
||||
/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2009 Sam Lantinga
|
||||
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
|
||||
@@ -400,15 +400,19 @@ ${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||
register int eps = 0;
|
||||
EOF
|
||||
|
||||
my $endcomparison = '!=';
|
||||
|
||||
# Upsampling (growing the buffer) needs to work backwards, since we
|
||||
# overwrite the buffer as we go.
|
||||
if ($upsample) {
|
||||
$endcomparison = '>'; # dst > target
|
||||
print <<EOF;
|
||||
$fctype *dst = (($fctype *) (cvt->buf + dstsize)) - $channels;
|
||||
const $fctype *src = (($fctype *) (cvt->buf + cvt->len_cvt)) - $channels;
|
||||
const $fctype *target = ((const $fctype *) cvt->buf) - $channels;
|
||||
EOF
|
||||
} else {
|
||||
$endcomparison = '<'; # dst < target
|
||||
print <<EOF;
|
||||
$fctype *dst = ($fctype *) cvt->buf;
|
||||
const $fctype *src = ($fctype *) cvt->buf;
|
||||
@@ -432,7 +436,7 @@ EOF
|
||||
}
|
||||
|
||||
print <<EOF;
|
||||
while (dst != target) {
|
||||
while (dst $endcomparison target) {
|
||||
EOF
|
||||
|
||||
if ($upsample) {
|
||||
|
||||
@@ -92,11 +92,13 @@ SDL_Unlock_EventThread(void)
|
||||
static __inline__ SDL_bool
|
||||
SDL_ShouldPollJoystick()
|
||||
{
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
if (SDL_numjoysticks &&
|
||||
(!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] ||
|
||||
SDL_JoystickEventState(SDL_QUERY))) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -254,6 +256,7 @@ SDL_StartEventLoop(Uint32 flags)
|
||||
retcode = 0;
|
||||
retcode += SDL_KeyboardInit();
|
||||
retcode += SDL_MouseInit();
|
||||
retcode += SDL_TouchInit();
|
||||
retcode += SDL_QuitInit();
|
||||
if (retcode < 0) {
|
||||
/* We don't expect them to fail, but... */
|
||||
@@ -492,6 +495,10 @@ SDL_PushEvent(SDL_Event * event)
|
||||
if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_GestureProcessEvent(event);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_mouse_c.h"
|
||||
#include "SDL_keyboard_c.h"
|
||||
#include "SDL_touch_c.h"
|
||||
#include "SDL_windowevents_c.h"
|
||||
|
||||
#include "SDL_gesture_c.h"
|
||||
/* Start and stop the event processing loop */
|
||||
extern int SDL_StartEventLoop(Uint32 flags);
|
||||
extern void SDL_StopEventLoop(void);
|
||||
|
||||
663
project/sdl/sdl-1.3/src/events/SDL_gesture.c
Normal file
663
project/sdl/sdl-1.3/src/events/SDL_gesture.c
Normal file
@@ -0,0 +1,663 @@
|
||||
/*
|
||||
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 Founation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* General mouse handling code for SDL */
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_gesture_c.h"
|
||||
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
//TODO: Replace with malloc
|
||||
|
||||
#define MAXPATHSIZE 1024
|
||||
|
||||
|
||||
|
||||
|
||||
#define DOLLARNPOINTS 64
|
||||
#define DOLLARSIZE 256
|
||||
|
||||
#define ENABLE_DOLLAR
|
||||
|
||||
#define PHI 0.618033989
|
||||
|
||||
typedef struct {
|
||||
float x,y;
|
||||
} SDL_FloatPoint;
|
||||
|
||||
typedef struct {
|
||||
float length;
|
||||
|
||||
int numPoints;
|
||||
SDL_FloatPoint p[MAXPATHSIZE];
|
||||
} SDL_DollarPath;
|
||||
|
||||
typedef struct {
|
||||
SDL_FloatPoint path[DOLLARNPOINTS];
|
||||
unsigned long hash;
|
||||
} SDL_DollarTemplate;
|
||||
|
||||
typedef struct {
|
||||
SDL_GestureID id;
|
||||
SDL_FloatPoint res;
|
||||
SDL_FloatPoint centroid;
|
||||
SDL_DollarPath dollarPath;
|
||||
Uint16 numDownFingers;
|
||||
|
||||
int numDollarTemplates;
|
||||
SDL_DollarTemplate *dollarTemplate;
|
||||
|
||||
SDL_bool recording;
|
||||
} SDL_GestureTouch;
|
||||
|
||||
SDL_GestureTouch *SDL_gestureTouch;
|
||||
int SDL_numGestureTouches = 0;
|
||||
SDL_bool recordAll;
|
||||
|
||||
#if 0
|
||||
static void PrintPath(SDL_FloatPoint *path) {
|
||||
int i;
|
||||
printf("Path:");
|
||||
for(i=0;i<DOLLARNPOINTS;i++) {
|
||||
printf(" (%f,%f)",path[i].x,path[i].y);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
int SDL_RecordGesture(SDL_TouchID touchId) {
|
||||
int i;
|
||||
if(touchId < 0) recordAll = SDL_TRUE;
|
||||
for(i = 0;i < SDL_numGestureTouches; i++) {
|
||||
if((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) {
|
||||
SDL_gestureTouch[i].recording = SDL_TRUE;
|
||||
if(touchId >= 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return (touchId < 0);
|
||||
}
|
||||
|
||||
unsigned long SDL_HashDollar(SDL_FloatPoint* points) {
|
||||
unsigned long hash = 5381;
|
||||
int i;
|
||||
for(i = 0;i < DOLLARNPOINTS; i++) {
|
||||
hash = ((hash<<5) + hash) + (unsigned long)points[i].x;
|
||||
hash = ((hash<<5) + hash) + (unsigned long)points[i].y;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) {
|
||||
if(src == NULL) return 0;
|
||||
|
||||
|
||||
//No Longer storing the Hash, rehash on load
|
||||
//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)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int SDL_SaveAllDollarTemplates(SDL_RWops *src) {
|
||||
int i,j,rtrn = 0;
|
||||
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);
|
||||
}
|
||||
}
|
||||
return rtrn;
|
||||
}
|
||||
|
||||
int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) {
|
||||
int i,j;
|
||||
for(i = 0; i < SDL_numGestureTouches; i++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_SetError("Unknown gestureId");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//path is an already sampled set of points
|
||||
//Returns the index of the gesture on success, or -1
|
||||
static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch,SDL_FloatPoint* path) {
|
||||
SDL_DollarTemplate* dollarTemplate;
|
||||
SDL_DollarTemplate *templ;
|
||||
int i = 0;
|
||||
if(inTouch == NULL) {
|
||||
if(SDL_numGestureTouches == 0) return -1;
|
||||
for(i = 0;i < SDL_numGestureTouches; i++) {
|
||||
inTouch = &SDL_gestureTouch[i];
|
||||
|
||||
dollarTemplate =
|
||||
(SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
|
||||
(inTouch->numDollarTemplates + 1) *
|
||||
sizeof(SDL_DollarTemplate));
|
||||
if(!dollarTemplate) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
inTouch->dollarTemplate = dollarTemplate;
|
||||
|
||||
templ =
|
||||
&inTouch->dollarTemplate[inTouch->numDollarTemplates];
|
||||
SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
|
||||
templ->hash = SDL_HashDollar(templ->path);
|
||||
inTouch->numDollarTemplates++;
|
||||
}
|
||||
return inTouch->numDollarTemplates - 1;
|
||||
} else {
|
||||
SDL_DollarTemplate* dollarTemplate =
|
||||
( SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
|
||||
(inTouch->numDollarTemplates + 1) *
|
||||
sizeof(SDL_DollarTemplate));
|
||||
if(!dollarTemplate) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
inTouch->dollarTemplate = dollarTemplate;
|
||||
|
||||
templ =
|
||||
&inTouch->dollarTemplate[inTouch->numDollarTemplates];
|
||||
SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
|
||||
templ->hash = SDL_HashDollar(templ->path);
|
||||
inTouch->numDollarTemplates++;
|
||||
return inTouch->numDollarTemplates - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) {
|
||||
int i,loaded = 0;
|
||||
SDL_GestureTouch *touch = NULL;
|
||||
if(src == NULL) return 0;
|
||||
if(touchId >= 0) {
|
||||
for(i = 0;i < SDL_numGestureTouches; i++)
|
||||
if(SDL_gestureTouch[i].id == touchId)
|
||||
touch = &SDL_gestureTouch[i];
|
||||
if(touch == NULL) return -1;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
SDL_DollarTemplate templ;
|
||||
|
||||
if(SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) <
|
||||
DOLLARNPOINTS) break;
|
||||
|
||||
if(touchId >= 0) {
|
||||
//printf("Adding loaded gesture to 1 touch\n");
|
||||
if(SDL_AddDollarGesture(touch,templ.path)) loaded++;
|
||||
}
|
||||
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);
|
||||
}
|
||||
loaded++;
|
||||
}
|
||||
}
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
|
||||
float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) {
|
||||
// SDL_FloatPoint p[DOLLARNPOINTS];
|
||||
float dist = 0;
|
||||
SDL_FloatPoint p;
|
||||
int i;
|
||||
for(i = 0; i < DOLLARNPOINTS; i++) {
|
||||
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)));
|
||||
}
|
||||
return dist/DOLLARNPOINTS;
|
||||
|
||||
}
|
||||
|
||||
float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) {
|
||||
//------------BEGIN DOLLAR BLACKBOX----------------//
|
||||
//-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-//
|
||||
//-"http://depts.washington.edu/aimgroup/proj/dollar/"-//
|
||||
double ta = -M_PI/4;
|
||||
double tb = M_PI/4;
|
||||
double dt = M_PI/90;
|
||||
float x1 = (float)(PHI*ta + (1-PHI)*tb);
|
||||
float f1 = dollarDifference(points,templ,x1);
|
||||
float x2 = (float)((1-PHI)*ta + PHI*tb);
|
||||
float f2 = dollarDifference(points,templ,x2);
|
||||
while(SDL_fabs(ta-tb) > dt) {
|
||||
if(f1 < f2) {
|
||||
tb = x2;
|
||||
x2 = x1;
|
||||
f2 = f1;
|
||||
x1 = (float)(PHI*ta + (1-PHI)*tb);
|
||||
f1 = dollarDifference(points,templ,x1);
|
||||
}
|
||||
else {
|
||||
ta = x1;
|
||||
x1 = x2;
|
||||
f1 = f2;
|
||||
x2 = (float)((1-PHI)*ta + PHI*tb);
|
||||
f2 = dollarDifference(points,templ,x2);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if(f1 <= f2)
|
||||
printf("Min angle (x1): %f\n",x1);
|
||||
else if(f1 > f2)
|
||||
printf("Min angle (x2): %f\n",x2);
|
||||
*/
|
||||
return SDL_min(f1,f2);
|
||||
}
|
||||
|
||||
//DollarPath contains raw points, plus (possibly) the calculated length
|
||||
int dollarNormalize(SDL_DollarPath path,SDL_FloatPoint *points) {
|
||||
int i;
|
||||
float interval;
|
||||
float dist;
|
||||
int numPoints = 0;
|
||||
SDL_FloatPoint centroid;
|
||||
float xmin,xmax,ymin,ymax;
|
||||
float ang;
|
||||
float w,h;
|
||||
|
||||
//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));
|
||||
}
|
||||
}
|
||||
|
||||
//Resample
|
||||
interval = path.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("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);
|
||||
centroid.x += points[numPoints].x;
|
||||
centroid.y += points[numPoints].y;
|
||||
numPoints++;
|
||||
|
||||
dist -= interval;
|
||||
}
|
||||
dist += d;
|
||||
}
|
||||
if(numPoints < DOLLARNPOINTS-1) {
|
||||
SDL_SetError("ERROR: NumPoints = %i\n",numPoints);
|
||||
return 0;
|
||||
}
|
||||
//copy the last point
|
||||
points[DOLLARNPOINTS-1] = path.p[path.numPoints-1];
|
||||
numPoints = DOLLARNPOINTS;
|
||||
|
||||
centroid.x /= numPoints;
|
||||
centroid.y /= numPoints;
|
||||
|
||||
//printf("Centroid (%f,%f)",centroid.x,centroid.y);
|
||||
//Rotate Points so point 0 is left of centroid and solve for the bounding box
|
||||
xmin = centroid.x;
|
||||
xmax = centroid.x;
|
||||
ymin = centroid.y;
|
||||
ymax = centroid.y;
|
||||
|
||||
ang = (float)(SDL_atan2(centroid.y - points[0].y,
|
||||
centroid.x - points[0].x));
|
||||
|
||||
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) -
|
||||
(py - centroid.y)*SDL_sin(ang) + centroid.x);
|
||||
points[i].y = (float)((px - centroid.x)*SDL_sin(ang) +
|
||||
(py - centroid.y)*SDL_cos(ang) + centroid.y);
|
||||
|
||||
|
||||
if(points[i].x < xmin) xmin = points[i].x;
|
||||
if(points[i].x > xmax) xmax = points[i].x;
|
||||
if(points[i].y < ymin) ymin = points[i].y;
|
||||
if(points[i].y > ymax) ymax = points[i].y;
|
||||
}
|
||||
|
||||
//Scale points to DOLLARSIZE, and translate to the origin
|
||||
w = xmax-xmin;
|
||||
h = ymax-ymin;
|
||||
|
||||
for(i=0;i<numPoints;i++) {
|
||||
points[i].x = (points[i].x - centroid.x)*DOLLARSIZE/w;
|
||||
points[i].y = (points[i].y - centroid.y)*DOLLARSIZE/h;
|
||||
}
|
||||
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;
|
||||
|
||||
//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));
|
||||
|
||||
if(!gestureTouch) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_gestureTouch = gestureTouch;
|
||||
|
||||
SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres;
|
||||
SDL_gestureTouch[SDL_numGestureTouches].res.y = touch->yres;
|
||||
SDL_gestureTouch[SDL_numGestureTouches].numDownFingers = 0;
|
||||
|
||||
SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres;
|
||||
SDL_gestureTouch[SDL_numGestureTouches].id = touch->id;
|
||||
|
||||
SDL_gestureTouch[SDL_numGestureTouches].numDollarTemplates = 0;
|
||||
|
||||
SDL_gestureTouch[SDL_numGestureTouches].recording = SDL_FALSE;
|
||||
|
||||
SDL_numGestureTouches++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_GestureRemoveTouch(SDL_TouchID id) {
|
||||
int i;
|
||||
for (i = 0; i < SDL_numGestureTouches; i++) {
|
||||
if (SDL_gestureTouch[i].id == id) {
|
||||
SDL_numGestureTouches--;
|
||||
SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i]));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) {
|
||||
int i;
|
||||
for(i = 0;i < SDL_numGestureTouches; i++) {
|
||||
//printf("%i ?= %i\n",SDL_gestureTouch[i].id,id);
|
||||
if(SDL_gestureTouch[i].id == id) return &SDL_gestureTouch[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) {
|
||||
SDL_Event event;
|
||||
event.mgesture.type = SDL_MULTIGESTURE;
|
||||
event.mgesture.touchId = touch->id;
|
||||
event.mgesture.x = touch->centroid.x;
|
||||
event.mgesture.y = touch->centroid.y;
|
||||
event.mgesture.dTheta = dTheta;
|
||||
event.mgesture.dDist = dDist;
|
||||
event.mgesture.numFingers = touch->numDownFingers;
|
||||
return SDL_PushEvent(&event) > 0;
|
||||
}
|
||||
|
||||
int SDL_SendGestureDollar(SDL_GestureTouch* touch,
|
||||
SDL_GestureID gestureId,float error) {
|
||||
SDL_Event event;
|
||||
event.dgesture.type = SDL_DOLLARGESTURE;
|
||||
event.dgesture.touchId = touch->id;
|
||||
/*
|
||||
//TODO: Add this to give location of gesture?
|
||||
event.mgesture.x = touch->centroid.x;
|
||||
event.mgesture.y = touch->centroid.y;
|
||||
*/
|
||||
event.dgesture.gestureId = gestureId;
|
||||
event.dgesture.error = error;
|
||||
//A finger came up to trigger this event.
|
||||
event.dgesture.numFingers = touch->numDownFingers + 1;
|
||||
return SDL_PushEvent(&event) > 0;
|
||||
}
|
||||
|
||||
|
||||
int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) {
|
||||
SDL_Event event;
|
||||
event.dgesture.type = SDL_DOLLARRECORD;
|
||||
event.dgesture.touchId = touch->id;
|
||||
event.dgesture.gestureId = gestureId;
|
||||
return SDL_PushEvent(&event) > 0;
|
||||
}
|
||||
|
||||
|
||||
void SDL_GestureProcessEvent(SDL_Event* event)
|
||||
{
|
||||
float x,y;
|
||||
SDL_FloatPoint path[DOLLARNPOINTS];
|
||||
int index;
|
||||
int i;
|
||||
float pathDx, pathDy;
|
||||
SDL_FloatPoint lastP;
|
||||
SDL_FloatPoint lastCentroid;
|
||||
float lDist;
|
||||
float Dist;
|
||||
float dtheta;
|
||||
float dDist;
|
||||
|
||||
if(event->type == SDL_FINGERMOTION ||
|
||||
event->type == SDL_FINGERDOWN ||
|
||||
event->type == SDL_FINGERUP) {
|
||||
SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId);
|
||||
|
||||
//Shouldn't be possible
|
||||
if(inTouch == NULL) return;
|
||||
|
||||
//printf("@ (%i,%i) with res: (%i,%i)\n",(int)event->tfinger.x,
|
||||
// (int)event->tfinger.y,
|
||||
// (int)inTouch->res.x,(int)inTouch->res.y);
|
||||
|
||||
|
||||
x = ((float)event->tfinger.x)/(float)inTouch->res.x;
|
||||
y = ((float)event->tfinger.y)/(float)inTouch->res.y;
|
||||
|
||||
|
||||
//Finger Up
|
||||
if(event->type == SDL_FINGERUP) {
|
||||
inTouch->numDownFingers--;
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
else if(event->type == SDL_FINGERMOTION) {
|
||||
float dx = ((float)event->tfinger.dx)/(float)inTouch->res.x;
|
||||
float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y;
|
||||
//printf("dx,dy: (%f,%f)\n",dx,dy);
|
||||
#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++;
|
||||
}
|
||||
#endif
|
||||
lastP.x = x - dx;
|
||||
lastP.y = y - dy;
|
||||
lastCentroid = inTouch->centroid;
|
||||
|
||||
inTouch->centroid.x += dx/inTouch->numDownFingers;
|
||||
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);
|
||||
}
|
||||
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].f.p.x = x;
|
||||
//inTouch->gestureLast[j].f.p.y = y;
|
||||
//break;
|
||||
//pressure?
|
||||
}
|
||||
|
||||
if(event->type == SDL_FINGERDOWN) {
|
||||
|
||||
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;
|
||||
//printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
|
||||
// inTouch->centroid.x,inTouch->centroid.y);
|
||||
|
||||
#ifdef ENABLE_DOLLAR
|
||||
inTouch->dollarPath.length = 0;
|
||||
inTouch->dollarPath.p[0].x = x;
|
||||
inTouch->dollarPath.p[0].y = y;
|
||||
inTouch->dollarPath.numPoints = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
35
project/sdl/sdl-1.3/src/events/SDL_gesture_c.h
Normal file
35
project/sdl/sdl-1.3/src/events/SDL_gesture_c.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_gesture_c_h
|
||||
#define _SDL_gesture_c_h
|
||||
|
||||
extern void SDL_GestureProcessEvent(SDL_Event* event);
|
||||
|
||||
extern int SDL_RecordGesture(SDL_TouchID touchId);
|
||||
|
||||
extern int SDL_GestureAddTouch(SDL_Touch* touch);
|
||||
|
||||
#endif /* _SDL_gesture_c_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -566,7 +566,7 @@ SDL_ResetKeyboard(void)
|
||||
|
||||
for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
||||
if (keyboard->keystate[scancode] == SDL_PRESSED) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -612,6 +612,14 @@ SDL_SetKeyboardFocus(SDL_Window * window)
|
||||
if (keyboard->focus && keyboard->focus != window) {
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
|
||||
0, 0);
|
||||
|
||||
/* Ensures IME compositions are committed */
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
SDL_VideoDevice *video = SDL_GetVideoDevice();
|
||||
if (video && video->StopTextInput) {
|
||||
video->StopTextInput(video);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keyboard->focus = window;
|
||||
@@ -621,18 +629,22 @@ SDL_SetKeyboardFocus(SDL_Window * window)
|
||||
0, 0);
|
||||
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
SDL_StartTextInput();
|
||||
SDL_VideoDevice *video = SDL_GetVideoDevice();
|
||||
if (video && video->StartTextInput) {
|
||||
video->StartTextInput(video);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode, SDL_bool repeat)
|
||||
SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
int posted;
|
||||
Uint16 modstate;
|
||||
Uint32 type;
|
||||
Uint8 repeat;
|
||||
|
||||
if (!scancode) {
|
||||
return 0;
|
||||
@@ -732,6 +744,7 @@ SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode, SDL_bool repeat)
|
||||
}
|
||||
|
||||
/* Drop events that don't change state */
|
||||
repeat = (state && keyboard->keystate[scancode]);
|
||||
if (keyboard->keystate[scancode] == state && !repeat) {
|
||||
#if 0
|
||||
printf("Keyboard event didn't change state - dropped!\n");
|
||||
@@ -748,7 +761,7 @@ SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode, SDL_bool repeat)
|
||||
SDL_Event event;
|
||||
event.key.type = type;
|
||||
event.key.state = state;
|
||||
event.key.repeat = repeat ? 1 : 0;
|
||||
event.key.repeat = repeat;
|
||||
event.key.keysym.scancode = scancode;
|
||||
event.key.keysym.sym = keyboard->keymap[scancode];
|
||||
event.key.keysym.mod = modstate;
|
||||
@@ -766,7 +779,7 @@ SDL_SendKeyboardText(const char *text)
|
||||
int posted;
|
||||
|
||||
/* Don't post text events for unprintable characters */
|
||||
if (*text < ' ' || *text == 127) {
|
||||
if ((unsigned char)*text < ' ' || *text == 127) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -776,7 +789,7 @@ SDL_SendKeyboardText(const char *text)
|
||||
SDL_Event event;
|
||||
event.text.type = SDL_TEXTINPUT;
|
||||
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
|
||||
SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
|
||||
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
@@ -797,7 +810,7 @@ SDL_SendEditingText(const char *text, int start, int length)
|
||||
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
event.edit.start = start;
|
||||
event.edit.length = length;
|
||||
SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
|
||||
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
return (posted);
|
||||
|
||||
@@ -49,7 +49,7 @@ extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
|
||||
extern void SDL_SetKeyboardFocus(SDL_Window * window);
|
||||
|
||||
/* Send a keyboard key event */
|
||||
extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode, SDL_bool repeat);
|
||||
extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode);
|
||||
|
||||
/* Send keyboard text input */
|
||||
extern int SDL_SendKeyboardText(const char *text);
|
||||
|
||||
568
project/sdl/sdl-1.3/src/events/SDL_touch.c
Normal file
568
project/sdl/sdl-1.3/src/events/SDL_touch.c
Normal file
@@ -0,0 +1,568 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* General touch handling code for SDL */
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_events_c.h"
|
||||
#include "../video/SDL_sysvideo.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
static int SDL_num_touch = 0;
|
||||
static SDL_Touch **SDL_touchPads = NULL;
|
||||
|
||||
|
||||
/* Public functions */
|
||||
int
|
||||
SDL_TouchInit(void)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
SDL_Touch *
|
||||
SDL_GetTouch(SDL_TouchID id)
|
||||
{
|
||||
int index = SDL_GetTouchIndexId(id);
|
||||
if (index < 0 || index >= SDL_num_touch) {
|
||||
return NULL;
|
||||
}
|
||||
return SDL_touchPads[index];
|
||||
}
|
||||
|
||||
SDL_Touch *
|
||||
SDL_GetTouchIndex(int index)
|
||||
{
|
||||
if (index < 0 || index >= SDL_num_touch) {
|
||||
return NULL;
|
||||
}
|
||||
return SDL_touchPads[index];
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
SDL_Finger *
|
||||
SDL_GetFinger(SDL_Touch* touch,SDL_FingerID id)
|
||||
{
|
||||
int index = SDL_GetFingerIndexId(touch,id);
|
||||
if(index < 0 || index >= touch->num_fingers)
|
||||
return NULL;
|
||||
return touch->fingers[index];
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_GetTouchIndexId(SDL_TouchID id)
|
||||
{
|
||||
int index;
|
||||
SDL_Touch *touch;
|
||||
|
||||
for (index = 0; index < SDL_num_touch; ++index) {
|
||||
touch = SDL_touchPads[index];
|
||||
if (touch->id == id) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AddTouch(const SDL_Touch * touch, char *name)
|
||||
{
|
||||
SDL_Touch **touchPads;
|
||||
int index,length;
|
||||
|
||||
if (SDL_GetTouchIndexId(touch->id) != -1) {
|
||||
SDL_SetError("Touch ID already in use");
|
||||
}
|
||||
|
||||
/* Add the touch to the list of touch */
|
||||
touchPads = (SDL_Touch **) SDL_realloc(SDL_touchPads,
|
||||
(SDL_num_touch + 1) * sizeof(*touch));
|
||||
if (!touchPads) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_touchPads = touchPads;
|
||||
index = SDL_num_touch++;
|
||||
|
||||
SDL_touchPads[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchPads[index]));
|
||||
if (!SDL_touchPads[index]) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
*SDL_touchPads[index] = *touch;
|
||||
|
||||
/* we're setting the touch properties */
|
||||
length = 0;
|
||||
length = SDL_strlen(name);
|
||||
SDL_touchPads[index]->focus = 0;
|
||||
SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char));
|
||||
SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1);
|
||||
|
||||
SDL_touchPads[index]->num_fingers = 0;
|
||||
SDL_touchPads[index]->max_fingers = 1;
|
||||
SDL_touchPads[index]->fingers = (SDL_Finger **) SDL_malloc(sizeof(SDL_Finger*));
|
||||
SDL_touchPads[index]->fingers[0] = NULL;
|
||||
SDL_touchPads[index]->buttonstate = 0;
|
||||
SDL_touchPads[index]->relative_mode = SDL_FALSE;
|
||||
SDL_touchPads[index]->flush_motion = SDL_FALSE;
|
||||
|
||||
SDL_touchPads[index]->xres = (1<<(16-1));
|
||||
SDL_touchPads[index]->yres = (1<<(16-1));
|
||||
//Do I want this here? Probably
|
||||
SDL_GestureAddTouch(SDL_touchPads[index]);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_DelTouch(SDL_TouchID id)
|
||||
{
|
||||
int index = SDL_GetTouchIndexId(id);
|
||||
SDL_Touch *touch = SDL_GetTouch(id);
|
||||
|
||||
if (!touch) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SDL_free(touch->name);
|
||||
|
||||
if (touch->FreeTouch) {
|
||||
touch->FreeTouch(touch);
|
||||
}
|
||||
SDL_free(touch);
|
||||
|
||||
SDL_num_touch--;
|
||||
SDL_touchPads[index] = SDL_touchPads[SDL_num_touch];
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TouchQuit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = SDL_num_touch-1; i > 0 ; --i) {
|
||||
SDL_DelTouch(i);
|
||||
}
|
||||
SDL_num_touch = 0;
|
||||
|
||||
if (SDL_touchPads) {
|
||||
SDL_free(SDL_touchPads);
|
||||
SDL_touchPads = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetNumTouch(void)
|
||||
{
|
||||
return SDL_num_touch;
|
||||
}
|
||||
SDL_Window *
|
||||
SDL_GetTouchFocusWindow(SDL_TouchID id)
|
||||
{
|
||||
SDL_Touch *touch = SDL_GetTouch(id);
|
||||
|
||||
if (!touch) {
|
||||
return 0;
|
||||
}
|
||||
return touch->focus;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetTouchFocus(SDL_TouchID id, SDL_Window * window)
|
||||
{
|
||||
int index = SDL_GetTouchIndexId(id);
|
||||
SDL_Touch *touch = SDL_GetTouch(id);
|
||||
int i;
|
||||
SDL_bool focus;
|
||||
|
||||
if (!touch || (touch->focus == window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* See if the current window has lost focus */
|
||||
if (touch->focus) {
|
||||
focus = SDL_FALSE;
|
||||
for (i = 0; i < SDL_num_touch; ++i) {
|
||||
SDL_Touch *check;
|
||||
if (i != index) {
|
||||
check = SDL_touchPads[i];
|
||||
if (check && check->focus == touch->focus) {
|
||||
focus = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!focus) {
|
||||
SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
touch->focus = window;
|
||||
|
||||
if (touch->focus) {
|
||||
focus = SDL_FALSE;
|
||||
for (i = 0; i < SDL_num_touch; ++i) {
|
||||
SDL_Touch *check;
|
||||
if (i != index) {
|
||||
check = SDL_touchPads[i];
|
||||
if (check && check->focus == touch->focus) {
|
||||
focus = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!focus) {
|
||||
SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AddFinger(SDL_Touch* touch,SDL_Finger *finger)
|
||||
{
|
||||
int index;
|
||||
SDL_Finger **fingers;
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
index = touch->num_fingers;
|
||||
//printf("Max_Fingers: %i Index: %i\n",touch->max_fingers,index);
|
||||
|
||||
touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(SDL_Finger));
|
||||
if (!touch->fingers[index]) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
*(touch->fingers[index]) = *finger;
|
||||
touch->num_fingers++;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DelFinger(SDL_Touch* touch,SDL_FingerID fingerid)
|
||||
{
|
||||
int index = SDL_GetFingerIndexId(touch,fingerid);
|
||||
SDL_Finger* finger = SDL_GetFinger(touch,fingerid);
|
||||
|
||||
if (!finger) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
SDL_free(finger);
|
||||
touch->num_fingers--;
|
||||
touch->fingers[index] = touch->fingers[touch->num_fingers];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down,
|
||||
float xin, float yin, float pressurein)
|
||||
{
|
||||
int posted;
|
||||
Uint16 x;
|
||||
Uint16 y;
|
||||
Uint16 pressure;
|
||||
SDL_Finger *finger;
|
||||
|
||||
SDL_Touch* touch = SDL_GetTouch(id);
|
||||
|
||||
if(!touch) {
|
||||
return SDL_TouchNotFoundError(id);
|
||||
}
|
||||
|
||||
|
||||
//scale to Integer coordinates
|
||||
x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
|
||||
y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
|
||||
pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
int index = SDL_GetTouchIndexId(id);
|
||||
SDL_Touch *touch = SDL_GetTouch(id);
|
||||
SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
|
||||
int posted;
|
||||
Sint16 xrel, yrel;
|
||||
float x_max = 0, y_max = 0;
|
||||
Uint16 x;
|
||||
Uint16 y;
|
||||
Uint16 pressure;
|
||||
|
||||
if (!touch) {
|
||||
return SDL_TouchNotFoundError(id);
|
||||
}
|
||||
|
||||
//scale to Integer coordinates
|
||||
x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
|
||||
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;
|
||||
}
|
||||
|
||||
if(finger == NULL || !finger->down) {
|
||||
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) {
|
||||
#if 0
|
||||
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;
|
||||
}
|
||||
}
|
||||
int
|
||||
SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button)
|
||||
{
|
||||
SDL_Touch *touch = SDL_GetTouch(id);
|
||||
int posted;
|
||||
Uint32 type;
|
||||
|
||||
|
||||
if (!touch) {
|
||||
return SDL_TouchNotFoundError(id);
|
||||
}
|
||||
|
||||
/* Figure out which event to perform */
|
||||
switch (state) {
|
||||
case SDL_PRESSED:
|
||||
if (touch->buttonstate & SDL_BUTTON(button)) {
|
||||
/* Ignore this event, no state change */
|
||||
return 0;
|
||||
}
|
||||
type = SDL_TOUCHBUTTONDOWN;
|
||||
touch->buttonstate |= SDL_BUTTON(button);
|
||||
break;
|
||||
case SDL_RELEASED:
|
||||
if (!(touch->buttonstate & SDL_BUTTON(button))) {
|
||||
/* Ignore this event, no state change */
|
||||
return 0;
|
||||
}
|
||||
type = SDL_TOUCHBUTTONUP;
|
||||
touch->buttonstate &= ~SDL_BUTTON(button);
|
||||
break;
|
||||
default:
|
||||
/* Invalid state -- bail */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(type) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = type;
|
||||
event.tbutton.touchId = touch->id;
|
||||
event.tbutton.state = state;
|
||||
event.tbutton.button = button;
|
||||
event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
return posted;
|
||||
}
|
||||
|
||||
char *
|
||||
SDL_GetTouchName(SDL_TouchID id)
|
||||
{
|
||||
SDL_Touch *touch = SDL_GetTouch(id);
|
||||
if (!touch) {
|
||||
return NULL;
|
||||
}
|
||||
return touch->name;
|
||||
}
|
||||
|
||||
int SDL_TouchNotFoundError(SDL_TouchID id) {
|
||||
//int i;
|
||||
SDL_SetError("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
|
||||
#if 0
|
||||
printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
|
||||
for(i=0;i < SDL_num_touch;i++) {
|
||||
printf("ERROR: %li\n",SDL_touchPads[i]->id);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
79
project/sdl/sdl-1.3/src/events/SDL_touch_c.h
Normal file
79
project/sdl/sdl-1.3/src/events/SDL_touch_c.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "../../include/SDL_touch.h"
|
||||
|
||||
#ifndef _SDL_touch_c_h
|
||||
#define _SDL_touch_c_h
|
||||
|
||||
|
||||
|
||||
/* Initialize the touch subsystem */
|
||||
extern int SDL_TouchInit(void);
|
||||
|
||||
/*Get the touch at an index */
|
||||
extern SDL_Touch *SDL_GetTouchIndex(int index);
|
||||
|
||||
/* Get the touch with id = id */
|
||||
extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);
|
||||
|
||||
/*Get the finger at an index */
|
||||
extern SDL_Finger *SDL_GetFingerIndex(SDL_Touch *touch, int index);
|
||||
|
||||
/* Get the finger with id = id */
|
||||
extern SDL_Finger *SDL_GetFinger(SDL_Touch *touch,SDL_FingerID id);
|
||||
|
||||
|
||||
/* Add a touch, possibly reattaching at a particular index (or -1),
|
||||
returning the index of the touch, or -1 if there was an error. */
|
||||
extern int SDL_AddTouch(const SDL_Touch * touch, char *name);
|
||||
|
||||
|
||||
/* Remove a touch at an index, clearing the slot for later */
|
||||
extern void SDL_DelTouch(SDL_TouchID id);
|
||||
|
||||
/* Set the touch focus window */
|
||||
extern void SDL_SetTouchFocus(SDL_TouchID id, SDL_Window * window);
|
||||
|
||||
/* Send a touch motion event for a touch */
|
||||
extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
|
||||
int relative, float x, float y, float z);
|
||||
|
||||
/* Send a touch down/up event for a touch */
|
||||
extern int SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid,
|
||||
SDL_bool down, float x, float y, float pressure);
|
||||
|
||||
/* Send a touch button event for a touch */
|
||||
extern int SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button);
|
||||
|
||||
/* Shutdown the touch subsystem */
|
||||
extern void SDL_TouchQuit(void);
|
||||
|
||||
/* Get the index of a touch device */
|
||||
extern int SDL_GetTouchIndexId(SDL_TouchID id);
|
||||
|
||||
/* Print a debug message for a nonexistent touch */
|
||||
extern int SDL_TouchNotFoundError(SDL_TouchID id);
|
||||
|
||||
#endif /* _SDL_touch_c_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -43,35 +43,36 @@ typedef struct
|
||||
} NDS_HapticData;
|
||||
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
NDS_EZF_OpenNorWrite()
|
||||
{
|
||||
{
|
||||
|
||||
GBA_BUS[0x0FF0000] = 0xD200;
|
||||
|
||||
GBA_BUS[0x0000000] = 0x1500;
|
||||
|
||||
GBA_BUS[0x0010000] = 0xD200;
|
||||
GBA_BUS[0x0FF0000] = 0xD200;
|
||||
GBA_BUS[0x0000000] = 0x1500;
|
||||
GBA_BUS[0x0010000] = 0xD200;
|
||||
GBA_BUS[0x0020000] = 0x1500;
|
||||
GBA_BUS[0x0E20000] = 0x1500;
|
||||
GBA_BUS[0x0FE0000] = 0x1500;
|
||||
}
|
||||
|
||||
GBA_BUS[0x0020000] = 0x1500;
|
||||
void
|
||||
NDS_EZF_CloseNorWrite()
|
||||
{
|
||||
GBA_BUS[0x0E20000] = 0x1500;
|
||||
|
||||
GBA_BUS[0x0FE0000] = 0x1500;
|
||||
|
||||
}
|
||||
|
||||
|
||||
GBA_BUS[0x0FF0000] = 0xD200;
|
||||
GBA_BUS[0x0000000] = 0x1500;
|
||||
GBA_BUS[0x0010000] = 0xD200;
|
||||
GBA_BUS[0x0020000] = 0x1500;
|
||||
GBA_BUS[0x0E20000] = 0xD200;
|
||||
GBA_BUS[0x0FE0000] = 0x1500;
|
||||
}
|
||||
|
||||
void
|
||||
NDS_EZF_ChipReset()
|
||||
{
|
||||
|
||||
GBA_BUS[0x0FF0000] = 0xD200;
|
||||
|
||||
GBA_BUS[0x0000] = 0x00F0;
|
||||
GBA_BUS[0x1000] = 0x00F0;
|
||||
} uint32 NDS_EZF_IsPresent()
|
||||
{
|
||||
|
||||
vuint16 id1, id2;
|
||||
|
||||
NDS_EZF_OpenNorWrite();
|
||||
|
||||
@@ -81,35 +82,35 @@ NDS_EZF_ChipReset()
|
||||
GBA_BUS[0x1555] = 0x00AA;
|
||||
GBA_BUS[0x12AA] = 0x0055;
|
||||
GBA_BUS[0x1555] = 0x0090;
|
||||
|
||||
void
|
||||
NDS_EZF_ChipReset()
|
||||
id1 = GBA_BUS[0x0001];
|
||||
id2 = GBA_BUS[0x1001];
|
||||
if ((id1 != 0x227E) || (id2 != 0x227E)) {
|
||||
NDS_EZF_CloseNorWrite();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GBA_BUS[0x1000] = 0x00F0;
|
||||
id1 = GBA_BUS[0x000E];
|
||||
id2 = GBA_BUS[0x100E];
|
||||
|
||||
NDS_EZF_CloseNorWrite();
|
||||
{
|
||||
|
||||
if (id1 == 0x2218 && id2 == 0x2218) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
NDS_EZF_OpenNorWrite();
|
||||
|
||||
GBA_BUS[0x0555] = 0x00AA;
|
||||
return 0;
|
||||
}
|
||||
void
|
||||
NDS_EZF_SetShake(u8 pos)
|
||||
{
|
||||
u16 data = ((pos % 3) | 0x00F0);
|
||||
GBA_BUS[0x1555] = 0x00AA;
|
||||
GBA_BUS[0x12AA] = 0x0055;
|
||||
GBA_BUS[0x1555] = 0x0090;
|
||||
|
||||
id1 = GBA_BUS[0x0001];
|
||||
|
||||
GBA_BUS[0x0FF0000] = 0xD200;
|
||||
GBA_BUS[0x0000000] = 0x1500;
|
||||
GBA_BUS[0x0010000] = 0xD200;
|
||||
GBA_BUS[0x0020000] = 0x1500;
|
||||
GBA_BUS[0x0F10000] = data;
|
||||
GBA_BUS[0x0FE0000] = 0x1500;
|
||||
|
||||
GBA_BUS[0] = 0x0000; /* write any value for vibration. */
|
||||
GBA_BUS[0] = 0x0002;
|
||||
NDS_EZF_CloseNorWrite();
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_SYS_LogicError(void)
|
||||
|
||||
@@ -45,7 +45,7 @@ int
|
||||
SDL_SYS_JoystickInit(void)
|
||||
{
|
||||
SDL_numjoysticks = 1;
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Function to get the device-dependent name of a joystick */
|
||||
@@ -73,7 +73,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Function to update the state of a joystick - called as a device poll.
|
||||
* This function shouldn't update the joystick structure directly,
|
||||
* but instead should call SDL_PrivateJoystick*() to deliver events
|
||||
@@ -84,8 +84,8 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
||||
{
|
||||
u32 keysd, keysu;
|
||||
int magnitude = 16384;
|
||||
int magnitude = 16384;
|
||||
|
||||
|
||||
/*scanKeys(); - this is done in PumpEvents, because touch uses it too */
|
||||
keysd = keysDown();
|
||||
keysu = keysUp();
|
||||
|
||||
@@ -101,61 +101,61 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
||||
if ((keysd & KEY_RIGHT)) {
|
||||
SDL_PrivateJoystickAxis(joystick, 0, magnitude);
|
||||
}
|
||||
}
|
||||
if ((keysu & (KEY_UP | KEY_DOWN))) {
|
||||
SDL_PrivateJoystickAxis(joystick, 1, 0);
|
||||
}
|
||||
SDL_PrivateJoystickAxis(joystick, 1, 0);
|
||||
if ((keysu & (KEY_LEFT | KEY_RIGHT))) {
|
||||
SDL_PrivateJoystickAxis(joystick, 0, 0);
|
||||
}
|
||||
if ((keysu & (KEY_LEFT | KEY_RIGHT))) {
|
||||
if ((keysd & KEY_A)) {
|
||||
SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
|
||||
}
|
||||
|
||||
if ((keysd & KEY_B)) {
|
||||
SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED);
|
||||
}
|
||||
}
|
||||
if ((keysd & KEY_X)) {
|
||||
SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED);
|
||||
}
|
||||
SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED);
|
||||
if ((keysd & KEY_Y)) {
|
||||
SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_X)) {
|
||||
if ((keysd & KEY_L)) {
|
||||
SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED);
|
||||
}
|
||||
|
||||
if ((keysd & KEY_R)) {
|
||||
SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED);
|
||||
}
|
||||
}
|
||||
if ((keysd & KEY_SELECT)) {
|
||||
SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED);
|
||||
}
|
||||
SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED);
|
||||
if ((keysd & KEY_START)) {
|
||||
SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_R)) {
|
||||
if ((keysu & KEY_A)) {
|
||||
SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
|
||||
}
|
||||
|
||||
if ((keysu & KEY_B)) {
|
||||
SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
if ((keysu & KEY_X)) {
|
||||
SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED);
|
||||
}
|
||||
SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED);
|
||||
if ((keysu & KEY_Y)) {
|
||||
SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_A)) {
|
||||
if ((keysu & KEY_L)) {
|
||||
SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED);
|
||||
}
|
||||
|
||||
if ((keysu & KEY_R)) {
|
||||
SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
if ((keysu & KEY_SELECT)) {
|
||||
SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED);
|
||||
}
|
||||
SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED);
|
||||
if ((keysu & KEY_START)) {
|
||||
SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_Y)) {
|
||||
}
|
||||
|
||||
/* Function to close a joystick after use */
|
||||
void
|
||||
|
||||
116
project/sdl/sdl-1.3/src/libm/e_atan2.c
Normal file
116
project/sdl/sdl-1.3/src/libm/e_atan2.c
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/* __ieee754_atan2(y,x)
|
||||
* Method :
|
||||
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
|
||||
* 2. Reduce x to positive by (if x and y are unexceptional):
|
||||
* ARG (x+iy) = arctan(y/x) ... if x > 0,
|
||||
* ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
|
||||
*
|
||||
* Special cases:
|
||||
*
|
||||
* ATAN2((anything), NaN ) is NaN;
|
||||
* ATAN2(NAN , (anything) ) is NaN;
|
||||
* ATAN2(+-0, +(anything but NaN)) is +-0 ;
|
||||
* ATAN2(+-0, -(anything but NaN)) is +-pi ;
|
||||
* ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2;
|
||||
* ATAN2(+-(anything but INF and NaN), +INF) is +-0 ;
|
||||
* ATAN2(+-(anything but INF and NaN), -INF) is +-pi;
|
||||
* ATAN2(+-INF,+INF ) is +-pi/4 ;
|
||||
* ATAN2(+-INF,-INF ) is +-3pi/4;
|
||||
* ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
|
||||
*
|
||||
* Constants:
|
||||
* The hexadecimal values are the intended ones for the following
|
||||
* constants. The decimal values may be used, provided that the
|
||||
* compiler will convert from decimal to binary accurately enough
|
||||
* to produce the hexadecimal values shown.
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "math_private.h"
|
||||
|
||||
static const double
|
||||
tiny = 1.0e-300,
|
||||
zero = 0.0,
|
||||
pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */
|
||||
pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
|
||||
pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
|
||||
pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
|
||||
|
||||
double attribute_hidden __ieee754_atan2(double y, double x)
|
||||
{
|
||||
double z;
|
||||
int32_t k,m,hx,hy,ix,iy;
|
||||
u_int32_t lx,ly;
|
||||
|
||||
EXTRACT_WORDS(hx,lx,x);
|
||||
ix = hx&0x7fffffff;
|
||||
EXTRACT_WORDS(hy,ly,y);
|
||||
iy = hy&0x7fffffff;
|
||||
if(((ix|((lx|-(int32_t)lx)>>31))>0x7ff00000)||
|
||||
((iy|((ly|-(int32_t)ly)>>31))>0x7ff00000)) /* x or y is NaN */
|
||||
return x+y;
|
||||
if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */
|
||||
m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */
|
||||
|
||||
/* when y = 0 */
|
||||
if((iy|ly)==0) {
|
||||
switch(m) {
|
||||
case 0:
|
||||
case 1: return y; /* atan(+-0,+anything)=+-0 */
|
||||
case 2: return pi+tiny;/* atan(+0,-anything) = pi */
|
||||
case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
|
||||
}
|
||||
}
|
||||
/* when x = 0 */
|
||||
if((ix|lx)==0) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
|
||||
|
||||
/* when x is INF */
|
||||
if(ix==0x7ff00000) {
|
||||
if(iy==0x7ff00000) {
|
||||
switch(m) {
|
||||
case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */
|
||||
case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */
|
||||
case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/
|
||||
case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/
|
||||
}
|
||||
} else {
|
||||
switch(m) {
|
||||
case 0: return zero ; /* atan(+...,+INF) */
|
||||
case 1: return -zero ; /* atan(-...,+INF) */
|
||||
case 2: return pi+tiny ; /* atan(+...,-INF) */
|
||||
case 3: return -pi-tiny ; /* atan(-...,-INF) */
|
||||
}
|
||||
}
|
||||
}
|
||||
/* when y is INF */
|
||||
if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
|
||||
|
||||
/* compute y/x */
|
||||
k = (iy-ix)>>20;
|
||||
if(k > 60) z=pi_o_2+0.5*pi_lo; /* |y/x| > 2**60 */
|
||||
else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */
|
||||
else z=atan(fabs(y/x)); /* safe to do y/x */
|
||||
switch (m) {
|
||||
case 0: return z ; /* atan(+,+) */
|
||||
case 1: {
|
||||
u_int32_t zh;
|
||||
GET_HIGH_WORD(zh,z);
|
||||
SET_HIGH_WORD(z,zh ^ 0x80000000);
|
||||
}
|
||||
return z ; /* atan(-,+) */
|
||||
case 2: return pi-(z-pi_lo);/* atan(+,-) */
|
||||
default: /* case 3 */
|
||||
return (z-pi_lo)-pi;/* atan(-,-) */
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,16 @@
|
||||
|
||||
/* Math routines from uClibc: http://www.uclibc.org */
|
||||
|
||||
#ifdef HAVE_ATAN
|
||||
#define atan SDL_uclibc_atan
|
||||
#else
|
||||
#define atan SDL_atan
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ATAN2
|
||||
#define __ieee754_atan2 SDL_atan2
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COPYSIGN
|
||||
#define copysign SDL_uclibc_copysign
|
||||
#else
|
||||
|
||||
114
project/sdl/sdl-1.3/src/libm/s_atan.c
Normal file
114
project/sdl/sdl-1.3/src/libm/s_atan.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/* atan(x)
|
||||
* Method
|
||||
* 1. Reduce x to positive by atan(x) = -atan(-x).
|
||||
* 2. According to the integer k=4t+0.25 chopped, t=x, the argument
|
||||
* is further reduced to one of the following intervals and the
|
||||
* arctangent of t is evaluated by the corresponding formula:
|
||||
*
|
||||
* [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
|
||||
* [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
|
||||
* [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
|
||||
* [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
|
||||
* [39/16,INF] atan(x) = atan(INF) + atan( -1/t )
|
||||
*
|
||||
* Constants:
|
||||
* The hexadecimal values are the intended ones for the following
|
||||
* constants. The decimal values may be used, provided that the
|
||||
* compiler will convert from decimal to binary accurately enough
|
||||
* to produce the hexadecimal values shown.
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "math_private.h"
|
||||
|
||||
static const double atanhi[] = {
|
||||
4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
|
||||
7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */
|
||||
9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */
|
||||
1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */
|
||||
};
|
||||
|
||||
static const double atanlo[] = {
|
||||
2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */
|
||||
3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */
|
||||
1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */
|
||||
6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */
|
||||
};
|
||||
|
||||
static const double aT[] = {
|
||||
3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */
|
||||
-1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */
|
||||
1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */
|
||||
-1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */
|
||||
9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */
|
||||
-7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */
|
||||
6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */
|
||||
-5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */
|
||||
4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */
|
||||
-3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */
|
||||
1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
|
||||
};
|
||||
|
||||
static const double
|
||||
one = 1.0,
|
||||
huge = 1.0e300;
|
||||
|
||||
double atan(double x)
|
||||
{
|
||||
double w,s1,s2,z;
|
||||
int32_t ix,hx,id;
|
||||
|
||||
GET_HIGH_WORD(hx,x);
|
||||
ix = hx&0x7fffffff;
|
||||
if(ix>=0x44100000) { /* if |x| >= 2^66 */
|
||||
u_int32_t low;
|
||||
GET_LOW_WORD(low,x);
|
||||
if(ix>0x7ff00000||
|
||||
(ix==0x7ff00000&&(low!=0)))
|
||||
return x+x; /* NaN */
|
||||
if(hx>0) return atanhi[3]+atanlo[3];
|
||||
else return -atanhi[3]-atanlo[3];
|
||||
} if (ix < 0x3fdc0000) { /* |x| < 0.4375 */
|
||||
if (ix < 0x3e200000) { /* |x| < 2^-29 */
|
||||
if(huge+x>one) return x; /* raise inexact */
|
||||
}
|
||||
id = -1;
|
||||
} else {
|
||||
x = fabs(x);
|
||||
if (ix < 0x3ff30000) { /* |x| < 1.1875 */
|
||||
if (ix < 0x3fe60000) { /* 7/16 <=|x|<11/16 */
|
||||
id = 0; x = (2.0*x-one)/(2.0+x);
|
||||
} else { /* 11/16<=|x|< 19/16 */
|
||||
id = 1; x = (x-one)/(x+one);
|
||||
}
|
||||
} else {
|
||||
if (ix < 0x40038000) { /* |x| < 2.4375 */
|
||||
id = 2; x = (x-1.5)/(one+1.5*x);
|
||||
} else { /* 2.4375 <= |x| < 2^66 */
|
||||
id = 3; x = -1.0/x;
|
||||
}
|
||||
}}
|
||||
/* end of argument reduction */
|
||||
z = x*x;
|
||||
w = z*z;
|
||||
/* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
|
||||
s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10])))));
|
||||
s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9]))));
|
||||
if (id<0) return x - x*(s1+s2);
|
||||
else {
|
||||
z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
|
||||
return (hx<0)? -z:z;
|
||||
}
|
||||
}
|
||||
libm_hidden_def(atan)
|
||||
@@ -39,6 +39,12 @@ __declspec(selectany) int _fltused = 1;
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_chkstk()
|
||||
{
|
||||
}
|
||||
|
||||
/* Float to long */
|
||||
void
|
||||
__declspec(naked)
|
||||
|
||||
@@ -29,6 +29,21 @@
|
||||
#define SDL_isupperhex(X) (((X) >= 'A') && ((X) <= 'F'))
|
||||
#define SDL_islowerhex(X) (((X) >= 'a') && ((X) <= 'f'))
|
||||
|
||||
#define UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4)
|
||||
#define UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF)
|
||||
|
||||
int UTF8_TrailingBytes(unsigned char c)
|
||||
{
|
||||
if (c >= 0xC0 && c<= 0xDF)
|
||||
return 1;
|
||||
else if (c >= 0xE0 && c <= 0xEF)
|
||||
return 2;
|
||||
else if (c >= 0xF0 && c <= 0xF4)
|
||||
return 3;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOL)
|
||||
static size_t
|
||||
SDL_ScanLong(const char *text, int radix, long *valuep)
|
||||
@@ -348,6 +363,33 @@ SDL_wcslen(const wchar_t * string)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSLCPY
|
||||
size_t
|
||||
SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen)
|
||||
{
|
||||
size_t srclen = SDL_wcslen(src);
|
||||
if (maxlen > 0) {
|
||||
size_t len = SDL_min(srclen, maxlen - 1);
|
||||
SDL_memcpy(dst, src, len * sizeof(wchar_t));
|
||||
dst[len] = '\0';
|
||||
}
|
||||
return srclen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSLCAT
|
||||
size_t
|
||||
SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen)
|
||||
{
|
||||
size_t dstlen = SDL_wcslen(dst);
|
||||
size_t srclen = SDL_wcslen(src);
|
||||
if (dstlen < maxlen) {
|
||||
SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
|
||||
}
|
||||
return dstlen + srclen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
size_t
|
||||
SDL_strlcpy(char *dst, const char *src, size_t maxlen)
|
||||
@@ -362,6 +404,38 @@ SDL_strlcpy(char *dst, const char *src, size_t maxlen)
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes)
|
||||
{
|
||||
size_t src_bytes = SDL_strlen(src);
|
||||
size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
|
||||
int i = 0;
|
||||
char trailing_bytes = 0;
|
||||
if (bytes)
|
||||
{
|
||||
unsigned char c = (unsigned char)src[bytes - 1];
|
||||
if (UTF8_IsLeadByte(c))
|
||||
--bytes;
|
||||
else if (UTF8_IsTrailingByte(c))
|
||||
{
|
||||
for (i = bytes - 1; i != 0; --i)
|
||||
{
|
||||
c = (unsigned char)src[i];
|
||||
trailing_bytes = UTF8_TrailingBytes(c);
|
||||
if (trailing_bytes)
|
||||
{
|
||||
if (bytes - i != trailing_bytes + 1)
|
||||
bytes = i;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_memcpy(dst, src, bytes);
|
||||
}
|
||||
dst[bytes] = '\0';
|
||||
return bytes;
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
size_t
|
||||
SDL_strlcat(char *dst, const char *src, size_t maxlen)
|
||||
|
||||
279
project/sdl/sdl-1.3/src/video/SDL_shape.c
Normal file
279
project/sdl/sdl-1.3/src/video/SDL_shape.c
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_surface.h"
|
||||
#include "SDL_shape.h"
|
||||
#include "SDL_shape_internals.h"
|
||||
|
||||
SDL_Window*
|
||||
SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
|
||||
SDL_Window *result = NULL;
|
||||
result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/);
|
||||
if(result != NULL) {
|
||||
result->shaper = result->display->device->shape_driver.CreateShaper(result);
|
||||
if(result->shaper != NULL) {
|
||||
result->shaper->userx = x;
|
||||
result->shaper->usery = y;
|
||||
result->shaper->mode.mode = ShapeModeDefault;
|
||||
result->shaper->mode.parameters.binarizationCutoff = 1;
|
||||
result->shaper->hasshape = SDL_FALSE;
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
SDL_DestroyWindow(result);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IsShapedWindow(const SDL_Window *window) {
|
||||
if(window == NULL)
|
||||
return SDL_FALSE;
|
||||
else
|
||||
return (SDL_bool)(window->shaper != NULL);
|
||||
}
|
||||
|
||||
/* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */
|
||||
void
|
||||
SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
Uint8 r = 0,g = 0,b = 0,alpha = 0;
|
||||
Uint8* pixel = NULL;
|
||||
Uint32 bitmap_pixel,pixel_value = 0,mask_value = 0;
|
||||
SDL_Color key;
|
||||
if(SDL_MUSTLOCK(shape))
|
||||
SDL_LockSurface(shape);
|
||||
pixel = (Uint8*)shape->pixels;
|
||||
for(y = 0;y<shape->h;y++) {
|
||||
for(x=0;x<shape->w;x++) {
|
||||
alpha = 0;
|
||||
pixel_value = 0;
|
||||
pixel = (Uint8 *)(shape->pixels) + (y*shape->pitch) + (x*shape->format->BytesPerPixel);
|
||||
switch(shape->format->BytesPerPixel) {
|
||||
case(1):
|
||||
pixel_value = *(Uint8*)pixel;
|
||||
break;
|
||||
case(2):
|
||||
pixel_value = *(Uint16*)pixel;
|
||||
break;
|
||||
case(3):
|
||||
pixel_value = *(Uint32*)pixel & (~shape->format->Amask);
|
||||
break;
|
||||
case(4):
|
||||
pixel_value = *(Uint32*)pixel;
|
||||
break;
|
||||
}
|
||||
SDL_GetRGBA(pixel_value,shape->format,&r,&g,&b,&alpha);
|
||||
bitmap_pixel = y*shape->w + x;
|
||||
switch(mode.mode) {
|
||||
case(ShapeModeDefault):
|
||||
mask_value = (alpha >= 1 ? 1 : 0);
|
||||
break;
|
||||
case(ShapeModeBinarizeAlpha):
|
||||
mask_value = (alpha >= mode.parameters.binarizationCutoff ? 1 : 0);
|
||||
break;
|
||||
case(ShapeModeReverseBinarizeAlpha):
|
||||
mask_value = (alpha <= mode.parameters.binarizationCutoff ? 1 : 0);
|
||||
break;
|
||||
case(ShapeModeColorKey):
|
||||
key = mode.parameters.colorKey;
|
||||
mask_value = ((key.r != r || key.g != g || key.b != b) ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
bitmap[bitmap_pixel / ppb] |= mask_value << (7 - ((ppb - 1) - (bitmap_pixel % ppb)));
|
||||
}
|
||||
}
|
||||
if(SDL_MUSTLOCK(shape))
|
||||
SDL_UnlockSurface(shape);
|
||||
}
|
||||
|
||||
SDL_ShapeTree*
|
||||
RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rect dimensions) {
|
||||
int x = 0,y = 0;
|
||||
Uint8* pixel = NULL;
|
||||
Uint32 pixel_value = 0;
|
||||
Uint8 r = 0,g = 0,b = 0,a = 0;
|
||||
SDL_bool pixel_opaque = SDL_FALSE;
|
||||
int last_opaque = -1;
|
||||
SDL_Color key;
|
||||
SDL_ShapeTree* result = (SDL_ShapeTree*)SDL_malloc(sizeof(SDL_ShapeTree));
|
||||
SDL_Rect next = {0,0,0,0};
|
||||
for(y=dimensions.y;y<dimensions.y + dimensions.h;y++) {
|
||||
for(x=dimensions.x;x<dimensions.x + dimensions.w;x++) {
|
||||
pixel_value = 0;
|
||||
pixel = (Uint8 *)(mask->pixels) + (y*mask->pitch) + (x*mask->format->BytesPerPixel);
|
||||
switch(mask->format->BytesPerPixel) {
|
||||
case(1):
|
||||
pixel_value = *(Uint8*)pixel;
|
||||
break;
|
||||
case(2):
|
||||
pixel_value = *(Uint16*)pixel;
|
||||
break;
|
||||
case(3):
|
||||
pixel_value = *(Uint32*)pixel & (~mask->format->Amask);
|
||||
break;
|
||||
case(4):
|
||||
pixel_value = *(Uint32*)pixel;
|
||||
break;
|
||||
}
|
||||
SDL_GetRGBA(pixel_value,mask->format,&r,&g,&b,&a);
|
||||
switch(mode.mode) {
|
||||
case(ShapeModeDefault):
|
||||
pixel_opaque = (a >= 1 ? SDL_TRUE : SDL_FALSE);
|
||||
break;
|
||||
case(ShapeModeBinarizeAlpha):
|
||||
pixel_opaque = (a >= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE);
|
||||
break;
|
||||
case(ShapeModeReverseBinarizeAlpha):
|
||||
pixel_opaque = (a <= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE);
|
||||
break;
|
||||
case(ShapeModeColorKey):
|
||||
key = mode.parameters.colorKey;
|
||||
pixel_opaque = ((key.r != r || key.g != g || key.b != b) ? SDL_TRUE : SDL_FALSE);
|
||||
break;
|
||||
}
|
||||
if(last_opaque == -1)
|
||||
last_opaque = pixel_opaque;
|
||||
if(last_opaque != pixel_opaque) {
|
||||
result->kind = QuadShape;
|
||||
//These will stay the same.
|
||||
next.w = dimensions.w / 2;
|
||||
next.h = dimensions.h / 2;
|
||||
//These will change from recursion to recursion.
|
||||
next.x = dimensions.x;
|
||||
next.y = dimensions.y;
|
||||
result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
|
||||
next.x += next.w;
|
||||
//Unneeded: next.y = dimensions.y;
|
||||
result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
|
||||
next.x = dimensions.x;
|
||||
next.y += next.h;
|
||||
result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
|
||||
next.x += next.w;
|
||||
//Unneeded: next.y = dimensions.y + dimensions.h /2;
|
||||
result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
//If we never recursed, all the pixels in this quadrant have the same "value".
|
||||
result->kind = (last_opaque == SDL_TRUE ? OpaqueShape : TransparentShape);
|
||||
result->data.shape = dimensions;
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_ShapeTree*
|
||||
SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape) {
|
||||
SDL_Rect dimensions = {0,0,shape->w,shape->h};
|
||||
SDL_ShapeTree* result = NULL;
|
||||
if(SDL_MUSTLOCK(shape))
|
||||
SDL_LockSurface(shape);
|
||||
result = RecursivelyCalculateShapeTree(mode,shape,dimensions);
|
||||
if(SDL_MUSTLOCK(shape))
|
||||
SDL_UnlockSurface(shape);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure) {
|
||||
SDL_assert(tree != NULL);
|
||||
if(tree->kind == QuadShape) {
|
||||
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft,function,closure);
|
||||
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright,function,closure);
|
||||
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downleft,function,closure);
|
||||
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downright,function,closure);
|
||||
}
|
||||
else
|
||||
function(tree,closure);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_FreeShapeTree(SDL_ShapeTree** shape_tree) {
|
||||
if((*shape_tree)->kind == QuadShape) {
|
||||
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upleft);
|
||||
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upright);
|
||||
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downleft);
|
||||
SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downright);
|
||||
}
|
||||
SDL_free(*shape_tree);
|
||||
*shape_tree = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
|
||||
int result;
|
||||
if(window == NULL || !SDL_IsShapedWindow(window))
|
||||
//The window given was not a shapeable window.
|
||||
return SDL_NONSHAPEABLE_WINDOW;
|
||||
if(shape == NULL)
|
||||
//Invalid shape argument.
|
||||
return SDL_INVALID_SHAPE_ARGUMENT;
|
||||
|
||||
if(shape_mode != NULL)
|
||||
window->shaper->mode = *shape_mode;
|
||||
result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode);
|
||||
window->shaper->hasshape = SDL_TRUE;
|
||||
if(window->shaper->userx != 0 && window->shaper->usery != 0) {
|
||||
SDL_SetWindowPosition(window,window->shaper->userx,window->shaper->usery);
|
||||
window->shaper->userx = 0;
|
||||
window->shaper->usery = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_WindowHasAShape(SDL_Window *window) {
|
||||
if (window == NULL || !SDL_IsShapedWindow(window))
|
||||
return SDL_FALSE;
|
||||
return window->shaper->hasshape;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode) {
|
||||
if(window != NULL && SDL_IsShapedWindow(window)) {
|
||||
if(shape_mode == NULL) {
|
||||
if(SDL_WindowHasAShape(window))
|
||||
//The window given has a shape.
|
||||
return 0;
|
||||
else
|
||||
//The window given is shapeable but lacks a shape.
|
||||
return SDL_WINDOW_LACKS_SHAPE;
|
||||
}
|
||||
else {
|
||||
*shape_mode = window->shaper->mode;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
//The window given is not a valid shapeable window.
|
||||
return SDL_NONSHAPEABLE_WINDOW;
|
||||
}
|
||||
70
project/sdl/sdl-1.3/src/video/SDL_shape_internals.h
Normal file
70
project/sdl/sdl-1.3/src/video/SDL_shape_internals.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_shape_internals_h
|
||||
#define _SDL_shape_internals_h
|
||||
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_shape.h"
|
||||
#include "SDL_surface.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
struct SDL_ShapeTree *upleft,*upright,*downleft,*downright;
|
||||
} SDL_QuadTreeChildren;
|
||||
|
||||
typedef union {
|
||||
SDL_QuadTreeChildren children;
|
||||
SDL_Rect shape;
|
||||
} SDL_ShapeUnion;
|
||||
|
||||
typedef enum { QuadShape,TransparentShape,OpaqueShape } SDL_ShapeKind;
|
||||
|
||||
typedef struct {
|
||||
SDL_ShapeKind kind;
|
||||
SDL_ShapeUnion data;
|
||||
} SDL_ShapeTree;
|
||||
|
||||
typedef void(*SDL_TraversalFunction)(SDL_ShapeTree*,void*);
|
||||
|
||||
extern void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb);
|
||||
extern SDL_ShapeTree* SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape);
|
||||
extern void SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure);
|
||||
extern void SDL_FreeShapeTree(SDL_ShapeTree** shape_tree);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif
|
||||
@@ -26,11 +26,14 @@
|
||||
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_keysym.h"
|
||||
#include "SDL_shape.h"
|
||||
|
||||
/* The SDL video driver */
|
||||
|
||||
typedef struct SDL_Renderer SDL_Renderer;
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
typedef struct SDL_WindowShaper SDL_WindowShaper;
|
||||
typedef struct SDL_ShapeDriver SDL_ShapeDriver;
|
||||
typedef struct SDL_VideoDisplay SDL_VideoDisplay;
|
||||
typedef struct SDL_VideoDevice SDL_VideoDevice;
|
||||
|
||||
@@ -97,10 +100,6 @@ struct SDL_Renderer
|
||||
int count);
|
||||
int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
|
||||
int count);
|
||||
int (*RenderDrawEllipse) (SDL_Renderer * renderer, int x, int y,
|
||||
int w, int h);
|
||||
int (*RenderFillEllipse) (SDL_Renderer * renderer, int x, int y,
|
||||
int w, int h);
|
||||
int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * dstrect);
|
||||
int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
@@ -138,6 +137,32 @@ struct SDL_RenderDriver
|
||||
size_t infoSize;
|
||||
};
|
||||
|
||||
/* Define the SDL window-shaper structure */
|
||||
struct SDL_WindowShaper
|
||||
{
|
||||
/* The window associated with the shaper */
|
||||
SDL_Window *window;
|
||||
|
||||
/* The user's specified coordinates for the window, for once we give it a shape. */
|
||||
Uint32 userx,usery;
|
||||
|
||||
/* The parameters for shape calculation. */
|
||||
SDL_WindowShapeMode mode;
|
||||
|
||||
/* Has this window been assigned a shape? */
|
||||
SDL_bool hasshape;
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Define the SDL shape driver structure */
|
||||
struct SDL_ShapeDriver
|
||||
{
|
||||
SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
|
||||
int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
|
||||
int (*ResizeWindowShape)(SDL_Window *window);
|
||||
};
|
||||
|
||||
/* Define the SDL window structure, corresponding to toplevel windows */
|
||||
struct SDL_Window
|
||||
{
|
||||
@@ -152,6 +177,8 @@ struct SDL_Window
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
|
||||
SDL_WindowShaper *shaper;
|
||||
|
||||
void *userdata;
|
||||
void *driverdata;
|
||||
@@ -272,6 +299,12 @@ struct SDL_VideoDevice
|
||||
void (*RestoreWindow) (_THIS, SDL_Window * window);
|
||||
void (*SetWindowGrab) (_THIS, SDL_Window * window);
|
||||
void (*DestroyWindow) (_THIS, SDL_Window * window);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* Shaped-window functions
|
||||
*/
|
||||
SDL_ShapeDriver shape_driver;
|
||||
|
||||
/* Get some platform dependent window information */
|
||||
SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
|
||||
@@ -389,9 +422,6 @@ extern VideoBootStrap PS3_bootstrap;
|
||||
#if SDL_VIDEO_DRIVER_SVGALIB
|
||||
extern VideoBootStrap SVGALIB_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_GAPI
|
||||
extern VideoBootStrap GAPI_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WIN32
|
||||
extern VideoBootStrap WIN32_bootstrap;
|
||||
#endif
|
||||
@@ -425,6 +455,9 @@ extern VideoBootStrap NDS_bootstrap;
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
extern VideoBootStrap PND_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
extern VideoBootStrap Android_bootstrap;
|
||||
#endif
|
||||
|
||||
#define SDL_CurrentDisplay (&_this->displays[_this->current_display])
|
||||
#define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer)
|
||||
|
||||
461
project/sdl/sdl-1.3/src/video/SDL_sysvideo.h.orig
Normal file
461
project/sdl/sdl-1.3/src/video/SDL_sysvideo.h.orig
Normal file
@@ -0,0 +1,461 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_sysvideo_h
|
||||
#define _SDL_sysvideo_h
|
||||
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_keysym.h"
|
||||
|
||||
/* The SDL video driver */
|
||||
|
||||
typedef struct SDL_Renderer SDL_Renderer;
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
typedef struct SDL_VideoDisplay SDL_VideoDisplay;
|
||||
typedef struct SDL_VideoDevice SDL_VideoDevice;
|
||||
|
||||
/* Define the SDL texture structure */
|
||||
struct SDL_Texture
|
||||
{
|
||||
const void *magic;
|
||||
Uint32 format; /**< The pixel format of the texture */
|
||||
int access; /**< SDL_TextureAccess */
|
||||
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 */
|
||||
Uint8 r, g, b, a; /**< Texture modulation values */
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
void *driverdata; /**< Driver specific texture representation */
|
||||
|
||||
SDL_Texture *prev;
|
||||
SDL_Texture *next;
|
||||
};
|
||||
|
||||
/* Define the SDL renderer structure */
|
||||
struct SDL_Renderer
|
||||
{
|
||||
int (*ActivateRenderer) (SDL_Renderer * renderer);
|
||||
int (*DisplayModeChanged) (SDL_Renderer * renderer);
|
||||
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
void **pixels, int *pitch);
|
||||
int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Color * colors, int firstcolor,
|
||||
int ncolors);
|
||||
int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
SDL_Color * colors, int firstcolor,
|
||||
int ncolors);
|
||||
int (*SetTextureColorMod) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*SetTextureBlendMode) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*SetTextureScaleMode) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, int markDirty, void **pixels,
|
||||
int *pitch);
|
||||
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
int numrects, const SDL_Rect * rects);
|
||||
int (*SetDrawColor) (SDL_Renderer * renderer);
|
||||
int (*SetDrawBlendMode) (SDL_Renderer * renderer);
|
||||
int (*RenderClear) (SDL_Renderer * renderer);
|
||||
int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
|
||||
int count);
|
||||
int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
|
||||
int count);
|
||||
int (*RenderDrawRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
|
||||
int count);
|
||||
int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
|
||||
int count);
|
||||
int (*RenderDrawEllipse) (SDL_Renderer * renderer, int x, int y,
|
||||
int w, int h);
|
||||
int (*RenderFillEllipse) (SDL_Renderer * renderer, int x, int y,
|
||||
int w, int h);
|
||||
int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * dstrect);
|
||||
int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch);
|
||||
int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, const void * pixels, int pitch);
|
||||
void (*RenderPresent) (SDL_Renderer * renderer);
|
||||
void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
|
||||
void (*DestroyRenderer) (SDL_Renderer * renderer);
|
||||
|
||||
/* The current renderer info */
|
||||
SDL_RendererInfo info;
|
||||
|
||||
/* The window associated with the renderer */
|
||||
SDL_Window *window;
|
||||
|
||||
/* The list of textures */
|
||||
SDL_Texture *textures;
|
||||
|
||||
Uint8 r, g, b, a; /**< Color for drawing operations values */
|
||||
int blendMode; /**< The drawing blend mode */
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Define the SDL render driver structure */
|
||||
struct SDL_RenderDriver
|
||||
{
|
||||
SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
|
||||
|
||||
/* Info about the renderer capabilities */
|
||||
SDL_RendererInfo info;
|
||||
/* Used for resizing renderer */
|
||||
size_t infoSize;
|
||||
};
|
||||
|
||||
/* Define the SDL window structure, corresponding to toplevel windows */
|
||||
struct SDL_Window
|
||||
{
|
||||
const void *magic;
|
||||
Uint32 id;
|
||||
char *title;
|
||||
int x, y;
|
||||
int w, h;
|
||||
Uint32 flags;
|
||||
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
|
||||
void *userdata;
|
||||
void *driverdata;
|
||||
|
||||
SDL_Window *prev;
|
||||
SDL_Window *next;
|
||||
};
|
||||
#define FULLSCREEN_VISIBLE(W) \
|
||||
(((W)->flags & SDL_WINDOW_FULLSCREEN) && \
|
||||
((W)->flags & SDL_WINDOW_SHOWN) && \
|
||||
!((W)->flags & SDL_WINDOW_MINIMIZED))
|
||||
|
||||
/*
|
||||
* Define the SDL display structure This corresponds to physical monitors
|
||||
* attached to the system.
|
||||
*/
|
||||
struct SDL_VideoDisplay
|
||||
{
|
||||
int max_display_modes;
|
||||
int num_display_modes;
|
||||
SDL_DisplayMode *display_modes;
|
||||
SDL_DisplayMode desktop_mode;
|
||||
SDL_DisplayMode current_mode;
|
||||
SDL_bool updating_fullscreen;
|
||||
SDL_Palette *palette;
|
||||
|
||||
Uint16 *gamma;
|
||||
Uint16 *saved_gamma; /* (just offset into gamma) */
|
||||
|
||||
int num_render_drivers;
|
||||
SDL_RenderDriver *render_drivers;
|
||||
|
||||
SDL_Window *windows;
|
||||
SDL_Window *fullscreen_window;
|
||||
|
||||
SDL_Renderer *current_renderer;
|
||||
|
||||
SDL_VideoDevice *device;
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Define the SDL video driver structure */
|
||||
#define _THIS SDL_VideoDevice *_this
|
||||
|
||||
struct SDL_VideoDevice
|
||||
{
|
||||
/* * * */
|
||||
/* The name of this video driver */
|
||||
const char *name;
|
||||
|
||||
/* * * */
|
||||
/* Initialization/Query functions */
|
||||
|
||||
/*
|
||||
* Initialize the native video subsystem, filling in the list of
|
||||
* displays for this driver, returning 0 or -1 if there's an error.
|
||||
*/
|
||||
int (*VideoInit) (_THIS);
|
||||
|
||||
/*
|
||||
* Reverse the effects VideoInit() -- called if VideoInit() fails or
|
||||
* if the application is shutting down the video subsystem.
|
||||
*/
|
||||
void (*VideoQuit) (_THIS);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* Display functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get the bounds of a display
|
||||
*/
|
||||
int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
|
||||
/*
|
||||
* Get a list of the available display modes. e.g.
|
||||
* SDL_AddDisplayMode(_this->current_display, mode)
|
||||
*/
|
||||
void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
|
||||
|
||||
/*
|
||||
* Setting the display mode is independent of creating windows, so
|
||||
* when the display mode is changed, all existing windows should have
|
||||
* their data updated accordingly, including the display surfaces
|
||||
* associated with them.
|
||||
*/
|
||||
int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
|
||||
/* Set the color entries of the display palette */
|
||||
int (*SetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
|
||||
|
||||
/* Get the color entries of the display palette */
|
||||
int (*GetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
|
||||
|
||||
/* Set the gamma ramp */
|
||||
int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
|
||||
|
||||
/* Get the gamma ramp */
|
||||
int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* Window functions
|
||||
*/
|
||||
int (*CreateWindow) (_THIS, SDL_Window * window);
|
||||
int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
|
||||
void (*SetWindowTitle) (_THIS, SDL_Window * window);
|
||||
void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||
void (*SetWindowPosition) (_THIS, SDL_Window * window);
|
||||
void (*SetWindowSize) (_THIS, SDL_Window * window);
|
||||
void (*ShowWindow) (_THIS, SDL_Window * window);
|
||||
void (*HideWindow) (_THIS, SDL_Window * window);
|
||||
void (*RaiseWindow) (_THIS, SDL_Window * window);
|
||||
void (*MaximizeWindow) (_THIS, SDL_Window * window);
|
||||
void (*MinimizeWindow) (_THIS, SDL_Window * window);
|
||||
void (*RestoreWindow) (_THIS, SDL_Window * window);
|
||||
void (*SetWindowGrab) (_THIS, SDL_Window * window);
|
||||
void (*DestroyWindow) (_THIS, SDL_Window * window);
|
||||
|
||||
/* Get some platform dependent window information */
|
||||
SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo * info);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* OpenGL support
|
||||
*/
|
||||
int (*GL_LoadLibrary) (_THIS, const char *path);
|
||||
void *(*GL_GetProcAddress) (_THIS, const char *proc);
|
||||
void (*GL_UnloadLibrary) (_THIS);
|
||||
SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
|
||||
int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
|
||||
int (*GL_SetSwapInterval) (_THIS, int interval);
|
||||
int (*GL_GetSwapInterval) (_THIS);
|
||||
void (*GL_SwapWindow) (_THIS, SDL_Window * window);
|
||||
void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* Event manager functions
|
||||
*/
|
||||
void (*PumpEvents) (_THIS);
|
||||
|
||||
/* Suspend the screensaver */
|
||||
void (*SuspendScreenSaver) (_THIS);
|
||||
|
||||
/* Text input */
|
||||
void (*StartTextInput) (_THIS);
|
||||
void (*StopTextInput) (_THIS);
|
||||
void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
|
||||
|
||||
/* Clipboard */
|
||||
int (*SetClipboardText) (_THIS, const char *text);
|
||||
char * (*GetClipboardText) (_THIS);
|
||||
SDL_bool (*HasClipboardText) (_THIS);
|
||||
|
||||
/* * * */
|
||||
/* Data common to all drivers */
|
||||
SDL_bool suspend_screensaver;
|
||||
int num_displays;
|
||||
SDL_VideoDisplay *displays;
|
||||
int current_display;
|
||||
Uint8 window_magic;
|
||||
Uint8 texture_magic;
|
||||
Uint32 next_object_id;
|
||||
char * clipboard_text;
|
||||
|
||||
/* * * */
|
||||
/* Data used by the GL drivers */
|
||||
struct
|
||||
{
|
||||
int red_size;
|
||||
int green_size;
|
||||
int blue_size;
|
||||
int alpha_size;
|
||||
int depth_size;
|
||||
int buffer_size;
|
||||
int stencil_size;
|
||||
int double_buffer;
|
||||
int accum_red_size;
|
||||
int accum_green_size;
|
||||
int accum_blue_size;
|
||||
int accum_alpha_size;
|
||||
int stereo;
|
||||
int multisamplebuffers;
|
||||
int multisamplesamples;
|
||||
int accelerated;
|
||||
int major_version;
|
||||
int minor_version;
|
||||
int retained_backing;
|
||||
int driver_loaded;
|
||||
char driver_path[256];
|
||||
void *dll_handle;
|
||||
} gl_config;
|
||||
|
||||
/* * * */
|
||||
/* Data private to this driver */
|
||||
void *driverdata;
|
||||
struct SDL_GLDriverData *gl_data;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
struct SDL_PrivateGLESData *gles_data;
|
||||
#endif
|
||||
|
||||
/* * * */
|
||||
/* The function used to dispose of this structure */
|
||||
void (*free) (_THIS);
|
||||
};
|
||||
|
||||
typedef struct VideoBootStrap
|
||||
{
|
||||
const char *name;
|
||||
const char *desc;
|
||||
int (*available) (void);
|
||||
SDL_VideoDevice *(*create) (int devindex);
|
||||
} VideoBootStrap;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
extern VideoBootStrap COCOA_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11
|
||||
extern VideoBootStrap X11_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_FBCON
|
||||
extern VideoBootStrap FBCON_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DIRECTFB
|
||||
extern VideoBootStrap DirectFB_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PS3
|
||||
extern VideoBootStrap PS3_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_SVGALIB
|
||||
extern VideoBootStrap SVGALIB_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_GAPI
|
||||
extern VideoBootStrap GAPI_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WIN32
|
||||
extern VideoBootStrap WIN32_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_BWINDOW
|
||||
extern VideoBootStrap BWINDOW_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PHOTON
|
||||
extern VideoBootStrap photon_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_QNXGF
|
||||
extern VideoBootStrap qnxgf_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_EPOC
|
||||
extern VideoBootStrap EPOC_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_RISCOS
|
||||
extern VideoBootStrap RISCOS_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
extern VideoBootStrap UIKIT_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
extern VideoBootStrap ANDROID_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
extern VideoBootStrap DUMMY_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_NDS
|
||||
extern VideoBootStrap NDS_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
extern VideoBootStrap PND_bootstrap;
|
||||
#endif
|
||||
|
||||
#define SDL_CurrentDisplay (&_this->displays[_this->current_display])
|
||||
#define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer)
|
||||
|
||||
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
|
||||
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
|
||||
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
|
||||
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
|
||||
extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display);
|
||||
extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode);
|
||||
extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
|
||||
extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
|
||||
extern int SDL_SetPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors);
|
||||
extern int SDL_GetPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors);
|
||||
extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
|
||||
extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
|
||||
extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver);
|
||||
|
||||
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
|
||||
|
||||
extern void SDL_OnWindowShown(SDL_Window * window);
|
||||
extern void SDL_OnWindowHidden(SDL_Window * window);
|
||||
extern void SDL_OnWindowResized(SDL_Window * window);
|
||||
extern void SDL_OnWindowMinimized(SDL_Window * window);
|
||||
extern void SDL_OnWindowRestored(SDL_Window * window);
|
||||
extern void SDL_OnWindowFocusGained(SDL_Window * window);
|
||||
extern void SDL_OnWindowFocusLost(SDL_Window * window);
|
||||
extern SDL_Window * SDL_GetFocusWindow(void);
|
||||
|
||||
#endif /* _SDL_sysvideo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -43,12 +43,14 @@
|
||||
|
||||
#if SDL_VIDEO_OPENGL
|
||||
#include "SDL_opengl.h"
|
||||
#endif /* SDL_VIDEO_OPENGL */
|
||||
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
/* On Windows, windows.h defines CreateWindow */
|
||||
#ifdef CreateWindow
|
||||
#undef CreateWindow
|
||||
#endif
|
||||
#endif /* SDL_VIDEO_OPENGL */
|
||||
|
||||
/* Available video drivers */
|
||||
static VideoBootStrap *bootstrap[] = {
|
||||
@@ -70,9 +72,6 @@ static VideoBootStrap *bootstrap[] = {
|
||||
#if SDL_VIDEO_DRIVER_SVGALIB
|
||||
&SVGALIB_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_GAPI
|
||||
&GAPI_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WIN32
|
||||
&WIN32_bootstrap,
|
||||
#endif
|
||||
@@ -105,6 +104,9 @@ static VideoBootStrap *bootstrap[] = {
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
&PND_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
&Android_bootstrap,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
@@ -1104,7 +1106,7 @@ SDL_SetWindowTitle(SDL_Window * window, const char *title)
|
||||
if (window->title) {
|
||||
SDL_free(window->title);
|
||||
}
|
||||
if (title) {
|
||||
if (title && *title) {
|
||||
window->title = SDL_strdup(title);
|
||||
} else {
|
||||
window->title = NULL;
|
||||
@@ -1118,9 +1120,9 @@ SDL_SetWindowTitle(SDL_Window * window, const char *title)
|
||||
const char *
|
||||
SDL_GetWindowTitle(SDL_Window * window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, NULL);
|
||||
CHECK_WINDOW_MAGIC(window, "");
|
||||
|
||||
return window->title;
|
||||
return window->title ? window->title : "";
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1453,7 +1455,6 @@ SDL_DestroyWindow(SDL_Window * window)
|
||||
SDL_VideoDisplay *display;
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, );
|
||||
window->magic = NULL;
|
||||
|
||||
if (window->title) {
|
||||
SDL_free(window->title);
|
||||
@@ -1472,6 +1473,9 @@ SDL_DestroyWindow(SDL_Window * window)
|
||||
SDL_GL_UnloadLibrary();
|
||||
}
|
||||
|
||||
/* Now invalidate magic */
|
||||
window->magic = NULL;
|
||||
|
||||
/* Unlink the window from the list */
|
||||
display = window->display;
|
||||
if (window->next) {
|
||||
@@ -3562,6 +3566,11 @@ SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
|
||||
|
||||
if (!info) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
info->subsystem = SDL_SYSWM_UNKNOWN;
|
||||
|
||||
if (!_this->GetWindowWMInfo) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
3630
project/sdl/sdl-1.3/src/video/SDL_video.c.orig
Normal file
3630
project/sdl/sdl-1.3/src/video/SDL_video.c.orig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -192,6 +192,7 @@ Cocoa_PumpEvents(_THIS)
|
||||
if ( event == nil ) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch ([event type]) {
|
||||
case NSLeftMouseDown:
|
||||
case NSOtherMouseDown:
|
||||
|
||||
@@ -144,6 +144,8 @@
|
||||
{
|
||||
[_markedText release];
|
||||
_markedText = nil;
|
||||
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
}
|
||||
|
||||
- (NSRect) firstRectForCharacterRange: (NSRange) theRange
|
||||
@@ -219,14 +221,14 @@ DoUnsidedModifiers(unsigned short scancode,
|
||||
if (oldMask && oldMask != newMask) { /* modifier up event */
|
||||
/* If this was Caps Lock, we need some additional voodoo to make SDL happy */
|
||||
if (bit == NSAlphaShiftKeyMask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, mapping[i], SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, mapping[i]);
|
||||
}
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, mapping[i], SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]);
|
||||
} else if (newMask && oldMask != newMask) { /* modifier down event */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, mapping[i], SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, mapping[i]);
|
||||
/* If this was Caps Lock, we need some additional voodoo to make SDL happy */
|
||||
if (bit == NSAlphaShiftKeyMask) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, mapping[i], SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,9 +253,9 @@ HandleNonDeviceModifier(unsigned int device_independent_mask,
|
||||
newMask = newMods & device_independent_mask;
|
||||
|
||||
if (oldMask && oldMask != newMask) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
} else if (newMask && oldMask != newMask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,9 +280,9 @@ HandleModifierOneSide(unsigned int oldMods, unsigned int newMods,
|
||||
* find out which it is.
|
||||
*/
|
||||
if (new_dep_mask && old_dep_mask != new_dep_mask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
|
||||
} else {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +353,7 @@ ReleaseModifierSide(unsigned int device_independent_mask,
|
||||
/* In this case, we can't detect the keyboard, so use the left side
|
||||
* to represent both, and release it.
|
||||
*/
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, left_scancode, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, left_scancode);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -362,10 +364,10 @@ ReleaseModifierSide(unsigned int device_independent_mask,
|
||||
* so I hope this doesn't cause other problems.
|
||||
*/
|
||||
if ( left_device_dependent_mask & oldMods ) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, left_scancode, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, left_scancode);
|
||||
}
|
||||
if ( right_device_dependent_mask & oldMods ) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, right_scancode, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, right_scancode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,16 +384,16 @@ HandleCapsLock(unsigned short scancode,
|
||||
newMask = newMods & NSAlphaShiftKeyMask;
|
||||
|
||||
if (oldMask != newMask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||
}
|
||||
|
||||
oldMask = oldMods & NSNumericPadKeyMask;
|
||||
newMask = newMods & NSNumericPadKeyMask;
|
||||
|
||||
if (oldMask != newMask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,7 +672,6 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
unsigned short scancode = [event keyCode];
|
||||
SDL_scancode code;
|
||||
SDL_bool repeat;
|
||||
#if 0
|
||||
const char *text;
|
||||
#endif
|
||||
@@ -689,13 +690,12 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
|
||||
switch ([event type]) {
|
||||
case NSKeyDown:
|
||||
repeat = [event isARepeat] ? SDL_TRUE : SDL_FALSE;
|
||||
if (!repeat) {
|
||||
if (![event isARepeat]) {
|
||||
/* See if we need to rebuild the keyboard layout */
|
||||
UpdateKeymap(data);
|
||||
}
|
||||
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code, repeat);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
#if 1
|
||||
if (code == SDL_SCANCODE_UNKNOWN) {
|
||||
fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
|
||||
@@ -714,7 +714,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
}
|
||||
break;
|
||||
case NSKeyUp:
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||
break;
|
||||
case NSFlagsChanged:
|
||||
/* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */
|
||||
|
||||
44
project/sdl/sdl-1.3/src/video/cocoa/SDL_cocoashape.h
Normal file
44
project/sdl/sdl-1.3/src/video/cocoa/SDL_cocoashape.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_cocoashape_h
|
||||
#define _SDL_cocoashape_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_shape.h"
|
||||
#include "../SDL_shape_internals.h"
|
||||
|
||||
typedef struct {
|
||||
NSGraphicsContext* context;
|
||||
SDL_bool saved;
|
||||
|
||||
SDL_ShapeTree* shape;
|
||||
} SDL_ShapeData;
|
||||
|
||||
extern SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window);
|
||||
extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
|
||||
extern int Cocoa_ResizeWindowShape(SDL_Window *window);
|
||||
|
||||
#endif
|
||||
98
project/sdl/sdl-1.3/src/video/cocoa/SDL_cocoashape.m
Normal file
98
project/sdl/sdl-1.3/src/video/cocoa/SDL_cocoashape.m
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "SDL_shape.h"
|
||||
#include "SDL_cocoashape.h"
|
||||
#include "../src/video/SDL_sysvideo.h"
|
||||
|
||||
SDL_WindowShaper*
|
||||
Cocoa_CreateShaper(SDL_Window* window) {
|
||||
SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
|
||||
[windata->nswindow setOpaque:NO];
|
||||
[windata->nswindow setStyleMask:NSBorderlessWindowMask];
|
||||
SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper));
|
||||
result->window = window;
|
||||
result->mode.mode = ShapeModeDefault;
|
||||
result->mode.parameters.binarizationCutoff = 1;
|
||||
result->userx = result->usery = 0;
|
||||
window->shaper = result;
|
||||
|
||||
SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData));
|
||||
result->driverdata = data;
|
||||
data->context = [windata->nswindow graphicsContext];
|
||||
data->saved = SDL_FALSE;
|
||||
data->shape = NULL;
|
||||
|
||||
int resized_properly = Cocoa_ResizeWindowShape(window);
|
||||
assert(resized_properly == 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
NSView* view;
|
||||
NSBezierPath* path;
|
||||
SDL_Window* window;
|
||||
} SDL_CocoaClosure;
|
||||
|
||||
void
|
||||
ConvertRects(SDL_ShapeTree* tree,void* closure) {
|
||||
SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure;
|
||||
if(tree->kind == OpaqueShape) {
|
||||
NSRect rect = NSMakeRect(tree->data.shape.x,data->window->h - tree->data.shape.y,tree->data.shape.w,tree->data.shape.h);
|
||||
[data->path appendBezierPathWithRect:[data->view convertRect:rect toView:nil]];
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
|
||||
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
|
||||
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
|
||||
SDL_CocoaClosure closure;
|
||||
NSAutoreleasePool *pool = NULL;
|
||||
if(data->saved == SDL_TRUE) {
|
||||
[data->context restoreGraphicsState];
|
||||
data->saved = SDL_FALSE;
|
||||
}
|
||||
|
||||
//[data->context saveGraphicsState];
|
||||
//data->saved = SDL_TRUE;
|
||||
[NSGraphicsContext setCurrentContext:data->context];
|
||||
|
||||
[[NSColor clearColor] set];
|
||||
NSRectFill([[windata->nswindow contentView] frame]);
|
||||
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
closure.view = [windata->nswindow contentView];
|
||||
closure.path = [[NSBezierPath bezierPath] autorelease];
|
||||
closure.window = shaper->window;
|
||||
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
|
||||
[closure.path addClip];
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_ResizeWindowShape(SDL_Window *window) {
|
||||
SDL_ShapeData* data = window->shaper->driverdata;
|
||||
assert(data != NULL);
|
||||
return 0;
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "SDL_cocoashape.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
@@ -92,6 +93,11 @@ Cocoa_CreateDevice(int devindex)
|
||||
device->SetWindowGrab = Cocoa_SetWindowGrab;
|
||||
device->DestroyWindow = Cocoa_DestroyWindow;
|
||||
device->GetWindowWMInfo = Cocoa_GetWindowWMInfo;
|
||||
|
||||
device->shape_driver.CreateShaper = Cocoa_CreateShaper;
|
||||
device->shape_driver.SetWindowShape = Cocoa_SetWindowShape;
|
||||
device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape;
|
||||
|
||||
#ifdef SDL_VIDEO_OPENGL_CGL
|
||||
device->GL_LoadLibrary = Cocoa_GL_LoadLibrary;
|
||||
device->GL_GetProcAddress = Cocoa_GL_GetProcAddress;
|
||||
|
||||
@@ -64,6 +64,20 @@ typedef struct SDL_WindowData SDL_WindowData;
|
||||
-(void) rightMouseDragged:(NSEvent *) theEvent;
|
||||
-(void) otherMouseDragged:(NSEvent *) theEvent;
|
||||
-(void) scrollWheel:(NSEvent *) theEvent;
|
||||
-(void) touchesBeganWithEvent:(NSEvent *) theEvent;
|
||||
-(void) touchesMovedWithEvent:(NSEvent *) theEvent;
|
||||
-(void) touchesEndedWithEvent:(NSEvent *) theEvent;
|
||||
-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
|
||||
|
||||
/* Touch event handling */
|
||||
typedef enum {
|
||||
COCOA_TOUCH_DOWN,
|
||||
COCOA_TOUCH_UP,
|
||||
COCOA_TOUCH_MOVE,
|
||||
COCOA_TOUCH_CANCELLED
|
||||
} cocoaTouchType;
|
||||
-(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
|
||||
|
||||
@end
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
#include "../../events/SDL_windowevents_c.h"
|
||||
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "SDL_cocoashape.h"
|
||||
|
||||
static __inline__ void ConvertNSRect(NSRect *r)
|
||||
{
|
||||
@@ -60,6 +61,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
||||
[center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp];
|
||||
|
||||
[_data->nswindow setAcceptsMouseMovedEvents:YES];
|
||||
[[_data->nswindow contentView] setAcceptsTouchEvents:YES];
|
||||
}
|
||||
|
||||
- (void)close
|
||||
@@ -111,6 +113,7 @@ 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);
|
||||
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||
}
|
||||
|
||||
@@ -268,6 +271,91 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
||||
SDL_SendMouseWheel(_data->window, (int)x, (int)y);
|
||||
}
|
||||
|
||||
- (void)touchesBeganWithEvent:(NSEvent *) theEvent
|
||||
{
|
||||
[self handleTouches:COCOA_TOUCH_DOWN withEvent:theEvent];
|
||||
}
|
||||
|
||||
- (void)touchesMovedWithEvent:(NSEvent *) theEvent
|
||||
{
|
||||
[self handleTouches:COCOA_TOUCH_MOVE withEvent:theEvent];
|
||||
}
|
||||
|
||||
- (void)touchesEndedWithEvent:(NSEvent *) theEvent
|
||||
{
|
||||
[self handleTouches:COCOA_TOUCH_UP withEvent:theEvent];
|
||||
}
|
||||
|
||||
- (void)touchesCancelledWithEvent:(NSEvent *) theEvent
|
||||
{
|
||||
[self handleTouches:COCOA_TOUCH_CANCELLED withEvent:theEvent];
|
||||
}
|
||||
|
||||
- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
|
||||
{
|
||||
NSSet *touches = 0;
|
||||
NSEnumerator *enumerator;
|
||||
NSTouch *touch;
|
||||
|
||||
switch (type) {
|
||||
case COCOA_TOUCH_DOWN:
|
||||
touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil];
|
||||
break;
|
||||
case COCOA_TOUCH_UP:
|
||||
case COCOA_TOUCH_CANCELLED:
|
||||
touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil];
|
||||
break;
|
||||
case COCOA_TOUCH_MOVE:
|
||||
touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil];
|
||||
break;
|
||||
}
|
||||
|
||||
enumerator = [touches objectEnumerator];
|
||||
touch = (NSTouch*)[enumerator nextObject];
|
||||
while (touch) {
|
||||
SDL_TouchID touchId = (SDL_TouchID)[touch device];
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_FingerID fingerId = (SDL_FingerID)[touch identity];
|
||||
float x = [touch normalizedPosition].x;
|
||||
float y = [touch normalizedPosition].y;
|
||||
/* Make the origin the upper left instead of the lower left */
|
||||
y = 1.0f - y;
|
||||
|
||||
switch (type) {
|
||||
case COCOA_TOUCH_DOWN:
|
||||
SDL_SendFingerDown(touchId, fingerId, SDL_TRUE, x, y, 1);
|
||||
break;
|
||||
case COCOA_TOUCH_UP:
|
||||
case COCOA_TOUCH_CANCELLED:
|
||||
SDL_SendFingerDown(touchId, fingerId, SDL_FALSE, x, y, 1);
|
||||
break;
|
||||
case COCOA_TOUCH_MOVE:
|
||||
SDL_SendTouchMotion(touchId, fingerId, SDL_FALSE, x, y, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
touch = (NSTouch*)[enumerator nextObject];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface SDLWindow : NSWindow
|
||||
@@ -616,10 +704,11 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
|
||||
SDL_bool
|
||||
Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
{
|
||||
//NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
//info->window = nswindow;
|
||||
info->subsystem = SDL_SYSWM_COCOA;
|
||||
info->cocoa.window = nswindow;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "SDL_DirectFB_video.h"
|
||||
|
||||
#include "../../events/SDL_windowevents_c.h"
|
||||
|
||||
#define COLOR_EXPAND(col) col.r, col.g, col.b, col.a
|
||||
|
||||
static DFB_Theme theme_std = {
|
||||
@@ -52,7 +54,7 @@ static DFB_Theme theme_none = {
|
||||
};
|
||||
|
||||
static void
|
||||
DrTriangle(IDirectFBSurface * s, int down, int x, int y, int w)
|
||||
DrawTriangle(IDirectFBSurface * s, int down, int x, int y, int w)
|
||||
{
|
||||
int x1, x2, x3;
|
||||
int y1, y2, y3;
|
||||
@@ -76,7 +78,33 @@ DrTriangle(IDirectFBSurface * s, int down, int x, int y, int w)
|
||||
}
|
||||
|
||||
static void
|
||||
DrCaption(IDirectFBSurface * s, int x, int y, char *text)
|
||||
LoadFont(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
if (windata->font != NULL) {
|
||||
SDL_DFB_RELEASE(windata->font);
|
||||
windata->font = NULL;
|
||||
SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font));
|
||||
}
|
||||
|
||||
if (windata->theme.font != NULL)
|
||||
{
|
||||
DFBFontDescription fdesc;
|
||||
|
||||
SDL_zero(fdesc);
|
||||
fdesc.flags = DFDESC_HEIGHT;
|
||||
fdesc.height = windata->theme.font_size;
|
||||
SDL_DFB_CHECK(devdata->
|
||||
dfb->CreateFont(devdata->dfb, windata->theme.font,
|
||||
&fdesc, &windata->font));
|
||||
SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
DrawCraption(_THIS, IDirectFBSurface * s, int x, int y, char *text)
|
||||
{
|
||||
DFBSurfaceTextFlags flags;
|
||||
|
||||
@@ -86,7 +114,7 @@ DrCaption(IDirectFBSurface * s, int x, int y, char *text)
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_WM_RedrawLayout(SDL_Window * window)
|
||||
DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
IDirectFBSurface *s = windata->window_surface;
|
||||
@@ -99,6 +127,7 @@ DirectFB_WM_RedrawLayout(SDL_Window * window)
|
||||
if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN))
|
||||
return;
|
||||
|
||||
LoadFont(_this, window);
|
||||
//s->SetDrawingFlags(s, DSDRAW_BLEND);
|
||||
s->SetColor(s, COLOR_EXPAND(t->frame_color));
|
||||
/* top */
|
||||
@@ -122,16 +151,16 @@ DirectFB_WM_RedrawLayout(SDL_Window * window)
|
||||
x = windata->size.w - t->right_size - w + d;
|
||||
y = t->top_size + d;
|
||||
s->SetColor(s, COLOR_EXPAND(t->close_color));
|
||||
DrTriangle(s, 1, x, y, w - 2 * d);
|
||||
DrawTriangle(s, 1, x, y, w - 2 * d);
|
||||
/* Max Button */
|
||||
s->SetColor(s, COLOR_EXPAND(t->max_color));
|
||||
DrTriangle(s, window->flags & SDL_WINDOW_MAXIMIZED ? 1 : 0, x - w,
|
||||
DrawTriangle(s, window->flags & SDL_WINDOW_MAXIMIZED ? 1 : 0, x - w,
|
||||
y, w - 2 * d);
|
||||
|
||||
/* Caption */
|
||||
if (window->title) {
|
||||
s->SetColor(s, COLOR_EXPAND(t->font_color));
|
||||
DrCaption(s, (x - w) / 2, t->top_size + d, window->title);
|
||||
s->SetColor(s, COLOR_EXPAND(t->font_color));
|
||||
DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
|
||||
}
|
||||
/* Icon */
|
||||
if (windata->icon) {
|
||||
@@ -152,26 +181,25 @@ DFBResult
|
||||
DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
DFBResult ret;
|
||||
|
||||
ret = windata->window->GetSize(windata->window, cw, ch);
|
||||
SDL_DFB_CHECK(windata->window->GetSize(windata->window, cw, ch));
|
||||
*cw -= windata->theme.left_size + windata->theme.right_size;
|
||||
*ch -=
|
||||
windata->theme.top_size + windata->theme.caption_size +
|
||||
windata->theme.bottom_size;
|
||||
return ret;
|
||||
return DFB_OK;
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_WM_AdjustWindowLayout(SDL_Window * window)
|
||||
DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
if (!windata->is_managed)
|
||||
windata->theme = theme_none;
|
||||
else if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
else if (flags & SDL_WINDOW_FULLSCREEN) {
|
||||
windata->theme = theme_none;
|
||||
} else if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
||||
} else if (flags & SDL_WINDOW_MAXIMIZED) {
|
||||
windata->theme = theme_std;
|
||||
windata->theme.left_size = 0;
|
||||
windata->theme.right_size = 0;
|
||||
@@ -183,12 +211,12 @@ DirectFB_WM_AdjustWindowLayout(SDL_Window * window)
|
||||
|
||||
windata->client.x = windata->theme.left_size;
|
||||
windata->client.y = windata->theme.top_size + windata->theme.caption_size;
|
||||
windata->client.w = window->w;
|
||||
windata->client.h = window->h;
|
||||
windata->client.w = w;
|
||||
windata->client.h = h;
|
||||
windata->size.w =
|
||||
window->w + windata->theme.left_size + windata->theme.right_size;
|
||||
w + windata->theme.left_size + windata->theme.right_size;
|
||||
windata->size.h =
|
||||
window->h + windata->theme.top_size +
|
||||
h + windata->theme.top_size +
|
||||
windata->theme.caption_size + windata->theme.bottom_size;
|
||||
}
|
||||
|
||||
@@ -198,19 +226,16 @@ DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window)
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
|
||||
windata->window->GetPosition(windata->window,
|
||||
&windata->restore.x, &windata->restore.y);
|
||||
windata->window->GetSize(windata->window, &windata->restore.w,
|
||||
&windata->restore.h);
|
||||
SDL_DFB_CHECK(windata->window->GetPosition(windata->window,
|
||||
&windata->restore.x, &windata->restore.y));
|
||||
SDL_DFB_CHECK(windata->window->GetSize(windata->window, &windata->restore.w,
|
||||
&windata->restore.h));
|
||||
|
||||
/* Do this already here */
|
||||
window->flags |= SDL_WINDOW_MAXIMIZED;
|
||||
DirectFB_WM_AdjustWindowLayout(window);
|
||||
DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ;
|
||||
|
||||
windata->window->MoveTo(windata->window, 0, 0);
|
||||
windata->window->Resize(windata->window,
|
||||
display->current_mode.w, display->current_mode.h);
|
||||
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
|
||||
SDL_DFB_CHECK(windata->window->MoveTo(windata->window, 0, 0));
|
||||
SDL_DFB_CHECK(windata->window->Resize(windata->window,
|
||||
display->current_mode.w, display->current_mode.h));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -218,15 +243,13 @@ DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
/* Do this already here */
|
||||
//window->flags &= ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED);
|
||||
DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED),
|
||||
windata->restore.w, windata->restore.h);
|
||||
|
||||
DirectFB_WM_AdjustWindowLayout(window);
|
||||
windata->window->MoveTo(windata->window, windata->restore.x,
|
||||
windata->restore.y);
|
||||
windata->window->Resize(windata->window, windata->restore.w,
|
||||
windata->restore.h);
|
||||
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
||||
SDL_DFB_CHECK(windata->window->Resize(windata->window, windata->restore.w,
|
||||
windata->restore.h));
|
||||
SDL_DFB_CHECK(windata->window->MoveTo(windata->window, windata->restore.x,
|
||||
windata->restore.y));
|
||||
}
|
||||
|
||||
enum
|
||||
@@ -291,7 +314,9 @@ static int wm_lasty;
|
||||
int
|
||||
DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
|
||||
|
||||
if (!windata->is_managed)
|
||||
return 0;
|
||||
@@ -304,19 +329,26 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
|
||||
case WM_POS_NONE:
|
||||
return 0;
|
||||
case WM_POS_CLOSE:
|
||||
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_CLOSE, 0,
|
||||
wm_grab = WM_POS_NONE;
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0,
|
||||
0);
|
||||
return 1;
|
||||
case WM_POS_MAX:
|
||||
wm_grab = WM_POS_NONE;
|
||||
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
||||
DirectFB_WM_RestoreWindow(_this, window);
|
||||
SDL_RestoreWindow(window);
|
||||
} else {
|
||||
DirectFB_WM_MaximizeWindow(_this, window);
|
||||
SDL_MaximizeWindow(window);
|
||||
}
|
||||
return 1;
|
||||
case WM_POS_CAPTION:
|
||||
DirectFB_RaiseWindow(_this, window);
|
||||
/* fall through */
|
||||
default:
|
||||
wm_grab = pos;
|
||||
windata->window->GrabPointer(windata->window);
|
||||
if (gwindata != NULL)
|
||||
SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window));
|
||||
SDL_DFB_CHECK(windata->window->GrabPointer(windata->window));
|
||||
wm_lastx = evt->cx;
|
||||
wm_lasty = evt->cy;
|
||||
}
|
||||
@@ -333,20 +365,22 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
|
||||
int cw, ch;
|
||||
|
||||
if (wm_grab & WM_POS_CAPTION)
|
||||
windata->window->Move(windata->window, dx, dy);
|
||||
if (wm_grab & WM_POS_RIGHT) {
|
||||
windata->window->GetSize(windata->window, &cw, &ch);
|
||||
windata->window->Resize(windata->window, cw + dx, ch);
|
||||
}
|
||||
if (wm_grab & WM_POS_BOTTOM) {
|
||||
windata->window->GetSize(windata->window, &cw, &ch);
|
||||
windata->window->Resize(windata->window, cw, ch + dy);
|
||||
SDL_DFB_CHECK(windata->window->Move(windata->window, dx, dy));
|
||||
if (wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
|
||||
if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
|
||||
dx = 0;
|
||||
else if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
|
||||
dy = 0;
|
||||
SDL_DFB_CHECK(windata->window->GetSize(windata->window, &cw, &ch));
|
||||
SDL_DFB_CHECK(windata->window->Resize(windata->window, cw + dx, ch + dy));
|
||||
}
|
||||
wm_lastx = evt->cx;
|
||||
wm_lasty = evt->cy;
|
||||
return 1;
|
||||
}
|
||||
windata->window->UngrabPointer(windata->window);
|
||||
SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
|
||||
if (gwindata != NULL)
|
||||
SDL_DFB_CHECK(gwindata->window->GrabPointer(gwindata->window));
|
||||
wm_grab = WM_POS_NONE;
|
||||
break;
|
||||
case DWET_KEYDOWN:
|
||||
|
||||
@@ -41,10 +41,10 @@ struct _DFB_Theme
|
||||
DFBColor max_color;
|
||||
};
|
||||
|
||||
extern void DirectFB_WM_AdjustWindowLayout(SDL_Window * window);
|
||||
extern void DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h);
|
||||
extern void DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window);
|
||||
extern void DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window);
|
||||
extern void DirectFB_WM_RedrawLayout(SDL_Window * window);
|
||||
extern void DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window);
|
||||
|
||||
extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window,
|
||||
DFBWindowEvent * evt);
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
#define DFB_SYM(ret, name, args, al, func) ret (*name) args;
|
||||
static struct _SDL_DirectFB_Symbols
|
||||
{
|
||||
DFB_SYMS const unsigned int *directfb_major_version;
|
||||
DFB_SYMS
|
||||
const unsigned int *directfb_major_version;
|
||||
const unsigned int *directfb_minor_version;
|
||||
const unsigned int *directfb_micro_version;
|
||||
} SDL_DirectFB_Symbols;
|
||||
|
||||
@@ -32,9 +32,29 @@
|
||||
#include "../../events/scancodes_linux.h"
|
||||
#include "SDL_DirectFB_events.h"
|
||||
|
||||
#if USE_MULTI_API
|
||||
#define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(id, relative, x, y, p)
|
||||
#define SDL_SendMouseButton_ex(w, id, state, button) SDL_SendMouseButton(id, state, button)
|
||||
#define SDL_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(id, state, scancode)
|
||||
#define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(id, text)
|
||||
#else
|
||||
#define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(w, relative, x, y)
|
||||
#define SDL_SendMouseButton_ex(w, id, state, button) SDL_SendMouseButton(w, state, button)
|
||||
#define SDL_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(state, scancode)
|
||||
#define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(text)
|
||||
#endif
|
||||
|
||||
typedef struct _cb_data cb_data;
|
||||
struct _cb_data
|
||||
{
|
||||
DFB_DeviceData *devdata;
|
||||
int sys_ids;
|
||||
int sys_kbd;
|
||||
};
|
||||
|
||||
/* The translation tables from a DirectFB keycode to a SDL keysym */
|
||||
static SDLKey oskeymap[256];
|
||||
static int sys_ids;
|
||||
|
||||
|
||||
static SDL_keysym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt,
|
||||
SDL_keysym * keysym);
|
||||
@@ -54,17 +74,13 @@ DirectFB_SetContext(_THIS, SDL_Window *window)
|
||||
* This has simply no effect.
|
||||
*/
|
||||
|
||||
SDL_Window *window = SDL_GetWindowFromID(id);
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
|
||||
int ret;
|
||||
|
||||
/* FIXME: should we handle the error */
|
||||
if (dispdata->vidIDinuse)
|
||||
SDL_DFB_CHECKERR(dispdata->vidlayer->SwitchContext(dispdata->vidlayer,
|
||||
SDL_DFB_CHECK(dispdata->vidlayer->SwitchContext(dispdata->vidlayer,
|
||||
DFB_TRUE));
|
||||
|
||||
error:
|
||||
return;
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -72,27 +88,36 @@ DirectFB_SetContext(_THIS, SDL_Window *window)
|
||||
static void
|
||||
FocusAllMice(_THIS, SDL_Window *window)
|
||||
{
|
||||
#if USE_MULTI_API
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
int index;
|
||||
|
||||
for (index = 0; index < devdata->num_mice; index++)
|
||||
SDL_SetMouseFocus(devdata->mouse_id[index], id);
|
||||
#else
|
||||
SDL_SetMouseFocus(window);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
FocusAllKeyboards(_THIS, SDL_Window *window)
|
||||
{
|
||||
#if USE_MULTI_API
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
int index;
|
||||
|
||||
for (index = 0; index < devdata->num_keyboard; index++)
|
||||
SDL_SetKeyboardFocus(index, id);
|
||||
#else
|
||||
SDL_SetKeyboardFocus(window);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
MotionAllMice(_THIS, int x, int y)
|
||||
{
|
||||
#if USE_MULTI_API
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
int index;
|
||||
|
||||
@@ -102,6 +127,7 @@ MotionAllMice(_THIS, int x, int y)
|
||||
mouse->y = mouse->last_y = y;
|
||||
//SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -150,9 +176,9 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
|
||||
case DWET_BUTTONDOWN:
|
||||
if (ClientXY(p, &evt->x, &evt->y)) {
|
||||
if (!devdata->use_linux_input) {
|
||||
SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt->x,
|
||||
SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0, evt->x,
|
||||
evt->y, 0);
|
||||
SDL_SendMouseButton(devdata->mouse_id[0],
|
||||
SDL_SendMouseButton_ex(p->sdl_window, devdata->mouse_id[0],
|
||||
SDL_PRESSED,
|
||||
DirectFB_TranslateButton
|
||||
(evt->button));
|
||||
@@ -164,9 +190,9 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
|
||||
case DWET_BUTTONUP:
|
||||
if (ClientXY(p, &evt->x, &evt->y)) {
|
||||
if (!devdata->use_linux_input) {
|
||||
SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt->x,
|
||||
SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0, evt->x,
|
||||
evt->y, 0);
|
||||
SDL_SendMouseButton(devdata->mouse_id[0],
|
||||
SDL_SendMouseButton_ex(p->sdl_window, devdata->mouse_id[0],
|
||||
SDL_RELEASED,
|
||||
DirectFB_TranslateButton
|
||||
(evt->button));
|
||||
@@ -177,10 +203,10 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
|
||||
break;
|
||||
case DWET_MOTION:
|
||||
if (ClientXY(p, &evt->x, &evt->y)) {
|
||||
SDL_Window *window = p->window;
|
||||
SDL_Window *window = p->sdl_window;
|
||||
if (!devdata->use_linux_input) {
|
||||
if (!(flags & SDL_WINDOW_INPUT_GRABBED))
|
||||
SDL_SendMouseMotion(devdata->mouse_id[0], 0,
|
||||
SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0,
|
||||
evt->x, evt->y, 0);
|
||||
} else {
|
||||
/* relative movements are not exact!
|
||||
@@ -193,19 +219,19 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
|
||||
}
|
||||
}
|
||||
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS))
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_ENTER, 0,
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_ENTER, 0,
|
||||
0);
|
||||
}
|
||||
break;
|
||||
case DWET_KEYDOWN:
|
||||
if (!devdata->use_linux_input) {
|
||||
DirectFB_TranslateKey(_this, evt, &keysym);
|
||||
SDL_SendKeyboardKey(0, SDL_PRESSED, keysym.scancode);
|
||||
SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode);
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
SDL_memcpy(text, &keysym.unicode, 4);
|
||||
text[4] = 0;
|
||||
if (*text) {
|
||||
SDL_SendKeyboardText(0, text);
|
||||
SDL_SendKeyboardText_ex(0, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,18 +239,18 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
|
||||
case DWET_KEYUP:
|
||||
if (!devdata->use_linux_input) {
|
||||
DirectFB_TranslateKey(_this, evt, &keysym);
|
||||
SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode);
|
||||
SDL_SendKeyboardKey_ex(0, SDL_RELEASED, keysym.scancode);
|
||||
}
|
||||
break;
|
||||
case DWET_POSITION:
|
||||
if (ClientXY(p, &evt->x, &evt->y)) {
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_MOVED,
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_MOVED,
|
||||
evt->x, evt->y);
|
||||
}
|
||||
break;
|
||||
case DWET_POSITION_SIZE:
|
||||
if (ClientXY(p, &evt->x, &evt->y)) {
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_MOVED,
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_MOVED,
|
||||
evt->x, evt->y);
|
||||
}
|
||||
/* fall throught */
|
||||
@@ -234,32 +260,32 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
|
||||
evt->h -=
|
||||
(p->theme.top_size + p->theme.bottom_size +
|
||||
p->theme.caption_size);
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_RESIZED,
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_RESIZED,
|
||||
evt->w, evt->h);
|
||||
break;
|
||||
case DWET_CLOSE:
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_CLOSE, 0, 0);
|
||||
break;
|
||||
case DWET_GOTFOCUS:
|
||||
DirectFB_SetContext(_this, p->window);
|
||||
FocusAllKeyboards(_this, p->window);
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_FOCUS_GAINED,
|
||||
DirectFB_SetContext(_this, p->sdl_window);
|
||||
FocusAllKeyboards(_this, p->sdl_window);
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_FOCUS_GAINED,
|
||||
0, 0);
|
||||
break;
|
||||
case DWET_LOSTFOCUS:
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
|
||||
FocusAllKeyboards(_this, 0);
|
||||
break;
|
||||
case DWET_ENTER:
|
||||
/* SDL_DirectFB_ReshowCursor(_this, 0); */
|
||||
FocusAllMice(_this, p->window);
|
||||
FocusAllMice(_this, p->sdl_window);
|
||||
// FIXME: when do we really enter ?
|
||||
if (ClientXY(p, &evt->x, &evt->y))
|
||||
MotionAllMice(_this, evt->x, evt->y);
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_ENTER, 0, 0);
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_ENTER, 0, 0);
|
||||
break;
|
||||
case DWET_LEAVE:
|
||||
SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_LEAVE, 0, 0);
|
||||
SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_LEAVE, 0, 0);
|
||||
FocusAllMice(_this, 0);
|
||||
/* SDL_DirectFB_ReshowCursor(_this, 1); */
|
||||
break;
|
||||
@@ -271,7 +297,7 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
|
||||
}
|
||||
|
||||
static void
|
||||
ProcessInputEvent(_THIS, Sint32 grabbed_window, DFBInputEvent * ievt)
|
||||
ProcessInputEvent(_THIS, DFBInputEvent * ievt)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_keysym keysym;
|
||||
@@ -280,12 +306,12 @@ ProcessInputEvent(_THIS, Sint32 grabbed_window, DFBInputEvent * ievt)
|
||||
|
||||
if (!devdata->use_linux_input) {
|
||||
if (ievt->type == DIET_AXISMOTION) {
|
||||
if ((grabbed_window >= 0) && (ievt->flags & DIEF_AXISREL)) {
|
||||
if ((devdata->grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) {
|
||||
if (ievt->axis == DIAI_X)
|
||||
SDL_SendMouseMotion(ievt->device_id, 1,
|
||||
SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1,
|
||||
ievt->axisrel, 0, 0);
|
||||
else if (ievt->axis == DIAI_Y)
|
||||
SDL_SendMouseMotion(ievt->device_id, 1, 0,
|
||||
SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, 0,
|
||||
ievt->axisrel, 0);
|
||||
}
|
||||
}
|
||||
@@ -300,65 +326,69 @@ ProcessInputEvent(_THIS, Sint32 grabbed_window, DFBInputEvent * ievt)
|
||||
else if (ievt->axis == DIAI_Y)
|
||||
last_y = ievt->axisabs;
|
||||
if (!(ievt->flags & DIEF_FOLLOW)) {
|
||||
#if USE_MULTI_API
|
||||
SDL_Mouse *mouse = SDL_GetMouse(ievt->device_id);
|
||||
SDL_Window *window = SDL_GetWindowFromID(mouse->focus);
|
||||
#else
|
||||
SDL_Window *window = devdata->grabbed_window;
|
||||
#endif
|
||||
if (window) {
|
||||
DFB_WindowData *windata =
|
||||
(DFB_WindowData *) window->driverdata;
|
||||
int x, y;
|
||||
|
||||
windata->window->GetPosition(windata->window, &x, &y);
|
||||
SDL_SendMouseMotion(ievt->device_id, 0,
|
||||
SDL_SendMouseMotion_ex(window, ievt->device_id, 0,
|
||||
last_x - (x +
|
||||
windata->client.x),
|
||||
last_y - (y +
|
||||
windata->client.y), 0);
|
||||
} else {
|
||||
SDL_SendMouseMotion(ievt->device_id, 0, last_x,
|
||||
SDL_SendMouseMotion_ex(window, ievt->device_id, 0, last_x,
|
||||
last_y, 0);
|
||||
}
|
||||
}
|
||||
} else if (ievt->flags & DIEF_AXISREL) {
|
||||
if (ievt->axis == DIAI_X)
|
||||
SDL_SendMouseMotion(ievt->device_id, 1,
|
||||
SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1,
|
||||
ievt->axisrel, 0, 0);
|
||||
else if (ievt->axis == DIAI_Y)
|
||||
SDL_SendMouseMotion(ievt->device_id, 1, 0,
|
||||
SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, 0,
|
||||
ievt->axisrel, 0);
|
||||
}
|
||||
break;
|
||||
case DIET_KEYPRESS:
|
||||
kbd_idx = KbdIndex(_this, ievt->device_id);
|
||||
DirectFB_TranslateKeyInputEvent(_this, kbd_idx, ievt, &keysym);
|
||||
SDL_SendKeyboardKey(kbd_idx, SDL_PRESSED, keysym.scancode);
|
||||
SDL_SendKeyboardKey_ex(kbd_idx, SDL_PRESSED, keysym.scancode);
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
SDL_memcpy(text, &keysym.unicode, 4);
|
||||
text[4] = 0;
|
||||
if (*text) {
|
||||
SDL_SendKeyboardText(kbd_idx, text);
|
||||
SDL_SendKeyboardText_ex(kbd_idx, text);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DIET_KEYRELEASE:
|
||||
kbd_idx = KbdIndex(_this, ievt->device_id);
|
||||
DirectFB_TranslateKeyInputEvent(_this, kbd_idx, ievt, &keysym);
|
||||
SDL_SendKeyboardKey(kbd_idx, SDL_RELEASED, keysym.scancode);
|
||||
SDL_SendKeyboardKey_ex(kbd_idx, SDL_RELEASED, keysym.scancode);
|
||||
break;
|
||||
case DIET_BUTTONPRESS:
|
||||
if (ievt->buttons & DIBM_LEFT)
|
||||
SDL_SendMouseButton(ievt->device_id, SDL_PRESSED, 1);
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 1);
|
||||
if (ievt->buttons & DIBM_MIDDLE)
|
||||
SDL_SendMouseButton(ievt->device_id, SDL_PRESSED, 2);
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 2);
|
||||
if (ievt->buttons & DIBM_RIGHT)
|
||||
SDL_SendMouseButton(ievt->device_id, SDL_PRESSED, 3);
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 3);
|
||||
break;
|
||||
case DIET_BUTTONRELEASE:
|
||||
if (!(ievt->buttons & DIBM_LEFT))
|
||||
SDL_SendMouseButton(ievt->device_id, SDL_RELEASED, 1);
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 1);
|
||||
if (!(ievt->buttons & DIBM_MIDDLE))
|
||||
SDL_SendMouseButton(ievt->device_id, SDL_RELEASED, 2);
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 2);
|
||||
if (!(ievt->buttons & DIBM_RIGHT))
|
||||
SDL_SendMouseButton(ievt->device_id, SDL_RELEASED, 3);
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 3);
|
||||
break;
|
||||
default:
|
||||
break; /* please gcc */
|
||||
@@ -372,17 +402,10 @@ DirectFB_PumpEventsWindow(_THIS)
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
DFB_WindowData *p;
|
||||
DFBInputEvent ievt;
|
||||
SDL_Window *grabbed_window;
|
||||
|
||||
grabbed_window = NULL;
|
||||
|
||||
for (p = devdata->firstwin; p != NULL; p = p->next) {
|
||||
DFBWindowEvent evt;
|
||||
SDL_Window *w = SDL_GetWindowFromID(p->window);
|
||||
|
||||
if (w->flags & SDL_WINDOW_INPUT_GRABBED) {
|
||||
grabbed_window = w;
|
||||
}
|
||||
SDL_Window *w = p->sdl_window;
|
||||
|
||||
while (p->eventbuffer->GetEvent(p->eventbuffer,
|
||||
DFB_EVENT(&evt)) == DFB_OK) {
|
||||
@@ -394,7 +417,7 @@ DirectFB_PumpEventsWindow(_THIS)
|
||||
/* Now get relative events in case we need them */
|
||||
while (devdata->events->GetEvent(devdata->events,
|
||||
DFB_EVENT(&ievt)) == DFB_OK) {
|
||||
ProcessInputEvent(_this, grabbed_window, &ievt);
|
||||
ProcessInputEvent(_this, &ievt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,56 +622,49 @@ DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button)
|
||||
}
|
||||
|
||||
static DFBEnumerationResult
|
||||
input_device_cb(DFBInputDeviceID device_id,
|
||||
EnumKeyboards(DFBInputDeviceID device_id,
|
||||
DFBInputDeviceDescription desc, void *callbackdata)
|
||||
{
|
||||
DFB_DeviceData *devdata = callbackdata;
|
||||
cb_data *cb = callbackdata;
|
||||
DFB_DeviceData *devdata = cb->devdata;
|
||||
#if USE_MULTI_API
|
||||
SDL_Keyboard keyboard;
|
||||
#endif
|
||||
SDLKey keymap[SDL_NUM_SCANCODES];
|
||||
|
||||
if ((desc.caps & DIDTF_KEYBOARD) && device_id == DIDID_KEYBOARD) {
|
||||
SDL_zero(keyboard);
|
||||
SDL_AddKeyboard(&keyboard, 0);
|
||||
devdata->keyboard[0].id = device_id;
|
||||
devdata->keyboard[0].is_generic = 0;
|
||||
if (!strncmp("X11", desc.name, 3))
|
||||
devdata->keyboard[0].is_generic = 1;
|
||||
|
||||
SDL_GetDefaultKeymap(keymap);
|
||||
SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
|
||||
devdata->num_keyboard++;
|
||||
|
||||
return DFENUM_CANCEL;
|
||||
}
|
||||
return DFENUM_OK;
|
||||
}
|
||||
|
||||
static DFBEnumerationResult
|
||||
EnumKeyboards(DFBInputDeviceID device_id,
|
||||
DFBInputDeviceDescription desc, void *callbackdata)
|
||||
{
|
||||
DFB_DeviceData *devdata = callbackdata;
|
||||
SDL_Keyboard keyboard;
|
||||
SDLKey keymap[SDL_NUM_SCANCODES];
|
||||
|
||||
if (sys_ids) {
|
||||
if (device_id >= 0x10)
|
||||
return DFENUM_OK;
|
||||
} else {
|
||||
if (device_id < 0x10)
|
||||
return DFENUM_OK;
|
||||
}
|
||||
if (!cb->sys_kbd) {
|
||||
if (cb->sys_ids) {
|
||||
if (device_id >= 0x10)
|
||||
return DFENUM_OK;
|
||||
} else {
|
||||
if (device_id < 0x10)
|
||||
return DFENUM_OK;
|
||||
}
|
||||
} else {
|
||||
if (device_id != DIDID_KEYBOARD)
|
||||
return DFENUM_OK;
|
||||
}
|
||||
|
||||
if ((desc.caps & DIDTF_KEYBOARD)) {
|
||||
#if USE_MULTI_API
|
||||
SDL_zero(keyboard);
|
||||
SDL_AddKeyboard(&keyboard, devdata->num_keyboard);
|
||||
#endif
|
||||
devdata->keyboard[devdata->num_keyboard].id = device_id;
|
||||
devdata->keyboard[devdata->num_keyboard].is_generic = 0;
|
||||
if (!strncmp("X11", desc.name, 3))
|
||||
devdata->keyboard[devdata->num_keyboard].is_generic = 1;
|
||||
|
||||
SDL_GetDefaultKeymap(keymap);
|
||||
#if USE_MULTI_API
|
||||
SDL_SetKeymap(devdata->num_keyboard, 0, keymap, SDL_NUM_SCANCODES);
|
||||
#else
|
||||
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
|
||||
#endif
|
||||
devdata->num_keyboard++;
|
||||
|
||||
if (cb->sys_kbd)
|
||||
return DFENUM_CANCEL;
|
||||
}
|
||||
return DFENUM_OK;
|
||||
}
|
||||
@@ -657,33 +673,36 @@ void
|
||||
DirectFB_InitKeyboard(_THIS)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
int ret;
|
||||
|
||||
cb_data cb;
|
||||
|
||||
DirectFB_InitOSKeymap(_this, &oskeymap[0], SDL_arraysize(oskeymap));
|
||||
|
||||
devdata->num_keyboard = 0;
|
||||
cb.devdata = devdata;
|
||||
|
||||
if (devdata->use_linux_input) {
|
||||
sys_ids = 0;
|
||||
cb.sys_kbd = 0;
|
||||
cb.sys_ids = 0;
|
||||
SDL_DFB_CHECK(devdata->dfb->
|
||||
EnumInputDevices(devdata->dfb, EnumKeyboards, devdata));
|
||||
EnumInputDevices(devdata->dfb, EnumKeyboards, &cb));
|
||||
if (devdata->num_keyboard == 0) {
|
||||
sys_ids = 1;
|
||||
cb.sys_ids = 1;
|
||||
SDL_DFB_CHECK(devdata->dfb->EnumInputDevices(devdata->dfb,
|
||||
EnumKeyboards,
|
||||
devdata));
|
||||
&cb));
|
||||
}
|
||||
} else {
|
||||
cb.sys_kbd = 1;
|
||||
SDL_DFB_CHECK(devdata->dfb->EnumInputDevices(devdata->dfb,
|
||||
input_device_cb,
|
||||
devdata));
|
||||
EnumKeyboards,
|
||||
&cb));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_QuitKeyboard(_THIS)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
int ret;
|
||||
//SDL_DFB_DEVICEDATA(_this);
|
||||
|
||||
SDL_KeyboardQuit();
|
||||
|
||||
@@ -759,3 +778,4 @@ DirectFB_PumpEvents(_THIS)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -40,112 +40,101 @@ struct modes_callback_t
|
||||
SDL_DisplayMode *modelist;
|
||||
};
|
||||
|
||||
static int
|
||||
DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat, Uint32 * fmt)
|
||||
static const struct {
|
||||
DFBSurfacePixelFormat dfb;
|
||||
Uint32 sdl;
|
||||
} pixelformat_tab[] =
|
||||
{
|
||||
switch (pixelformat) {
|
||||
case DSPF_ALUT44:
|
||||
*fmt = SDL_PIXELFORMAT_INDEX4LSB;
|
||||
break;
|
||||
case DSPF_LUT8:
|
||||
*fmt = SDL_PIXELFORMAT_INDEX8;
|
||||
break;
|
||||
case DSPF_RGB332:
|
||||
*fmt = SDL_PIXELFORMAT_RGB332;
|
||||
break;
|
||||
case DSPF_ARGB4444:
|
||||
*fmt = SDL_PIXELFORMAT_ARGB4444;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_ARGB1555:
|
||||
*fmt = SDL_PIXELFORMAT_ARGB1555;
|
||||
break;
|
||||
case DSPF_RGB16:
|
||||
*fmt = SDL_PIXELFORMAT_RGB565;
|
||||
break;
|
||||
case DSPF_RGB24:
|
||||
*fmt = SDL_PIXELFORMAT_RGB24;
|
||||
break;
|
||||
case DSPF_RGB32:
|
||||
*fmt = SDL_PIXELFORMAT_RGB888;
|
||||
break;
|
||||
case DSPF_ARGB:
|
||||
*fmt = SDL_PIXELFORMAT_ARGB8888;
|
||||
break;
|
||||
case DSPF_YV12:
|
||||
*fmt = SDL_PIXELFORMAT_YV12;
|
||||
break; /* Planar mode: Y + V + U (3 planes) */
|
||||
case DSPF_I420:
|
||||
*fmt = SDL_PIXELFORMAT_IYUV;
|
||||
break; /* Planar mode: Y + U + V (3 planes) */
|
||||
case DSPF_YUY2:
|
||||
*fmt = SDL_PIXELFORMAT_YUY2;
|
||||
break; /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
case DSPF_UYVY:
|
||||
*fmt = SDL_PIXELFORMAT_UYVY;
|
||||
break; /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
{ DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 }, /* 8 bit LUT (8 bit color and alpha lookup from palette) */
|
||||
{ DSPF_RGB332, SDL_PIXELFORMAT_RGB332 }, /* 8 bit RGB (1 byte, red 3@5, green 3@2, blue 2@0) */
|
||||
{ DSPF_ARGB4444, SDL_PIXELFORMAT_ARGB4444 }, /* 16 bit ARGB (2 byte, alpha 4@12, red 4@8, green 4@4, blue 4@0) */
|
||||
{ DSPF_ARGB1555, SDL_PIXELFORMAT_ARGB1555 }, /* 16 bit ARGB (2 byte, alpha 1@15, red 5@10, green 5@5, blue 5@0) */
|
||||
{ DSPF_RGB16, SDL_PIXELFORMAT_RGB565 }, /* 16 bit RGB (2 byte, red 5@11, green 6@5, blue 5@0) */
|
||||
{ DSPF_RGB24, SDL_PIXELFORMAT_RGB24 }, /* 24 bit RGB (3 byte, red 8@16, green 8@8, blue 8@0) */
|
||||
{ DSPF_RGB32, SDL_PIXELFORMAT_RGB888 }, /* 24 bit RGB (4 byte, nothing@24, red 8@16, green 8@8, blue 8@0) */
|
||||
{ DSPF_ARGB, SDL_PIXELFORMAT_ARGB8888 }, /* 32 bit ARGB (4 byte, alpha 8@24, red 8@16, green 8@8, blue 8@0) */
|
||||
{ DSPF_RGB444, SDL_PIXELFORMAT_RGB444 }, /* 16 bit RGB (2 byte, nothing @12, red 4@8, green 4@4, blue 4@0) */
|
||||
{ DSPF_YV12, SDL_PIXELFORMAT_YV12 }, /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size V/U planes) */
|
||||
{ DSPF_I420,SDL_PIXELFORMAT_IYUV }, /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size U/V planes) */
|
||||
{ DSPF_YUY2, SDL_PIXELFORMAT_YUY2 }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */
|
||||
{ DSPF_UYVY, SDL_PIXELFORMAT_UYVY }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */
|
||||
{ DSPF_RGB555, SDL_PIXELFORMAT_RGB555 }, /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */
|
||||
|
||||
#if (DFB_VERSION_ATLEAST(1,2,0))
|
||||
{ DSPF_BGR555, SDL_PIXELFORMAT_BGR555 }, /* 16 bit BGR (2 byte, nothing @15, blue 5@10, green 5@5, red 5@0) */
|
||||
#else
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR555 },
|
||||
#endif
|
||||
|
||||
/* Pfff ... nonmatching formats follow */
|
||||
|
||||
{ DSPF_ALUT44, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit ALUT (1 byte, alpha 4@4, color lookup 4@0) */
|
||||
{ DSPF_A8, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */
|
||||
{ DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */
|
||||
{ DSPF_A1, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */
|
||||
{ DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */
|
||||
{ DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */
|
||||
{ DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */
|
||||
{ DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */
|
||||
{ DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */
|
||||
{ DSPF_A4, SDL_PIXELFORMAT_UNKNOWN }, /* 4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */
|
||||
{ DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */
|
||||
{ DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */
|
||||
{ DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */
|
||||
{ DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN }, /* 2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */
|
||||
|
||||
#if (DFB_VERSION_ATLEAST(1,3,0))
|
||||
{ DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */
|
||||
#endif
|
||||
|
||||
#if (DFB_VERSION_ATLEAST(1,4,0))
|
||||
{ DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */
|
||||
{ DSPF_YUV444P, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit full YUV planar (8 bit Y plane followed by an 8 bit Cb and an 8 bit Cr plane) */
|
||||
{ DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */
|
||||
{ DSPF_AVYU, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AVYU 4:4:4 (4 byte, alpha 8@24, Cr 8@16, Y 8@8, Cb 8@0) */
|
||||
{ DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0) */
|
||||
#endif
|
||||
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1MSB },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4MSB },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_RGBA8888 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR8888 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGRA8888 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ARGB2101010 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR1555 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR565 },
|
||||
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU }, /**< Packed mode: Y0+V0+Y1+U0 (1 pla */
|
||||
};
|
||||
|
||||
static Uint32
|
||||
DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
|
||||
if (pixelformat_tab[i].dfb == pixelformat)
|
||||
{
|
||||
return pixelformat_tab[i].sdl;
|
||||
}
|
||||
return SDL_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static DFBSurfacePixelFormat
|
||||
SDLToDFBPixelFormat(Uint32 format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_INDEX4LSB:
|
||||
return DSPF_ALUT44;
|
||||
case SDL_PIXELFORMAT_INDEX8:
|
||||
return DSPF_LUT8;
|
||||
case SDL_PIXELFORMAT_RGB332:
|
||||
return DSPF_RGB332;
|
||||
case SDL_PIXELFORMAT_RGB555:
|
||||
return DSPF_ARGB1555;
|
||||
case SDL_PIXELFORMAT_ARGB4444:
|
||||
return DSPF_ARGB4444;
|
||||
case SDL_PIXELFORMAT_ARGB1555:
|
||||
return DSPF_ARGB1555;
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
return DSPF_RGB16;
|
||||
case SDL_PIXELFORMAT_RGB24:
|
||||
return DSPF_RGB24;
|
||||
case SDL_PIXELFORMAT_RGB888:
|
||||
return DSPF_RGB32;
|
||||
case SDL_PIXELFORMAT_ARGB8888:
|
||||
return DSPF_ARGB;
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
return DSPF_YV12; /* Planar mode: Y + V + U (3 planes) */
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
return DSPF_I420; /* Planar mode: Y + U + V (3 planes) */
|
||||
case SDL_PIXELFORMAT_YUY2:
|
||||
return DSPF_YUY2; /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
case SDL_PIXELFORMAT_UYVY:
|
||||
return DSPF_UYVY; /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
case SDL_PIXELFORMAT_YVYU:
|
||||
return DSPF_UNKNOWN; /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
case SDL_PIXELFORMAT_INDEX1LSB:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_INDEX1MSB:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_INDEX4MSB:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_RGB444:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_BGR24:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_BGR888:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_RGBA8888:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_ABGR8888:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_BGRA8888:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_ARGB2101010:
|
||||
return DSPF_UNKNOWN;
|
||||
default:
|
||||
return DSPF_UNKNOWN;
|
||||
}
|
||||
int i;
|
||||
|
||||
for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
|
||||
if (pixelformat_tab[i].sdl == format)
|
||||
{
|
||||
return pixelformat_tab[i].dfb;
|
||||
}
|
||||
return DSPF_UNKNOWN;
|
||||
}
|
||||
|
||||
static DFBEnumerationResult
|
||||
@@ -164,7 +153,6 @@ EnumModesCallback(int width, int height, int bpp, void *data)
|
||||
modedata->modelist[modedata->nummodes++] = mode;
|
||||
}
|
||||
|
||||
SDL_DFB_DEBUG("w %d h %d bpp %d\n", width, height, bpp);
|
||||
return DFENUM_OK;
|
||||
}
|
||||
|
||||
@@ -202,7 +190,6 @@ CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, S
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
DFBDisplayLayerConfig config;
|
||||
DFBDisplayLayerConfigFlags failed;
|
||||
int ret;
|
||||
|
||||
SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
|
||||
DLSCL_ADMINISTRATIVE));
|
||||
@@ -221,7 +208,7 @@ CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, S
|
||||
if (failed == 0)
|
||||
SDL_AddDisplayMode(display, mode);
|
||||
else
|
||||
SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w,
|
||||
SDL_DFB_ERR("Mode %d x %d not available: %x\n", mode->w,
|
||||
mode->h, failed);
|
||||
|
||||
return;
|
||||
@@ -295,19 +282,21 @@ DirectFB_InitModes(_THIS)
|
||||
dlc.pixelformat = DSPF_ARGB;
|
||||
dlc.options = DLOP_ALPHACHANNEL;
|
||||
|
||||
ret = layer->SetConfiguration(layer, &dlc);
|
||||
if (ret) {
|
||||
ret = SDL_DFB_CHECK(layer->SetConfiguration(layer, &dlc));
|
||||
if (ret != DFB_OK) {
|
||||
/* try AiRGB if the previous failed */
|
||||
dlc.pixelformat = DSPF_AiRGB;
|
||||
ret = layer->SetConfiguration(layer, &dlc);
|
||||
SDL_DFB_CHECKERR(layer->SetConfiguration(layer, &dlc));
|
||||
}
|
||||
}
|
||||
|
||||
/* Query layer configuration to determine the current mode and pixelformat */
|
||||
dlc.flags = DLCONF_ALL;
|
||||
layer->GetConfiguration(layer, &dlc);
|
||||
SDL_DFB_CHECKERR(layer->GetConfiguration(layer, &dlc));
|
||||
|
||||
if (DFBToSDLPixelFormat(dlc.pixelformat, &mode.format) != 0) {
|
||||
mode.format = DFBToSDLPixelFormat(dlc.pixelformat);
|
||||
|
||||
if (mode.format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
SDL_DFB_ERR("Unknown dfb pixelformat %x !\n", dlc.pixelformat);
|
||||
goto error;
|
||||
}
|
||||
@@ -363,7 +352,6 @@ DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||
SDL_DisplayMode mode;
|
||||
struct modes_callback_t data;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
data.nummodes = 0;
|
||||
/* Enumerate the available fullscreen modes */
|
||||
@@ -403,7 +391,6 @@ DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mod
|
||||
DFB_DisplayData *data = (DFB_DisplayData *) display->driverdata;
|
||||
DFBDisplayLayerConfig config, rconfig;
|
||||
DFBDisplayLayerConfigFlags fail = 0;
|
||||
DFBResult ret;
|
||||
|
||||
SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
|
||||
DLSCL_ADMINISTRATIVE));
|
||||
@@ -469,7 +456,6 @@ DirectFB_QuitModes(_THIS)
|
||||
{
|
||||
//DFB_DeviceData *devdata = (DFB_DeviceData *) _this->driverdata;
|
||||
SDL_DisplayMode tmode;
|
||||
DFBResult ret;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "SDL_DirectFB_video.h"
|
||||
|
||||
#define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (dev)->displays[(win)->display].driverdata : NULL)
|
||||
#define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (win)->display->driverdata : NULL)
|
||||
|
||||
typedef struct _DFB_DisplayData DFB_DisplayData;
|
||||
struct _DFB_DisplayData
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
#if USE_MULTI_API
|
||||
static SDL_Cursor *DirectFB_CreateCursor(SDL_Surface * surface,
|
||||
int hot_x, int hot_y);
|
||||
static int DirectFB_ShowCursor(SDL_Cursor * cursor);
|
||||
@@ -239,4 +240,23 @@ DirectFB_FreeMouse(SDL_Mouse * mouse)
|
||||
/* nothing yet */
|
||||
}
|
||||
|
||||
#else /* USE_MULTI_API */
|
||||
|
||||
void
|
||||
DirectFB_InitMouse(_THIS)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
|
||||
devdata->num_mice = 1;
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_QuitMouse(_THIS)
|
||||
{
|
||||
//SDL_DFB_DEVICEDATA(_this);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -30,6 +30,10 @@ struct SDL_GLDriverData
|
||||
int gl_active; /* to stop switching drivers while we have a valid context */
|
||||
int initialized;
|
||||
DirectFB_GLContext *firstgl; /* linked list */
|
||||
|
||||
/* OpenGL */
|
||||
void (*glFinish) (void);
|
||||
void (*glFlush) (void);
|
||||
};
|
||||
|
||||
#define OPENGL_REQUIRS_DLOPEN
|
||||
@@ -94,7 +98,7 @@ DirectFB_GL_Shutdown(_THIS)
|
||||
int
|
||||
DirectFB_GL_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
//SDL_DFB_DEVICEDATA(_this);
|
||||
|
||||
void *handle = NULL;
|
||||
|
||||
@@ -122,9 +126,6 @@ DirectFB_GL_LoadLibrary(_THIS, const char *path)
|
||||
|
||||
SDL_DFB_DEBUG("Loaded library: %s\n", path);
|
||||
|
||||
/* Unload the old driver and reset the pointers */
|
||||
DirectFB_GL_UnloadLibrary(_this);
|
||||
|
||||
_this->gl_config.dll_handle = handle;
|
||||
_this->gl_config.driver_loaded = 1;
|
||||
if (path) {
|
||||
@@ -134,8 +135,8 @@ DirectFB_GL_LoadLibrary(_THIS, const char *path)
|
||||
*_this->gl_config.driver_path = '\0';
|
||||
}
|
||||
|
||||
devdata->glFinish = DirectFB_GL_GetProcAddress(_this, "glFinish");
|
||||
devdata->glFlush = DirectFB_GL_GetProcAddress(_this, "glFlush");
|
||||
_this->gl_data->glFinish = DirectFB_GL_GetProcAddress(_this, "glFinish");
|
||||
_this->gl_data->glFlush = DirectFB_GL_GetProcAddress(_this, "glFlush");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -143,6 +144,7 @@ DirectFB_GL_LoadLibrary(_THIS, const char *path)
|
||||
static void
|
||||
DirectFB_GL_UnloadLibrary(_THIS)
|
||||
{
|
||||
#if 0
|
||||
int ret;
|
||||
|
||||
if (_this->gl_config.driver_loaded) {
|
||||
@@ -153,6 +155,10 @@ DirectFB_GL_UnloadLibrary(_THIS)
|
||||
_this->gl_config.dll_handle = NULL;
|
||||
_this->gl_config.driver_loaded = 0;
|
||||
}
|
||||
#endif
|
||||
/* Free OpenGL memory */
|
||||
SDL_free(_this->gl_data);
|
||||
_this->gl_data = NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
@@ -167,11 +173,11 @@ DirectFB_GL_GetProcAddress(_THIS, const char *proc)
|
||||
SDL_GLContext
|
||||
DirectFB_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
//SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
DirectFB_GLContext *context;
|
||||
int ret;
|
||||
|
||||
SDL_DFB_CALLOC(context, 1, sizeof(*context));
|
||||
SDL_DFB_CALLOC(context, 1, sizeof(DirectFB_GLContext));
|
||||
|
||||
SDL_DFB_CHECKERR(windata->surface->GetGL(windata->surface,
|
||||
&context->context));
|
||||
@@ -179,11 +185,14 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
if (!context->context)
|
||||
return NULL;
|
||||
|
||||
SDL_DFB_CHECKERR(context->context->Unlock(context->context));
|
||||
|
||||
context->is_locked = 0;
|
||||
context->sdl_window = window;
|
||||
|
||||
context->next = _this->gl_data->firstgl;
|
||||
_this->gl_data->firstgl = context;
|
||||
|
||||
SDL_DFB_CHECK(context->context->Unlock(context->context));
|
||||
|
||||
if (DirectFB_GL_MakeCurrent(_this, window, context) < 0) {
|
||||
DirectFB_GL_DeleteContext(_this, context);
|
||||
return NULL;
|
||||
@@ -198,28 +207,24 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
int
|
||||
DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
//SDL_DFB_WINDOWDATA(window);
|
||||
DirectFB_GLContext *ctx = (DirectFB_GLContext *) context;
|
||||
DirectFB_GLContext *p;
|
||||
|
||||
int ret;
|
||||
|
||||
for (p = _this->gl_data->firstgl; p; p = p->next)
|
||||
p->context->Unlock(p->context);
|
||||
|
||||
if (windata) {
|
||||
windata->gl_context = NULL;
|
||||
/* Everything is unlocked, check for a resize */
|
||||
DirectFB_AdjustWindowSurface(window);
|
||||
{
|
||||
if (p->is_locked) {
|
||||
SDL_DFB_CHECKERR(p->context->Unlock(p->context));
|
||||
p->is_locked = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ctx != NULL) {
|
||||
SDL_DFB_CHECKERR(ctx->context->Lock(ctx->context));
|
||||
ctx->is_locked = 1;
|
||||
}
|
||||
|
||||
if (windata)
|
||||
windata->gl_context = ctx;
|
||||
|
||||
return 0;
|
||||
error:
|
||||
return -1;
|
||||
@@ -242,28 +247,36 @@ DirectFB_GL_GetSwapInterval(_THIS)
|
||||
void
|
||||
DirectFB_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
//SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
int ret;
|
||||
DFBRegion region;
|
||||
DirectFB_GLContext *p;
|
||||
|
||||
region.x1 = 0;
|
||||
region.y1 = 0;
|
||||
region.x2 = window->w;
|
||||
region.y2 = window->h;
|
||||
|
||||
#if 0
|
||||
if (devdata->glFinish)
|
||||
devdata->glFinish();
|
||||
else if (devdata->glFlush)
|
||||
devdata->glFlush();
|
||||
#endif
|
||||
|
||||
if (1 || windata->gl_context) {
|
||||
/* SDL_DFB_CHECKERR(windata->gl_context->context->Unlock(windata->gl_context->context)); */
|
||||
SDL_DFB_CHECKERR(windata->surface->Flip(windata->surface, ®ion,
|
||||
DSFLIP_ONSYNC));
|
||||
/* SDL_DFB_CHECKERR(windata->gl_context->context->Lock(windata->gl_context->context)); */
|
||||
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
|
||||
if (p->sdl_window == window && p->is_locked)
|
||||
{
|
||||
SDL_DFB_CHECKERR(p->context->Unlock(p->context));
|
||||
p->is_locked = 0;
|
||||
}
|
||||
|
||||
}
|
||||
SDL_DFB_CHECKERR(windata->window_surface->Flip(windata->window_surface,NULL, DSFLIP_PIPELINE |DSFLIP_BLIT | DSFLIP_ONSYNC ));
|
||||
|
||||
//if (windata->gl_context) {
|
||||
//SDL_DFB_CHECKERR(windata->surface->Flip(windata->surface,NULL, DSFLIP_ONSYNC));
|
||||
//SDL_DFB_CHECKERR(windata->gl_context->context->Lock(windata->gl_context->context));
|
||||
//}
|
||||
|
||||
return;
|
||||
error:
|
||||
@@ -276,19 +289,58 @@ DirectFB_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
DirectFB_GLContext *ctx = (DirectFB_GLContext *) context;
|
||||
DirectFB_GLContext *p;
|
||||
|
||||
ctx->context->Unlock(ctx->context);
|
||||
ctx->context->Release(ctx->context);
|
||||
if (ctx->is_locked)
|
||||
SDL_DFB_CHECK(ctx->context->Unlock(ctx->context));
|
||||
SDL_DFB_RELEASE(ctx->context);
|
||||
|
||||
p = _this->gl_data->firstgl;
|
||||
while (p && p->next != ctx)
|
||||
p = p->next;
|
||||
for (p = _this->gl_data->firstgl; p && p->next != ctx; p = p->next)
|
||||
;
|
||||
if (p)
|
||||
p->next = ctx->next;
|
||||
else
|
||||
_this->gl_data->firstgl = ctx->next;
|
||||
|
||||
SDL_DFB_FREE(ctx);
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window)
|
||||
{
|
||||
DirectFB_GLContext *p;
|
||||
|
||||
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
|
||||
if (p->sdl_window == window)
|
||||
{
|
||||
if (p->is_locked)
|
||||
SDL_DFB_CHECK(p->context->Unlock(p->context));
|
||||
SDL_DFB_RELEASE(p->context);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window)
|
||||
{
|
||||
DirectFB_GLContext *p;
|
||||
|
||||
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
|
||||
if (p->sdl_window == window)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
SDL_DFB_CHECK(windata->surface->GetGL(windata->surface,
|
||||
&p->context));
|
||||
if (p->is_locked)
|
||||
SDL_DFB_CHECK(p->context->Lock(p->context));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window)
|
||||
{
|
||||
DirectFB_GLContext *p;
|
||||
|
||||
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
|
||||
if (p->sdl_window == window)
|
||||
DirectFB_GL_DeleteContext(_this, p);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,9 @@ struct _DirectFB_GLContext
|
||||
{
|
||||
IDirectFBGL *context;
|
||||
DirectFB_GLContext *next;
|
||||
|
||||
SDL_Window *sdl_window;
|
||||
int is_locked;
|
||||
};
|
||||
|
||||
/* OpenGL functions */
|
||||
@@ -48,6 +51,10 @@ extern int DirectFB_GL_GetSwapInterval(_THIS);
|
||||
extern void DirectFB_GL_SwapWindow(_THIS, SDL_Window * window);
|
||||
extern void DirectFB_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
|
||||
extern void DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window);
|
||||
extern void DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window);
|
||||
extern void DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window);
|
||||
|
||||
#endif /* SDL_DIRECTFB_OPENGL */
|
||||
|
||||
#endif /* _SDL_directfb_opengl_h */
|
||||
|
||||
@@ -72,6 +72,7 @@ static void DirectFB_UnlockTexture(SDL_Renderer * renderer,
|
||||
static void DirectFB_DirtyTexture(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture, int numrects,
|
||||
const SDL_Rect * rects);
|
||||
static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer);
|
||||
static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
const SDL_Point * points, int count);
|
||||
static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
|
||||
@@ -194,20 +195,20 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode,
|
||||
/**< No blending */
|
||||
data->blitFlags = DSBLIT_NOFX;
|
||||
data->drawFlags = DSDRAW_NOFX;
|
||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
|
||||
destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO);
|
||||
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE));
|
||||
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO));
|
||||
break;
|
||||
case SDL_BLENDMODE_MASK:
|
||||
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
||||
data->drawFlags = DSDRAW_BLEND;
|
||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
||||
destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA);
|
||||
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
|
||||
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA));
|
||||
break;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
||||
data->drawFlags = DSDRAW_BLEND;
|
||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
||||
destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA);
|
||||
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
|
||||
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA));
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
||||
@@ -216,16 +217,16 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode,
|
||||
// It will be cheaper to copy the surface to
|
||||
// a temporay surface and premultiply
|
||||
if (source && TextureHasAlpha(source))
|
||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
||||
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
|
||||
else
|
||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
|
||||
destsurf->SetDstBlendFunction(destsurf, DSBF_ONE);
|
||||
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE));
|
||||
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ONE));
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
||||
data->drawFlags = DSDRAW_BLEND;
|
||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR);
|
||||
destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO);
|
||||
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR));
|
||||
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO));
|
||||
break;
|
||||
}
|
||||
data->lastBlendMode = blendMode;
|
||||
@@ -250,7 +251,6 @@ DisplayPaletteChanged(void *userdata, SDL_Palette * palette)
|
||||
SDL_DFB_WINDOWSURFACE(data->window);
|
||||
IDirectFBPalette *surfpal;
|
||||
|
||||
int ret;
|
||||
int i;
|
||||
int ncolors;
|
||||
DFBColor entries[256];
|
||||
@@ -283,7 +283,6 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_Renderer *renderer = NULL;
|
||||
DirectFB_RenderData *data = NULL;
|
||||
DFBResult ret;
|
||||
DFBSurfaceCapabilities scaps;
|
||||
char *p;
|
||||
|
||||
@@ -306,10 +305,16 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->DirtyTexture = DirectFB_DirtyTexture;
|
||||
renderer->RenderDrawPoints = DirectFB_RenderDrawPoints;
|
||||
renderer->RenderDrawLines = DirectFB_RenderDrawLines;
|
||||
/* SetDrawColor - no needed */
|
||||
renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
|
||||
renderer->RenderFillRects = DirectFB_RenderFillRects;
|
||||
renderer->RenderDrawRects = DirectFB_RenderDrawRects;
|
||||
/* RenderDrawEllipse - no reference implementation yet */
|
||||
/* RenderFillEllipse - no reference implementation yet */
|
||||
renderer->RenderCopy = DirectFB_RenderCopy;
|
||||
renderer->RenderPresent = DirectFB_RenderPresent;
|
||||
/* RenderReadPixels is difficult to implement */
|
||||
/* RenderWritePixels is difficult to implement */
|
||||
renderer->DestroyTexture = DirectFB_DestroyTexture;
|
||||
renderer->DestroyRenderer = DirectFB_DestroyRenderer;
|
||||
renderer->info = DirectFB_RenderDriver.info;
|
||||
@@ -324,7 +329,7 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
data->flipflags = DSFLIP_PIPELINE | DSFLIP_BLIT;
|
||||
|
||||
if (flags & SDL_RENDERER_PRESENTVSYNC) {
|
||||
data->flipflags |= DSFLIP_WAITFORSYNC;
|
||||
data->flipflags |= DSFLIP_WAITFORSYNC | DSFLIP_ONSYNC;
|
||||
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
} else
|
||||
data->flipflags |= DSFLIP_ONSYNC;
|
||||
@@ -396,11 +401,9 @@ SDLToDFBPixelFormat(Uint32 format)
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_INDEX4MSB:
|
||||
return DSPF_UNKNOWN;
|
||||
case SDL_PIXELFORMAT_RGB444:
|
||||
#if (DFB_VERSION_ATLEAST(1,2,0))
|
||||
case SDL_PIXELFORMAT_RGB444:
|
||||
return DSPF_RGB444;
|
||||
#else
|
||||
return DSPF_UNKNOWN;
|
||||
#endif
|
||||
case SDL_PIXELFORMAT_BGR24:
|
||||
return DSPF_UNKNOWN;
|
||||
@@ -423,11 +426,11 @@ static int
|
||||
DirectFB_ActivateRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_DFB_RENDERERDATA(renderer);
|
||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
if (renddata->size_changed || windata->wm_needs_redraw) {
|
||||
DirectFB_AdjustWindowSurface(window);
|
||||
// DirectFB_AdjustWindowSurface(window);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -445,13 +448,13 @@ static int
|
||||
DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SDL_DFB_RENDERERDATA(renderer);
|
||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_DFB_DEVICEDATA(display->device);
|
||||
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
|
||||
DirectFB_TextureData *data = texture->driverdata;
|
||||
DFBDisplayLayerConfig layconf;
|
||||
int ret;
|
||||
DFBResult ret;
|
||||
|
||||
if (renddata->isyuvdirect && (dispdata->vidID >= 0)
|
||||
&& (!dispdata->vidIDinuse)
|
||||
@@ -472,7 +475,7 @@ DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
DLSCL_EXCLUSIVE));
|
||||
|
||||
if (devdata->use_yuv_underlays) {
|
||||
ret = dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1);
|
||||
ret = SDL_DFB_CHECK(dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1));
|
||||
if (ret != DFB_OK)
|
||||
SDL_DFB_DEBUG("Underlay Setlevel not supported\n");
|
||||
}
|
||||
@@ -501,11 +504,10 @@ DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int
|
||||
DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_DFB_DEVICEDATA(display->device);
|
||||
DirectFB_TextureData *data;
|
||||
DFBResult ret;
|
||||
DFBSurfaceDescription dsc;
|
||||
DFBSurfacePixelFormat pixelformat;
|
||||
|
||||
@@ -600,8 +602,7 @@ DirectFB_SetTexturePalette(SDL_Renderer * renderer,
|
||||
int ncolors)
|
||||
{
|
||||
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
||||
DFBResult ret;
|
||||
|
||||
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(data->format)
|
||||
&& !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
|
||||
DFBColor entries[256];
|
||||
@@ -631,7 +632,6 @@ DirectFB_GetTexturePalette(SDL_Renderer * renderer,
|
||||
int firstcolor, int ncolors)
|
||||
{
|
||||
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
||||
DFBResult ret;
|
||||
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(data->format)
|
||||
&& !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
|
||||
@@ -686,6 +686,23 @@ DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
DirectFB_SetDrawBlendMode(SDL_Renderer * renderer)
|
||||
{
|
||||
switch (renderer->blendMode) {
|
||||
case SDL_BLENDMODE_NONE:
|
||||
case SDL_BLENDMODE_MASK:
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
case SDL_BLENDMODE_ADD:
|
||||
case SDL_BLENDMODE_MOD:
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
renderer->blendMode = SDL_BLENDMODE_NONE;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
@@ -720,7 +737,6 @@ DirectFB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
{
|
||||
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
||||
DFBResult ret;
|
||||
Uint8 *dpixels;
|
||||
int dpitch;
|
||||
Uint8 *src, *dst;
|
||||
@@ -772,7 +788,6 @@ DirectFB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
{
|
||||
DirectFB_TextureData *texturedata =
|
||||
(DirectFB_TextureData *) texture->driverdata;
|
||||
DFBResult ret;
|
||||
|
||||
if (markDirty) {
|
||||
SDL_AddDirtyRect(&texturedata->dirty, rect);
|
||||
@@ -807,7 +822,7 @@ DirectFB_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
(DirectFB_TextureData *) texture->driverdata;
|
||||
|
||||
if (texturedata->display) {
|
||||
texturedata->surface->Unlock(texturedata->surface);
|
||||
SDL_DFB_CHECK(texturedata->surface->Unlock(texturedata->surface));
|
||||
texturedata->pixels = NULL;
|
||||
}
|
||||
}
|
||||
@@ -830,7 +845,6 @@ PrepareDraw(SDL_Renderer * renderer)
|
||||
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
||||
SDL_DFB_WINDOWSURFACE(data->window);
|
||||
|
||||
DFBResult ret;
|
||||
Uint8 r, g, b, a;
|
||||
|
||||
r = renderer->r;
|
||||
@@ -866,7 +880,6 @@ static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
{
|
||||
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
||||
SDL_DFB_WINDOWSURFACE(data->window);
|
||||
DFBResult ret;
|
||||
int i;
|
||||
|
||||
PrepareDraw(renderer);
|
||||
@@ -882,7 +895,6 @@ static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
|
||||
{
|
||||
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
||||
SDL_DFB_WINDOWSURFACE(data->window);
|
||||
DFBResult ret;
|
||||
int i;
|
||||
|
||||
PrepareDraw(renderer);
|
||||
@@ -904,7 +916,6 @@ DirectFB_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int c
|
||||
{
|
||||
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
||||
SDL_DFB_WINDOWSURFACE(data->window);
|
||||
DFBResult ret;
|
||||
int i;
|
||||
|
||||
PrepareDraw(renderer);
|
||||
@@ -923,7 +934,6 @@ DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int c
|
||||
{
|
||||
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
||||
SDL_DFB_WINDOWSURFACE(data->window);
|
||||
DFBResult ret;
|
||||
int i;
|
||||
|
||||
PrepareDraw(renderer);
|
||||
@@ -946,11 +956,10 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
DirectFB_TextureData *texturedata =
|
||||
(DirectFB_TextureData *) texture->driverdata;
|
||||
Uint8 alpha = 0xFF;
|
||||
DFBResult ret;
|
||||
|
||||
if (texturedata->display) {
|
||||
int px, py;
|
||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
SDL_VideoDisplay *display = texturedata->display;
|
||||
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
|
||||
@@ -960,7 +969,7 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
srcrect->x, srcrect->y,
|
||||
srcrect->w,
|
||||
srcrect->h));
|
||||
windata->window->GetPosition(windata->window, &px, &py);
|
||||
SDL_DFB_CHECK(windata->window->GetPosition(windata->window, &px, &py));
|
||||
px += windata->client.x;
|
||||
py += windata->client.y;
|
||||
SDL_DFB_CHECKERR(dispdata->
|
||||
@@ -1048,11 +1057,10 @@ static void
|
||||
DirectFB_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
DFBRectangle sr;
|
||||
DFBResult ret;
|
||||
|
||||
sr.x = 0;
|
||||
sr.y = 0;
|
||||
@@ -1078,8 +1086,9 @@ DirectFB_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
DFB_DisplayData *dispdata =
|
||||
(DFB_DisplayData *) data->display->driverdata;
|
||||
dispdata->vidIDinuse = 0;
|
||||
dispdata->vidlayer->SetCooperativeLevel(dispdata->vidlayer,
|
||||
DLSCL_ADMINISTRATIVE);
|
||||
/* FIXME: Shouldn't we reset the cooperative level */
|
||||
SDL_DFB_CHECK(dispdata->vidlayer->SetCooperativeLevel(dispdata->vidlayer,
|
||||
DLSCL_ADMINISTRATIVE));
|
||||
SDL_DFB_RELEASE(dispdata->vidlayer);
|
||||
}
|
||||
SDL_FreeDirtyRects(&data->dirty);
|
||||
|
||||
@@ -129,7 +129,7 @@ DirectFB_CreateDevice(int devindex)
|
||||
#endif
|
||||
|
||||
device->free = DirectFB_DeleteDevice;
|
||||
|
||||
fprintf(LOG_CHANNEL, "Device setup %p!!\n", device->ShowWindow);
|
||||
return device;
|
||||
error:
|
||||
if (device)
|
||||
@@ -163,19 +163,20 @@ DirectFB_DeviceInformation(IDirectFB * dfb)
|
||||
fprintf(LOG_CHANNEL, "\nBlitting flags:\n");
|
||||
for (n = 0; blitting_flags[n].flag; n++) {
|
||||
if (desc.blitting_flags & blitting_flags[n].flag)
|
||||
printf(" %s\n", blitting_flags[n].name);
|
||||
fprintf(LOG_CHANNEL, " %s\n", blitting_flags[n].name);
|
||||
}
|
||||
|
||||
fprintf(LOG_CHANNEL, "\nDrawing flags:\n");
|
||||
for (n = 0; drawing_flags[n].flag; n++) {
|
||||
if (desc.drawing_flags & drawing_flags[n].flag)
|
||||
printf(" %s\n", drawing_flags[n].name);
|
||||
fprintf(LOG_CHANNEL, " %s\n", drawing_flags[n].name);
|
||||
}
|
||||
|
||||
|
||||
fprintf(LOG_CHANNEL, "\nAcceleration flags:\n");
|
||||
for (n = 0; acceleration_mask[n].mask; n++) {
|
||||
if (desc.acceleration_mask & acceleration_mask[n].mask)
|
||||
printf(" %s\n", acceleration_mask[n].name);
|
||||
fprintf(LOG_CHANNEL, " %s\n", acceleration_mask[n].name);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +209,8 @@ DirectFB_VideoInit(_THIS)
|
||||
DirectFBSetOption("disable-module", "x11input");
|
||||
}
|
||||
|
||||
devdata->use_linux_input = 1; /* default: on */
|
||||
/* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */
|
||||
devdata->use_linux_input = 0; /* default: on */
|
||||
stemp = SDL_getenv(DFBENV_USE_LINUX_INPUT);
|
||||
if (stemp)
|
||||
devdata->use_linux_input = atoi(stemp);
|
||||
@@ -248,6 +250,7 @@ DirectFB_VideoInit(_THIS)
|
||||
|
||||
devdata->dfb = dfb;
|
||||
devdata->firstwin = NULL;
|
||||
devdata->grabbed_window = NULL;
|
||||
|
||||
_this->driverdata = devdata;
|
||||
|
||||
|
||||
@@ -31,7 +31,14 @@
|
||||
|
||||
#include "SDL_mouse.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
/* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in
|
||||
* in case we see this again ...
|
||||
*/
|
||||
|
||||
#define USE_MULTI_API (0)
|
||||
|
||||
#define DEBUG 1
|
||||
#define LOG_CHANNEL stdout
|
||||
|
||||
#define DFB_VERSIONNUM(X, Y, Z) \
|
||||
@@ -71,49 +78,38 @@
|
||||
#define DFBENV_USE_LINUX_INPUT "SDL_DIRECTFB_LINUX_INPUT" /* Default: on */
|
||||
#define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */
|
||||
|
||||
#define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { x->Release(x); x = NULL; } } while (0)
|
||||
#define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { SDL_DFB_CHECK(x->Release(x)); x = NULL; } } while (0)
|
||||
#define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0)
|
||||
#define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0)
|
||||
|
||||
#if DEBUG
|
||||
#define SDL_DFB_DEBUG(x...) do { fprintf(LOG_CHANNEL, "%s:", __FUNCTION__); fprintf(LOG_CHANNEL, x); } while (0)
|
||||
#define SDL_DFB_DEBUGC(x...) do { fprintf(LOG_CHANNEL, x); } while (0)
|
||||
#else
|
||||
#define SDL_DFB_DEBUG(x...) do { } while (0)
|
||||
#define SDL_DFB_DEBUGC(x...) do { } while (0)
|
||||
/* FIXME: do something with DEBUG */
|
||||
#endif
|
||||
|
||||
#define SDL_DFB_CONTEXT "SDL_DirectFB"
|
||||
|
||||
#define SDL_DFB_ERR(x...) \
|
||||
static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line, const char *src_code) {
|
||||
if (ret != DFB_OK) {
|
||||
fprintf(LOG_CHANNEL, "%s <%d>:\n\t", src_file, src_line );
|
||||
fprintf(LOG_CHANNEL, "\t%s\n", src_code );
|
||||
fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) );
|
||||
SDL_SetError( src_code, DirectFBErrorString (ret) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define SDL_DFB_CHECK(x...) sdl_dfb_check( x, __FILE__, __LINE__, #x )
|
||||
|
||||
#define SDL_DFB_CHECKERR(x...) if ( sdl_dfb_check( x, __FILE__, __LINE__, #x ) != DFB_OK ) goto error
|
||||
|
||||
#define SDL_DFB_DEBUG(x...) \
|
||||
do { \
|
||||
fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t", \
|
||||
SDL_DFB_CONTEXT, __FILE__, __LINE__ ); \
|
||||
fprintf(LOG_CHANNEL, x ); \
|
||||
fprintf(LOG_CHANNEL, x ); \
|
||||
} while (0)
|
||||
|
||||
#define SDL_DFB_CHECK(x...) \
|
||||
do { \
|
||||
ret = x; \
|
||||
if (ret != DFB_OK) { \
|
||||
fprintf(LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
|
||||
fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
|
||||
fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
|
||||
SDL_SetError( #x, DirectFBErrorString (ret) ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SDL_DFB_CHECKERR(x...) \
|
||||
do { \
|
||||
ret = x; \
|
||||
if (ret != DFB_OK) { \
|
||||
fprintf(LOG_CHANNEL, "%s <%d>:\n", __FILE__, __LINE__ ); \
|
||||
fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
|
||||
fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
|
||||
SDL_SetError( #x, DirectFBErrorString (ret) ); \
|
||||
goto error; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SDL_DFB_ERR(x...) SDL_DFB_DEBUG( x )
|
||||
|
||||
#define SDL_DFB_CALLOC(r, n, s) \
|
||||
do { \
|
||||
@@ -151,9 +147,8 @@ struct _DFB_DeviceData
|
||||
int use_linux_input;
|
||||
int has_own_wm;
|
||||
|
||||
/* OpenGL */
|
||||
void (*glFinish) (void);
|
||||
void (*glFlush) (void);
|
||||
/* window grab */
|
||||
SDL_Window *grabbed_window;
|
||||
|
||||
/* global events */
|
||||
IDirectFBEventBuffer *events;
|
||||
|
||||
@@ -24,9 +24,14 @@
|
||||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../video/SDL_pixels_c.h"
|
||||
|
||||
#include "SDL_DirectFB_video.h"
|
||||
#if SDL_DIRECTFB_OPENGL
|
||||
#include "SDL_DirectFB_opengl.h"
|
||||
#endif
|
||||
|
||||
static void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window);
|
||||
|
||||
int
|
||||
DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||
@@ -36,8 +41,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||
DFB_WindowData *windata = NULL;
|
||||
DFBWindowOptions wopts;
|
||||
DFBWindowDescription desc;
|
||||
IDirectFBFont *font;
|
||||
int ret, x, y;
|
||||
int x, y;
|
||||
|
||||
SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData));
|
||||
windata = (DFB_WindowData *) window->driverdata;
|
||||
@@ -69,7 +73,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||
y = 0;
|
||||
}
|
||||
|
||||
DirectFB_WM_AdjustWindowLayout(window);
|
||||
DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
|
||||
|
||||
/* Create Window */
|
||||
desc.flags =
|
||||
@@ -87,7 +91,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||
&windata->window));
|
||||
|
||||
/* Set Options */
|
||||
windata->window->GetOptions(windata->window, &wopts);
|
||||
SDL_DFB_CHECK(windata->window->GetOptions(windata->window, &wopts));
|
||||
|
||||
if (window->flags & SDL_WINDOW_RESIZABLE)
|
||||
wopts |= DWOP_SCALE;
|
||||
@@ -96,9 +100,9 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE;
|
||||
windata->window->SetStackingClass(windata->window, DWSC_UPPER);
|
||||
SDL_DFB_CHECK(windata->window->SetStackingClass(windata->window, DWSC_UPPER));
|
||||
}
|
||||
windata->window->SetOptions(windata->window, wopts);
|
||||
SDL_DFB_CHECK(windata->window->SetOptions(windata->window, wopts));
|
||||
|
||||
/* See what we got */
|
||||
SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
|
||||
@@ -112,7 +116,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||
GetSubSurface(windata->window_surface, &windata->client,
|
||||
&windata->surface));
|
||||
|
||||
windata->window->SetOpacity(windata->window, 0xFF);
|
||||
SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0xFF));
|
||||
|
||||
/* Create Eventbuffer */
|
||||
SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window,
|
||||
@@ -123,24 +127,13 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||
|
||||
/* Create a font */
|
||||
/* FIXME: once during Video_Init */
|
||||
if (windata->is_managed) {
|
||||
DFBFontDescription fdesc;
|
||||
|
||||
fdesc.flags = DFDESC_HEIGHT;
|
||||
fdesc.height = windata->theme.font_size;
|
||||
font = NULL;
|
||||
SDL_DFB_CHECK(devdata->
|
||||
dfb->CreateFont(devdata->dfb, windata->theme.font,
|
||||
&fdesc, &font));
|
||||
windata->window_surface->SetFont(windata->window_surface, font);
|
||||
SDL_DFB_RELEASE(font);
|
||||
}
|
||||
windata->font = NULL;
|
||||
|
||||
/* Make it the top most window. */
|
||||
windata->window->RaiseToTop(windata->window);
|
||||
SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window));
|
||||
|
||||
/* remember parent */
|
||||
windata->window = window;
|
||||
windata->sdl_window = window;
|
||||
|
||||
/* Add to list ... */
|
||||
|
||||
@@ -149,7 +142,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||
devdata->firstwin = windata;
|
||||
|
||||
/* Draw Frame */
|
||||
DirectFB_WM_RedrawLayout(window);
|
||||
DirectFB_WM_RedrawLayout(_this, window);
|
||||
|
||||
return 0;
|
||||
error:
|
||||
@@ -172,6 +165,7 @@ DirectFB_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
|
||||
if (windata->is_managed) {
|
||||
windata->wm_needs_redraw = 1;
|
||||
DirectFB_WM_RedrawLayout(_this, window);
|
||||
} else
|
||||
SDL_Unsupported();
|
||||
}
|
||||
@@ -182,7 +176,6 @@ DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
SDL_Surface *surface = NULL;
|
||||
DFBResult ret;
|
||||
|
||||
if (icon) {
|
||||
SDL_PixelFormat format;
|
||||
@@ -216,7 +209,7 @@ DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
||||
memcpy((char *) dest + i * pitch,
|
||||
(char *) p + i * surface->pitch, 4 * surface->w);
|
||||
|
||||
windata->icon->Unlock(windata->icon);
|
||||
SDL_DFB_CHECK(windata->icon->Unlock(windata->icon));
|
||||
SDL_FreeSurface(surface);
|
||||
} else {
|
||||
SDL_DFB_RELEASE(windata->icon);
|
||||
@@ -249,16 +242,15 @@ DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
DirectFB_WM_AdjustWindowLayout(window);
|
||||
windata->window->MoveTo(windata->window, x, y);
|
||||
DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
|
||||
SDL_DFB_CHECK(windata->window->MoveTo(windata->window, x, y));
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_SetWindowSize(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
//SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
int ret;
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||
int cw;
|
||||
@@ -272,23 +264,23 @@ DirectFB_SetWindowSize(_THIS, SDL_Window * window)
|
||||
|
||||
if (cw != window->w || ch != window->h) {
|
||||
|
||||
DirectFB_WM_AdjustWindowLayout(window);
|
||||
DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
|
||||
SDL_DFB_CHECKERR(windata->window->Resize(windata->window,
|
||||
windata->size.w,
|
||||
windata->size.h));
|
||||
}
|
||||
|
||||
SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
|
||||
(_this, window, &window->w, &window->h));
|
||||
DirectFB_AdjustWindowSurface(_this, window);
|
||||
|
||||
SDL_DFB_CHECKERR(windata->window->EnableEvents(windata->window,
|
||||
DWET_ALL));
|
||||
|
||||
SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
|
||||
(_this, window, &window->w, &window->h));
|
||||
|
||||
SDL_OnWindowResized(window);
|
||||
}
|
||||
return;
|
||||
error:
|
||||
windata->window->EnableEvents(windata->window, DWET_ALL);
|
||||
SDL_DFB_CHECK(windata->window->EnableEvents(windata->window, DWET_ALL));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -297,7 +289,7 @@ DirectFB_ShowWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
windata->window->SetOpacity(windata->window, windata->opacity);
|
||||
SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, windata->opacity));
|
||||
|
||||
}
|
||||
|
||||
@@ -306,8 +298,8 @@ DirectFB_HideWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
windata->window->GetOpacity(windata->window, &windata->opacity);
|
||||
windata->window->SetOpacity(windata->window, 0);
|
||||
SDL_DFB_CHECK(windata->window->GetOpacity(windata->window, &windata->opacity));
|
||||
SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -315,8 +307,8 @@ DirectFB_RaiseWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
windata->window->RaiseToTop(windata->window);
|
||||
windata->window->RequestFocus(windata->window);
|
||||
SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window));
|
||||
SDL_DFB_CHECK(windata->window->RequestFocus(windata->window));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -352,14 +344,23 @@ DirectFB_RestoreWindow(_THIS, SDL_Window * window)
|
||||
void
|
||||
DirectFB_SetWindowGrab(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
|
||||
|
||||
if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) {
|
||||
windata->window->GrabPointer(windata->window);
|
||||
windata->window->GrabKeyboard(windata->window);
|
||||
if (gwindata != NULL)
|
||||
{
|
||||
SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window));
|
||||
SDL_DFB_CHECK(gwindata->window->UngrabKeyboard(gwindata->window));
|
||||
}
|
||||
SDL_DFB_CHECK(windata->window->GrabPointer(windata->window));
|
||||
SDL_DFB_CHECK(windata->window->GrabKeyboard(windata->window));
|
||||
devdata->grabbed_window = window;
|
||||
} else {
|
||||
windata->window->UngrabPointer(windata->window);
|
||||
windata->window->UngrabKeyboard(windata->window);
|
||||
SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
|
||||
SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window));
|
||||
devdata->grabbed_window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,14 +371,19 @@ DirectFB_DestroyWindow(_THIS, SDL_Window * window)
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
DFB_WindowData *p;
|
||||
|
||||
SDL_DFB_DEBUG("Trace\n");
|
||||
|
||||
/* Some cleanups */
|
||||
windata->window->UngrabPointer(windata->window);
|
||||
windata->window->UngrabKeyboard(windata->window);
|
||||
SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
|
||||
SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window));
|
||||
|
||||
windata->window_surface->SetFont(windata->window_surface, NULL);
|
||||
SDL_DFB_RELEASE(windata->icon);
|
||||
#if SDL_DIRECTFB_OPENGL
|
||||
DirectFB_GL_DestroyWindowContexts(_this, window);
|
||||
#endif
|
||||
|
||||
SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, NULL));
|
||||
SDL_DFB_CHECK(windata->surface->ReleaseSource(windata->surface));
|
||||
SDL_DFB_CHECK(windata->window_surface->ReleaseSource(windata->window_surface));
|
||||
SDL_DFB_RELEASE(windata->icon);
|
||||
SDL_DFB_RELEASE(windata->font);
|
||||
SDL_DFB_RELEASE(windata->eventbuffer);
|
||||
SDL_DFB_RELEASE(windata->surface);
|
||||
SDL_DFB_RELEASE(windata->window_surface);
|
||||
@@ -405,15 +411,14 @@ DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_AdjustWindowSurface(SDL_Window * window)
|
||||
static void
|
||||
DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
int adjust = windata->wm_needs_redraw;
|
||||
int cw, ch;
|
||||
int ret;
|
||||
|
||||
DirectFB_WM_AdjustWindowLayout(window);
|
||||
DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
|
||||
|
||||
SDL_DFB_CHECKERR(windata->
|
||||
window_surface->GetSize(windata->window_surface, &cw,
|
||||
@@ -423,6 +428,10 @@ DirectFB_AdjustWindowSurface(SDL_Window * window)
|
||||
}
|
||||
|
||||
if (adjust) {
|
||||
#if SDL_DIRECTFB_OPENGL
|
||||
DirectFB_GL_FreeWindowContexts(_this, window);
|
||||
#endif
|
||||
|
||||
#if DFB_VERSION_ATLEAST(1,2,1)
|
||||
SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
|
||||
windata->size.w,
|
||||
@@ -446,8 +455,12 @@ DirectFB_AdjustWindowSurface(SDL_Window * window)
|
||||
GetSubSurface(windata->window_surface,
|
||||
&windata->client, &windata->surface));
|
||||
#endif
|
||||
DirectFB_WM_RedrawLayout(window);
|
||||
}
|
||||
DirectFB_WM_RedrawLayout(_this, window);
|
||||
|
||||
#if SDL_DIRECTFB_OPENGL
|
||||
DirectFB_GL_ReAllocWindowContexts(_this, window);
|
||||
#endif
|
||||
}
|
||||
error:
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,8 @@ struct _DFB_WindowData
|
||||
IDirectFBSurface *surface;
|
||||
IDirectFBSurface *window_surface; /* only used with has_own_wm */
|
||||
IDirectFBWindow *window;
|
||||
DirectFB_GLContext *gl_context;
|
||||
IDirectFBEventBuffer *eventbuffer;
|
||||
SDL_Window *window;
|
||||
SDL_Window *sdl_window;
|
||||
DFB_WindowData *next;
|
||||
Uint8 opacity;
|
||||
DFBRectangle client;
|
||||
@@ -46,6 +45,7 @@ struct _DFB_WindowData
|
||||
int is_managed;
|
||||
int wm_needs_redraw;
|
||||
IDirectFBSurface *icon;
|
||||
IDirectFBFont *font;
|
||||
DFB_Theme theme;
|
||||
};
|
||||
|
||||
@@ -69,7 +69,7 @@ extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo *info);
|
||||
|
||||
extern void DirectFB_AdjustWindowSurface(SDL_Window * window);
|
||||
//extern void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window);
|
||||
|
||||
#endif /* _SDL_directfb_window_h */
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
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
|
||||
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
|
||||
@@ -24,10 +23,11 @@
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
#if SDL_IPHONE_MULTIPLE_MICE
|
||||
#define IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||
#define FIXED_MULTITOUCH
|
||||
|
||||
#ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||
#define MAX_SIMULTANEOUS_TOUCHES 5
|
||||
#else
|
||||
#define MAX_SIMULTANEOUS_TOUCHES 1
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
@@ -37,8 +37,11 @@
|
||||
@interface SDL_uikitview : UIView {
|
||||
#endif
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES];
|
||||
#ifdef FIXED_MULTITOUCH
|
||||
long touchId;
|
||||
#ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||
UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SDL_IPHONE_KEYBOARD
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
|
||||
#if SDL_IPHONE_KEYBOARD
|
||||
#import "keyinfotable.h"
|
||||
@@ -48,16 +49,27 @@
|
||||
[self initializeKeyboard];
|
||||
#endif
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
int i;
|
||||
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES; i++) {
|
||||
mice[i].id = i;
|
||||
mice[i].driverdata = NULL;
|
||||
SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1);
|
||||
}
|
||||
self.multipleTouchEnabled = YES;
|
||||
#ifdef FIXED_MULTITOUCH
|
||||
SDL_Touch touch;
|
||||
touch.id = 0; //TODO: Should be -1?
|
||||
|
||||
//touch.driverdata = SDL_malloc(sizeof(EventTouchData));
|
||||
//EventTouchData* data = (EventTouchData*)(touch.driverdata);
|
||||
|
||||
touch.x_min = 0;
|
||||
touch.x_max = frame.size.width;
|
||||
touch.native_xres = touch.x_max - touch.x_min;
|
||||
touch.y_min = 0;
|
||||
touch.y_max = frame.size.height;
|
||||
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;
|
||||
|
||||
|
||||
touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
|
||||
#endif
|
||||
|
||||
|
||||
return self;
|
||||
|
||||
}
|
||||
@@ -67,48 +79,8 @@
|
||||
NSEnumerator *enumerator = [touches objectEnumerator];
|
||||
UITouch *touch = (UITouch*)[enumerator nextObject];
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
/* associate touches with mice, so long as we have slots */
|
||||
int i;
|
||||
int found = 0;
|
||||
for(i=0; touch && i < MAX_SIMULTANEOUS_TOUCHES; i++) {
|
||||
//NSLog("Click");
|
||||
|
||||
/* check if this mouse is already tracking a touch */
|
||||
if (mice[i].driverdata != NULL) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
mouse not associated with anything right now,
|
||||
associate the touch with this mouse
|
||||
*/
|
||||
found = 1;
|
||||
|
||||
/* save old mouse so we can switch back */
|
||||
int oldMouse = SDL_SelectMouse(-1);
|
||||
|
||||
/* select this slot's mouse */
|
||||
SDL_SelectMouse(i);
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
|
||||
/* set driver data to touch object, we'll use touch object later */
|
||||
mice[i].driverdata = [touch retain];
|
||||
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0);
|
||||
|
||||
/* send mouse down event */
|
||||
SDL_SendMouseButton(i, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
|
||||
/* re-calibrate relative mouse motion */
|
||||
SDL_GetRelativeMouseState(i, NULL, NULL);
|
||||
|
||||
/* switch back to our old mouse */
|
||||
SDL_SelectMouse(oldMouse);
|
||||
|
||||
/* grab next touch */
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#else
|
||||
if (touch) {
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
|
||||
@@ -118,6 +90,37 @@
|
||||
/* send mouse down event */
|
||||
SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
#ifdef FIXED_MULTITOUCH
|
||||
while(touch) {
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
|
||||
|
||||
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||
//FIXME: TODO: Using touch as the fingerId is potentially dangerous
|
||||
//It is also much more efficient than storing the UITouch pointer
|
||||
//and comparing it to the incoming event.
|
||||
SDL_SendFingerDown(touchId,(long)touch,
|
||||
SDL_TRUE,locationInView.x,locationInView.y,
|
||||
1);
|
||||
#else
|
||||
int i;
|
||||
for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
|
||||
if(finger[i] == NULL) {
|
||||
finger[i] = touch;
|
||||
SDL_SendFingerDown(touchId,i,
|
||||
SDL_TRUE,locationInView.x,locationInView.y,
|
||||
1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -126,30 +129,34 @@
|
||||
NSEnumerator *enumerator = [touches objectEnumerator];
|
||||
UITouch *touch = (UITouch*)[enumerator nextObject];
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
while(touch) {
|
||||
/* search for the mouse slot associated with this touch */
|
||||
int i, found = NO;
|
||||
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
|
||||
if (mice[i].driverdata == touch) {
|
||||
/* found the mouse associate with the touch */
|
||||
[(UITouch*)(mice[i].driverdata) release];
|
||||
mice[i].driverdata = NULL;
|
||||
/* send mouse up */
|
||||
SDL_SendMouseButton(i, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
/* discontinue search for this touch */
|
||||
found = YES;
|
||||
}
|
||||
}
|
||||
|
||||
/* grab next touch */
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#else
|
||||
if (touch) {
|
||||
/* send mouse up */
|
||||
SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
#ifdef FIXED_MULTITOUCH
|
||||
while(touch) {
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
|
||||
|
||||
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||
SDL_SendFingerDown(touchId,(long)touch,
|
||||
SDL_FALSE,locationInView.x,locationInView.y,
|
||||
1);
|
||||
#else
|
||||
int i;
|
||||
for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
|
||||
if(finger[i] == touch) {
|
||||
SDL_SendFingerDown(touchId,i,
|
||||
SDL_FALSE,locationInView.x,locationInView.y,
|
||||
1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -167,31 +174,36 @@
|
||||
NSEnumerator *enumerator = [touches objectEnumerator];
|
||||
UITouch *touch = (UITouch*)[enumerator nextObject];
|
||||
|
||||
#if FIXME_MULTITOUCH
|
||||
while(touch) {
|
||||
/* try to find the mouse associated with this touch */
|
||||
int i, found = NO;
|
||||
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
|
||||
if (mice[i].driverdata == touch) {
|
||||
/* found proper mouse */
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0);
|
||||
/* discontinue search */
|
||||
found = YES;
|
||||
}
|
||||
}
|
||||
|
||||
/* grab next touch */
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#else
|
||||
if (touch) {
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
|
||||
/* send moved event */
|
||||
SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
|
||||
}
|
||||
|
||||
#ifdef FIXED_MULTITOUCH
|
||||
while(touch) {
|
||||
CGPoint locationInView = [touch locationInView: self];
|
||||
|
||||
|
||||
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||
SDL_SendTouchMotion(touchId,(long)touch,
|
||||
SDL_FALSE,locationInView.x,locationInView.y,
|
||||
1);
|
||||
#else
|
||||
int i;
|
||||
for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
|
||||
if(finger[i] == touch) {
|
||||
SDL_SendTouchMotion(touchId,i,
|
||||
SDL_FALSE,locationInView.x,locationInView.y,
|
||||
1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
touch = (UITouch*)[enumerator nextObject];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -245,8 +257,8 @@
|
||||
|
||||
if ([string length] == 0) {
|
||||
/* it wants to replace text with nothing, ie a delete */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
|
||||
}
|
||||
else {
|
||||
/* go through all the characters in the string we've been sent
|
||||
@@ -272,14 +284,14 @@
|
||||
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift down */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
/* send a keydown and keyup even for the character */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift back up */
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,6 +459,8 @@ DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
data->ddraw = videodata->ddraw;
|
||||
|
||||
videodata->render = RENDER_DDRAW;
|
||||
|
||||
renderer->DisplayModeChanged = DDRAW_DisplayModeChanged;
|
||||
renderer->CreateTexture = DDRAW_CreateTexture;
|
||||
renderer->QueryTexturePixels = DDRAW_QueryTexturePixels;
|
||||
|
||||
@@ -451,6 +451,8 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
data->d3d = videodata->d3d;
|
||||
|
||||
videodata->render = RENDER_D3D;
|
||||
|
||||
renderer->DisplayModeChanged = D3D_DisplayModeChanged;
|
||||
renderer->CreateTexture = D3D_CreateTexture;
|
||||
renderer->QueryTexturePixels = D3D_QueryTexturePixels;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,11 @@
|
||||
/* SDL surface based renderer implementation */
|
||||
|
||||
#if SDL_VIDEO_RENDER_GAPI
|
||||
extern void GAPI_AddRenderDriver(_THIS);
|
||||
extern void WINCE_AddRenderDriver(_THIS);
|
||||
extern int WINCE_Available(void);
|
||||
extern void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible);
|
||||
extern int WINCE_GetDMOrientation(void);
|
||||
extern int WINCE_SetDMOrientation(int orientation);
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -22,100 +22,3 @@
|
||||
Stefan Klug
|
||||
klug.stefan@gmx.de
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
/* hi res definitions */
|
||||
typedef struct _RawFrameBufferInfo
|
||||
{
|
||||
WORD wFormat;
|
||||
WORD wBPP;
|
||||
VOID *pFramePointer;
|
||||
int cxStride;
|
||||
int cyStride;
|
||||
int cxPixels;
|
||||
int cyPixels;
|
||||
} RawFrameBufferInfo;
|
||||
|
||||
#define GETRAWFRAMEBUFFER 0x00020001
|
||||
|
||||
#define FORMAT_565 1
|
||||
#define FORMAT_555 2
|
||||
#define FORMAT_OTHER 3
|
||||
|
||||
|
||||
/* From gx.h, since it's not really C compliant */
|
||||
|
||||
struct GXDisplayProperties
|
||||
{
|
||||
DWORD cxWidth;
|
||||
DWORD cyHeight; // notice lack of 'th' in the word height.
|
||||
long cbxPitch; // number of bytes to move right one x pixel - can be negative.
|
||||
long cbyPitch; // number of bytes to move down one y pixel - can be negative.
|
||||
long cBPP; // # of bits in each pixel
|
||||
DWORD ffFormat; // format flags.
|
||||
};
|
||||
|
||||
struct GXKeyList
|
||||
{
|
||||
short vkUp; // key for up
|
||||
POINT ptUp; // x,y position of key/button. Not on screen but in screen coordinates.
|
||||
short vkDown;
|
||||
POINT ptDown;
|
||||
short vkLeft;
|
||||
POINT ptLeft;
|
||||
short vkRight;
|
||||
POINT ptRight;
|
||||
short vkA;
|
||||
POINT ptA;
|
||||
short vkB;
|
||||
POINT ptB;
|
||||
short vkC;
|
||||
POINT ptC;
|
||||
short vkStart;
|
||||
POINT ptStart;
|
||||
};
|
||||
|
||||
typedef int (*PFNGXOpenDisplay) (HWND hWnd, DWORD dwFlags);
|
||||
typedef int (*PFNGXCloseDisplay) ();
|
||||
typedef void *(*PFNGXBeginDraw) ();
|
||||
typedef int (*PFNGXEndDraw) ();
|
||||
typedef int (*PFNGXOpenInput) ();
|
||||
typedef int (*PFNGXCloseInput) ();
|
||||
typedef struct GXDisplayProperties (*PFNGXGetDisplayProperties) ();
|
||||
typedef struct GXKeyList (*PFNGXGetDefaultKeys) (int iOptions);
|
||||
typedef int (*PFNGXSuspend) ();
|
||||
typedef int (*PFNGXResume) ();
|
||||
typedef int (*PFNGXSetViewport) (DWORD dwTop, DWORD dwHeight,
|
||||
DWORD dwReserved1, DWORD dwReserved2);
|
||||
typedef BOOL(*PFNGXIsDisplayDRAMBuffer) ();
|
||||
|
||||
struct GapiFunc
|
||||
{
|
||||
PFNGXOpenDisplay GXOpenDisplay;
|
||||
PFNGXCloseDisplay GXCloseDisplay;
|
||||
PFNGXBeginDraw GXBeginDraw;
|
||||
PFNGXEndDraw GXEndDraw;
|
||||
PFNGXOpenInput GXOpenInput;
|
||||
PFNGXCloseInput GXCloseInput;
|
||||
PFNGXGetDisplayProperties GXGetDisplayProperties;
|
||||
PFNGXGetDefaultKeys GXGetDefaultKeys;
|
||||
PFNGXSuspend GXSuspend;
|
||||
PFNGXResume GXResume;
|
||||
PFNGXSetViewport GXSetViewport;
|
||||
PFNGXIsDisplayDRAMBuffer GXIsDisplayDRAMBuffer;
|
||||
} gx;
|
||||
|
||||
#define kfLandscape 0x8 // Screen is rotated 270 degrees
|
||||
#define kfPalette 0x10 // Pixel values are indexes into a palette
|
||||
#define kfDirect 0x20 // Pixel values contain actual level information
|
||||
#define kfDirect555 0x40 // 5 bits each for red, green and blue values in a pixel.
|
||||
#define kfDirect565 0x80 // 5 red bits, 6 green bits and 5 blue bits per pixel
|
||||
#define kfDirect888 0x100 // 8 bits each for red, green and blue values in a pixel.
|
||||
#define kfDirect444 0x200 // 4 red, 4 green, 4 blue
|
||||
#define kfDirectInverted 0x400
|
||||
|
||||
#define GX_FULLSCREEN 0x01 // for OpenDisplay()
|
||||
#define GX_NORMALKEYS 0x02
|
||||
#define GX_LANDSCAPEKEYS 0x03
|
||||
|
||||
@@ -184,6 +184,8 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
windowdata->videodata->render = RENDER_GDI;
|
||||
|
||||
renderer->DisplayModeChanged = GDI_DisplayModeChanged;
|
||||
renderer->CreateTexture = GDI_CreateTexture;
|
||||
renderer->QueryTexturePixels = GDI_QueryTexturePixels;
|
||||
@@ -267,6 +269,34 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
data->current_hbm = 0;
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
// check size for GDI fullscreen and rotate
|
||||
if((window->flags & SDL_WINDOW_FULLSCREEN) &&
|
||||
GetSystemMetrics(SM_CXSCREEN) != GetSystemMetrics(SM_CYSCREEN) &&
|
||||
((GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN) && window->w > window->h) ||
|
||||
(GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) && window->w < window->h)))
|
||||
{
|
||||
int orientation = WINCE_GetDMOrientation();
|
||||
switch(orientation)
|
||||
{
|
||||
case DMDO_0: orientation = DMDO_90; break;
|
||||
case DMDO_270: orientation = DMDO_180; break;
|
||||
case DMDO_90: orientation = DMDO_0; break;
|
||||
case DMDO_180: orientation = DMDO_270; break;
|
||||
|
||||
default:
|
||||
GDI_DestroyRenderer(renderer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(0 > WINCE_SetDMOrientation(orientation))
|
||||
{
|
||||
GDI_DestroyRenderer(renderer);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@@ -416,6 +446,7 @@ GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
WIN_SetError("Couldn't create bitmap");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
196
project/sdl/sdl-1.3/src/video/win32/SDL_msctf.h
Normal file
196
project/sdl/sdl-1.3/src/video/win32/SDL_msctf.h
Normal file
@@ -0,0 +1,196 @@
|
||||
#ifndef _SDL_msctf_h
|
||||
#define _SDL_msctf_h
|
||||
|
||||
#include <unknwn.h>
|
||||
|
||||
#define TF_INVALID_COOKIE (0xffffffff)
|
||||
#define TF_IPSINK_FLAG_ACTIVE 0x0001
|
||||
#define TF_TMAE_UIELEMENTENABLEDONLY 0x00000004
|
||||
|
||||
typedef struct ITfThreadMgr ITfThreadMgr;
|
||||
typedef struct ITfDocumentMgr ITfDocumentMgr;
|
||||
typedef struct ITfClientId ITfClientId;
|
||||
|
||||
typedef struct IEnumTfDocumentMgrs IEnumTfDocumentMgrs;
|
||||
typedef struct IEnumTfFunctionProviders IEnumTfFunctionProviders;
|
||||
typedef struct ITfFunctionProvider ITfFunctionProvider;
|
||||
typedef struct ITfCompartmentMgr ITfCompartmentMgr;
|
||||
typedef struct ITfContext ITfContext;
|
||||
typedef struct IEnumTfContexts IEnumTfContexts;
|
||||
typedef struct ITfUIElementSink ITfUIElementSink;
|
||||
typedef struct ITfUIElement ITfUIElement;
|
||||
typedef struct ITfUIElementMgr ITfUIElementMgr;
|
||||
typedef struct IEnumTfUIElements IEnumTfUIElements;
|
||||
typedef struct ITfThreadMgrEx ITfThreadMgrEx;
|
||||
typedef struct ITfReadingInformationUIElement ITfReadingInformationUIElement;
|
||||
typedef struct ITfInputProcessorProfileActivationSink ITfInputProcessorProfileActivationSink;
|
||||
typedef struct ITfSource ITfSource;
|
||||
|
||||
typedef DWORD TfClientId;
|
||||
typedef DWORD TfEditCookie;
|
||||
|
||||
typedef struct ITfThreadMgrVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgr *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgr *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgr *, TfClientId *);
|
||||
HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgr *, IEnumTfDocumentMgrs **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgr *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgr *, ITfDocumentMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgr *, HWND, ITfDocumentMgr *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgr *, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgr *, REFCLSID, ITfFunctionProvider **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgr *, IEnumTfFunctionProviders **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgr *, ITfCompartmentMgr **);
|
||||
} ITfThreadMgrVtbl;
|
||||
|
||||
struct ITfThreadMgr
|
||||
{
|
||||
const struct ITfThreadMgrVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfThreadMgrExVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgrEx *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgrEx *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgrEx *);
|
||||
HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgrEx *, TfClientId *);
|
||||
HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgrEx *);
|
||||
HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgrEx *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgrEx *, IEnumTfDocumentMgrs **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgrEx *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgrEx *, ITfDocumentMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgrEx *, ITfDocumentMgr *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgrEx *, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgrEx *, REFCLSID, ITfFunctionProvider **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgrEx *, IEnumTfFunctionProviders **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgrEx *, ITfCompartmentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *ActivateEx)(ITfThreadMgrEx *, TfClientId *, DWORD);
|
||||
HRESULT (STDMETHODCALLTYPE *GetActiveFlags)(ITfThreadMgrEx *, DWORD *);
|
||||
} ITfThreadMgrExVtbl;
|
||||
|
||||
struct ITfThreadMgrEx
|
||||
{
|
||||
const struct ITfThreadMgrExVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfDocumentMgrVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfDocumentMgr *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfDocumentMgr *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfDocumentMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *CreateContext)(ITfDocumentMgr *, TfClientId, DWORD, IUnknown *, ITfContext **, TfEditCookie *);
|
||||
HRESULT (STDMETHODCALLTYPE *Push)(ITfDocumentMgr *, ITfContext *);
|
||||
HRESULT (STDMETHODCALLTYPE *Pop)(ITfDocumentMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetTop)(ITfDocumentMgr *, ITfContext **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetBase)(ITfDocumentMgr *, ITfContext **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumContexts)(ITfDocumentMgr *, IEnumTfContexts **);
|
||||
} ITfDocumentMgrVtbl;
|
||||
|
||||
struct ITfDocumentMgr
|
||||
{
|
||||
const struct ITfDocumentMgrVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfUIElementSinkVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementSink *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementSink *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementSink *);
|
||||
HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementSink *, DWORD, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementSink *, DWORD);
|
||||
HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementSink *, DWORD);
|
||||
} ITfUIElementSinkVtbl;
|
||||
|
||||
struct ITfUIElementSink
|
||||
{
|
||||
const struct ITfUIElementSinkVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfUIElementMgrVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementMgr *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementMgr *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementMgr *, ITfUIElement *, BOOL *, DWORD *);
|
||||
HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementMgr *, DWORD);
|
||||
HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementMgr *, DWORD);
|
||||
HRESULT (STDMETHODCALLTYPE *GetUIElement)(ITfUIElementMgr *, DWORD, ITfUIElement **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumUIElements)(ITfUIElementMgr *, IEnumTfUIElements **);
|
||||
} ITfUIElementMgrVtbl;
|
||||
|
||||
struct ITfUIElementMgr
|
||||
{
|
||||
const struct ITfUIElementMgrVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfReadingInformationUIElementVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfReadingInformationUIElement *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfReadingInformationUIElement *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfReadingInformationUIElement *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfReadingInformationUIElement *, BSTR *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfReadingInformationUIElement *, GUID *);
|
||||
HRESULT (STDMETHODCALLTYPE *Show)(ITfReadingInformationUIElement *, BOOL);
|
||||
HRESULT (STDMETHODCALLTYPE *IsShown)(ITfReadingInformationUIElement *, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfReadingInformationUIElement *, DWORD *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetContext)(ITfReadingInformationUIElement *, ITfContext **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetString)(ITfReadingInformationUIElement *, BSTR *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetMaxReadingStringLength)(ITfReadingInformationUIElement *, UINT *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetErrorIndex)(ITfReadingInformationUIElement *, UINT *);
|
||||
HRESULT (STDMETHODCALLTYPE *IsVerticalOrderPreferred)(ITfReadingInformationUIElement *, BOOL *);
|
||||
} ITfReadingInformationUIElementVtbl;
|
||||
|
||||
struct ITfReadingInformationUIElement
|
||||
{
|
||||
const struct ITfReadingInformationUIElementVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfUIElementVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElement *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElement *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfUIElement *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfUIElement *, BSTR *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfUIElement *, GUID *);
|
||||
HRESULT (STDMETHODCALLTYPE *Show)(ITfUIElement *, BOOL);
|
||||
HRESULT (STDMETHODCALLTYPE *IsShown)(ITfUIElement *, BOOL *);
|
||||
} ITfUIElementVtbl;
|
||||
|
||||
struct ITfUIElement
|
||||
{
|
||||
const struct ITfUIElementVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfInputProcessorProfileActivationSinkVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfInputProcessorProfileActivationSink *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfInputProcessorProfileActivationSink *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfInputProcessorProfileActivationSink *);
|
||||
HRESULT (STDMETHODCALLTYPE *OnActivated)(ITfInputProcessorProfileActivationSink *, DWORD, LANGID, REFCLSID, REFGUID, REFGUID, HKL, DWORD);
|
||||
|
||||
} ITfInputProcessorProfileActivationSinkVtbl;
|
||||
|
||||
struct ITfInputProcessorProfileActivationSink
|
||||
{
|
||||
const struct ITfInputProcessorProfileActivationSinkVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfSourceVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfSource *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfSource *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfSource *);
|
||||
HRESULT (STDMETHODCALLTYPE *AdviseSink)(ITfSource *, REFIID, IUnknown *, DWORD *);
|
||||
HRESULT (STDMETHODCALLTYPE *UnadviseSink)(ITfSource *, DWORD);
|
||||
} ITfSourceVtbl;
|
||||
|
||||
struct ITfSource
|
||||
{
|
||||
const struct ITfSourceVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
#endif /* _SDL_msctf_h */
|
||||
@@ -95,7 +95,11 @@ WIN_SetClipboardText(_THIS, const char *text)
|
||||
WIN_SetError("Couldn't set clipboard data");
|
||||
result = -1;
|
||||
}
|
||||
#ifdef _WIN32_WCE
|
||||
data->clipboard_count = 0;
|
||||
#else
|
||||
data->clipboard_count = GetClipboardSequenceNumber();
|
||||
#endif
|
||||
}
|
||||
SDL_free(tstr);
|
||||
|
||||
@@ -149,7 +153,11 @@ WIN_CheckClipboardUpdate(struct SDL_VideoData * data)
|
||||
{
|
||||
DWORD count;
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
count = 0;
|
||||
#else
|
||||
count = GetClipboardSequenceNumber();
|
||||
#endif
|
||||
if (count != data->clipboard_count) {
|
||||
if (data->clipboard_count) {
|
||||
SDL_SendClipboardUpdate();
|
||||
|
||||
@@ -20,21 +20,19 @@
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#if (_WIN32_WINNT < 0x0501)
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#endif
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_win32video.h"
|
||||
#include "SDL_win32shape.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "SDL_vkeys.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
|
||||
|
||||
/*#define WMMSG_DEBUG*/
|
||||
#ifdef WMMSG_DEBUG
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include "wmmsg.h"
|
||||
#endif
|
||||
|
||||
@@ -57,6 +55,12 @@
|
||||
#ifndef WM_INPUT
|
||||
#define WM_INPUT 0x00ff
|
||||
#endif
|
||||
#ifndef WM_GESTURE
|
||||
#define WM_GESTURE 0x0119
|
||||
#endif
|
||||
#ifndef WM_TOUCH
|
||||
#define WM_TOUCH 0x0240
|
||||
#endif
|
||||
|
||||
static WPARAM
|
||||
RemapVKEY(WPARAM wParam, LPARAM lParam)
|
||||
@@ -109,10 +113,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
SDL_SysWMmsg wmmsg;
|
||||
|
||||
SDL_VERSION(&wmmsg.version);
|
||||
wmmsg.hwnd = hwnd;
|
||||
wmmsg.msg = msg;
|
||||
wmmsg.wParam = wParam;
|
||||
wmmsg.lParam = lParam;
|
||||
wmmsg.subsystem = SDL_SYSWM_WINDOWS;
|
||||
wmmsg.win.hwnd = hwnd;
|
||||
wmmsg.win.msg = msg;
|
||||
wmmsg.win.wParam = wParam;
|
||||
wmmsg.win.lParam = lParam;
|
||||
SDL_SendSysWMEvent(&wmmsg);
|
||||
}
|
||||
|
||||
@@ -121,9 +126,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
if (!data) {
|
||||
return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
#ifdef WMMSG_DEBUG
|
||||
{
|
||||
FILE *log = fopen("wmmsg.txt", "a");
|
||||
{
|
||||
FILE *log = fopen("wmmsg.txt", "a");
|
||||
fprintf(log, "Received windows message: %p ", hwnd);
|
||||
if (msg > MAX_WMMSG) {
|
||||
fprintf(log, "%d", msg);
|
||||
@@ -133,9 +139,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
fprintf(log, " -- 0x%X, 0x%X\n", wParam, lParam);
|
||||
fclose(log);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata))
|
||||
return 0;
|
||||
|
||||
switch (msg) {
|
||||
|
||||
case WM_SHOWWINDOW:
|
||||
@@ -184,6 +192,22 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
#ifdef _WIN32_WCE
|
||||
/* transform coords for VGA, WVGA... */
|
||||
{
|
||||
SDL_VideoData *videodata = data->videodata;
|
||||
if(videodata->CoordTransform &&
|
||||
(videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
|
||||
{
|
||||
POINT pt;
|
||||
pt.x = LOWORD(lParam);
|
||||
pt.y = HIWORD(lParam);
|
||||
videodata->CoordTransform(data->window, &pt);
|
||||
SDL_SendMouseMotion(data->window, 0, pt.x, pt.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam));
|
||||
break;
|
||||
|
||||
@@ -205,14 +229,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
SDL_bool repeat;
|
||||
|
||||
if (lParam & REPEATED_KEYMASK) {
|
||||
repeat = SDL_TRUE;
|
||||
} else {
|
||||
repeat = SDL_FALSE;
|
||||
}
|
||||
|
||||
wParam = RemapVKEY(wParam, lParam);
|
||||
switch (wParam) {
|
||||
case VK_CONTROL:
|
||||
@@ -250,8 +266,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
if (wParam < 256) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED,
|
||||
data->videodata->key_layout[wParam],
|
||||
repeat);
|
||||
data->videodata->key_layout[wParam]);
|
||||
}
|
||||
}
|
||||
returnCode = 0;
|
||||
@@ -301,13 +316,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
&& SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] ==
|
||||
SDL_RELEASED) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED,
|
||||
data->videodata->key_layout[wParam],
|
||||
SDL_FALSE);
|
||||
data->videodata->key_layout[wParam]);
|
||||
}
|
||||
if (wParam < 256) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED,
|
||||
data->videodata->key_layout[wParam],
|
||||
SDL_FALSE);
|
||||
data->videodata->key_layout[wParam]);
|
||||
}
|
||||
}
|
||||
returnCode = 0;
|
||||
@@ -353,6 +366,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
BOOL menu;
|
||||
|
||||
/* If we allow resizing, let the resize happen naturally */
|
||||
if(SDL_IsShapedWindow(data->window))
|
||||
Win32_ResizeWindowShape(data->window);
|
||||
if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
|
||||
returnCode = 0;
|
||||
break;
|
||||
@@ -504,7 +519,42 @@ 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]);
|
||||
}
|
||||
fprintf(log, "WM_TOUCH = %d -- 0x%X, 0x%X\n",msg, wParam, lParam);
|
||||
fclose(log);
|
||||
#endif
|
||||
|
||||
}
|
||||
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 */
|
||||
if (data->wndproc) {
|
||||
@@ -564,7 +614,7 @@ SDL_RegisterApp(char *name, Uint32 style, void *hInst)
|
||||
class.hbrBackground = NULL;
|
||||
class.hInstance = SDL_Instance;
|
||||
class.style = SDL_Appstyle;
|
||||
class.lpfnWndProc = DefWindowProc;
|
||||
class.lpfnWndProc = WIN_WindowProc;
|
||||
class.cbWndExtra = 0;
|
||||
class.cbClsExtra = 0;
|
||||
if (!RegisterClass(&class)) {
|
||||
|
||||
@@ -26,6 +26,14 @@
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/scancodes_win32.h"
|
||||
|
||||
#include <imm.h>
|
||||
#include <oleauto.h>
|
||||
|
||||
static void IME_Init(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Enable(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Disable(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Quit(SDL_VideoData *videodata);
|
||||
|
||||
#ifndef MAPVK_VK_TO_VSC
|
||||
#define MAPVK_VK_TO_VSC 0
|
||||
#endif
|
||||
@@ -81,6 +89,34 @@ WIN_InitKeyboard(_THIS)
|
||||
|
||||
data->key_layout = win32_scancode_table;
|
||||
|
||||
data->ime_com_initialized = SDL_FALSE;
|
||||
data->ime_threadmgr = 0;
|
||||
data->ime_initialized = SDL_FALSE;
|
||||
data->ime_enabled = SDL_FALSE;
|
||||
data->ime_available = SDL_FALSE;
|
||||
data->ime_hwnd_main = 0;
|
||||
data->ime_hwnd_current = 0;
|
||||
data->ime_himc = 0;
|
||||
data->ime_composition[0] = 0;
|
||||
data->ime_readingstring[0] = 0;
|
||||
data->ime_cursor = 0;
|
||||
data->ime_hkl = 0;
|
||||
data->ime_himm32 = 0;
|
||||
data->GetReadingString = 0;
|
||||
data->ShowReadingWindow = 0;
|
||||
data->ImmLockIMC = 0;
|
||||
data->ImmUnlockIMC = 0;
|
||||
data->ImmLockIMCC = 0;
|
||||
data->ImmUnlockIMCC = 0;
|
||||
data->ime_uiless = SDL_FALSE;
|
||||
data->ime_threadmgrex = 0;
|
||||
data->ime_uielemsinkcookie = TF_INVALID_COOKIE;
|
||||
data->ime_alpnsinkcookie = TF_INVALID_COOKIE;
|
||||
data->ime_openmodesinkcookie = TF_INVALID_COOKIE;
|
||||
data->ime_convmodesinkcookie = TF_INVALID_COOKIE;
|
||||
data->ime_uielemsink = 0;
|
||||
data->ime_ippasink = 0;
|
||||
|
||||
WIN_UpdateKeymap();
|
||||
|
||||
SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
|
||||
@@ -119,6 +155,865 @@ WIN_UpdateKeymap()
|
||||
void
|
||||
WIN_QuitKeyboard(_THIS)
|
||||
{
|
||||
IME_Quit((SDL_VideoData *)_this->driverdata);
|
||||
}
|
||||
|
||||
void
|
||||
WIN_StartTextInput(_THIS)
|
||||
{
|
||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||
if (window) {
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
IME_Init(videodata, hwnd);
|
||||
IME_Enable(videodata, hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WIN_StopTextInput(_THIS)
|
||||
{
|
||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||
if (window) {
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
IME_Init(videodata, hwnd);
|
||||
IME_Disable(videodata, hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
#undef DEFINE_GUID
|
||||
#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) static const GUID n = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
|
||||
DEFINE_GUID(IID_ITfInputProcessorProfileActivationSink, 0x71C6E74E,0x0F28,0x11D8,0xA8,0x2A,0x00,0x06,0x5B,0x84,0x43,0x5C);
|
||||
DEFINE_GUID(IID_ITfUIElementSink, 0xEA1EA136,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
|
||||
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_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);
|
||||
DEFINE_GUID(IID_ITfThreadMgrEx, 0x3E90ADE3,0x7594,0x4CB0,0xBB,0x58,0x69,0x62,0x8F,0x5F,0x45,0x8C);
|
||||
#endif
|
||||
|
||||
#define LANG_CHT MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
|
||||
#define LANG_CHS MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
|
||||
|
||||
#define MAKEIMEVERSION(major,minor) ((DWORD) (((BYTE)(major) << 24) | ((BYTE)(minor) << 16) ))
|
||||
#define IMEID_VER(id) ((id) & 0xffff0000)
|
||||
#define IMEID_LANG(id) ((id) & 0x0000ffff)
|
||||
|
||||
#define CHT_HKL_DAYI ((HKL)0xE0060404)
|
||||
#define CHT_HKL_NEW_PHONETIC ((HKL)0xE0080404)
|
||||
#define CHT_HKL_NEW_CHANG_JIE ((HKL)0xE0090404)
|
||||
#define CHT_HKL_NEW_QUICK ((HKL)0xE00A0404)
|
||||
#define CHT_HKL_HK_CANTONESE ((HKL)0xE00B0404)
|
||||
#define CHT_IMEFILENAME1 "TINTLGNT.IME"
|
||||
#define CHT_IMEFILENAME2 "CINTLGNT.IME"
|
||||
#define CHT_IMEFILENAME3 "MSTCIPHA.IME"
|
||||
#define IMEID_CHT_VER42 (LANG_CHT | MAKEIMEVERSION(4, 2))
|
||||
#define IMEID_CHT_VER43 (LANG_CHT | MAKEIMEVERSION(4, 3))
|
||||
#define IMEID_CHT_VER44 (LANG_CHT | MAKEIMEVERSION(4, 4))
|
||||
#define IMEID_CHT_VER50 (LANG_CHT | MAKEIMEVERSION(5, 0))
|
||||
#define IMEID_CHT_VER51 (LANG_CHT | MAKEIMEVERSION(5, 1))
|
||||
#define IMEID_CHT_VER52 (LANG_CHT | MAKEIMEVERSION(5, 2))
|
||||
#define IMEID_CHT_VER60 (LANG_CHT | MAKEIMEVERSION(6, 0))
|
||||
#define IMEID_CHT_VER_VISTA (LANG_CHT | MAKEIMEVERSION(7, 0))
|
||||
|
||||
#define CHS_HKL ((HKL)0xE00E0804)
|
||||
#define CHS_IMEFILENAME1 "PINTLGNT.IME"
|
||||
#define CHS_IMEFILENAME2 "MSSCIPYA.IME"
|
||||
#define IMEID_CHS_VER41 (LANG_CHS | MAKEIMEVERSION(4, 1))
|
||||
#define IMEID_CHS_VER42 (LANG_CHS | MAKEIMEVERSION(4, 2))
|
||||
#define IMEID_CHS_VER53 (LANG_CHS | MAKEIMEVERSION(5, 3))
|
||||
|
||||
#define LANG() LOWORD((videodata->ime_hkl))
|
||||
#define PRIMLANG() ((WORD)PRIMARYLANGID(LANG()))
|
||||
#define SUBLANG() SUBLANGID(LANG())
|
||||
|
||||
static void IME_UpdateInputLocale(SDL_VideoData *videodata);
|
||||
static void IME_ClearComposition(SDL_VideoData *videodata);
|
||||
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);
|
||||
#define SDL_IsEqualIID(riid1, riid2) SDL_IsEqualGUID(riid1, riid2)
|
||||
#define SDL_IsEqualGUID(rguid1, rguid2) (!SDL_memcmp(rguid1, rguid2, sizeof(GUID)))
|
||||
|
||||
static SDL_bool UILess_SetupSinks(SDL_VideoData *videodata);
|
||||
static void UILess_ReleaseSinks(SDL_VideoData *videodata);
|
||||
static void UILess_EnableUIUpdates(SDL_VideoData *videodata);
|
||||
static void UILess_DisableUIUpdates(SDL_VideoData *videodata);
|
||||
|
||||
static void
|
||||
IME_Init(SDL_VideoData *videodata, HWND hwnd)
|
||||
{
|
||||
if (videodata->ime_initialized)
|
||||
return;
|
||||
|
||||
videodata->ime_hwnd_main = hwnd;
|
||||
if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) {
|
||||
videodata->ime_com_initialized = SDL_TRUE;
|
||||
CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
|
||||
}
|
||||
videodata->ime_initialized = SDL_TRUE;
|
||||
videodata->ime_himm32 = LoadLibraryA("imm32.dll");
|
||||
if (!videodata->ime_himm32) {
|
||||
videodata->ime_available = SDL_FALSE;
|
||||
return;
|
||||
}
|
||||
videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))GetProcAddress(videodata->ime_himm32, "ImmLockIMC");
|
||||
videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))GetProcAddress(videodata->ime_himm32, "ImmUnlockIMC");
|
||||
videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))GetProcAddress(videodata->ime_himm32, "ImmLockIMCC");
|
||||
videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))GetProcAddress(videodata->ime_himm32, "ImmUnlockIMCC");
|
||||
|
||||
IME_SetWindow(videodata, hwnd);
|
||||
videodata->ime_himc = ImmGetContext(hwnd);
|
||||
ImmReleaseContext(hwnd, videodata->ime_himc);
|
||||
if (!videodata->ime_himc) {
|
||||
videodata->ime_available = SDL_FALSE;
|
||||
IME_Disable(videodata, hwnd);
|
||||
return;
|
||||
}
|
||||
videodata->ime_available = SDL_TRUE;
|
||||
IME_UpdateInputLocale(videodata);
|
||||
IME_SetupAPI(videodata);
|
||||
videodata->ime_uiless = UILess_SetupSinks(videodata);
|
||||
IME_UpdateInputLocale(videodata);
|
||||
IME_Disable(videodata, hwnd);
|
||||
}
|
||||
|
||||
static void
|
||||
IME_Enable(SDL_VideoData *videodata, HWND hwnd)
|
||||
{
|
||||
if (!videodata->ime_initialized || !videodata->ime_hwnd_current)
|
||||
return;
|
||||
|
||||
if (!videodata->ime_available) {
|
||||
IME_Disable(videodata, hwnd);
|
||||
return;
|
||||
}
|
||||
if (videodata->ime_hwnd_current == videodata->ime_hwnd_main)
|
||||
ImmAssociateContext(videodata->ime_hwnd_current, videodata->ime_himc);
|
||||
|
||||
videodata->ime_enabled = SDL_TRUE;
|
||||
IME_UpdateInputLocale(videodata);
|
||||
UILess_EnableUIUpdates(videodata);
|
||||
}
|
||||
|
||||
static void
|
||||
IME_Disable(SDL_VideoData *videodata, HWND hwnd)
|
||||
{
|
||||
if (!videodata->ime_initialized || !videodata->ime_hwnd_current)
|
||||
return;
|
||||
|
||||
IME_ClearComposition(videodata);
|
||||
if (videodata->ime_hwnd_current == videodata->ime_hwnd_main)
|
||||
ImmAssociateContext(videodata->ime_hwnd_current, (HIMC)0);
|
||||
|
||||
videodata->ime_enabled = SDL_FALSE;
|
||||
UILess_DisableUIUpdates(videodata);
|
||||
}
|
||||
|
||||
static void
|
||||
IME_Quit(SDL_VideoData *videodata)
|
||||
{
|
||||
if (!videodata->ime_initialized)
|
||||
return;
|
||||
|
||||
UILess_ReleaseSinks(videodata);
|
||||
if (videodata->ime_hwnd_main)
|
||||
ImmAssociateContext(videodata->ime_hwnd_main, videodata->ime_himc);
|
||||
|
||||
videodata->ime_hwnd_main = 0;
|
||||
videodata->ime_himc = 0;
|
||||
if (videodata->ime_himm32) {
|
||||
FreeLibrary(videodata->ime_himm32);
|
||||
videodata->ime_himm32 = 0;
|
||||
}
|
||||
if (videodata->ime_threadmgr) {
|
||||
videodata->ime_threadmgr->lpVtbl->Release(videodata->ime_threadmgr);
|
||||
videodata->ime_threadmgr = 0;
|
||||
}
|
||||
if (videodata->ime_com_initialized) {
|
||||
CoUninitialize();
|
||||
videodata->ime_com_initialized = SDL_FALSE;
|
||||
}
|
||||
videodata->ime_initialized = SDL_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd)
|
||||
{
|
||||
DWORD id = 0;
|
||||
HIMC himc = 0;
|
||||
WCHAR buffer[16];
|
||||
WCHAR *s = buffer;
|
||||
DWORD len = 0;
|
||||
INT err = 0;
|
||||
BOOL vertical = FALSE;
|
||||
UINT maxuilen = 0;
|
||||
static OSVERSIONINFOA osversion = {0};
|
||||
if (videodata->ime_uiless)
|
||||
return;
|
||||
|
||||
videodata->ime_readingstring[0] = 0;
|
||||
if (!osversion.dwOSVersionInfoSize) {
|
||||
osversion.dwOSVersionInfoSize = sizeof(osversion);
|
||||
GetVersionExA(&osversion);
|
||||
}
|
||||
id = IME_GetId(videodata, 0);
|
||||
if (!id)
|
||||
return;
|
||||
|
||||
himc = ImmGetContext(hwnd);
|
||||
if (!himc)
|
||||
return;
|
||||
|
||||
if (videodata->GetReadingString) {
|
||||
len = videodata->GetReadingString(himc, 0, 0, &err, &vertical, &maxuilen);
|
||||
if (len) {
|
||||
if (len > SDL_arraysize(buffer))
|
||||
len = SDL_arraysize(buffer);
|
||||
|
||||
len = videodata->GetReadingString(himc, len, s, &err, &vertical, &maxuilen);
|
||||
}
|
||||
SDL_wcslcpy(videodata->ime_readingstring, s, len);
|
||||
}
|
||||
else {
|
||||
LPINPUTCONTEXT2 lpimc = videodata->ImmLockIMC(himc);
|
||||
LPBYTE p = 0;
|
||||
s = 0;
|
||||
switch (id)
|
||||
{
|
||||
case IMEID_CHT_VER42:
|
||||
case IMEID_CHT_VER43:
|
||||
case IMEID_CHT_VER44:
|
||||
p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 24);
|
||||
if (!p)
|
||||
break;
|
||||
|
||||
len = *(DWORD *)(p + 7*4 + 32*4);
|
||||
s = (WCHAR *)(p + 56);
|
||||
break;
|
||||
case IMEID_CHT_VER51:
|
||||
case IMEID_CHT_VER52:
|
||||
case IMEID_CHS_VER53:
|
||||
p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 4);
|
||||
if (!p)
|
||||
break;
|
||||
|
||||
p = *(LPBYTE *)((LPBYTE)p + 1*4 + 5*4);
|
||||
if (!p)
|
||||
break;
|
||||
|
||||
len = *(DWORD *)(p + 1*4 + (16*2+2*4) + 5*4 + 16*2);
|
||||
s = (WCHAR *)(p + 1*4 + (16*2+2*4) + 5*4);
|
||||
break;
|
||||
case IMEID_CHS_VER41:
|
||||
{
|
||||
int offset = (IME_GetId(videodata, 1) >= 0x00000002) ? 8 : 7;
|
||||
p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + offset * 4);
|
||||
if (!p)
|
||||
break;
|
||||
|
||||
len = *(DWORD *)(p + 7*4 + 16*2*4);
|
||||
s = (WCHAR *)(p + 6*4 + 16*2*1);
|
||||
}
|
||||
break;
|
||||
case IMEID_CHS_VER42:
|
||||
if (osversion.dwPlatformId != VER_PLATFORM_WIN32_NT)
|
||||
break;
|
||||
|
||||
p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 1*4 + 1*4 + 6*4);
|
||||
if (!p)
|
||||
break;
|
||||
|
||||
len = *(DWORD *)(p + 1*4 + (16*2+2*4) + 5*4 + 16*2);
|
||||
s = (WCHAR *)(p + 1*4 + (16*2+2*4) + 5*4);
|
||||
break;
|
||||
}
|
||||
if (s)
|
||||
SDL_wcslcpy(videodata->ime_readingstring, s, len + 1);
|
||||
|
||||
videodata->ImmUnlockIMCC(lpimc->hPrivate);
|
||||
videodata->ImmUnlockIMC(himc);
|
||||
}
|
||||
ImmReleaseContext(hwnd, himc);
|
||||
IME_SendEditingEvent(videodata);
|
||||
}
|
||||
|
||||
static void
|
||||
IME_InputLangChanged(SDL_VideoData *videodata)
|
||||
{
|
||||
UINT lang = PRIMLANG();
|
||||
HWND hwndime = 0;
|
||||
IME_UpdateInputLocale(videodata);
|
||||
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
|
||||
IME_GetId(SDL_VideoData *videodata, UINT uIndex)
|
||||
{
|
||||
static HKL hklprev = 0;
|
||||
static DWORD dwRet[2] = {0};
|
||||
DWORD dwVerSize = 0;
|
||||
DWORD dwVerHandle = 0;
|
||||
LPVOID lpVerBuffer = 0;
|
||||
LPVOID lpVerData = 0;
|
||||
UINT cbVerData = 0;
|
||||
char szTemp[256];
|
||||
HKL hkl = 0;
|
||||
DWORD dwLang = 0;
|
||||
if (uIndex >= sizeof(dwRet) / sizeof(dwRet[0]))
|
||||
return 0;
|
||||
|
||||
hkl = videodata->ime_hkl;
|
||||
if (hklprev == hkl)
|
||||
return dwRet[uIndex];
|
||||
|
||||
hklprev = hkl;
|
||||
dwLang = ((DWORD)hkl & 0xffff);
|
||||
if (videodata->ime_uiless && LANG() == LANG_CHT) {
|
||||
dwRet[0] = IMEID_CHT_VER_VISTA;
|
||||
dwRet[1] = 0;
|
||||
return dwRet[0];
|
||||
}
|
||||
if (hkl != CHT_HKL_NEW_PHONETIC
|
||||
&& hkl != CHT_HKL_NEW_CHANG_JIE
|
||||
&& hkl != CHT_HKL_NEW_QUICK
|
||||
&& hkl != CHT_HKL_HK_CANTONESE
|
||||
&& hkl != CHS_HKL) {
|
||||
dwRet[0] = dwRet[1] = 0;
|
||||
return dwRet[uIndex];
|
||||
}
|
||||
if (ImmGetIMEFileNameA(hkl, szTemp, sizeof(szTemp) - 1) <= 0) {
|
||||
dwRet[0] = dwRet[1] = 0;
|
||||
return dwRet[uIndex];
|
||||
}
|
||||
if (!videodata->GetReadingString) {
|
||||
#define LCID_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
|
||||
if (CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME1, -1) != 2
|
||||
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME2, -1) != 2
|
||||
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME3, -1) != 2
|
||||
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME1, -1) != 2
|
||||
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME2, -1) != 2) {
|
||||
dwRet[0] = dwRet[1] = 0;
|
||||
return dwRet[uIndex];
|
||||
}
|
||||
#undef LCID_INVARIANT
|
||||
dwVerSize = GetFileVersionInfoSizeA(szTemp, &dwVerHandle);
|
||||
if (dwVerSize) {
|
||||
lpVerBuffer = SDL_malloc(dwVerSize);
|
||||
if (lpVerBuffer) {
|
||||
if (GetFileVersionInfoA(szTemp, dwVerHandle, dwVerSize, lpVerBuffer)) {
|
||||
if (VerQueryValueA(lpVerBuffer, "\\", &lpVerData, &cbVerData)) {
|
||||
#define pVerFixedInfo ((VS_FIXEDFILEINFO FAR*)lpVerData)
|
||||
DWORD dwVer = pVerFixedInfo->dwFileVersionMS;
|
||||
dwVer = (dwVer & 0x00ff0000) << 8 | (dwVer & 0x000000ff) << 16;
|
||||
if (videodata->GetReadingString ||
|
||||
dwLang == LANG_CHT && (
|
||||
dwVer == MAKEIMEVERSION(4, 2) ||
|
||||
dwVer == MAKEIMEVERSION(4, 3) ||
|
||||
dwVer == MAKEIMEVERSION(4, 4) ||
|
||||
dwVer == MAKEIMEVERSION(5, 0) ||
|
||||
dwVer == MAKEIMEVERSION(5, 1) ||
|
||||
dwVer == MAKEIMEVERSION(5, 2) ||
|
||||
dwVer == MAKEIMEVERSION(6, 0))
|
||||
||
|
||||
dwLang == LANG_CHS && (
|
||||
dwVer == MAKEIMEVERSION(4, 1) ||
|
||||
dwVer == MAKEIMEVERSION(4, 2) ||
|
||||
dwVer == MAKEIMEVERSION(5, 3))) {
|
||||
dwRet[0] = dwVer | dwLang;
|
||||
dwRet[1] = pVerFixedInfo->dwFileVersionLS;
|
||||
SDL_free(lpVerBuffer);
|
||||
return dwRet[0];
|
||||
}
|
||||
#undef pVerFixedInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_free(lpVerBuffer);
|
||||
}
|
||||
}
|
||||
dwRet[0] = dwRet[1] = 0;
|
||||
return dwRet[uIndex];
|
||||
}
|
||||
|
||||
static void
|
||||
IME_SetupAPI(SDL_VideoData *videodata)
|
||||
{
|
||||
char ime_file[MAX_PATH + 1];
|
||||
HMODULE hime = 0;
|
||||
HKL hkl = 0;
|
||||
videodata->GetReadingString = 0;
|
||||
videodata->ShowReadingWindow = 0;
|
||||
if (videodata->ime_uiless)
|
||||
return;
|
||||
|
||||
hkl = videodata->ime_hkl;
|
||||
if (ImmGetIMEFileNameA(hkl, ime_file, sizeof(ime_file) - 1) <= 0)
|
||||
return;
|
||||
|
||||
hime = LoadLibraryA(ime_file);
|
||||
if (!hime)
|
||||
return;
|
||||
|
||||
videodata->GetReadingString = (UINT (WINAPI *)(HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT))
|
||||
GetProcAddress(hime, "GetReadingString");
|
||||
videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL))
|
||||
GetProcAddress(hime, "ShowReadingWindow");
|
||||
|
||||
if (videodata->ShowReadingWindow) {
|
||||
HIMC himc = ImmGetContext(videodata->ime_hwnd_current);
|
||||
if (himc) {
|
||||
videodata->ShowReadingWindow(himc, FALSE);
|
||||
ImmReleaseContext(videodata->ime_hwnd_current, himc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
IME_SetWindow(SDL_VideoData* videodata, HWND hwnd)
|
||||
{
|
||||
videodata->ime_hwnd_current = hwnd;
|
||||
if (videodata->ime_threadmgr) {
|
||||
struct ITfDocumentMgr *document_mgr = 0;
|
||||
if (SUCCEEDED(videodata->ime_threadmgr->lpVtbl->AssociateFocus(videodata->ime_threadmgr, hwnd, NULL, &document_mgr))) {
|
||||
if (document_mgr)
|
||||
document_mgr->lpVtbl->Release(document_mgr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
IME_UpdateInputLocale(SDL_VideoData *videodata)
|
||||
{
|
||||
static HKL hklprev = 0;
|
||||
videodata->ime_hkl = GetKeyboardLayout(0);
|
||||
if (hklprev == videodata->ime_hkl)
|
||||
return;
|
||||
|
||||
hklprev = videodata->ime_hkl;
|
||||
}
|
||||
|
||||
static void
|
||||
IME_ClearComposition(SDL_VideoData *videodata)
|
||||
{
|
||||
HIMC himc = 0;
|
||||
if (!videodata->ime_initialized)
|
||||
return;
|
||||
|
||||
himc = ImmGetContext(videodata->ime_hwnd_current);
|
||||
if (!himc)
|
||||
return;
|
||||
|
||||
ImmNotifyIME(himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
|
||||
if (videodata->ime_uiless)
|
||||
ImmSetCompositionString(himc, SCS_SETSTR, TEXT(""), sizeof(TCHAR), TEXT(""), sizeof(TCHAR));
|
||||
|
||||
ImmNotifyIME(himc, NI_CLOSECANDIDATE, 0, 0);
|
||||
ImmReleaseContext(videodata->ime_hwnd_current, himc);
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
IME_ClearEditing(SDL_VideoData *videodata)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)
|
||||
{
|
||||
LONG length = ImmGetCompositionStringW(himc, string, videodata->ime_composition, sizeof(videodata->ime_composition));
|
||||
if (length < 0)
|
||||
length = 0;
|
||||
|
||||
length /= sizeof(videodata->ime_composition[0]);
|
||||
videodata->ime_cursor = LOWORD(ImmGetCompositionStringW(himc, GCS_CURSORPOS, 0, 0));
|
||||
if (videodata->ime_composition[videodata->ime_cursor] == 0x3000) {
|
||||
int i;
|
||||
for (i = videodata->ime_cursor + 1; i < length; ++i)
|
||||
videodata->ime_composition[i - 1] = videodata->ime_composition[i];
|
||||
|
||||
--length;
|
||||
}
|
||||
videodata->ime_composition[length] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
IME_SendInputEvent(SDL_VideoData *videodata)
|
||||
{
|
||||
char *s = 0;
|
||||
s = WIN_StringToUTF8(videodata->ime_composition);
|
||||
SDL_SendKeyboardText(s);
|
||||
SDL_free(s);
|
||||
|
||||
videodata->ime_composition[0] = 0;
|
||||
videodata->ime_readingstring[0] = 0;
|
||||
videodata->ime_cursor = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
IME_SendEditingEvent(SDL_VideoData *videodata)
|
||||
{
|
||||
char *s = 0;
|
||||
WCHAR buffer[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
buffer[0] = 0;
|
||||
if (videodata->ime_readingstring[0]) {
|
||||
size_t len = SDL_min(SDL_wcslen(videodata->ime_composition), (size_t)videodata->ime_cursor);
|
||||
SDL_wcslcpy(buffer, videodata->ime_composition, len + 1);
|
||||
SDL_wcslcat(buffer, videodata->ime_readingstring, sizeof(buffer));
|
||||
SDL_wcslcat(buffer, &videodata->ime_composition[len], sizeof(buffer) - len);
|
||||
}
|
||||
else {
|
||||
SDL_wcslcpy(buffer, videodata->ime_composition, sizeof(videodata->ime_composition));
|
||||
}
|
||||
s = WIN_StringToUTF8(buffer);
|
||||
SDL_SendEditingText(s, videodata->ime_cursor + SDL_wcslen(videodata->ime_readingstring), 0);
|
||||
SDL_free(s);
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata)
|
||||
{
|
||||
SDL_bool trap = SDL_FALSE;
|
||||
HIMC himc = 0;
|
||||
if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled)
|
||||
return SDL_FALSE;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case WM_INPUTLANGCHANGE:
|
||||
//IME_InputLangChanged(videodata);
|
||||
break;
|
||||
case WM_IME_SETCONTEXT:
|
||||
*lParam = 0;
|
||||
break;
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
trap = SDL_TRUE;
|
||||
break;
|
||||
case WM_IME_COMPOSITION:
|
||||
trap = SDL_TRUE;
|
||||
himc = ImmGetContext(hwnd);
|
||||
if (*lParam & GCS_RESULTSTR) {
|
||||
IME_GetCompositionString(videodata, himc, GCS_RESULTSTR);
|
||||
IME_SendInputEvent(videodata);
|
||||
}
|
||||
if (*lParam & GCS_COMPSTR) {
|
||||
if (!videodata->ime_uiless)
|
||||
videodata->ime_readingstring[0] = 0;
|
||||
|
||||
IME_GetCompositionString(videodata, himc, GCS_COMPSTR);
|
||||
IME_SendEditingEvent(videodata);
|
||||
}
|
||||
ImmReleaseContext(hwnd, himc);
|
||||
break;
|
||||
case WM_IME_ENDCOMPOSITION:
|
||||
videodata->ime_composition[0] = 0;
|
||||
videodata->ime_readingstring[0] = 0;
|
||||
videodata->ime_cursor = 0;
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
break;
|
||||
case WM_IME_NOTIFY:
|
||||
switch (wParam)
|
||||
{
|
||||
case IMN_SETCONVERSIONMODE:
|
||||
case IMN_SETOPENSTATUS:
|
||||
IME_UpdateInputLocale(videodata);
|
||||
break;
|
||||
case IMN_OPENCANDIDATE:
|
||||
case IMN_CHANGECANDIDATE:
|
||||
trap = SDL_TRUE;
|
||||
break;
|
||||
case IMN_CLOSECANDIDATE:
|
||||
trap = SDL_TRUE;
|
||||
break;
|
||||
case IMN_PRIVATE:
|
||||
{
|
||||
DWORD dwId = IME_GetId(videodata, 0);
|
||||
IME_GetReadingString(videodata, hwnd);
|
||||
switch (dwId)
|
||||
{
|
||||
case IMEID_CHT_VER42:
|
||||
case IMEID_CHT_VER43:
|
||||
case IMEID_CHT_VER44:
|
||||
case IMEID_CHS_VER41:
|
||||
case IMEID_CHS_VER42:
|
||||
if (*lParam == 1 || *lParam == 2)
|
||||
trap = SDL_TRUE;
|
||||
|
||||
break;
|
||||
case IMEID_CHT_VER50:
|
||||
case IMEID_CHT_VER51:
|
||||
case IMEID_CHT_VER52:
|
||||
case IMEID_CHT_VER60:
|
||||
case IMEID_CHS_VER53:
|
||||
if (*lParam == 16
|
||||
|| *lParam == 17
|
||||
|| *lParam == 26
|
||||
|| *lParam == 27
|
||||
|| *lParam == 28)
|
||||
trap = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
trap = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return trap;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) TSFSink_AddRef(TSFSink *sink)
|
||||
{
|
||||
return ++sink->refcount;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)TSFSink_Release(TSFSink *sink)
|
||||
{
|
||||
--sink->refcount;
|
||||
if (sink->refcount == 0)
|
||||
{
|
||||
SDL_free(sink);
|
||||
return 0;
|
||||
}
|
||||
return sink->refcount;
|
||||
}
|
||||
|
||||
STDMETHODIMP UIElementSink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv)
|
||||
{
|
||||
if (!ppv)
|
||||
return E_INVALIDARG;
|
||||
|
||||
*ppv = 0;
|
||||
if (SDL_IsEqualIID(riid, &IID_IUnknown))
|
||||
*ppv = (IUnknown *)sink;
|
||||
else if (SDL_IsEqualIID(riid, &IID_ITfUIElementSink))
|
||||
*ppv = (ITfUIElementSink *)sink;
|
||||
|
||||
if (*ppv) {
|
||||
TSFSink_AddRef(sink);
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ITfUIElement *UILess_GetUIElement(SDL_VideoData *videodata, DWORD dwUIElementId)
|
||||
{
|
||||
ITfUIElementMgr *puiem = 0;
|
||||
ITfUIElement *pelem = 0;
|
||||
ITfThreadMgrEx *threadmgrex = videodata->ime_threadmgrex;
|
||||
|
||||
if (SUCCEEDED(threadmgrex->lpVtbl->QueryInterface(threadmgrex, &IID_ITfUIElementMgr, (LPVOID *)&puiem))) {
|
||||
puiem->lpVtbl->GetUIElement(puiem, dwUIElementId, &pelem);
|
||||
puiem->lpVtbl->Release(puiem);
|
||||
}
|
||||
return pelem;
|
||||
}
|
||||
|
||||
STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BOOL *pbShow)
|
||||
{
|
||||
ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
|
||||
ITfReadingInformationUIElement *preading = 0;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
|
||||
if (!element)
|
||||
return E_INVALIDARG;
|
||||
|
||||
*pbShow = FALSE;
|
||||
if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
|
||||
BSTR bstr;
|
||||
if (SUCCEEDED(preading->lpVtbl->GetString(preading, &bstr)) && bstr) {
|
||||
WCHAR *s = (WCHAR *)bstr;
|
||||
SysFreeString(bstr);
|
||||
}
|
||||
preading->lpVtbl->Release(preading);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId)
|
||||
{
|
||||
ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
|
||||
ITfReadingInformationUIElement *preading = 0;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
|
||||
if (!element)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
|
||||
BSTR bstr;
|
||||
if (SUCCEEDED(preading->lpVtbl->GetString(preading, &bstr)) && bstr) {
|
||||
WCHAR *s = (WCHAR *)bstr;
|
||||
SDL_wcslcpy(videodata->ime_readingstring, s, sizeof(videodata->ime_readingstring));
|
||||
IME_SendEditingEvent(videodata);
|
||||
SysFreeString(bstr);
|
||||
}
|
||||
preading->lpVtbl->Release(preading);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId)
|
||||
{
|
||||
ITfUIElement *element = UILess_GetUIElement((SDL_VideoData *)sink->data, dwUIElementId);
|
||||
ITfReadingInformationUIElement *preading = 0;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
|
||||
if (!element)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfReadingInformationUIElement, (LPVOID *)&preading))) {
|
||||
videodata->ime_readingstring[0] = 0;
|
||||
IME_SendEditingEvent(videodata);
|
||||
preading->lpVtbl->Release(preading);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv)
|
||||
{
|
||||
if (!ppv)
|
||||
return E_INVALIDARG;
|
||||
|
||||
*ppv = 0;
|
||||
if (SDL_IsEqualIID(riid, &IID_IUnknown))
|
||||
*ppv = (IUnknown *)sink;
|
||||
else if (SDL_IsEqualIID(riid, &IID_ITfInputProcessorProfileActivationSink))
|
||||
*ppv = (ITfInputProcessorProfileActivationSink *)sink;
|
||||
|
||||
if (*ppv) {
|
||||
TSFSink_AddRef(sink);
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
STDMETHODIMP IPPASink_OnActivated(TSFSink *sink, DWORD dwProfileType, LANGID langid, REFCLSID clsid, REFGUID catid, REFGUID guidProfile, HKL hkl, DWORD dwFlags)
|
||||
{
|
||||
if (SDL_IsEqualIID(catid, &GUID_TFCAT_TIP_KEYBOARD) && (dwFlags & TF_IPSINK_FLAG_ACTIVE))
|
||||
IME_InputLangChanged((SDL_VideoData *)sink->data);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void *vtUIElementSink[] = {
|
||||
(void *)(UIElementSink_QueryInterface),
|
||||
(void *)(TSFSink_AddRef),
|
||||
(void *)(TSFSink_Release),
|
||||
(void *)(UIElementSink_BeginUIElement),
|
||||
(void *)(UIElementSink_UpdateUIElement),
|
||||
(void *)(UIElementSink_EndUIElement)
|
||||
};
|
||||
|
||||
static void *vtIPPASink[] = {
|
||||
(void *)(IPPASink_QueryInterface),
|
||||
(void *)(TSFSink_AddRef),
|
||||
(void *)(TSFSink_Release),
|
||||
(void *)(IPPASink_OnActivated)
|
||||
};
|
||||
|
||||
static void
|
||||
UILess_EnableUIUpdates(SDL_VideoData *videodata)
|
||||
{
|
||||
ITfSource *source = 0;
|
||||
if (!videodata->ime_threadmgrex || videodata->ime_uielemsinkcookie != TF_INVALID_COOKIE)
|
||||
return;
|
||||
|
||||
if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) {
|
||||
source->lpVtbl->AdviseSink(source, &IID_ITfUIElementSink, (IUnknown *)videodata->ime_uielemsink, &videodata->ime_uielemsinkcookie);
|
||||
source->lpVtbl->Release(source);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
UILess_DisableUIUpdates(SDL_VideoData *videodata)
|
||||
{
|
||||
ITfSource *source = 0;
|
||||
if (!videodata->ime_threadmgrex || videodata->ime_uielemsinkcookie == TF_INVALID_COOKIE)
|
||||
return;
|
||||
|
||||
if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) {
|
||||
source->lpVtbl->UnadviseSink(source, videodata->ime_uielemsinkcookie);
|
||||
videodata->ime_uielemsinkcookie = TF_INVALID_COOKIE;
|
||||
source->lpVtbl->Release(source);
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
UILess_SetupSinks(SDL_VideoData *videodata)
|
||||
{
|
||||
TfClientId clientid = 0;
|
||||
SDL_bool result = SDL_FALSE;
|
||||
ITfSource *source = 0;
|
||||
if (FAILED(CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgrEx, (LPVOID *)&videodata->ime_threadmgrex)))
|
||||
return SDL_FALSE;
|
||||
|
||||
if (FAILED(videodata->ime_threadmgrex->lpVtbl->ActivateEx(videodata->ime_threadmgrex, &clientid, TF_TMAE_UIELEMENTENABLEDONLY)))
|
||||
return SDL_FALSE;
|
||||
|
||||
videodata->ime_uielemsink = SDL_malloc(sizeof(TSFSink));
|
||||
videodata->ime_ippasink = SDL_malloc(sizeof(TSFSink));
|
||||
|
||||
videodata->ime_uielemsink->lpVtbl = vtUIElementSink;
|
||||
videodata->ime_uielemsink->refcount = 1;
|
||||
videodata->ime_uielemsink->data = videodata;
|
||||
|
||||
videodata->ime_ippasink->lpVtbl = vtIPPASink;
|
||||
videodata->ime_ippasink->refcount = 1;
|
||||
videodata->ime_ippasink->data = videodata;
|
||||
|
||||
if (SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) {
|
||||
if (SUCCEEDED(source->lpVtbl->AdviseSink(source, &IID_ITfUIElementSink, (IUnknown *)videodata->ime_uielemsink, &videodata->ime_uielemsinkcookie))) {
|
||||
if (SUCCEEDED(source->lpVtbl->AdviseSink(source, &IID_ITfInputProcessorProfileActivationSink, (IUnknown *)videodata->ime_ippasink, &videodata->ime_alpnsinkcookie))) {
|
||||
result = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
source->lpVtbl->Release(source);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#define SAFE_RELEASE(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
(p)->lpVtbl->Release((p)); \
|
||||
(p) = 0; \
|
||||
} \
|
||||
}
|
||||
|
||||
static void
|
||||
UILess_ReleaseSinks(SDL_VideoData *videodata)
|
||||
{
|
||||
ITfSource *source = 0;
|
||||
if (videodata->ime_threadmgrex && SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) {
|
||||
source->lpVtbl->UnadviseSink(source, videodata->ime_uielemsinkcookie);
|
||||
source->lpVtbl->UnadviseSink(source, videodata->ime_alpnsinkcookie);
|
||||
SAFE_RELEASE(source);
|
||||
videodata->ime_threadmgrex->lpVtbl->Deactivate(videodata->ime_threadmgrex);
|
||||
SAFE_RELEASE(videodata->ime_threadmgrex);
|
||||
TSFSink_Release(videodata->ime_uielemsink);
|
||||
videodata->ime_uielemsink = 0;
|
||||
TSFSink_Release(videodata->ime_ippasink);
|
||||
videodata->ime_ippasink = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -31,6 +31,12 @@ extern void WIN_InitKeyboard(_THIS);
|
||||
extern void WIN_UpdateKeymap(void);
|
||||
extern void WIN_QuitKeyboard(_THIS);
|
||||
|
||||
extern void WIN_StartTextInput(_THIS);
|
||||
extern void WIN_StopTextInput(_THIS);
|
||||
extern void WIN_SetTextInputRect(_THIS, SDL_Rect *rect);
|
||||
|
||||
extern SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata);
|
||||
|
||||
#endif /* _SDL_win32keyboard_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -203,10 +203,18 @@ WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
||||
{
|
||||
SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
// WINCE: DEVMODE.dmPosition not found, or may be mingw32ce bug
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->w = display->windows->w;
|
||||
rect->h = display->windows->h;
|
||||
#else
|
||||
rect->x = (int)data->DeviceMode.dmPosition.x;
|
||||
rect->y = (int)data->DeviceMode.dmPosition.y;
|
||||
rect->w = data->DeviceMode.dmPelsWidth;
|
||||
rect->h = data->DeviceMode.dmPelsHeight;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
104
project/sdl/sdl-1.3/src/video/win32/SDL_win32shape.c
Normal file
104
project/sdl/sdl-1.3/src/video/win32/SDL_win32shape.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_win32shape.h"
|
||||
#include "SDL_win32video.h"
|
||||
|
||||
SDL_WindowShaper*
|
||||
Win32_CreateShaper(SDL_Window * window) {
|
||||
int resized_properly;
|
||||
SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
|
||||
result->window = window;
|
||||
result->mode.mode = ShapeModeDefault;
|
||||
result->mode.parameters.binarizationCutoff = 1;
|
||||
result->userx = result->usery = 0;
|
||||
result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
|
||||
((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
|
||||
//Put some driver-data here.
|
||||
window->shaper = result;
|
||||
resized_properly = Win32_ResizeWindowShape(window);
|
||||
if (resized_properly != 0)
|
||||
return NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
CombineRectRegions(SDL_ShapeTree* node,void* closure) {
|
||||
HRGN mask_region = *((HRGN*)closure),temp_region = NULL;
|
||||
if(node->kind == OpaqueShape) {
|
||||
//Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline.
|
||||
temp_region = CreateRectRgn(node->data.shape.x,node->data.shape.y,node->data.shape.x + node->data.shape.w + 1,node->data.shape.y + node->data.shape.h + 1);
|
||||
if(mask_region != NULL) {
|
||||
CombineRgn(mask_region,mask_region,temp_region,RGN_OR);
|
||||
DeleteObject(temp_region);
|
||||
}
|
||||
else
|
||||
*((HRGN*)closure) = temp_region;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
|
||||
SDL_ShapeData *data;
|
||||
HRGN mask_region = NULL;
|
||||
|
||||
if (shaper == NULL || shape == NULL)
|
||||
return SDL_INVALID_SHAPE_ARGUMENT;
|
||||
if(shape->format->Amask == 0 && shape_mode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
|
||||
return SDL_INVALID_SHAPE_ARGUMENT;
|
||||
|
||||
data = (SDL_ShapeData*)shaper->driverdata;
|
||||
if(data->mask_tree != NULL)
|
||||
SDL_FreeShapeTree(&data->mask_tree);
|
||||
data->mask_tree = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||
|
||||
SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&mask_region);
|
||||
SDL_assert(mask_region != NULL);
|
||||
|
||||
SetWindowRgn(((SDL_WindowData *)(shaper->window->driverdata))->hwnd, mask_region, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Win32_ResizeWindowShape(SDL_Window *window) {
|
||||
SDL_ShapeData* data;
|
||||
|
||||
if (window == NULL)
|
||||
return -1;
|
||||
data = (SDL_ShapeData *)window->shaper->driverdata;
|
||||
if (data == NULL)
|
||||
return -1;
|
||||
|
||||
if(data->mask_tree != NULL)
|
||||
SDL_FreeShapeTree(&data->mask_tree);
|
||||
if(window->shaper->hasshape == SDL_TRUE) {
|
||||
window->shaper->userx = window->x;
|
||||
window->shaper->usery = window->y;
|
||||
SDL_SetWindowPosition(window,-1000,-1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
41
project/sdl/sdl-1.3/src/video/win32/SDL_win32shape.h
Normal file
41
project/sdl/sdl-1.3/src/video/win32/SDL_win32shape.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_win32shape_h
|
||||
#define _SDL_win32shape_h
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_shape.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_shape_internals.h"
|
||||
|
||||
typedef struct {
|
||||
SDL_ShapeTree *mask_tree;
|
||||
} SDL_ShapeData;
|
||||
|
||||
extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window);
|
||||
extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
|
||||
extern int Win32_ResizeWindowShape(SDL_Window *window);
|
||||
|
||||
#endif /* _SDL_win32shape_h */
|
||||
@@ -28,8 +28,10 @@
|
||||
#include "../SDL_pixels_c.h"
|
||||
|
||||
#include "SDL_win32video.h"
|
||||
#include "SDL_win32shape.h"
|
||||
#include "SDL_d3drender.h"
|
||||
#include "SDL_gdirender.h"
|
||||
#include "SDL_gapirender.h"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int WIN_VideoInit(_THIS);
|
||||
@@ -48,6 +50,7 @@ WIN_SetError(const char *prefix)
|
||||
SDL_free(message);
|
||||
}
|
||||
|
||||
|
||||
/* WIN32 driver bootstrap functions */
|
||||
|
||||
static int
|
||||
@@ -73,6 +76,11 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
|
||||
data->ddraw->lpVtbl->Release(data->ddraw);
|
||||
FreeLibrary(data->ddrawDLL);
|
||||
}
|
||||
#endif
|
||||
#ifdef _WIN32_WCE
|
||||
if(data->hAygShell) {
|
||||
FreeLibrary(data->hAygShell);
|
||||
}
|
||||
#endif
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
@@ -138,6 +146,15 @@ WIN_CreateDevice(int devindex)
|
||||
}
|
||||
#endif /* SDL_VIDEO_RENDER_DDRAW */
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
data->hAygShell = LoadLibrary(TEXT("\\windows\\aygshell.dll"));
|
||||
if(0 == data->hAygShell)
|
||||
data->hAygShell = LoadLibrary(TEXT("aygshell.dll"));
|
||||
data->SHFullScreen = (0 != data->hAygShell ?
|
||||
(PFNSHFullScreen) GetProcAddress(data->hAygShell, TEXT("SHFullScreen")) : 0);
|
||||
data->CoordTransform = NULL;
|
||||
#endif
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = WIN_VideoInit;
|
||||
device->VideoQuit = WIN_VideoQuit;
|
||||
@@ -164,6 +181,11 @@ WIN_CreateDevice(int devindex)
|
||||
device->SetWindowGrab = WIN_SetWindowGrab;
|
||||
device->DestroyWindow = WIN_DestroyWindow;
|
||||
device->GetWindowWMInfo = WIN_GetWindowWMInfo;
|
||||
|
||||
device->shape_driver.CreateShaper = Win32_CreateShaper;
|
||||
device->shape_driver.SetWindowShape = Win32_SetWindowShape;
|
||||
device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape;
|
||||
|
||||
#ifdef SDL_VIDEO_OPENGL_WGL
|
||||
device->GL_LoadLibrary = WIN_GL_LoadLibrary;
|
||||
device->GL_GetProcAddress = WIN_GL_GetProcAddress;
|
||||
@@ -175,6 +197,9 @@ WIN_CreateDevice(int devindex)
|
||||
device->GL_SwapWindow = WIN_GL_SwapWindow;
|
||||
device->GL_DeleteContext = WIN_GL_DeleteContext;
|
||||
#endif
|
||||
device->StartTextInput = WIN_StartTextInput;
|
||||
device->StopTextInput = WIN_StopTextInput;
|
||||
device->SetTextInputRect = WIN_SetTextInputRect;
|
||||
|
||||
device->SetClipboardText = WIN_SetClipboardText;
|
||||
device->GetClipboardText = WIN_GetClipboardText;
|
||||
@@ -186,10 +211,13 @@ WIN_CreateDevice(int devindex)
|
||||
}
|
||||
|
||||
VideoBootStrap WIN32_bootstrap = {
|
||||
#ifdef _WIN32_WCE
|
||||
"wince", "SDL WinCE video driver", WINCE_Available, WIN_CreateDevice
|
||||
#else
|
||||
"win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
WIN_VideoInit(_THIS)
|
||||
{
|
||||
@@ -207,7 +235,7 @@ WIN_VideoInit(_THIS)
|
||||
GDI_AddRenderDriver(_this);
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_GAPI
|
||||
GAPI_AddRenderDriver(_this);
|
||||
WINCE_AddRenderDriver(_this);
|
||||
#endif
|
||||
|
||||
WIN_InitKeyboard(_this);
|
||||
|
||||
@@ -28,11 +28,22 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define STRICT
|
||||
#ifndef UNICODE
|
||||
#define UNICODE
|
||||
#endif
|
||||
#undef WINVER
|
||||
#define WINVER 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
#include <msctf.h>
|
||||
#else
|
||||
#include "SDL_msctf.h"
|
||||
#endif
|
||||
|
||||
#include <imm.h>
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
//#include <d3d9.h>
|
||||
#define D3D_DEBUG_INFO
|
||||
@@ -53,6 +64,7 @@
|
||||
#include "SDL_win32mouse.h"
|
||||
#include "SDL_win32opengl.h"
|
||||
#include "SDL_win32window.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
#ifdef UNICODE
|
||||
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
|
||||
@@ -63,10 +75,48 @@
|
||||
#endif
|
||||
extern void WIN_SetError(const char *prefix);
|
||||
|
||||
enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW };
|
||||
|
||||
typedef BOOL (*PFNSHFullScreen)(HWND, DWORD);
|
||||
typedef void (*PFCoordTransform)(SDL_Window*, POINT*);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void **lpVtbl;
|
||||
int refcount;
|
||||
void *data;
|
||||
} TSFSink;
|
||||
|
||||
/* 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;
|
||||
} lfFont;
|
||||
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 */
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
int render;
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
HANDLE d3dDLL;
|
||||
IDirect3D9 *d3d;
|
||||
@@ -75,10 +125,45 @@ typedef struct SDL_VideoData
|
||||
HANDLE ddrawDLL;
|
||||
IDirectDraw *ddraw;
|
||||
#endif
|
||||
|
||||
DWORD clipboard_count;
|
||||
#ifdef _WIN32_WCE
|
||||
HMODULE hAygShell;
|
||||
PFNSHFullScreen SHFullScreen;
|
||||
PFCoordTransform CoordTransform;
|
||||
#endif
|
||||
|
||||
const SDL_scancode *key_layout;
|
||||
DWORD clipboard_count;
|
||||
|
||||
SDL_bool ime_com_initialized;
|
||||
struct ITfThreadMgr *ime_threadmgr;
|
||||
SDL_bool ime_initialized;
|
||||
SDL_bool ime_enabled;
|
||||
SDL_bool ime_available;
|
||||
HWND ime_hwnd_main;
|
||||
HWND ime_hwnd_current;
|
||||
HIMC ime_himc;
|
||||
|
||||
WCHAR ime_composition[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
WCHAR ime_readingstring[16];
|
||||
int ime_cursor;
|
||||
|
||||
HKL ime_hkl;
|
||||
HMODULE ime_himm32;
|
||||
UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen);
|
||||
BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow);
|
||||
LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc);
|
||||
BOOL (WINAPI *ImmUnlockIMC)(HIMC himc);
|
||||
LPVOID (WINAPI *ImmLockIMCC)(HIMCC himcc);
|
||||
BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc);
|
||||
|
||||
SDL_bool ime_uiless;
|
||||
struct ITfThreadMgrEx *ime_threadmgrex;
|
||||
DWORD ime_uielemsinkcookie;
|
||||
DWORD ime_alpnsinkcookie;
|
||||
DWORD ime_openmodesinkcookie;
|
||||
DWORD ime_convmodesinkcookie;
|
||||
TSFSink *ime_uielemsink;
|
||||
TSFSink *ime_ippasink;
|
||||
} SDL_VideoData;
|
||||
|
||||
#endif /* _SDL_win32video_h */
|
||||
|
||||
@@ -34,45 +34,13 @@
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
|
||||
#include "SDL_win32video.h"
|
||||
#include "SDL_win32window.h"
|
||||
|
||||
/* This is included after SDL_win32video.h, which includes windows.h */
|
||||
#include "SDL_syswm.h"
|
||||
#include "SDL_gapirender.h"
|
||||
|
||||
|
||||
#define SHFS_SHOWTASKBAR 0x0001
|
||||
#define SHFS_HIDETASKBAR 0x0002
|
||||
#define SHFS_SHOWSIPBUTTON 0x0004
|
||||
#define SHFS_HIDESIPBUTTON 0x0008
|
||||
#define SHFS_SHOWSTARTICON 0x0010
|
||||
#define SHFS_HIDESTARTICON 0x0020
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
// dynamically load aygshell dll because we want SDL to work on HPC and be300
|
||||
int aygshell_loaded = 0;
|
||||
BOOL(WINAPI * SHFullScreen) (HWND hwndRequester, DWORD dwState) = 0;
|
||||
|
||||
|
||||
static BOOL
|
||||
CE_SHFullScreen(HWND hwndRequester, DWORD dwState)
|
||||
{
|
||||
if (SHFullScreen == 0 && aygshell_loaded == 0) {
|
||||
aygshell_loaded = 0;
|
||||
void *lib = SDL_LoadObject("aygshell.dll");
|
||||
if (lib) {
|
||||
SHFullScreen =
|
||||
(BOOL(WINAPI *) (HWND, DWORD)) SDL_LoadFunction(lib,
|
||||
"SHFullScreen");
|
||||
}
|
||||
}
|
||||
|
||||
if (SHFullScreen) {
|
||||
SHFullScreen(hwndRequester, dwState);
|
||||
//printf("SHFullscreen(%i)\n",dwState);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Fake window to help with DirectInput events. */
|
||||
HWND SDL_HelperWindow = NULL;
|
||||
static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
|
||||
@@ -109,10 +77,12 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
||||
|
||||
/* Set up the window proc function */
|
||||
data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
||||
if (data->wndproc == DefWindowProc) {
|
||||
if (data->wndproc == WIN_WindowProc) {
|
||||
data->wndproc = NULL;
|
||||
}
|
||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc);
|
||||
else {
|
||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc);
|
||||
}
|
||||
|
||||
/* Fill in the SDL window with the window data */
|
||||
{
|
||||
@@ -250,6 +220,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
WIN_SetError("Couldn't create window");
|
||||
return -1;
|
||||
}
|
||||
//RegisterTouchWindow(hwnd, 0);
|
||||
|
||||
WIN_PumpEvents(_this);
|
||||
|
||||
@@ -472,32 +443,22 @@ WIN_SetWindowSize(_THIS, SDL_Window * window)
|
||||
void
|
||||
WIN_ShowWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
|
||||
ShowWindow(hwnd, SW_SHOW);
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
CE_SHFullScreen(hwnd,
|
||||
SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
|
||||
SHFS_HIDESIPBUTTON);
|
||||
}
|
||||
WINCE_ShowWindow(_this, window, 1);
|
||||
#else
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
ShowWindow(hwnd, SW_SHOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
WIN_HideWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
CE_SHFullScreen(hwnd,
|
||||
SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR |
|
||||
SHFS_SHOWSIPBUTTON);
|
||||
}
|
||||
WINCE_ShowWindow(_this, window, 0);
|
||||
#else
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -513,45 +474,33 @@ WIN_RaiseWindow(_THIS, SDL_Window * window)
|
||||
top = HWND_NOTOPMOST;
|
||||
}
|
||||
SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE));
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
CE_SHFullScreen(hwnd,
|
||||
SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
|
||||
SHFS_HIDESIPBUTTON);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
WIN_MaximizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
|
||||
ShowWindow(hwnd, SW_MAXIMIZE);
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
CE_SHFullScreen(hwnd,
|
||||
SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
|
||||
SHFS_HIDESIPBUTTON);
|
||||
}
|
||||
if((window->flags & SDL_WINDOW_FULLSCREEN) && videodata->SHFullScreen)
|
||||
videodata->SHFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
|
||||
#endif
|
||||
|
||||
ShowWindow(hwnd, SW_MAXIMIZE);
|
||||
}
|
||||
|
||||
void
|
||||
WIN_MinimizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
ShowWindow(hwnd, SW_MINIMIZE);
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
CE_SHFullScreen(hwnd,
|
||||
SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR |
|
||||
SHFS_SHOWSIPBUTTON);
|
||||
}
|
||||
if((window->flags & SDL_WINDOW_FULLSCREEN) && videodata->SHFullScreen)
|
||||
videodata->SHFullScreen(hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -586,6 +535,9 @@ WIN_DestroyWindow(_THIS, SDL_Window * window)
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (data) {
|
||||
#ifdef _WIN32_WCE
|
||||
WINCE_ShowWindow(_this, window, 0);
|
||||
#endif
|
||||
ReleaseDC(data->hwnd, data->hdc);
|
||||
if (data->created) {
|
||||
DestroyWindow(data->hwnd);
|
||||
@@ -599,7 +551,8 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
{
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
info->window = hwnd;
|
||||
info->subsystem = SDL_SYSWM_WINDOWS;
|
||||
info->win.window = hwnd;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||
|
||||
@@ -24,6 +24,15 @@
|
||||
#ifndef _SDL_win32window_h
|
||||
#define _SDL_win32window_h
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#define SHFS_SHOWTASKBAR 0x0001
|
||||
#define SHFS_HIDETASKBAR 0x0002
|
||||
#define SHFS_SHOWSIPBUTTON 0x0004
|
||||
#define SHFS_HIDESIPBUTTON 0x0008
|
||||
#define SHFS_SHOWSTARTICON 0x0010
|
||||
#define SHFS_HIDESTARTICON 0x0020
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_Window *window;
|
||||
|
||||
@@ -283,7 +283,7 @@ char *wmtab[] = {
|
||||
"WM_INITMENU",
|
||||
"WM_INITMENUPOPUP",
|
||||
"UNKNOWN (280)",
|
||||
"UNKNOWN (281)",
|
||||
"WM_GESTURE",
|
||||
"UNKNOWN (282)",
|
||||
"UNKNOWN (283)",
|
||||
"UNKNOWN (284)",
|
||||
@@ -578,7 +578,7 @@ char *wmtab[] = {
|
||||
"UNKNOWN (573)",
|
||||
"UNKNOWN (574)",
|
||||
"UNKNOWN (575)",
|
||||
"UNKNOWN (576)",
|
||||
"WM_TOUCH",
|
||||
"UNKNOWN (577)",
|
||||
"UNKNOWN (578)",
|
||||
"UNKNOWN (579)",
|
||||
|
||||
128
project/sdl/sdl-1.3/src/video/x11/SDL_eventtouch.c
Normal file
128
project/sdl/sdl-1.3/src/video/x11/SDL_eventtouch.c
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_x11video.h"
|
||||
#include "SDL_eventtouch.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
#include <linux/input.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
X11_InitTouch(_THIS)
|
||||
{
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
printf("Initializing touch...\n");
|
||||
|
||||
FILE *fd;
|
||||
fd = fopen("/proc/bus/input/devices","r");
|
||||
|
||||
char c;
|
||||
int i = 0;
|
||||
char line[256];
|
||||
char tstr[256];
|
||||
int vendor = -1,product = -1,event = -1;
|
||||
while(!feof(fd)) {
|
||||
if(fgets(line,256,fd) <=0) continue;
|
||||
//printf("%s",line);
|
||||
if(line[0] == '\n') {
|
||||
if(vendor == 1386){
|
||||
printf("Wacom... Assuming it is a touch device\n");
|
||||
sprintf(tstr,"/dev/input/event%i",event);
|
||||
printf("At location: %s\n",tstr);
|
||||
|
||||
SDL_Touch touch;
|
||||
touch.pressure_max = 0;
|
||||
touch.pressure_min = 0;
|
||||
touch.id = event;
|
||||
|
||||
|
||||
touch.driverdata = SDL_malloc(sizeof(EventTouchData));
|
||||
EventTouchData* data = (EventTouchData*)(touch.driverdata);
|
||||
|
||||
data->x = -1;
|
||||
data->y = -1;
|
||||
data->pressure = -1;
|
||||
data->finger = 0;
|
||||
data->up = SDL_FALSE;
|
||||
|
||||
|
||||
printf("Opening device...\n");
|
||||
//printf("New Touch - DataPtr: %i\n",data);
|
||||
data->eventStream = open(tstr,
|
||||
O_RDONLY | O_NONBLOCK);
|
||||
ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr);
|
||||
printf ("Reading From : %s\n", tstr);
|
||||
|
||||
|
||||
|
||||
int abs[5];
|
||||
ioctl(data->eventStream,EVIOCGABS(0),abs);
|
||||
touch.x_min = abs[1];
|
||||
touch.x_max = abs[2];
|
||||
touch.native_xres = touch.x_max - touch.x_min;
|
||||
ioctl(data->eventStream,EVIOCGABS(ABS_Y),abs);
|
||||
touch.y_min = abs[1];
|
||||
touch.y_max = abs[2];
|
||||
touch.native_yres = touch.y_max - touch.y_min;
|
||||
ioctl(data->eventStream,EVIOCGABS(ABS_PRESSURE),abs);
|
||||
touch.pressure_min = abs[1];
|
||||
touch.pressure_max = abs[2];
|
||||
touch.native_pressureres = touch.pressure_max - touch.pressure_min;
|
||||
|
||||
SDL_AddTouch(&touch, tstr);
|
||||
}
|
||||
vendor = -1;
|
||||
product = -1;
|
||||
event = -1;
|
||||
}
|
||||
else if(line[0] == 'I') {
|
||||
i = 1;
|
||||
while(line[i]) {
|
||||
sscanf(&line[i],"Vendor=%x",&vendor);
|
||||
sscanf(&line[i],"Product=%x",&product);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else if(line[0] == 'H') {
|
||||
i = 1;
|
||||
while(line[i]) {
|
||||
sscanf(&line[i],"event%d",&event);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
X11_QuitTouch(_THIS)
|
||||
{
|
||||
SDL_TouchQuit();
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
43
project/sdl/sdl-1.3/src/video/x11/SDL_eventtouch.h
Normal file
43
project/sdl/sdl-1.3/src/video/x11/SDL_eventtouch.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_eventtouch_h
|
||||
#define _SDL_eventtouch_h
|
||||
|
||||
|
||||
//What should this be?
|
||||
#if SDL_VIDEO_DRIVER_X11_XINPUT
|
||||
typedef struct EventTouchData
|
||||
{
|
||||
int x,y,pressure,finger; //Temporary Variables until sync
|
||||
int eventStream;
|
||||
SDL_bool up;
|
||||
} EventTouchData;
|
||||
#endif
|
||||
|
||||
extern void X11_InitTouch(_THIS);
|
||||
extern void X11_QuitTouch(_THIS);
|
||||
|
||||
#endif /* _SDL_eventtouch_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -52,6 +52,18 @@
|
||||
#include <X11/extensions/XInput.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XRENDER
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XDAMAGE
|
||||
#include <X11/extensions/Xdamage.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When using the "dynamic X11" functionality, we duplicate all the Xlib
|
||||
* symbols that would be referenced by SDL inside of SDL itself.
|
||||
|
||||
@@ -30,12 +30,38 @@
|
||||
#include "SDL_x11video.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
//Touch Input/event* includes
|
||||
#include <linux/input.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
/*#define DEBUG_XEVENTS*/
|
||||
|
||||
/* Check to see if this is a repeated key.
|
||||
(idea shamelessly lifted from GII -- thanks guys! :)
|
||||
*/
|
||||
static SDL_bool X11_KeyRepeat(Display *display, XEvent *event)
|
||||
{
|
||||
XEvent peekevent;
|
||||
|
||||
if (XPending(display)) {
|
||||
XPeekEvent(display, &peekevent);
|
||||
if ((peekevent.type == KeyPress) &&
|
||||
(peekevent.xkey.keycode == event->xkey.keycode) &&
|
||||
((peekevent.xkey.time-event->xkey.time) < 2)) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
X11_DispatchEvent(_THIS)
|
||||
{
|
||||
@@ -64,7 +90,7 @@ X11_DispatchEvent(_THIS)
|
||||
|
||||
SDL_VERSION(&wmmsg.version);
|
||||
wmmsg.subsystem = SDL_SYSWM_X11;
|
||||
wmmsg.event.xevent = xevent;
|
||||
wmmsg.x11.event = xevent;
|
||||
SDL_SendSysWMEvent(&wmmsg);
|
||||
}
|
||||
|
||||
@@ -103,7 +129,6 @@ X11_DispatchEvent(_THIS)
|
||||
SDL_SetMouseFocus(data->window);
|
||||
}
|
||||
break;
|
||||
|
||||
/* Losing mouse coverage? */
|
||||
case LeaveNotify:{
|
||||
#ifdef DEBUG_XEVENTS
|
||||
@@ -176,14 +201,14 @@ X11_DispatchEvent(_THIS)
|
||||
case KeyPress:{
|
||||
KeyCode keycode = xevent.xkey.keycode;
|
||||
KeySym keysym = NoSymbol;
|
||||
SDL_scancode scancode;
|
||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
|
||||
Status status = 0;
|
||||
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
|
||||
#endif
|
||||
/* FIXME: How do we tell if this was a key repeat? */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode], SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
|
||||
#if 1
|
||||
if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
|
||||
int min_keycode, max_keycode;
|
||||
@@ -218,7 +243,11 @@ X11_DispatchEvent(_THIS)
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
|
||||
#endif
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode], SDL_FALSE);
|
||||
if (X11_KeyRepeat(display, &xevent)) {
|
||||
/* We're about to get a repeated key down, ignore the key up */
|
||||
break;
|
||||
}
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -473,6 +502,79 @@ X11_PumpEvents(_THIS)
|
||||
while (X11_Pending(data->display)) {
|
||||
X11_DispatchEvent(_this);
|
||||
}
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
/* Process Touch events - TODO When X gets touch support, use that instead*/
|
||||
int i = 0,rd;
|
||||
char name[256];
|
||||
struct input_event ev[64];
|
||||
int size = sizeof (struct input_event);
|
||||
|
||||
for(i = 0;i < SDL_GetNumTouch();++i) {
|
||||
SDL_Touch* touch = SDL_GetTouchIndex(i);
|
||||
if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch());
|
||||
EventTouchData* data;
|
||||
data = (EventTouchData*)(touch->driverdata);
|
||||
if(data == NULL) {
|
||||
printf("No driver data\n");
|
||||
continue;
|
||||
}
|
||||
if(data->eventStream <= 0)
|
||||
printf("Error: Couldn't open stream\n");
|
||||
rd = read(data->eventStream, ev, size * 64);
|
||||
//printf("Got %i/%i bytes\n",rd,size);
|
||||
if(rd >= size) {
|
||||
for (i = 0; i < rd / sizeof(struct input_event); i++) {
|
||||
switch (ev[i].type) {
|
||||
case EV_ABS:
|
||||
//printf("Got position x: %i!\n",data->x);
|
||||
switch (ev[i].code) {
|
||||
case ABS_X:
|
||||
data->x = ev[i].value;
|
||||
break;
|
||||
case ABS_Y:
|
||||
data->y = ev[i].value;
|
||||
break;
|
||||
case ABS_PRESSURE:
|
||||
data->pressure = ev[i].value;
|
||||
if(data->pressure < 0) data->pressure = 0;
|
||||
break;
|
||||
case ABS_MISC:
|
||||
if(ev[i].value == 0)
|
||||
data->up = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EV_MSC:
|
||||
if(ev[i].code == MSC_SERIAL)
|
||||
data->finger = ev[i].value;
|
||||
break;
|
||||
case EV_SYN:
|
||||
//printf("Id: %i\n",touch->id);
|
||||
if(data->up) {
|
||||
SDL_SendFingerDown(touch->id,data->finger,
|
||||
SDL_FALSE,data->x,data->y,
|
||||
data->pressure);
|
||||
}
|
||||
else if(data->x >= 0 || data->y >= 0)
|
||||
SDL_SendTouchMotion(touch->id,data->finger,
|
||||
SDL_FALSE,data->x,data->y,
|
||||
data->pressure);
|
||||
|
||||
//printf("Synched: %i tx: %i, ty: %i\n",
|
||||
// data->finger,data->x,data->y);
|
||||
data->x = -1;
|
||||
data->y = -1;
|
||||
data->pressure = -1;
|
||||
data->finger = 0;
|
||||
data->up = SDL_FALSE;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This is so wrong it hurts */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
110
project/sdl/sdl-1.3/src/video/x11/SDL_x11shape.c
Normal file
110
project/sdl/sdl-1.3/src/video/x11/SDL_x11shape.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_x11video.h"
|
||||
#include "SDL_x11shape.h"
|
||||
#include "SDL_x11window.h"
|
||||
|
||||
SDL_Window*
|
||||
X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
|
||||
return SDL_CreateWindow(title,x,y,w,h,flags);
|
||||
}
|
||||
|
||||
SDL_WindowShaper*
|
||||
X11_CreateShaper(SDL_Window* window) {
|
||||
SDL_WindowShaper* result = NULL;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */
|
||||
result = malloc(sizeof(SDL_WindowShaper));
|
||||
result->window = window;
|
||||
result->mode.mode = ShapeModeDefault;
|
||||
result->mode.parameters.binarizationCutoff = 1;
|
||||
result->userx = result->usery = 0;
|
||||
SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData));
|
||||
result->driverdata = data;
|
||||
data->bitmapsize = 0;
|
||||
data->bitmap = NULL;
|
||||
window->shaper = result;
|
||||
int resized_properly = X11_ResizeWindowShape(window);
|
||||
SDL_assert(resized_properly == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
X11_ResizeWindowShape(SDL_Window* window) {
|
||||
SDL_ShapeData* data = window->shaper->driverdata;
|
||||
SDL_assert(data != NULL);
|
||||
|
||||
unsigned int bitmapsize = window->w / 8;
|
||||
if(window->w % 8 > 0)
|
||||
bitmapsize += 1;
|
||||
bitmapsize *= window->h;
|
||||
if(data->bitmapsize != bitmapsize || data->bitmap == NULL) {
|
||||
data->bitmapsize = bitmapsize;
|
||||
if(data->bitmap != NULL)
|
||||
free(data->bitmap);
|
||||
data->bitmap = malloc(data->bitmapsize);
|
||||
if(data->bitmap == NULL) {
|
||||
SDL_SetError("Could not allocate memory for shaped-window bitmap.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
memset(data->bitmap,0,data->bitmapsize);
|
||||
|
||||
window->shaper->userx = window->x;
|
||||
window->shaper->usery = window->y;
|
||||
SDL_SetWindowPosition(window,-1000,-1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
|
||||
if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
|
||||
return -1;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode))
|
||||
return -2;
|
||||
if(shape->w != shaper->window->w || shape->h != shaper->window->h)
|
||||
return -3;
|
||||
SDL_ShapeData *data = shaper->driverdata;
|
||||
|
||||
/* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */
|
||||
SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8);
|
||||
|
||||
SDL_WindowData *windowdata = (SDL_WindowData*)(shaper->window->driverdata);
|
||||
Pixmap shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
|
||||
|
||||
XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
|
||||
XSync(windowdata->videodata->display,False);
|
||||
|
||||
XFreePixmap(windowdata->videodata->display,shapemask);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
41
project/sdl/sdl-1.3/src/video/x11/SDL_x11shape.h
Normal file
41
project/sdl/sdl-1.3/src/video/x11/SDL_x11shape.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 2010 Eli Gottlieb
|
||||
|
||||
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
|
||||
|
||||
Eli Gottlieb
|
||||
eligottlieb@gmail.com
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_x11shape_h
|
||||
#define _SDL_x11shape_h
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_shape.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
typedef struct {
|
||||
void* bitmap;
|
||||
Uint32 bitmapsize;
|
||||
} SDL_ShapeData;
|
||||
|
||||
extern SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
|
||||
extern SDL_WindowShaper* X11_CreateShaper(SDL_Window* window);
|
||||
extern int X11_ResizeWindowShape(SDL_Window* window);
|
||||
extern int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
|
||||
|
||||
#endif /* _SDL_x11shape_h */
|
||||
@@ -39,6 +39,7 @@ SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return)
|
||||
SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XCopyArea,(Display* a,Drawable b,Drawable c,GC d,int e,int f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
|
||||
SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *data,unsigned int width,unsigned int height),(dpy,d,data,width,height),return)
|
||||
SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
|
||||
SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return)
|
||||
@@ -156,6 +157,10 @@ SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display* a,Bool b),(a,b),r
|
||||
SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return)
|
||||
SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return)
|
||||
SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return)
|
||||
SDL_X11_SYM(int,XFillRectangle,(Display *dpy,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height),(dpy,d,gc,x,y,width,height),return)
|
||||
SDL_X11_SYM(int,XSetBackground,(Display *dpy,GC gc,unsigned long background),(dpy,gc,background),return)
|
||||
SDL_X11_SYM(Status,XInitImage,(XImage *image),(image),return)
|
||||
SDL_X11_SYM(int,XSetClipMask,(Display *dpy,GC gc,Pixmap pixmap),(dpy,gc,pixmap),return)
|
||||
|
||||
#if NeedWidePrototypes
|
||||
SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return)
|
||||
@@ -182,6 +187,7 @@ SDL_X11_SYM(Status,XShmAttach,(Display* a,XShmSegmentInfo* b),(a,b),return)
|
||||
SDL_X11_SYM(Status,XShmDetach,(Display* a,XShmSegmentInfo* b),(a,b),return)
|
||||
SDL_X11_SYM(Status,XShmPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j,Bool k),(a,b,c,d,e,f,g,h,i,j,k),return)
|
||||
SDL_X11_SYM(XImage*,XShmCreateImage,(Display* a,Visual* b,unsigned int c,int d,char* e,XShmSegmentInfo* f,unsigned int g,unsigned int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_X11_SYM(Pixmap,XShmCreatePixmap,(Display *a,Drawable b,char* c,XShmSegmentInfo* d, unsigned int e, unsigned int f, unsigned int g),(a,b,c,d,e,f,g),return)
|
||||
SDL_X11_SYM(Bool,XShmQueryExtension,(Display* a),(a),return)
|
||||
#endif
|
||||
|
||||
@@ -237,6 +243,47 @@ SDL_X11_SYM(Status,XScreenSaverQueryVersion,(Display *dpy,int *major_versionp,in
|
||||
SDL_X11_SYM(void,XScreenSaverSuspend,(Display *dpy,Bool suspend),(dpy,suspend),return)
|
||||
#endif
|
||||
|
||||
/* XRender support */
|
||||
#if SDL_VIDEO_DRIVER_X11_XRENDER
|
||||
SDL_X11_MODULE(XRENDER)
|
||||
SDL_X11_SYM(Bool,XRenderQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
|
||||
SDL_X11_SYM(Bool,XRenderQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
|
||||
SDL_X11_SYM(XRenderPictFormat*,XRenderFindVisualFormat,(Display *dpy,_Xconst Visual *visual),(dpy,visual),return)
|
||||
SDL_X11_SYM(XRenderPictFormat*,XRenderFindStandardFormat,(Display *dpy,int format),(dpy,format),return)
|
||||
SDL_X11_SYM(XRenderPictFormat*,XRenderFindFormat,(Display *dpy,unsigned long mask,_Xconst XRenderPictFormat* templ,int count),(dpy,mask,templ,count),return)
|
||||
SDL_X11_SYM(Picture,XRenderCreatePicture,(Display *dpy,Drawable drawable,_Xconst XRenderPictFormat* format,unsigned long valuemask,_Xconst XRenderPictureAttributes* attributes),(dpy,drawable,format,valuemask,attributes),return)
|
||||
SDL_X11_SYM(void,XRenderFreePicture,(Display *dpy,Picture picture),(dpy,picture),return)
|
||||
SDL_X11_SYM(void,XRenderChangePicture,(Display *dpy,Picture picture,unsigned long valuemask,_Xconst XRenderPictureAttributes* attributes),(dpy,picture,valuemask,attributes),return)
|
||||
SDL_X11_SYM(void,XRenderComposite,(Display *dpy,int op,Picture src,Picture mask,Picture dst,int src_x,int src_y,int mask_x,int mask_y,int dst_x,int dst_y,unsigned int width,unsigned int height),(dpy,op,src,mask,dst,src_x,src_y,mask_x,mask_y,dst_x,dst_y,width,height),return)
|
||||
SDL_X11_SYM(Picture,XRenderCreateSolidFill,(Display *dpy,const XRenderColor *color),(dpy,color),return)
|
||||
SDL_X11_SYM(void,XRenderSetPictureTransform,(Display *dpy,Picture picture,XTransform *transform),(dpy,picture,transform),return)
|
||||
SDL_X11_SYM(void,XRenderFillRectangle,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,int x,int y,unsigned int width,unsigned int height),(dpy,op,dst,color,x,y,width,height),return)
|
||||
SDL_X11_SYM(void,XRenderFillRectangles,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,_Xconst XRectangle *rectangles,int n_rects),(dpy,op,dst,color,rectangles,n_rects),return)
|
||||
SDL_X11_SYM(void,XRenderSetPictureFilter,(Display *dpy,Picture picture,const char *filter,XFixed *params,int nparams),(dpy,picture,filter,params,nparams),return)
|
||||
#endif
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
|
||||
SDL_X11_MODULE(XDAMAGE)
|
||||
SDL_X11_SYM(Bool,XDamageQueryExtension,(Display *dpy,int *event_base_return,int *error_base_return),(dpy,event_base_return,error_base_return),return)
|
||||
SDL_X11_SYM(Status,XDamageQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
|
||||
SDL_X11_SYM(Damage,XDamageCreate,(Display *dpy,Drawable d,int level),(dpy,d,level),return)
|
||||
SDL_X11_SYM(void,XDamageSubtract,(Display *dpy,Damage damage,XserverRegion repair,XserverRegion parts),(dpy,damage,repair,parts),return)
|
||||
SDL_X11_SYM(void,XDamageDestroy,(Display *dpy,Damage damage),(dpy,damage),return)
|
||||
#endif
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
SDL_X11_MODULE(XFIXES)
|
||||
SDL_X11_SYM(Bool,XFixesQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
|
||||
SDL_X11_SYM(Status,XFixesQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
|
||||
SDL_X11_SYM(void,XFixesSetGCClipRegion,(Display *dpy,GC gc,int clip_x,int clip_y,XserverRegion region),(dpy,gc,clip_x,clip_y,region),return)
|
||||
SDL_X11_SYM(void,XFixesSetPictureClipRegion,(Display *dpy,XID picture,int clip_x,int clip_y,XserverRegion region),(dpy,picture,clip_x,clip_y,region),return)
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
SDL_X11_MODULE(XSHAPE)
|
||||
SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x_off,int y_off,Pixmap src,int op),(dpy,dest,dest_kind,x_off,y_off,src,op),)
|
||||
#endif
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -25,11 +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"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
#include "SDL_x11opengles.h"
|
||||
@@ -204,6 +206,9 @@ X11_CreateDevice(int devindex)
|
||||
device->SetWindowGrab = X11_SetWindowGrab;
|
||||
device->DestroyWindow = X11_DestroyWindow;
|
||||
device->GetWindowWMInfo = X11_GetWindowWMInfo;
|
||||
device->shape_driver.CreateShaper = X11_CreateShaper;
|
||||
device->shape_driver.SetWindowShape = X11_SetWindowShape;
|
||||
device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
|
||||
#ifdef SDL_VIDEO_OPENGL_GLX
|
||||
device->GL_LoadLibrary = X11_GL_LoadLibrary;
|
||||
device->GL_GetProcAddress = X11_GL_GetProcAddress;
|
||||
@@ -354,6 +359,7 @@ X11_VideoInit(_THIS)
|
||||
}
|
||||
X11_InitMouse(_this);
|
||||
|
||||
X11_InitTouch(_this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -374,6 +380,7 @@ X11_VideoQuit(_THIS)
|
||||
X11_QuitModes(_this);
|
||||
X11_QuitKeyboard(_this);
|
||||
X11_QuitMouse(_this);
|
||||
X11_QuitTouch(_this);
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
|
||||
@@ -45,6 +45,18 @@
|
||||
#if SDL_VIDEO_DRIVER_X11_SCRNSAVER
|
||||
#include <X11/extensions/scrnsaver.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XRENDER
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XDAMAGE
|
||||
#include <X11/extensions/Xdamage.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XFIXES
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif
|
||||
|
||||
#include "SDL_x11dyn.h"
|
||||
|
||||
@@ -54,6 +66,7 @@
|
||||
#include "SDL_x11keyboard.h"
|
||||
#include "SDL_x11modes.h"
|
||||
#include "SDL_x11mouse.h"
|
||||
#include "SDL_eventtouch.h"
|
||||
#include "SDL_x11opengl.h"
|
||||
#include "SDL_x11window.h"
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user