Changeset 10895

Timestamp:
Jan 11, 2012, 11:50:39 PM (13 years ago)
Author:
philip
Message:

SDL 1.3 build fixes.
Support SDL_CONFIG environment variable in update-workspaces to pick non-default sdl-config.
Avoid non-standard use of SDL/ in include paths.

Location:
ps/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/build/premake/extern_libs4.lua

    r10535 r10895  
    454454        compile_settings = function()
    455455            if os.is("windows") then
    456                 add_default_include_paths("sdl")
    457             else
     456                includedirs { libraries_dir .. "sdl/include/SDL" }
     457            else
     458
     459                -- Support SDL_CONFIG for overriding for the default PATH-based sdl-config
     460                sdl_config_path = os.getenv("SDL_CONFIG")
     461                if not sdl_config_path then
     462                    sdl_config_path = "sdl-config"
     463                end
     464
    458465                -- "pkg-config sdl --libs" appears to include both static and dynamic libs
    459466                -- when on MacPorts, which is bad, so use sdl-config instead
    460                 pkgconfig_cflags(nil, "sdl-config --cflags")
     467                pkgconfig_cflags(nil, --cflags")
    461468            end
    462469        end,
     
    465472                add_default_lib_paths("sdl")
    466473            else
    467                 pkgconfig_libs(nil, "sdl-config --libs")
     474                sdl_config_path = os.getenv("SDL_CONFIG")
     475                if not sdl_config_path then
     476                    sdl_config_path = "sdl-config"
     477                end
     478                pkgconfig_libs(nil, sdl_config_path.." --libs")
    468479            end
    469480        end,
  • ps/trunk/source/lib/external_libraries/sdl.h

    r7340 r10895  
    3535#else
    3636
    37 # include <SDL/SDL.h>
    38 # include <SDL/SDL_thread.h>
     37# include
     38# include
    3939
    4040// if the compiler doesn't support inlining, this header will pull
     
    4242// will strip them if unused, and this is more convenient than
    4343// another header that toggles between wsdl and SDL_endian.h.
    44 # include <SDL/SDL_endian.h>
     44# include
    4545
    4646# if MSC_VERSION
  • ps/trunk/source/lib/external_libraries/sdl_fwd.h

    r7316 r10895  
    3030// 2006-08-26 SDL is dragged into 6 of our 7 static library components.
    3131// it must be specified in each of their "extern_libs" so that the
    32 // include path is set and <SDL/sdl.h> can be found.
     32// include path is set and <SDL.h> can be found.
    3333//
    3434// obviously this is bad, so we work around the root cause. mostly only
  • ps/trunk/source/lib/sysdep/os/unix/x/x.cpp

    r9546 r10895  
    4242#include <Xatom.h>
    4343
    44 #include "SDL/SDL.h"
    45 #include "SDL/SDL_syswm.h"
     44#include "SDL.h"
     45#include "SDL_syswm.h"
    4646
    4747#include <algorithm>
     
    4949#undef Status
    5050
    51 static Display *SDL_Display;
    52 static Window SDL_Window;
    53 static void (*Lock_Display)(void);
    54 static void (*Unlock_Display)(void);
     51static Display *g_SDL_Display;
     52static Window g_SDL_Window;
     53#if !SDL_VERSION_ATLEAST(1, 3, 0)
     54static void (*g_Lock_Display)(void);
     55static void (*g_Unlock_Display)(void);
     56#endif
    5557static wchar_t *selection_data=NULL;
    5658static size_t selection_size=0;
     
    228230 * @see sys_clipboard_set
    229231 */
    230 int clipboard_filter(const SDL_Event *event)
     232#if SDL_VERSION_ATLEAST(1, 3, 0)
     233int clipboard_filter(void* UNUSED(userdata), SDL_Event* event)
     234#else
     235int clipboard_filter(const SDL_Event* event)
     236#endif
    231237{
    232238    /* Pass on all non-window manager specific events immediately */
     
    238244    /* (Note: libsdl must be compiled with X11 support (SDL_VIDEO_DRIVER_X11 in SDL_config.h) -
    239245       else you'll get errors like "'struct SDL_SysWMmsg' has no member named 'xevent'") */
    240     switch (event->syswm.msg->event.xevent.type) {
     246#if SDL_VERSION_ATLEAST(1, 3, 0)
     247    XEvent* xevent = &event->syswm.msg->msg.x11.event;
     248#else
     249    XEvent* xevent = &event->syswm.msg->event.xevent;
     250#endif
     251    switch (xevent->type) {
    241252        /* Copy the selection from our buffer to the requested property, and
    242253        convert to the requested target format */
     
    245256            XEvent sevent;
    246257
    247             req = &event->syswm.msg->event.xevent.xselectionrequest;
     258            req = &xselectionrequest;
    248259            sevent.xselection.type = SelectionNotify;
    249260            sevent.xselection.display = req->display;
     
    258269            {
    259270                size_t size = wcslen(selection_data);
    260                 u8 *buf = (u8 *)alloca(size);
     271                u8*)alloca(size);
    261272               
    262                 for (size_t i=0;i<size;i++)
     273                for (size_t ii++)
    263274                {
    264                     buf[i] = selection_data[i]<0x100?selection_data[i]:'?';
     275                    buf[i] = selection_data[i]'?';
    265276                }
    266277           
    267                 XChangeProperty(SDL_Display, req->requestor, req->property,
    268                     sevent.xselection.target, 8, PropModeReplace,
     278                XChangeProperty(SDL_Display, req->requestor, req->property,
     279        sevent.xselection.target, 8, PropModeReplace,
    269280                    buf, size);
    270281                sevent.xselection.property = req->property;
    271282            }
    272283            // TODO Add more target formats
    273             XSendEvent(SDL_Display,req->requestor,False,0,&sevent);
    274             XSync(SDL_Display, False);
     284            XSendEvent(&sevent);
     285            XSync(SDL_Display, False);
    275286        }
    276287        break;
     
    289300
    290301    SDL_VERSION(&info.version);
    291     if ( SDL_GetWMInfo(&info) )
     302    if ()
    292303    {
    293304        /* Save the information for later use */
    294         if ( info.subsystem == SDL_SYSWM_X11 )
     305        if ()
    295306        {
    296             SDL_Display = info.info.x11.display;
    297             SDL_Window = info.info.x11.window;
    298             Lock_Display = info.info.x11.lock_func;
    299             Unlock_Display = info.info.x11.unlock_func;
     307            g_SDL_Display = info.info.x11.display;
     308            g_SDL_Window = info.info.x11.window;
     309#if !SDL_VERSION_ATLEAST(1, 3, 0)
     310            g_Lock_Display = info.info.x11.lock_func;
     311            g_Unlock_Display = info.info.x11.unlock_func;
     312#endif
    300313
    301314            /* Enable the special window hook events */
    302315            SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
     316
     317
     318
    303319            SDL_SetEventFilter(clipboard_filter);
     320
    304321
    305322            return INFO::OK;
     
    340357    wcscpy(selection_data, str);
    341358
    342     Lock_Display();
     359#if !SDL_VERSION_ATLEAST(1, 3, 0)
     360    g_Lock_Display();
     361#endif
     362
    343363    // Like for the clipboard_get code above, we rather use CLIPBOARD than
    344364    // PRIMARY - more windows'y behaviour there.
    345     Atom clipboard_atom = XInternAtom(SDL_Display, "CLIPBOARD", False);
    346     XSetSelectionOwner(SDL_Display, clipboard_atom, SDL_Window, CurrentTime);
    347     XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window, CurrentTime);
    348     Unlock_Display();
    349    
     365    Atom clipboard_atom = XInternAtom(g_SDL_Display, "CLIPBOARD", False);
     366    XSetSelectionOwner(g_SDL_Display, clipboard_atom, g_SDL_Window, CurrentTime);
     367    XSetSelectionOwner(g_SDL_Display, XA_PRIMARY, g_SDL_Window, CurrentTime);
     368
     369#if !SDL_VERSION_ATLEAST(1, 3, 0)
     370    g_Unlock_Display();
     371#else
     372    // SDL 1.3 doesn't have a lockable event thread, so it just uses
     373    // XSync directly instead of lock_func/unlock_func
     374    XSync(g_SDL_Display, False);
     375#endif
     376
    350377    return INFO::OK;
    351378}
  • ps/trunk/source/lib/sysdep/os/win/wsdl.h

    r10826 r10895  
    3131#include "lib/byte_order.h"
    3232#ifndef WSDL_NO_KEYSYM
    33 # include "SDL/SDL_keysym.h"
     33# include "SDL_keysym.h"
    3434#endif
    3535
  • ps/trunk/source/ps/CConsole.cpp

    r10822 r10895  
    653653InReaction conInputHandler(const SDL_Event_* ev)
    654654{
    655     if (ev->ev.type == SDL_HOTKEYDOWN)
     655    if (ev->ev.type == SDL_HOTKEYDOWN)
    656656    {
    657657        std::string hotkey = static_cast<const char*>(ev->ev.user.data1);
  • ps/trunk/source/ps/Globals.cpp

    r7283 r10895  
    2525bool g_app_has_focus = true;
    2626
    27 bool g_keys[SDLK_LAST] = {0};
     27;
    2828int g_mouse_x = 50, g_mouse_y = 50;
    2929bool g_mouse_active = true;
  • ps/trunk/source/ps/Globals.h

    r7326 r10895  
    4242 * Updated by GlobalsInputHandler in response to key press/release events.
    4343 */
    44 extern bool g_keys[];
     44extern ;
    4545
    4646/**
  • ps/trunk/source/ps/Hotkey.cpp

    r10822 r10895  
    185185#endif
    186186        {
    187             keycode = SDLK_LAST + (int)ev->ev.button.button;
     187            keycode = + (int)ev->ev.button.button;
    188188            break;
    189189        }
     
    244244    bool consoleCapture = false;
    245245
    246     if( g_Console->IsActive() && keycode < SDLK_LAST )
     246    if( g_Console->IsActive() && keycode < )
    247247        consoleCapture = true;
    248248
     
    279279            bool rqdState = !itKey->negated;
    280280
    281             if( (int)itKey->code < SDLK_LAST )
     281            if( (int)itKey->code < )
    282282            {
    283283                if( g_keys[itKey->code] != rqdState ) accept = false;
     
    285285            else if( (int)itKey->code < UNIFIED_SHIFT )
    286286            {
    287                 if( g_mouse_buttons[itKey->code - SDLK_LAST] != rqdState ) accept = false;
     287                if( g_mouse_buttons[itKey->code - ] != rqdState ) accept = false;
    288288            }
    289289            else if( (int)itKey->code < UNIFIED_LAST )
     
    344344            bool rqdState = !itKey->negated;
    345345
    346             if( (int)itKey->code < SDLK_LAST )
     346            if( (int)itKey->code < )
    347347            {
    348348                if( g_keys[itKey->code] != rqdState ) accept = false;
     
    350350            else if( (int)itKey->code < UNIFIED_SHIFT )
    351351            {
    352                 if( g_mouse_buttons[itKey->code - SDLK_LAST] != rqdState ) accept = false;
     352                if( g_mouse_buttons[itKey->code - ] != rqdState ) accept = false;
    353353            }
    354354            else if( (int)itKey->code < UNIFIED_LAST )
  • ps/trunk/source/ps/KeyName.h

    r8833 r10895  
    2828extern int FindKeyCode( const CStr8& keyname );
    2929
     30
     31
     32
     33
     34
     35
     36
    3037enum {
    3138    // 'Keycodes' for the mouse buttons
    32     MOUSE_LEFT = SDLK_LAST + SDL_BUTTON_LEFT,
    33     MOUSE_RIGHT = SDLK_LAST + SDL_BUTTON_RIGHT,
    34     MOUSE_MIDDLE = SDLK_LAST + SDL_BUTTON_MIDDLE,
    35     MOUSE_WHEELUP = SDLK_LAST + SDL_BUTTON_WHEELUP,
    36     MOUSE_WHEELDOWN = SDLK_LAST + SDL_BUTTON_WHEELDOWN,
     39    MOUSE_LEFT = + SDL_BUTTON_LEFT,
     40    MOUSE_RIGHT = + SDL_BUTTON_RIGHT,
     41    MOUSE_MIDDLE = + SDL_BUTTON_MIDDLE,
     42    MOUSE_WHEELUP = + SDL_BUTTON_WHEELUP,
     43    MOUSE_WHEELDOWN = + SDL_BUTTON_WHEELDOWN,
    3744#if SDL_VERSION_ATLEAST(1, 2, 13)
    38     MOUSE_X1 = SDLK_LAST + SDL_BUTTON_X1,
    39     MOUSE_X2 = SDLK_LAST + SDL_BUTTON_X2,
     45    MOUSE_X1 = + SDL_BUTTON_X1,
     46    MOUSE_X2 = + SDL_BUTTON_X2,
    4047#else
    41     MOUSE_X1 = SDLK_LAST + SDL_BUTTON_WHEELDOWN + 1,
    42     MOUSE_X2 = SDLK_LAST + SDL_BUTTON_WHEELDOWN + 2,
     48    MOUSE_X1 = + SDL_BUTTON_WHEELDOWN + 1,
     49    MOUSE_X2 = + SDL_BUTTON_WHEELDOWN + 2,
    4350#endif
    4451
  • ps/trunk/source/ps/VideoMode.cpp

    r10826 r10895  
    157157    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
    158158    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
     159
    159160    SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, g_VSync ? 1 : 0);
    160 
     161#endif
     162   
    161163    if (!SetVideoMode(w, h, bpp, m_ConfigFullscreen))
    162164    {
     
    168170            return false;
    169171    }
     172
     173
     174
     175
    170176
    171177    // Work around a bug in the proprietary Linux ATI driver (at least versions 8.16.20 and 8.14.13).
  • ps/trunk/source/tools/atlas/AtlasUI/Misc/KeyMap.cpp

    r7607 r10895  
    2020#include "KeyMap.h"
    2121
    22 #include "SDL/SDL_keysym.h"
     22#include "SDL_keysym.h"
    2323
    2424int GetSDLKeyFromWxKeyCode(int wxkey)
Note: See TracChangeset for help on using the changeset viewer.