Remove disabled by default SDL1 support.
Refs #2041. This was SVN commit r17470.
This commit is contained in:
parent
7665a9ee31
commit
9a2d0f803e
@ -585,16 +585,9 @@ extern_lib_defs = {
|
||||
includedirs { libraries_dir .. "sdl2/include/SDL" }
|
||||
elseif not _OPTIONS["android"] then
|
||||
-- Support SDL*_CONFIG for overriding the default PATH-based sdl*-config
|
||||
if _OPTIONS["sdl1"] then
|
||||
sdl_config_path = os.getenv("SDL_CONFIG")
|
||||
if not sdl_config_path then
|
||||
sdl_config_path = "sdl-config"
|
||||
end
|
||||
else
|
||||
sdl_config_path = os.getenv("SDL2_CONFIG")
|
||||
if not sdl_config_path then
|
||||
sdl_config_path = "sdl2-config"
|
||||
end
|
||||
sdl_config_path = os.getenv("SDL2_CONFIG")
|
||||
if not sdl_config_path then
|
||||
sdl_config_path = "sdl2-config"
|
||||
end
|
||||
|
||||
pkgconfig_cflags(nil, sdl_config_path.." --cflags")
|
||||
@ -604,16 +597,9 @@ extern_lib_defs = {
|
||||
if os.is("windows") then
|
||||
add_default_lib_paths("sdl2")
|
||||
elseif not _OPTIONS["android"] then
|
||||
if _OPTIONS["sdl1"] then
|
||||
sdl_config_path = os.getenv("SDL_CONFIG")
|
||||
if not sdl_config_path then
|
||||
sdl_config_path = "sdl-config"
|
||||
end
|
||||
else
|
||||
sdl_config_path = os.getenv("SDL2_CONFIG")
|
||||
if not sdl_config_path then
|
||||
sdl_config_path = "sdl2-config"
|
||||
end
|
||||
sdl_config_path = os.getenv("SDL2_CONFIG")
|
||||
if not sdl_config_path then
|
||||
sdl_config_path = "sdl2-config"
|
||||
end
|
||||
pkgconfig_libs(nil, sdl_config_path.." --libs")
|
||||
end
|
||||
|
@ -321,11 +321,7 @@ InReaction CDropDown::ManuallyHandleEvent(const SDL_Event_* ev)
|
||||
// TODO: not too nice and doesn't deal with dashes.
|
||||
if (m_Open && ((szChar >= SDLK_a && szChar <= SDLK_z) || szChar == SDLK_SPACE
|
||||
|| (szChar >= SDLK_0 && szChar <= SDLK_9)
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
|| (szChar >= SDLK_KP0 && szChar <= SDLK_KP9)))
|
||||
#else // SDL2
|
||||
|| (szChar >= SDLK_KP_0 && szChar <= SDLK_KP_9)))
|
||||
#endif
|
||||
{
|
||||
// arbitrary 1 second limit to add to string or start fresh.
|
||||
// maximal amount of characters is 100, which imo is far more than enough.
|
||||
|
@ -146,22 +146,10 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
||||
ret = pNearest->SendEvent(GUIM_MOUSE_PRESS_RIGHT, "mouserightpress");
|
||||
break;
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case SDL_BUTTON_WHEELDOWN: // wheel down
|
||||
if (pNearest)
|
||||
ret = pNearest->SendEvent(GUIM_MOUSE_WHEEL_DOWN, "mousewheeldown");
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_WHEELUP: // wheel up
|
||||
if (pNearest)
|
||||
ret = pNearest->SendEvent(GUIM_MOUSE_WHEEL_UP, "mousewheelup");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
else if (ev->ev.type == SDL_MOUSEWHEEL)
|
||||
{
|
||||
if (ev->ev.wheel.y < 0)
|
||||
@ -175,7 +163,6 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
||||
ret = pNearest->SendEvent(GUIM_MOUSE_WHEEL_UP, "mousewheelup");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (ev->ev.type == SDL_MOUSEBUTTONUP)
|
||||
{
|
||||
switch (ev->ev.button.button)
|
||||
@ -265,9 +252,7 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
||||
!g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] &&
|
||||
!g_keys[SDLK_LALT] && !g_keys[SDLK_RALT])
|
||||
|| ev->ev.type == SDL_HOTKEYDOWN
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
|| ev->ev.type == SDL_TEXTINPUT || ev->ev.type == SDL_TEXTEDITING
|
||||
#endif
|
||||
)
|
||||
{
|
||||
ret = GetFocusedObject()->ManuallyHandleEvent(ev);
|
||||
|
@ -101,7 +101,6 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
||||
return IN_HANDLED;
|
||||
return(ManuallyHandleHotkeyEvent(ev));
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// SDL2 has a new method of text input that better supports Unicode and CJK
|
||||
// see https://wiki.libsdl.org/Tutorials/TextInput
|
||||
else if (ev->ev.type == SDL_TEXTINPUT)
|
||||
@ -182,7 +181,6 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
||||
|
||||
return IN_HANDLED;
|
||||
}
|
||||
#endif
|
||||
else if (ev->ev.type == SDL_KEYDOWN)
|
||||
{
|
||||
if (m_ComposingText)
|
||||
@ -193,15 +191,10 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
||||
CStrW* pCaption = (CStrW*)m_Settings["caption"].m_pSetting;
|
||||
bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT];
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
int szChar = ev->ev.key.keysym.sym;
|
||||
wchar_t cooked = (wchar_t)ev->ev.key.keysym.unicode;
|
||||
#else // SDL2
|
||||
int szChar = 0;
|
||||
if (ev->ev.type == SDL_KEYDOWN)
|
||||
szChar = ev->ev.key.keysym.sym;
|
||||
wchar_t cooked = 0;
|
||||
#endif
|
||||
|
||||
switch (szChar)
|
||||
{
|
||||
@ -492,15 +485,10 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
||||
}
|
||||
default: // Insert a character
|
||||
{
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
if (cooked == 0)
|
||||
return IN_PASS; // Important, because we didn't use any key
|
||||
#else // SDL2
|
||||
// In SDL2, we no longer get Unicode wchars via SDL_Keysym
|
||||
// we use text input events instead and they provide UTF-8 chars
|
||||
if (ev->ev.type == SDL_KEYDOWN && cooked == 0)
|
||||
return IN_HANDLED;
|
||||
#endif
|
||||
|
||||
// check max length
|
||||
int max_length;
|
||||
@ -1041,7 +1029,6 @@ void CInput::HandleMessage(SGUIMessage& Message)
|
||||
m_PrevTime = 0.0;
|
||||
m_CursorVisState = false;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// Tell the IME where to draw the candidate list
|
||||
SDL_Rect rect;
|
||||
rect.h = m_CachedActualSize.GetSize().cy;
|
||||
@ -1050,11 +1037,9 @@ void CInput::HandleMessage(SGUIMessage& Message)
|
||||
rect.y = m_CachedActualSize.TopLeft().y;
|
||||
SDL_SetTextInputRect(&rect);
|
||||
SDL_StartTextInput();
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GUIM_LOST_FOCUS:
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
if (m_ComposingText)
|
||||
{
|
||||
// Simulate a final text editing event to clear the composition
|
||||
@ -1066,7 +1051,6 @@ void CInput::HandleMessage(SGUIMessage& Message)
|
||||
ManuallyHandleEvent(&evt);
|
||||
}
|
||||
SDL_StopTextInput();
|
||||
#endif
|
||||
|
||||
m_iBufferPos = -1;
|
||||
m_iBufferPos_Tail = -1;
|
||||
|
@ -34,13 +34,7 @@ template<> void ScriptInterface::ToJSVal<SDL_Event_>(JSContext* cx, JS::MutableH
|
||||
|
||||
switch (val.ev.type)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case SDL_WINDOWEVENT: typeName = "windowevent"; break;
|
||||
#else
|
||||
case SDL_ACTIVEEVENT: typeName = "activeevent"; break;
|
||||
case SDL_VIDEOEXPOSE: typeName = "videoexpose"; break;
|
||||
case SDL_VIDEORESIZE: typeName = "videoresize"; break;
|
||||
#endif
|
||||
case SDL_KEYDOWN: typeName = "keydown"; break;
|
||||
case SDL_KEYUP: typeName = "keyup"; break;
|
||||
case SDL_MOUSEMOTION: typeName = "mousemotion"; break;
|
||||
@ -63,14 +57,6 @@ template<> void ScriptInterface::ToJSVal<SDL_Event_>(JSContext* cx, JS::MutableH
|
||||
|
||||
switch (val.ev.type)
|
||||
{
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case SDL_ACTIVEEVENT:
|
||||
{
|
||||
SET(obj, "gain", (int)val.ev.active.gain);
|
||||
SET(obj, "state", (int)val.ev.active.state);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
{
|
||||
@ -89,14 +75,6 @@ template<> void ScriptInterface::ToJSVal<SDL_Event_>(JSContext* cx, JS::MutableH
|
||||
// SET(keysym, "scancode", (int)val.ev.key.keysym.scancode); // (not in wsdl.h)
|
||||
SET(keysym, "sym", (int)val.ev.key.keysym.sym);
|
||||
// SET(keysym, "mod", (int)val.ev.key.keysym.mod); // (not in wsdl.h)
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
if (val.ev.key.keysym.unicode)
|
||||
{
|
||||
std::wstring unicode(1, (wchar_t)val.ev.key.keysym.unicode);
|
||||
SET(keysym, "unicode", unicode);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
SET(keysym, "unicode", JS::UndefinedHandleValue);
|
||||
}
|
||||
|
@ -32,12 +32,8 @@
|
||||
# include "SDL.h"
|
||||
# include "SDL_thread.h"
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
# if !SDL_VERSION_ATLEAST(2,0,2)
|
||||
# error You are using an old, untested libsdl2 release. It is \
|
||||
recommended to use libsdl2 >= 2.0.2. Alternatively, remove this \
|
||||
error message from this file, but remember you may encounter issues.
|
||||
# endif
|
||||
#if !SDL_VERSION_ATLEAST(2,0,2)
|
||||
#error You are using an old libsdl release. At least libsdl2 >= 2.0.2 is required.
|
||||
#endif
|
||||
|
||||
// if the compiler doesn't support inlining, this header will pull
|
||||
@ -47,13 +43,8 @@ error message from this file, but remember you may encounter issues.
|
||||
# include "SDL_endian.h"
|
||||
|
||||
# if MSC_VERSION
|
||||
# if SDL_VERSION_ATLEAST(2,0,0)
|
||||
# pragma comment(lib, "SDL2")
|
||||
# pragma comment(lib, "SDL2main")
|
||||
# else
|
||||
# pragma comment(lib, "SDL")
|
||||
# pragma comment(lib, "SDLmain")
|
||||
# endif
|
||||
# pragma comment(lib, "SDL2")
|
||||
# pragma comment(lib, "SDL2main")
|
||||
# endif
|
||||
|
||||
// complete definition of our forward-declared SDL_Event (see sdl_fwd.h)
|
||||
|
@ -46,38 +46,6 @@
|
||||
# define ALLOW_SYS_CURSOR 0
|
||||
#endif
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
static Status load_sys_cursor(const PIVFS& vfs, const VfsPath& pathname, int hx, int hy, sys_cursor* cursor)
|
||||
{
|
||||
# if !ALLOW_SYS_CURSOR
|
||||
UNUSED2(vfs);
|
||||
UNUSED2(pathname);
|
||||
UNUSED2(hx);
|
||||
UNUSED2(hy);
|
||||
UNUSED2(cursor);
|
||||
|
||||
return ERR::FAIL;
|
||||
# else
|
||||
shared_ptr<u8> file; size_t fileSize;
|
||||
RETURN_STATUS_IF_ERR(vfs->LoadFile(pathname, file, fileSize));
|
||||
|
||||
Tex t;
|
||||
RETURN_STATUS_IF_ERR(t.decode(file, fileSize));
|
||||
|
||||
// convert to required BGRA format.
|
||||
const size_t flags = (t.m_Flags | TEX_BGR) & ~TEX_DXT;
|
||||
RETURN_STATUS_IF_ERR(t.transform_to(flags));
|
||||
void* bgra_img = t.get_data();
|
||||
if(!bgra_img)
|
||||
WARN_RETURN(ERR::FAIL);
|
||||
|
||||
RETURN_STATUS_IF_ERR(sys_cursor_create((int)t.m_Width, (int)t.m_Height, bgra_img, hx, hy, cursor));
|
||||
return INFO::OK;
|
||||
# endif // ALLOW_SYS_CURSOR
|
||||
}
|
||||
|
||||
#else // SDL_VERSION_ATLEAST(2,0,0)
|
||||
|
||||
class SDLCursor
|
||||
{
|
||||
SDL_Surface* surface;
|
||||
@ -120,7 +88,6 @@ public:
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
};
|
||||
#endif // SDL_VERSION_ATLEAST(2,0,0)
|
||||
|
||||
// no init is necessary because this is stored in struct Cursor, which
|
||||
// is 0-initialized by h_mgr.
|
||||
@ -196,11 +163,7 @@ public:
|
||||
enum CursorKind
|
||||
{
|
||||
CK_Default,
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
CK_System,
|
||||
#else
|
||||
CK_SDL,
|
||||
#endif
|
||||
CK_OpenGL
|
||||
};
|
||||
|
||||
@ -211,19 +174,11 @@ struct Cursor
|
||||
|
||||
CursorKind kind;
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
// valid iff kind == CK_System
|
||||
sys_cursor system_cursor;
|
||||
#else
|
||||
// valid iff kind == CK_SDL
|
||||
SDLCursor sdl_cursor;
|
||||
#endif
|
||||
|
||||
// valid iff kind == CK_OpenGL
|
||||
GLCursor gl_cursor;
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
sys_cursor gl_empty_system_cursor;
|
||||
#endif
|
||||
};
|
||||
|
||||
H_TYPE_DEFINE(Cursor);
|
||||
@ -240,21 +195,12 @@ static void Cursor_dtor(Cursor* c)
|
||||
case CK_Default:
|
||||
break; // nothing to do
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
case CK_System:
|
||||
sys_cursor_free(c->system_cursor);
|
||||
break;
|
||||
#else
|
||||
case CK_SDL:
|
||||
c->sdl_cursor.destroy();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CK_OpenGL:
|
||||
c->gl_cursor.destroy();
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
sys_cursor_free(c->gl_empty_system_cursor);
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -280,23 +226,13 @@ static Status Cursor_reload(Cursor* c, const PIVFS& vfs, const VfsPath& name, Ha
|
||||
|
||||
const VfsPath pathnameImage = pathname.ChangeExtension(L".png");
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// try loading as SDL2 cursor
|
||||
if (!c->forceGL && c->sdl_cursor.create(vfs, pathnameImage, hotspotx, hotspoty) == INFO::OK)
|
||||
c->kind = CK_SDL;
|
||||
#else
|
||||
// try loading as system cursor (2d, hardware accelerated)
|
||||
if (!c->forceGL && load_sys_cursor(vfs, pathnameImage, hotspotx, hotspoty, &c->system_cursor) == INFO::OK)
|
||||
c->kind = CK_System;
|
||||
#endif
|
||||
// fall back to GLCursor (system cursor code is disabled or failed)
|
||||
else if(c->gl_cursor.create(vfs, pathnameImage, hotspotx, hotspoty) == INFO::OK)
|
||||
{
|
||||
c->kind = CK_OpenGL;
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// (we need to hide the system cursor when using a OpenGL cursor)
|
||||
sys_cursor_create_empty(&c->gl_empty_system_cursor);
|
||||
#endif
|
||||
}
|
||||
// everything failed, leave cursor unchanged
|
||||
else
|
||||
@ -312,15 +248,8 @@ static Status Cursor_validate(const Cursor* c)
|
||||
case CK_Default:
|
||||
break; // nothing to do
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
case CK_System:
|
||||
if(c->system_cursor == 0)
|
||||
WARN_RETURN(ERR::_1);
|
||||
break;
|
||||
#else
|
||||
case CK_SDL:
|
||||
break; // nothing to do
|
||||
#endif
|
||||
|
||||
case CK_OpenGL:
|
||||
RETURN_STATUS_IF_ERR(c->gl_cursor.validate());
|
||||
@ -343,15 +272,9 @@ static Status Cursor_to_string(const Cursor* c, wchar_t* buf)
|
||||
type = L"default";
|
||||
break;
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
case CK_System:
|
||||
type = L"sys";
|
||||
break;
|
||||
#else
|
||||
case CK_SDL:
|
||||
type = L"sdl";
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CK_OpenGL:
|
||||
type = L"gl";
|
||||
@ -395,11 +318,7 @@ Status cursor_draw(const PIVFS& vfs, const wchar_t* name, int x, int y, bool for
|
||||
// hide the cursor
|
||||
if(!name)
|
||||
{
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
sys_cursor_set(0);
|
||||
#else
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
#endif
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
@ -416,29 +335,14 @@ Status cursor_draw(const PIVFS& vfs, const wchar_t* name, int x, int y, bool for
|
||||
case CK_Default:
|
||||
break;
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
case CK_System:
|
||||
sys_cursor_set(c->system_cursor);
|
||||
break;
|
||||
#else
|
||||
case CK_SDL:
|
||||
c->sdl_cursor.set();
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CK_OpenGL:
|
||||
c->gl_cursor.draw(x, y);
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// note: gl_empty_system_cursor can be 0 if sys_cursor_create_empty
|
||||
// failed; in that case we don't want to sys_cursor_set because that
|
||||
// would restore the default cursor (which is exactly what we're
|
||||
// trying to avoid here)
|
||||
if(c->gl_empty_system_cursor)
|
||||
sys_cursor_set(c->gl_empty_system_cursor);
|
||||
#else
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -55,10 +55,6 @@
|
||||
|
||||
static Display *g_SDL_Display;
|
||||
static Window g_SDL_Window;
|
||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
static void (*g_Lock_Display)(void);
|
||||
static void (*g_Unlock_Display)(void);
|
||||
#endif
|
||||
static wchar_t *selection_data=NULL;
|
||||
static size_t selection_size=0;
|
||||
|
||||
@ -118,11 +114,8 @@ static bool get_wminfo(SDL_SysWMinfo& wminfo)
|
||||
{
|
||||
SDL_VERSION(&wminfo.version);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
const int ret = SDL_GetWindowWMInfo(g_VideoMode.GetWindow(), &wminfo);
|
||||
#else
|
||||
const int ret = SDL_GetWMInfo(&wminfo);
|
||||
#endif
|
||||
|
||||
if(ret == 1)
|
||||
return true;
|
||||
|
||||
@ -261,11 +254,7 @@ Status sys_clipboard_free(wchar_t *clip_buf)
|
||||
* @see x11_clipboard_init
|
||||
* @see sys_clipboard_set
|
||||
*/
|
||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
int clipboard_filter(void* UNUSED(userdata), SDL_Event* event)
|
||||
#else
|
||||
int clipboard_filter(const SDL_Event* event)
|
||||
#endif
|
||||
{
|
||||
/* Pass on all non-window manager specific events immediately */
|
||||
/* And do nothing if we don't actually have a clip-out to send out */
|
||||
@ -275,11 +264,7 @@ int clipboard_filter(const SDL_Event* event)
|
||||
/* Handle window-manager specific clipboard events */
|
||||
/* (Note: libsdl must be compiled with X11 support (SDL_VIDEO_DRIVER_X11 in SDL_config.h) -
|
||||
else you'll get errors like "'struct SDL_SysWMmsg' has no member named 'xevent'") */
|
||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
XEvent* xevent = &event->syswm.msg->msg.x11.event;
|
||||
#else
|
||||
XEvent* xevent = &event->syswm.msg->event.xevent;
|
||||
#endif
|
||||
switch(xevent->type) {
|
||||
/* Copy the selection from our buffer to the requested property, and
|
||||
convert to the requested target format */
|
||||
@ -337,18 +322,10 @@ Status x11_clipboard_init()
|
||||
{
|
||||
g_SDL_Display = info.info.x11.display;
|
||||
g_SDL_Window = info.info.x11.window;
|
||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
g_Lock_Display = info.info.x11.lock_func;
|
||||
g_Unlock_Display = info.info.x11.unlock_func;
|
||||
#endif
|
||||
|
||||
/* Enable the special window hook events */
|
||||
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
|
||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
SDL_SetEventFilter(clipboard_filter, NULL);
|
||||
#else
|
||||
SDL_SetEventFilter(clipboard_filter);
|
||||
#endif
|
||||
|
||||
return INFO::OK;
|
||||
}
|
||||
@ -387,23 +364,15 @@ Status sys_clipboard_set(const wchar_t *str)
|
||||
selection_data = (wchar_t *)malloc(selection_size);
|
||||
wcscpy(selection_data, str);
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
g_Lock_Display();
|
||||
#endif
|
||||
|
||||
// Like for the clipboard_get code above, we rather use CLIPBOARD than
|
||||
// PRIMARY - more windows'y behaviour there.
|
||||
Atom clipboard_atom = XInternAtom(g_SDL_Display, "CLIPBOARD", False);
|
||||
XSetSelectionOwner(g_SDL_Display, clipboard_atom, g_SDL_Window, CurrentTime);
|
||||
XSetSelectionOwner(g_SDL_Display, XA_PRIMARY, g_SDL_Window, CurrentTime);
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
g_Unlock_Display();
|
||||
#else
|
||||
// SDL 1.3 doesn't have a lockable event thread, so it just uses
|
||||
// SDL2 doesn't have a lockable event thread, so it just uses
|
||||
// XSync directly instead of lock_func/unlock_func
|
||||
XSync(g_SDL_Display, False);
|
||||
#endif
|
||||
|
||||
return INFO::OK;
|
||||
}
|
||||
@ -478,35 +447,19 @@ Status sys_cursor_set(sys_cursor cursor)
|
||||
if(wminfo.subsystem != SDL_SYSWM_X11)
|
||||
WARN_RETURN(ERR::FAIL);
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
wminfo.info.x11.lock_func();
|
||||
#endif
|
||||
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
||||
Window window;
|
||||
if(wminfo.info.x11.window)
|
||||
window = wminfo.info.x11.window;
|
||||
else
|
||||
{
|
||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
// wminfo.info.x11.window is sometimes 0, in which case
|
||||
// it causes a crash; in these cases use fswindow instead
|
||||
window = wminfo.info.x11.fswindow;
|
||||
#else
|
||||
WARN_RETURN(ERR::FAIL);
|
||||
#endif
|
||||
}
|
||||
|
||||
XDefineCursor(wminfo.info.x11.display, window,
|
||||
static_cast<sys_cursor_impl*>(cursor)->cursor);
|
||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
wminfo.info.x11.unlock_func();
|
||||
#else
|
||||
// SDL 1.3 doesn't have a lockable event thread, so it just uses
|
||||
// SDL2 doesn't have a lockable event thread, so it just uses
|
||||
// XSync directly instead of lock_func/unlock_func
|
||||
XSync(wminfo.info.x11.display, False);
|
||||
#endif
|
||||
}
|
||||
|
||||
return INFO::OK;}
|
||||
|
@ -96,7 +96,6 @@ static InReaction MainInputHandler(const SDL_Event_* ev)
|
||||
{
|
||||
switch(ev->ev.type)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case SDL_WINDOWEVENT:
|
||||
switch(ev->ev.window.event)
|
||||
{
|
||||
@ -114,24 +113,6 @@ static InReaction MainInputHandler(const SDL_Event_* ev)
|
||||
g_VideoMode.UpdatePosition(ev->ev.window.data1, ev->ev.window.data2);
|
||||
}
|
||||
break;
|
||||
#else
|
||||
case SDL_ACTIVEEVENT:
|
||||
if (ev->ev.active.state & SDL_APPMOUSEFOCUS)
|
||||
{
|
||||
// Tell renderer not to render cursor if mouse focus is lost
|
||||
// this restores system cursor, until/if focus is regained
|
||||
if (!ev->ev.active.gain)
|
||||
RenderCursor(false);
|
||||
else
|
||||
RenderCursor(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_VIDEORESIZE:
|
||||
g_ResizedW = ev->ev.resize.w;
|
||||
g_ResizedH = ev->ev.resize.h;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case SDL_QUIT:
|
||||
kill_mainloop();
|
||||
@ -374,11 +355,7 @@ static void Frame()
|
||||
Render();
|
||||
|
||||
PROFILE3("swap buffers");
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_GL_SwapWindow(g_VideoMode.GetWindow());
|
||||
#else
|
||||
SDL_GL_SwapBuffers();
|
||||
#endif
|
||||
}
|
||||
ogl_WarnIfError();
|
||||
|
||||
|
@ -93,13 +93,11 @@ void CConsole::ToggleVisible()
|
||||
m_bToggle = true;
|
||||
m_bVisible = !m_bVisible;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// TODO: this should be based on input focus, not visibility
|
||||
if (m_bVisible)
|
||||
SDL_StartTextInput();
|
||||
else
|
||||
SDL_StopTextInput();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CConsole::SetVisible(bool visible)
|
||||
@ -611,17 +609,8 @@ void CConsole::SaveHistory()
|
||||
g_VFS->CreateFile(m_sHistoryFile, buffer.Data(), buffer.Size());
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
static bool isUnprintableChar(SDL_Keysym key)
|
||||
#else
|
||||
static bool isUnprintableChar(SDL_keysym key)
|
||||
#endif
|
||||
{
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// U+0000 to U+001F are control characters
|
||||
if (key.unicode < 0x20)
|
||||
{
|
||||
#endif
|
||||
switch (key.sym)
|
||||
{
|
||||
// We want to allow some, which are handled specially
|
||||
@ -637,10 +626,6 @@ static bool isUnprintableChar(SDL_keysym key)
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
InReaction conInputHandler(const SDL_Event_* ev)
|
||||
@ -676,7 +661,6 @@ InReaction conInputHandler(const SDL_Event_* ev)
|
||||
if (!g_Console->IsActive())
|
||||
return IN_PASS;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// In SDL2, we no longer get Unicode wchars via SDL_Keysym
|
||||
// we use text input events instead and they provide UTF-8 chars
|
||||
if (ev->ev.type == SDL_TEXTINPUT && !HotkeyIsPressed("console.toggle"))
|
||||
@ -688,7 +672,6 @@ InReaction conInputHandler(const SDL_Event_* ev)
|
||||
return IN_HANDLED;
|
||||
}
|
||||
// TODO: text editing events for IME support
|
||||
#endif
|
||||
|
||||
if (ev->ev.type != SDL_KEYDOWN)
|
||||
return IN_PASS;
|
||||
@ -700,11 +683,7 @@ InReaction conInputHandler(const SDL_Event_* ev)
|
||||
if (!isUnprintableChar(ev->ev.key.keysym) &&
|
||||
!HotkeyIsPressed("console.toggle"))
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
g_Console->InsertChar(sym, 0);
|
||||
#else
|
||||
g_Console->InsertChar(sym, (wchar_t)ev->ev.key.keysym.unicode);
|
||||
#endif
|
||||
return IN_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -545,10 +545,6 @@ static void InitPs(bool setup_gui, const CStrW& gui_page, ScriptInterface* srcSc
|
||||
|
||||
static void InitInput()
|
||||
{
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
#endif
|
||||
|
||||
g_Joystick.Initialise();
|
||||
|
||||
// register input handlers
|
||||
@ -663,11 +659,7 @@ static void InitSDL()
|
||||
}
|
||||
atexit(SDL_Quit);
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_EnableUNICODE(1);
|
||||
#endif
|
||||
|
||||
#if OS_MACOSX && SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
#if OS_MACOSX
|
||||
// Some Mac mice only have one button, so they can't right-click
|
||||
// but SDL2 can emulate that with Ctrl+Click
|
||||
bool macMouse = false;
|
||||
@ -993,10 +985,6 @@ void InitGraphics(const CmdLineArgs& args, int flags)
|
||||
|
||||
if (!g_VideoMode.InitSDL())
|
||||
throw PSERROR_System_VmodeFailed(); // abort startup
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_WM_SetCaption("0 A.D.", "0 A.D.");
|
||||
#endif
|
||||
}
|
||||
|
||||
RunHardwareDetection();
|
||||
|
@ -729,18 +729,10 @@ static void ReportGLLimits(ScriptInterface& scriptInterface, JS::HandleValue set
|
||||
|
||||
SDL_SysWMinfo wminfo;
|
||||
SDL_VERSION(&wminfo.version);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
const int ret = SDL_GetWindowWMInfo(g_VideoMode.GetWindow(), &wminfo);
|
||||
#else
|
||||
const int ret = SDL_GetWMInfo(&wminfo);
|
||||
#endif
|
||||
if (ret && wminfo.subsystem == SDL_SYSWM_X11)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
Display* dpy = wminfo.info.x11.display;
|
||||
#else
|
||||
Display* dpy = wminfo.info.x11.gfxdisplay;
|
||||
#endif
|
||||
int scrnum = DefaultScreen(dpy);
|
||||
|
||||
const char* glxexts = glXQueryExtensionsString(dpy, scrnum);
|
||||
|
@ -43,7 +43,6 @@ InReaction GlobalsInputHandler(const SDL_Event_* ev)
|
||||
|
||||
switch(ev->ev.type)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case SDL_WINDOWEVENT:
|
||||
switch(ev->ev.window.event)
|
||||
{
|
||||
@ -68,26 +67,6 @@ InReaction GlobalsInputHandler(const SDL_Event_* ev)
|
||||
break;
|
||||
}
|
||||
return IN_PASS;
|
||||
#else
|
||||
case SDL_ACTIVEEVENT:
|
||||
if(ev->ev.active.state & SDL_APPACTIVE)
|
||||
{
|
||||
g_app_minimized = (ev->ev.active.gain == 0); // negated
|
||||
|
||||
if ( g_SoundManager )
|
||||
g_SoundManager->Pause( g_app_minimized && g_PauseOnFocusLoss && !g_NetClient );
|
||||
}
|
||||
if(ev->ev.active.state & SDL_APPINPUTFOCUS)
|
||||
{
|
||||
g_app_has_focus = (ev->ev.active.gain != 0);
|
||||
|
||||
if ( g_SoundManager )
|
||||
g_SoundManager->Pause( !g_app_has_focus && g_PauseOnFocusLoss && !g_NetClient );
|
||||
}
|
||||
if(ev->ev.active.state & SDL_APPMOUSEFOCUS)
|
||||
g_mouse_active = (ev->ev.active.gain != 0);
|
||||
return IN_PASS;
|
||||
#endif
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
g_mouse_x = ev->ev.motion.x;
|
||||
|
@ -30,11 +30,7 @@
|
||||
|
||||
static bool unified[UNIFIED_LAST - UNIFIED_SHIFT];
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
#define SDLKEY SDL_Keycode
|
||||
#else
|
||||
#define SDLKEY SDLKey
|
||||
#endif
|
||||
|
||||
struct SKey
|
||||
{
|
||||
@ -167,17 +163,14 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev)
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// Mousewheel events are no longer buttons, but we want to maintain the order
|
||||
// expected by g_mouse_buttons for compatibility
|
||||
if (ev->ev.button.button >= SDL_BUTTON_X1)
|
||||
keycode = MOUSE_BASE + (int)ev->ev.button.button + 2;
|
||||
else
|
||||
#endif
|
||||
keycode = MOUSE_BASE + (int)ev->ev.button.button;
|
||||
break;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case SDL_MOUSEWHEEL:
|
||||
if (ev->ev.wheel.y > 0)
|
||||
{
|
||||
@ -200,7 +193,6 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev)
|
||||
break;
|
||||
}
|
||||
return IN_PASS;
|
||||
#endif
|
||||
|
||||
case SDL_HOTKEYDOWN:
|
||||
g_HotkeyStatus[static_cast<const char*>(ev->ev.user.data1)] = true;
|
||||
@ -214,13 +206,6 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev)
|
||||
return IN_PASS;
|
||||
}
|
||||
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// Rather ugly hack to make the '"' key work better on a MacBook Pro on Windows so it doesn't
|
||||
// always close the console. (Maybe this would be better handled in wsdl or something?)
|
||||
if (keycode == SDLK_BACKQUOTE && (ev->ev.key.keysym.unicode == '\'' || ev->ev.key.keysym.unicode == '"'))
|
||||
keycode = ev->ev.key.keysym.unicode;
|
||||
#endif
|
||||
|
||||
// Somewhat hackish:
|
||||
// Create phantom 'unified-modifier' events when left- or right- modifier keys are pressed
|
||||
// Just send them to this handler; don't let the imaginary event codes leak back to real SDL.
|
||||
@ -245,11 +230,7 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev)
|
||||
unified[2] = (phantom.ev.type == SDL_KEYDOWN);
|
||||
HotkeyInputHandler(&phantom);
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
else if ((keycode == SDLK_LGUI) || (keycode == SDLK_RGUI))
|
||||
#else // SDL 1.2
|
||||
else if ((keycode == SDLK_LSUPER) || (keycode == SDLK_RSUPER) || (keycode == SDLK_LMETA) || (keycode == SDLK_RMETA))
|
||||
#endif
|
||||
{
|
||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SUPER;
|
||||
unified[3] = (phantom.ev.type == SDL_KEYDOWN);
|
||||
@ -278,11 +259,7 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev)
|
||||
// matching the conditions (i.e. the event with the highest number of auxiliary
|
||||
// keys, providing they're all down)
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
bool typeKeyDown = ( ev->ev.type == SDL_KEYDOWN ) || ( ev->ev.type == SDL_MOUSEBUTTONDOWN ) || (ev->ev.type == SDL_MOUSEWHEEL);
|
||||
#else
|
||||
bool typeKeyDown = ( ev->ev.type == SDL_KEYDOWN ) || ( ev->ev.type == SDL_MOUSEBUTTONDOWN );
|
||||
#endif
|
||||
|
||||
// -- KEYDOWN SECTION --
|
||||
|
||||
|
@ -51,7 +51,6 @@ void CJoystick::Initialise()
|
||||
|
||||
for (int i = 0; i < numJoysticks; ++i)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_Joystick* stick = SDL_JoystickOpen(i);
|
||||
if (!stick)
|
||||
{
|
||||
@ -59,13 +58,8 @@ void CJoystick::Initialise()
|
||||
continue;
|
||||
}
|
||||
const char* name = SDL_JoystickName(stick);
|
||||
#else // SDL 1.2
|
||||
const char* name = SDL_JoystickName(i);
|
||||
#endif
|
||||
LOGMESSAGE("Joystick %d: %s", i, name);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_JoystickClose(stick);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (numJoysticks)
|
||||
|
@ -112,7 +112,6 @@ static const SKeycodeMapping keycodeMapping[] =
|
||||
{ SDLK_z, "Z", 0 },
|
||||
{ SDLK_DELETE, "Delete", "Del" },
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
{ SDLK_KP_0, "Numpad 0", "Num0" },
|
||||
{ SDLK_KP_1, "Numpad 1", "Num1" },
|
||||
{ SDLK_KP_2, "Numpad 2", "Num2" },
|
||||
@ -123,115 +122,6 @@ static const SKeycodeMapping keycodeMapping[] =
|
||||
{ SDLK_KP_7, "Numpad 7", "Num7" },
|
||||
{ SDLK_KP_8, "Numpad 8", "Num8" },
|
||||
{ SDLK_KP_9, "Numpad 9", "Num9" },
|
||||
#else
|
||||
{ SDLK_WORLD_0, "World0", "W0" },
|
||||
{ SDLK_WORLD_1, "World1", "W1" },
|
||||
{ SDLK_WORLD_2, "World2", "W2" },
|
||||
{ SDLK_WORLD_3, "World3", "W3" },
|
||||
{ SDLK_WORLD_4, "World4", "W4" },
|
||||
{ SDLK_WORLD_5, "World5", "W5" },
|
||||
{ SDLK_WORLD_6, "World6", "W6" },
|
||||
{ SDLK_WORLD_7, "World7", "W7" },
|
||||
{ SDLK_WORLD_8, "World8", "W8" },
|
||||
{ SDLK_WORLD_9, "World9", "W9" },
|
||||
{ SDLK_WORLD_10, "World10", "W10" },
|
||||
{ SDLK_WORLD_11, "World11", "W11" },
|
||||
{ SDLK_WORLD_12, "World12", "W12" },
|
||||
{ SDLK_WORLD_13, "World13", "W13" },
|
||||
{ SDLK_WORLD_14, "World14", "W14" },
|
||||
{ SDLK_WORLD_15, "World15", "W15" },
|
||||
{ SDLK_WORLD_16, "World16", "W16" },
|
||||
{ SDLK_WORLD_17, "World17", "W17" },
|
||||
{ SDLK_WORLD_18, "World18", "W18" },
|
||||
{ SDLK_WORLD_19, "World19", "W19" },
|
||||
{ SDLK_WORLD_20, "World20", "W20" },
|
||||
{ SDLK_WORLD_21, "World21", "W21" },
|
||||
{ SDLK_WORLD_22, "World22", "W22" },
|
||||
{ SDLK_WORLD_23, "World23", "W23" },
|
||||
{ SDLK_WORLD_24, "World24", "W24" },
|
||||
{ SDLK_WORLD_25, "World25", "W25" },
|
||||
{ SDLK_WORLD_26, "World26", "W26" },
|
||||
{ SDLK_WORLD_27, "World27", "W27" },
|
||||
{ SDLK_WORLD_28, "World28", "W28" },
|
||||
{ SDLK_WORLD_29, "World29", "W29" },
|
||||
{ SDLK_WORLD_30, "World30", "W30" },
|
||||
{ SDLK_WORLD_31, "World31", "W31" },
|
||||
{ SDLK_WORLD_32, "World32", "W32" },
|
||||
{ SDLK_WORLD_33, "World33", "W33" },
|
||||
{ SDLK_WORLD_34, "World34", "W34" },
|
||||
{ SDLK_WORLD_35, "World35", "W35" },
|
||||
{ SDLK_WORLD_36, "World36", "W36" },
|
||||
{ SDLK_WORLD_37, "World37", "W37" },
|
||||
{ SDLK_WORLD_38, "World38", "W38" },
|
||||
{ SDLK_WORLD_39, "World39", "W39" },
|
||||
{ SDLK_WORLD_40, "World40", "W40" },
|
||||
{ SDLK_WORLD_41, "World41", "W41" },
|
||||
{ SDLK_WORLD_42, "World42", "W42" },
|
||||
{ SDLK_WORLD_43, "World43", "W43" },
|
||||
{ SDLK_WORLD_44, "World44", "W44" },
|
||||
{ SDLK_WORLD_45, "World45", "W45" },
|
||||
{ SDLK_WORLD_46, "World46", "W46" },
|
||||
{ SDLK_WORLD_47, "World47", "W47" },
|
||||
{ SDLK_WORLD_48, "World48", "W48" },
|
||||
{ SDLK_WORLD_49, "World49", "W49" },
|
||||
{ SDLK_WORLD_50, "World50", "W50" },
|
||||
{ SDLK_WORLD_51, "World51", "W51" },
|
||||
{ SDLK_WORLD_52, "World52", "W52" },
|
||||
{ SDLK_WORLD_53, "World53", "W53" },
|
||||
{ SDLK_WORLD_54, "World54", "W54" },
|
||||
{ SDLK_WORLD_55, "World55", "W55" },
|
||||
{ SDLK_WORLD_56, "World56", "W56" },
|
||||
{ SDLK_WORLD_57, "World57", "W57" },
|
||||
{ SDLK_WORLD_58, "World58", "W58" },
|
||||
{ SDLK_WORLD_59, "World59", "W59" },
|
||||
{ SDLK_WORLD_60, "World60", "W60" },
|
||||
{ SDLK_WORLD_61, "World61", "W61" },
|
||||
{ SDLK_WORLD_62, "World62", "W62" },
|
||||
{ SDLK_WORLD_63, "World63", "W63" },
|
||||
{ SDLK_WORLD_64, "World64", "W64" },
|
||||
{ SDLK_WORLD_65, "World65", "W65" },
|
||||
{ SDLK_WORLD_66, "World66", "W66" },
|
||||
{ SDLK_WORLD_67, "World67", "W67" },
|
||||
{ SDLK_WORLD_68, "World68", "W68" },
|
||||
{ SDLK_WORLD_69, "World69", "W69" },
|
||||
{ SDLK_WORLD_70, "World70", "W70" },
|
||||
{ SDLK_WORLD_71, "World71", "W71" },
|
||||
{ SDLK_WORLD_72, "World72", "W72" },
|
||||
{ SDLK_WORLD_73, "World73", "W73" },
|
||||
{ SDLK_WORLD_74, "World74", "W74" },
|
||||
{ SDLK_WORLD_75, "World75", "W75" },
|
||||
{ SDLK_WORLD_76, "World76", "W76" },
|
||||
{ SDLK_WORLD_77, "World77", "W77" },
|
||||
{ SDLK_WORLD_78, "World78", "W78" },
|
||||
{ SDLK_WORLD_79, "World79", "W79" },
|
||||
{ SDLK_WORLD_80, "World80", "W80" },
|
||||
{ SDLK_WORLD_81, "World81", "W81" },
|
||||
{ SDLK_WORLD_82, "World82", "W82" },
|
||||
{ SDLK_WORLD_83, "World83", "W83" },
|
||||
{ SDLK_WORLD_84, "World84", "W84" },
|
||||
{ SDLK_WORLD_85, "World85", "W85" },
|
||||
{ SDLK_WORLD_86, "World86", "W86" },
|
||||
{ SDLK_WORLD_87, "World87", "W87" },
|
||||
{ SDLK_WORLD_88, "World88", "W88" },
|
||||
{ SDLK_WORLD_89, "World89", "W89" },
|
||||
{ SDLK_WORLD_90, "World90", "W90" },
|
||||
{ SDLK_WORLD_91, "World91", "W91" },
|
||||
{ SDLK_WORLD_92, "World92", "W92" },
|
||||
{ SDLK_WORLD_93, "World93", "W93" },
|
||||
{ SDLK_WORLD_94, "World94", "W94" },
|
||||
{ SDLK_WORLD_95, "World95", "W95" },
|
||||
|
||||
{ SDLK_KP0, "Numpad 0", "Num0" },
|
||||
{ SDLK_KP1, "Numpad 1", "Num1" },
|
||||
{ SDLK_KP2, "Numpad 2", "Num2" },
|
||||
{ SDLK_KP3, "Numpad 3", "Num3" },
|
||||
{ SDLK_KP4, "Numpad 4", "Num4" },
|
||||
{ SDLK_KP5, "Numpad 5", "Num5" },
|
||||
{ SDLK_KP6, "Numpad 6", "Num6" },
|
||||
{ SDLK_KP7, "Numpad 7", "Num7" },
|
||||
{ SDLK_KP8, "Numpad 8", "Num8" },
|
||||
{ SDLK_KP9, "Numpad 9", "Num9" },
|
||||
#endif
|
||||
|
||||
{ SDLK_KP_PERIOD, "Numpad .", "NumPoint" },
|
||||
{ SDLK_KP_DIVIDE, "Numpad /", "NumDivide" },
|
||||
@ -267,19 +157,11 @@ static const SKeycodeMapping keycodeMapping[] =
|
||||
{ SDLK_F14, "F14", 0 },
|
||||
{ SDLK_F15, "F15", 0 },
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
{ SDLK_NUMLOCKCLEAR, "Num Lock", "NumLock" },
|
||||
#else
|
||||
{ SDLK_NUMLOCK, "Num Lock", "NumLock" },
|
||||
#endif
|
||||
|
||||
{ SDLK_CAPSLOCK, "Caps Lock", "CapsLock" },
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
{ SDLK_SCROLLLOCK, "Scroll Lock", "ScrlLock" },
|
||||
#else
|
||||
{ SDLK_SCROLLOCK, "Scroll Lock", "ScrlLock" },
|
||||
#endif
|
||||
|
||||
{ SDLK_RSHIFT, "Right Shift", "RightShift" },
|
||||
{ SDLK_LSHIFT, "Left Shift", "LeftShift" },
|
||||
@ -288,31 +170,18 @@ static const SKeycodeMapping keycodeMapping[] =
|
||||
{ SDLK_RALT, "Right Alt", "RightAlt" },
|
||||
{ SDLK_LALT, "Left Alt", "LeftAlt" },
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
{ SDLK_LGUI, "Left Super", "LeftWin" }, /* "Windows" keys */
|
||||
{ SDLK_RGUI, "Right Super", "RightWin" },
|
||||
#else
|
||||
{ SDLK_LSUPER, "Left Super", "LeftWin" }, /* "Windows" keys */
|
||||
{ SDLK_RSUPER, "Right Super", "RightWin" },
|
||||
#endif
|
||||
|
||||
{ SDLK_MODE, "Alt Gr", "AltGr" },
|
||||
|
||||
{ SDLK_HELP, "Help", 0 }, // ?
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
{ SDLK_PRINTSCREEN, "Print Screen", "PrtSc" },
|
||||
#else
|
||||
{ SDLK_PRINT, "Print Screen", "PrtSc" },
|
||||
#endif
|
||||
|
||||
{ SDLK_SYSREQ, "SysRq", 0 },
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
{ SDLK_STOP, "Break", 0 },
|
||||
#else
|
||||
{ SDLK_BREAK, "Break", 0 },
|
||||
#endif
|
||||
|
||||
{ SDLK_MENU, "Menu", 0 }, // ?
|
||||
{ SDLK_POWER, "Power", 0 }, // ?
|
||||
|
@ -28,11 +28,7 @@ extern CStr8 FindKeyName(int keycode);
|
||||
extern int FindKeyCode(const CStr8& keyname);
|
||||
|
||||
// Pick a code which is greater than any keycodes used by SDL itself
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
# define CUSTOM_SDL_KEYCODE SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES)
|
||||
#else
|
||||
# define CUSTOM_SDL_KEYCODE SDLK_LAST
|
||||
#endif
|
||||
|
||||
enum {
|
||||
// Start sequential IDs in the right place
|
||||
@ -51,26 +47,11 @@ enum {
|
||||
MOUSE_LEFT = MOUSE_BASE + SDL_BUTTON_LEFT,
|
||||
MOUSE_MIDDLE = MOUSE_BASE + SDL_BUTTON_MIDDLE,
|
||||
MOUSE_RIGHT = MOUSE_BASE + SDL_BUTTON_RIGHT,
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
// SDL2 doesn't count wheels as buttons, so just give them the previous sequential IDs
|
||||
MOUSE_WHEELUP = MOUSE_BASE + 4,
|
||||
MOUSE_WHEELDOWN = MOUSE_BASE + 5,
|
||||
MOUSE_X1 = MOUSE_BASE + SDL_BUTTON_X1 + 2,
|
||||
MOUSE_X2 = MOUSE_BASE + SDL_BUTTON_X2 + 2,
|
||||
#elif SDL_VERSION_ATLEAST(1, 2, 13)
|
||||
// SDL 1.2 defines wheel buttons before X1/X2 buttons
|
||||
MOUSE_WHEELUP = MOUSE_BASE + SDL_BUTTON_WHEELUP,
|
||||
MOUSE_WHEELDOWN = MOUSE_BASE + SDL_BUTTON_WHEELDOWN,
|
||||
MOUSE_X1 = MOUSE_BASE + SDL_BUTTON_X1,
|
||||
MOUSE_X2 = MOUSE_BASE + SDL_BUTTON_X2,
|
||||
#else
|
||||
// SDL <1.2.13 doesn't support X1/X2 buttons, so define them manually
|
||||
MOUSE_WHEELUP = MOUSE_BASE + SDL_BUTTON_WHEELUP,
|
||||
MOUSE_WHEELDOWN = MOUSE_BASE + SDL_BUTTON_WHEELDOWN,
|
||||
MOUSE_X1 = MOUSE_BASE + SDL_BUTTON_WHEELDOWN + 1,
|
||||
MOUSE_X2 = MOUSE_BASE + SDL_BUTTON_WHEELDOWN + 2,
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // #ifndef INCLUDED_KEYNAME
|
||||
|
@ -261,7 +261,6 @@ InReaction CTouchInput::HandleEvent(const SDL_Event_* ev)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
switch(ev->ev.type)
|
||||
{
|
||||
case SDL_FINGERDOWN:
|
||||
@ -285,7 +284,6 @@ InReaction CTouchInput::HandleEvent(const SDL_Event_* ev)
|
||||
return IN_HANDLED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return IN_PASS;
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ void CVideoMode::ReadConfig()
|
||||
|
||||
bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
Uint32 flags = 0;
|
||||
if (fullscreen)
|
||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
@ -154,47 +153,6 @@ bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
||||
else
|
||||
SDL_SetWindowGrab(m_Window, SDL_FALSE);
|
||||
|
||||
#else // SDL 1.2:
|
||||
|
||||
Uint32 flags = SDL_OPENGL;
|
||||
if (fullscreen)
|
||||
flags |= SDL_FULLSCREEN;
|
||||
else
|
||||
flags |= SDL_RESIZABLE;
|
||||
|
||||
SDL_Surface* screen = SDL_SetVideoMode(w, h, bpp, flags);
|
||||
|
||||
if (!screen)
|
||||
{
|
||||
// If fullscreen fails, try windowed mode
|
||||
if (fullscreen)
|
||||
{
|
||||
LOGWARNING("Failed to set the video mode to fullscreen for the chosen resolution "
|
||||
"%dx%d:%d (\"%hs\"), falling back to windowed mode",
|
||||
w, h, bpp, SDL_GetError());
|
||||
// Using default size for the window for now, as the attempted setting
|
||||
// could be as large, or larger than the screen size.
|
||||
return SetVideoMode(DEFAULT_WINDOW_W, DEFAULT_WINDOW_H, bpp, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGERROR("SetVideoMode failed: %dx%d:%d %d (\"%s\")",
|
||||
w, h, bpp, fullscreen ? 1 : 0, SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Grab the current video settings
|
||||
m_CurrentW = screen->w;
|
||||
m_CurrentH = screen->h;
|
||||
m_CurrentBPP = screen->format->BitsPerPixel;
|
||||
|
||||
if (fullscreen)
|
||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||
else
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
#endif
|
||||
|
||||
m_IsFullscreen = fullscreen;
|
||||
|
||||
g_xres = m_CurrentW;
|
||||
@ -249,11 +207,8 @@ bool CVideoMode::InitSDL()
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, g_VSync ? 1 : 0);
|
||||
#endif
|
||||
|
||||
#if CONFIG2_GLES && SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
#if CONFIG2_GLES
|
||||
// Require GLES 2.0
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
@ -270,9 +225,7 @@ bool CVideoMode::InitSDL()
|
||||
return false;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_GL_SetSwapInterval(g_VSync ? 1 : 0);
|
||||
#endif
|
||||
|
||||
// Work around a bug in the proprietary Linux ATI driver (at least versions 8.16.20 and 8.14.13).
|
||||
// The driver appears to register its own atexit hook on context creation.
|
||||
@ -287,26 +240,11 @@ bool CVideoMode::InitSDL()
|
||||
ogl_Init(); // required after each mode change
|
||||
// (TODO: does that mean we need to call this when toggling fullscreen later?)
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
#if !OS_ANDROID
|
||||
u16 ramp[256];
|
||||
SDL_CalculateGammaRamp(g_Gamma, ramp);
|
||||
if (SDL_SetWindowGammaRamp(m_Window, ramp, ramp, ramp) < 0)
|
||||
LOGWARNING("SDL_SetWindowGammaRamp failed");
|
||||
#endif
|
||||
#else
|
||||
# if OS_MACOSX
|
||||
// Workaround for crash on Mavericks, see http://trac.wildfiregames.com/ticket/2272
|
||||
int major, minor, bugfix;
|
||||
GetSystemVersion(major, minor, bugfix);
|
||||
if (minor < 9)
|
||||
{
|
||||
# endif
|
||||
if (SDL_SetGamma(g_Gamma, g_Gamma, g_Gamma) < 0)
|
||||
LOGWARNING("SDL_SetGamma failed");
|
||||
# if OS_MACOSX
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
m_IsInitialised = true;
|
||||
@ -339,13 +277,11 @@ void CVideoMode::Shutdown()
|
||||
|
||||
m_IsFullscreen = false;
|
||||
m_IsInitialised = false;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
if (m_Window)
|
||||
{
|
||||
SDL_DestroyWindow(m_Window);
|
||||
m_Window = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CVideoMode::EnableS3TC()
|
||||
|
@ -20,11 +20,7 @@
|
||||
#include "KeyMap.h"
|
||||
|
||||
#include "SDL_version.h"
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
# include "SDL_keycode.h"
|
||||
#else // SDL 1.2
|
||||
# include "SDL_keysym.h"
|
||||
#endif
|
||||
#include "SDL_keycode.h"
|
||||
|
||||
int GetSDLKeyFromWxKeyCode(int wxkey)
|
||||
{
|
||||
@ -37,7 +33,6 @@ int GetSDLKeyFromWxKeyCode(int wxkey)
|
||||
|
||||
switch (wxkey)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case WXK_NUMPAD0: return SDLK_KP_0;
|
||||
case WXK_NUMPAD1: return SDLK_KP_1;
|
||||
case WXK_NUMPAD2: return SDLK_KP_2;
|
||||
@ -48,18 +43,6 @@ int GetSDLKeyFromWxKeyCode(int wxkey)
|
||||
case WXK_NUMPAD7: return SDLK_KP_7;
|
||||
case WXK_NUMPAD8: return SDLK_KP_8;
|
||||
case WXK_NUMPAD9: return SDLK_KP_9;
|
||||
#else // SDL 1.2
|
||||
case WXK_NUMPAD0: return SDLK_KP0;
|
||||
case WXK_NUMPAD1: return SDLK_KP1;
|
||||
case WXK_NUMPAD2: return SDLK_KP2;
|
||||
case WXK_NUMPAD3: return SDLK_KP3;
|
||||
case WXK_NUMPAD4: return SDLK_KP4;
|
||||
case WXK_NUMPAD5: return SDLK_KP5;
|
||||
case WXK_NUMPAD6: return SDLK_KP6;
|
||||
case WXK_NUMPAD7: return SDLK_KP7;
|
||||
case WXK_NUMPAD8: return SDLK_KP8;
|
||||
case WXK_NUMPAD9: return SDLK_KP9;
|
||||
#endif
|
||||
case WXK_NUMPAD_DECIMAL: return SDLK_KP_PERIOD;
|
||||
case WXK_NUMPAD_DIVIDE: return SDLK_KP_DIVIDE;
|
||||
case WXK_NUMPAD_MULTIPLY: return SDLK_KP_MULTIPLY;
|
||||
@ -94,13 +77,8 @@ int GetSDLKeyFromWxKeyCode(int wxkey)
|
||||
case WXK_F14: return SDLK_F14;
|
||||
case WXK_F15: return SDLK_F15;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case WXK_NUMLOCK: return SDLK_NUMLOCKCLEAR;
|
||||
case WXK_SCROLL: return SDLK_SCROLLLOCK;
|
||||
#else // SDL 1.2
|
||||
case WXK_NUMLOCK: return SDLK_NUMLOCK;
|
||||
case WXK_SCROLL: return SDLK_SCROLLOCK;
|
||||
#endif
|
||||
// case WXK_: return SDLK_CAPSLOCK;
|
||||
case WXK_SHIFT: return SDLK_RSHIFT;
|
||||
// case WXK_: return SDLK_LSHIFT;
|
||||
@ -116,11 +94,7 @@ int GetSDLKeyFromWxKeyCode(int wxkey)
|
||||
// case WXK_: return SDLK_COMPOSE;
|
||||
|
||||
case WXK_HELP: return SDLK_HELP;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
case WXK_PRINT: return SDLK_PRINTSCREEN;
|
||||
#else // SDL 1.2
|
||||
case WXK_PRINT: return SDLK_PRINT;
|
||||
#endif
|
||||
// case WXK_: return SDLK_SYSREQ;
|
||||
// case WXK_: return SDLK_BREAK;
|
||||
case WXK_MENU: return SDLK_MENU;
|
||||
|
@ -196,12 +196,7 @@ MESSAGEHANDLER(GuiKeyEvent)
|
||||
{
|
||||
SDL_Event_ ev = { { 0 } };
|
||||
ev.ev.type = msg->pressed ? SDL_KEYDOWN : SDL_KEYUP;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
ev.ev.key.keysym.sym = (SDL_Keycode)(int)msg->sdlkey;
|
||||
#else
|
||||
ev.ev.key.keysym.sym = (SDLKey)(int)msg->sdlkey;
|
||||
ev.ev.key.keysym.unicode = msg->unichar;
|
||||
#endif
|
||||
in_dispatch_event(&ev);
|
||||
}
|
||||
|
||||
@ -213,12 +208,7 @@ MESSAGEHANDLER(GuiCharEvent)
|
||||
|
||||
SDL_Event_ ev = { { 0 } };
|
||||
ev.ev.type = SDL_KEYDOWN;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
ev.ev.key.keysym.sym = (SDL_Keycode)(int)msg->sdlkey;
|
||||
#else
|
||||
ev.ev.key.keysym.sym = (SDLKey)(int)msg->sdlkey;
|
||||
ev.ev.key.keysym.unicode = msg->unichar;
|
||||
#endif
|
||||
in_dispatch_event(&ev);
|
||||
|
||||
ev.ev.type = SDL_KEYUP;
|
||||
|
Loading…
Reference in New Issue
Block a user