include/SDL_syswm.h
author Jørgen P. Tjernø <jorgen@valvesoftware.com>
Wed, 05 Jun 2013 12:48:44 -0700
changeset 7277 1290cd7f34af
parent 7200 54c9f310f7c0
child 7282 df78adc8ba04
permissions -rw-r--r--
Mac: Fix invalid PS3 controller mapping.

PS3 controller had swapped D-Pad down & left buttons, as well as X & Y buttons.
Thanks to Alex Szpakowski for the bug report and fix.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1891
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 
    22 /**
    23  *  \file SDL_syswm.h
    24  *
    25  *  Include file for SDL custom system window manager hooks.
    26  */
    27 
    28 #ifndef _SDL_syswm_h
    29 #define _SDL_syswm_h
    30 
    31 #include "SDL_stdinc.h"
    32 #include "SDL_error.h"
    33 #include "SDL_video.h"
    34 #include "SDL_version.h"
    35 
    36 #include "begin_code.h"
    37 /* Set up for C function definitions, even when using C++ */
    38 #ifdef __cplusplus
    39 extern "C" {
    40 #endif
    41 
    42 /**
    43  *  \file SDL_syswm.h
    44  *
    45  *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
    46  *  which contains window-manager specific information and arrives whenever
    47  *  an unhandled window event occurs.  This event is ignored by default, but
    48  *  you can enable it with SDL_EventState().
    49  */
    50 #ifdef SDL_PROTOTYPES_ONLY
    51 struct SDL_SysWMinfo;
    52 #else
    53 
    54 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
    55 #define WIN32_LEAN_AND_MEAN
    56 #include <windows.h>
    57 #endif
    58 
    59 /* This is the structure for custom window manager events */
    60 #if defined(SDL_VIDEO_DRIVER_X11)
    61 #if defined(__APPLE__) && defined(__MACH__)
    62 /* conflicts with Quickdraw.h */
    63 #define Cursor X11Cursor
    64 #endif
    65 
    66 #include <X11/Xlib.h>
    67 #include <X11/Xatom.h>
    68 
    69 #if defined(__APPLE__) && defined(__MACH__)
    70 /* matches the re-define above */
    71 #undef Cursor
    72 #endif
    73 
    74 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
    75 
    76 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    77 #include <directfb.h>
    78 #endif
    79 
    80 #if defined(SDL_VIDEO_DRIVER_COCOA)
    81 #ifdef __OBJC__
    82 #include <Cocoa/Cocoa.h>
    83 #else
    84 typedef struct _NSWindow NSWindow;
    85 typedef struct _NSView NSView;
    86 #endif
    87 #endif
    88 
    89 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    90 #ifdef __OBJC__
    91 #include <UIKit/UIKit.h>
    92 #else
    93 typedef struct _UIWindow UIWindow;
    94 #endif
    95 #endif
    96 
    97 /**
    98  *  These are the various supported windowing subsystems
    99  */
   100 typedef enum
   101 {
   102     SDL_SYSWM_UNKNOWN,
   103     SDL_SYSWM_WINDOWS,
   104     SDL_SYSWM_X11,
   105     SDL_SYSWM_DIRECTFB,
   106     SDL_SYSWM_COCOA,
   107     SDL_SYSWM_UIKIT,
   108 } SDL_SYSWM_TYPE;
   109 
   110 /**
   111  *  The custom event structure.
   112  */
   113 struct SDL_SysWMmsg
   114 {
   115     SDL_version version;
   116     SDL_SYSWM_TYPE subsystem;
   117     union
   118     {
   119 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   120         struct {
   121             HWND hwnd;                  /**< The window for the message */
   122             UINT msg;                   /**< The type of message */
   123             WPARAM wParam;              /**< WORD message parameter */
   124             LPARAM lParam;              /**< LONG message parameter */
   125         } win;
   126 #endif
   127 #if defined(SDL_VIDEO_DRIVER_X11)
   128         struct {
   129             XEvent event;
   130         } x11;
   131 #endif
   132 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   133         struct {
   134             DFBEvent event;
   135         } dfb;
   136 #endif
   137 #if defined(SDL_VIDEO_DRIVER_COCOA)
   138         struct
   139         {
   140             /* No Cocoa window events yet */
   141         } cocoa;
   142 #endif
   143 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   144         struct
   145         {
   146             /* No UIKit window events yet */
   147         } uikit;
   148 #endif
   149         /* Can't have an empty union */
   150         int dummy;
   151     } msg;
   152 };
   153 
   154 /**
   155  *  The custom window manager information structure.
   156  *
   157  *  When this structure is returned, it holds information about which
   158  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   159  */
   160 struct SDL_SysWMinfo
   161 {
   162     SDL_version version;
   163     SDL_SYSWM_TYPE subsystem;
   164     union
   165     {
   166 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   167         struct
   168         {
   169             HWND window;                /**< The window handle */
   170         } win;
   171 #endif
   172 #if defined(SDL_VIDEO_DRIVER_X11)
   173         struct
   174         {
   175             Display *display;           /**< The X11 display */
   176             Window window;              /**< The X11 window */
   177         } x11;
   178 #endif
   179 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   180         struct
   181         {
   182             IDirectFB *dfb;             /**< The directfb main interface */
   183             IDirectFBWindow *window;    /**< The directfb window handle */
   184             IDirectFBSurface *surface;  /**< The directfb client surface */
   185         } dfb;
   186 #endif
   187 #if defined(SDL_VIDEO_DRIVER_COCOA)
   188         struct
   189         {
   190             NSWindow *window;           /* The Cocoa window */
   191             NSView *view;               /* The Cocoa view */
   192         } cocoa;
   193 #endif
   194 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   195         struct
   196         {
   197             UIWindow *window;           /* The UIKit window */
   198         } uikit;
   199 #endif
   200         /* Can't have an empty union */
   201         int dummy;
   202     } info;
   203 };
   204 
   205 #endif /* SDL_PROTOTYPES_ONLY */
   206 
   207 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   208 
   209 /* Function prototypes */
   210 /**
   211  *  \brief This function allows access to driver-dependent window information.
   212  *
   213  *  \param window The window about which information is being requested
   214  *  \param info This structure must be initialized with the SDL version, and is
   215  *              then filled in with information about the given window.
   216  *
   217  *  \return SDL_TRUE if the function is implemented and the version member of
   218  *          the \c info struct is valid, SDL_FALSE otherwise.
   219  *
   220  *  You typically use this function like this:
   221  *  \code
   222  *  SDL_SysWMinfo info;
   223  *  SDL_VERSION(&info.version);
   224  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   225  *  \endcode
   226  */
   227 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   228                                                      SDL_SysWMinfo * info);
   229 
   230 
   231 /* Ends C function definitions when using C++ */
   232 #ifdef __cplusplus
   233 }
   234 #endif
   235 #include "close_code.h"
   236 
   237 #endif /* _SDL_syswm_h */
   238 
   239 /* vi: set ts=4 sw=4 expandtab: */