Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
I think this also fixes the bug relating to non-latin characters in filenames, since UNICODE wasn't defined in SDL_rwops.c --HG-- rename : src/SDL_android.cpp => src/core/android/SDL_android.cpp rename : src/SDL_android.h => src/core/android/SDL_android.h
This commit is contained in:
parent
1775cf40fd
commit
b4497865bd
37 changed files with 274 additions and 273 deletions
23
Android.mk
23
Android.mk
|
@ -12,30 +12,31 @@ LOCAL_MODULE := SDL
|
|||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_SRC_FILES := src/SDL_android.cpp \
|
||||
LOCAL_SRC_FILES := \
|
||||
$(subst $(LOCAL_PATH)/,, \
|
||||
$(wildcard $(LOCAL_PATH)/src/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
|
||||
$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
|
||||
$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
|
||||
$(wildcard $(LOCAL_PATH)/src/core/android/*.cpp) \
|
||||
$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/events/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/file/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c)) \
|
||||
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/video/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c))
|
||||
$(wildcard $(LOCAL_PATH)/src/video/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/video/android/*.c)
|
||||
|
||||
LOCAL_LDLIBS := -ldl -lGLESv1_CM -llog
|
||||
|
||||
|
|
|
@ -1150,6 +1150,22 @@
|
|||
RelativePath="..\..\src\audio\SDL_wave.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\events\SDL_windowevents.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\events\SDL_windowevents_c.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\core\windows\SDL_windows.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\core\windows\SDL_windows.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
|
||||
>
|
||||
|
@ -1230,14 +1246,6 @@
|
|||
RelativePath="..\..\src\video\windows\SDL_windowswindow.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\events\SDL_windowevents.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\events\SDL_windowevents_c.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\video\SDL_yuv_mmx.c"
|
||||
>
|
||||
|
|
|
@ -272,6 +272,7 @@ echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
|
|||
<ClInclude Include="..\..\include\SDL_types.h" />
|
||||
<ClInclude Include="..\..\include\SDL_version.h" />
|
||||
<ClInclude Include="..\..\include\SDL_video.h" />
|
||||
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
|
||||
<ClInclude Include="..\..\src\events\blank_cursor.h" />
|
||||
<ClInclude Include="..\..\src\events\default_cursor.h" />
|
||||
<ClInclude Include="..\..\src\audio\windx5\directx.h" />
|
||||
|
@ -345,6 +346,7 @@ echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
|
|||
<ClInclude Include="..\..\src\video\windows\wmmsg.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
|
||||
<ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
|
||||
<ClCompile Include="..\..\src\events\SDL_gesture.c" />
|
||||
<ClCompile Include="..\..\src\events\SDL_touch.c" />
|
||||
|
@ -460,4 +462,4 @@ echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -1053,6 +1053,10 @@
|
|||
RelativePath="..\..\src\events\SDL_windowevents.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\core\windows\SDL_windows.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
|
||||
>
|
||||
|
@ -1358,6 +1362,10 @@
|
|||
RelativePath="..\..\src\events\SDL_windowevents_c.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\core\windows\SDL_windows.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\video\windows\SDL_windowsclipboard.h"
|
||||
>
|
||||
|
|
|
@ -329,8 +329,7 @@ SDL_GetPlatform()
|
|||
|
||||
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
|
||||
/* Need to include DllMain() on Watcom C for some reason.. */
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "core/windows/SDL_windows.h"
|
||||
|
||||
BOOL APIENTRY
|
||||
_DllMainCRTStartup(HANDLE hModule,
|
||||
|
|
|
@ -27,18 +27,11 @@
|
|||
#include "video/SDL_sysvideo.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "core/windows/SDL_windows.h"
|
||||
|
||||
#ifndef WS_OVERLAPPEDWINDOW
|
||||
#define WS_OVERLAPPEDWINDOW 0
|
||||
#endif
|
||||
|
||||
#ifdef UNICODE
|
||||
#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
|
||||
#else
|
||||
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
|
||||
#endif
|
||||
#else /* fprintf, _exit(), etc. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -25,14 +25,7 @@
|
|||
#include "SDL_timer.h"
|
||||
|
||||
/* Don't do the check for Visual Studio 2005, it's safe here */
|
||||
#if defined(_MSC_VER)
|
||||
#ifdef _WIN32_WCE
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
|
||||
/* This function is where all the magic happens... */
|
||||
SDL_bool
|
||||
|
@ -40,7 +33,7 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||
{
|
||||
#if defined(_MSC_VER)
|
||||
SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
|
||||
return (_InterlockedExchange((long*)lock, 1) == 0);
|
||||
return (InterlockedExchange((long*)lock, 1) == 0);
|
||||
|
||||
#elif defined(__MACOSX__)
|
||||
return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "../SDL_audio_c.h"
|
||||
#include "SDL_androidaudio.h"
|
||||
|
||||
#include "../../SDL_android.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
/* Allow access to a raw mixing buffer */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <mmsystem.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
|
@ -67,21 +66,14 @@ SetMMerror(char *function, MMRESULT code)
|
|||
{
|
||||
size_t len;
|
||||
char errbuf[MAXERRORLENGTH];
|
||||
#ifdef _WIN32_WCE
|
||||
wchar_t werrbuf[MAXERRORLENGTH];
|
||||
#endif
|
||||
|
||||
SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
|
||||
len = SDL_strlen(errbuf);
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
/* UNICODE version */
|
||||
waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len);
|
||||
WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len,
|
||||
MAXERRORLENGTH - len, NULL, NULL);
|
||||
#else
|
||||
waveOutGetErrorText(code, errbuf + len, (UINT) (MAXERRORLENGTH - len));
|
||||
#endif
|
||||
|
||||
SDL_SetError("%s", errbuf);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
/* Allow access to a raw mixing buffer */
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "SDL_dx5audio.h"
|
||||
|
@ -38,19 +39,19 @@
|
|||
#endif
|
||||
|
||||
/* DirectX function pointers for audio */
|
||||
static HINSTANCE DSoundDLL = NULL;
|
||||
static void* DSoundDLL = NULL;
|
||||
static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) =
|
||||
NULL;
|
||||
|
||||
static void
|
||||
DSOUND_Unload(void)
|
||||
{
|
||||
if (DSoundDLL != NULL) {
|
||||
FreeLibrary(DSoundDLL);
|
||||
}
|
||||
|
||||
DSoundCreate = NULL;
|
||||
DSoundDLL = NULL;
|
||||
|
||||
if (DSoundDLL != NULL) {
|
||||
SDL_UnloadObject(DSoundDLL);
|
||||
DSoundDLL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,17 +62,16 @@ DSOUND_Load(void)
|
|||
|
||||
DSOUND_Unload();
|
||||
|
||||
DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
|
||||
DSoundDLL = SDL_LoadObject("DSOUND.DLL");
|
||||
if (DSoundDLL == NULL) {
|
||||
SDL_SetError("DirectSound: failed to load DSOUND.DLL");
|
||||
} else {
|
||||
/* Now make sure we have DirectX 5 or better... */
|
||||
/* (DirectSoundCaptureCreate was added in DX5) */
|
||||
if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate"))) {
|
||||
if (!SDL_LoadFunction(DSoundDLL, "DirectSoundCaptureCreate")) {
|
||||
SDL_SetError("DirectSound: System doesn't appear to have DX5.");
|
||||
} else {
|
||||
DSoundCreate = (void *) GetProcAddress(DSoundDLL,
|
||||
TEXT("DirectSoundCreate"));
|
||||
DSoundCreate = SDL_LoadFunction(DSoundDLL, "DirectSoundCreate");
|
||||
}
|
||||
|
||||
if (!DSoundCreate) {
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
/* Include all of the DirectX 5.0 headers and adds any necessary tweaks */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <mmsystem.h>
|
||||
#ifndef WIN32
|
||||
#define WIN32
|
||||
|
|
41
src/core/windows/SDL_windows.c
Normal file
41
src/core/windows/SDL_windows.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
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_error.h"
|
||||
#include "SDL_windows.h"
|
||||
|
||||
|
||||
/* Sets an error message based on GetLastError() */
|
||||
void
|
||||
WIN_SetError(const char *prefix)
|
||||
{
|
||||
TCHAR buffer[1024];
|
||||
char *message;
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
|
||||
buffer, SDL_arraysize(buffer), NULL);
|
||||
message = WIN_StringToUTF8(buffer);
|
||||
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
|
||||
SDL_free(message);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
53
src/core/windows/SDL_windows.h
Normal file
53
src/core/windows/SDL_windows.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
/* This is an include file for windows.h with the SDL build settings */
|
||||
|
||||
#ifndef _INCLUDED_WINDOWS_H
|
||||
#define _INCLUDED_WINDOWS_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define STRICT
|
||||
#ifndef UNICODE
|
||||
#define UNICODE 1
|
||||
#endif
|
||||
#undef WINVER
|
||||
#define WINVER 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
/* Routines to convert from UTF8 to native Windows text */
|
||||
#if UNICODE
|
||||
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
|
||||
#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)(S), SDL_strlen(S)+1)
|
||||
#else
|
||||
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1))
|
||||
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
|
||||
#endif
|
||||
|
||||
/* Sets an error message based on GetLastError() */
|
||||
extern void WIN_SetError(const char *prefix);
|
||||
|
||||
#endif /* _INCLUDED_WINDOWS_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -39,8 +39,7 @@
|
|||
#include <setjmp.h>
|
||||
#endif
|
||||
#ifdef __WIN32__
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
#define CPU_HAS_RDTSC 0x00000001
|
||||
|
|
|
@ -44,8 +44,7 @@
|
|||
faster, and all stdio functions anyway are embedded in coredll.dll -
|
||||
the main wince dll*/
|
||||
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
|
||||
#ifndef INVALID_SET_FILE_POINTER
|
||||
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
|
||||
|
@ -98,34 +97,28 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
}
|
||||
#ifdef _WIN32_WCE
|
||||
{
|
||||
size_t size = SDL_strlen(filename) + 1;
|
||||
wchar_t *filenameW = SDL_stack_alloc(wchar_t, size);
|
||||
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) ==
|
||||
0) {
|
||||
SDL_stack_free(filenameW);
|
||||
SDL_free(context->hidden.windowsio.buffer.data);
|
||||
context->hidden.windowsio.buffer.data = NULL;
|
||||
SDL_SetError("Unable to convert filename to Unicode");
|
||||
return -1;
|
||||
}
|
||||
h = CreateFile(filenameW, (w_right | r_right),
|
||||
LPTSTR tstr = WIN_UTF8ToString(filename);
|
||||
h = CreateFile(tstr, (w_right | r_right),
|
||||
(w_right) ? 0 : FILE_SHARE_READ, NULL,
|
||||
(must_exist | truncate | a_mode),
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
SDL_stack_free(filenameW);
|
||||
SDL_free(tstr);
|
||||
}
|
||||
#else
|
||||
/* Do not open a dialog box if failure */
|
||||
old_error_mode =
|
||||
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
||||
|
||||
h = CreateFile(filename, (w_right | r_right),
|
||||
(w_right) ? 0 : FILE_SHARE_READ, NULL,
|
||||
(must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
{
|
||||
LPTSTR tstr = WIN_UTF8ToString(filename);
|
||||
h = CreateFile(tstr, (w_right | r_right),
|
||||
(w_right) ? 0 : FILE_SHARE_READ, NULL,
|
||||
(must_exist | truncate | a_mode),
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
SDL_free(tstr);
|
||||
}
|
||||
|
||||
/* restore old behaviour */
|
||||
/* restore old behavior */
|
||||
SetErrorMode(old_error_mode);
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
static struct
|
||||
{
|
||||
DIDEVICEINSTANCE instance;
|
||||
char *name;
|
||||
SDL_Haptic *haptic;
|
||||
DIDEVCAPS capabilities;
|
||||
} SDL_hapticlist[MAX_HAPTICS];
|
||||
|
@ -220,6 +221,9 @@ EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
|||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
/* Copy the name */
|
||||
SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName);
|
||||
|
||||
/* Close up device and count it. */
|
||||
IDirectInputDevice_Release(device);
|
||||
SDL_numhaptics++;
|
||||
|
@ -238,7 +242,7 @@ EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
|||
const char *
|
||||
SDL_SYS_HapticName(int index)
|
||||
{
|
||||
return SDL_hapticlist[index].instance.tszProductName;
|
||||
return SDL_hapticlist[index].name;
|
||||
}
|
||||
|
||||
|
||||
|
@ -630,6 +634,15 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
|
|||
void
|
||||
SDL_SYS_HapticQuit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) {
|
||||
if (SDL_hapticlist[i].name) {
|
||||
SDL_free(SDL_hapticlist[i].name);
|
||||
SDL_hapticlist[i].name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
IDirectInput_Release(dinput);
|
||||
dinput = NULL;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "SDL_joystick.h"
|
||||
#include "../SDL_sysjoystick.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
#include "../../SDL_android.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
static const char *accelerometerName = "Android accelerometer";
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
|
|||
LPDIRECTINPUT * ppDI,
|
||||
LPUNKNOWN punkOuter);
|
||||
static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS]; /* array to hold joystick ID values */
|
||||
static char *SYS_JoystickNames[MAX_JOYSTICKS];
|
||||
static int SYS_NumJoysticks;
|
||||
static HINSTANCE DInputDLL = NULL;
|
||||
|
||||
|
@ -326,6 +327,7 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
|||
{
|
||||
SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance,
|
||||
sizeof(DIDEVICEINSTANCE));
|
||||
SYS_JoystickNames[SYS_NumJoysticks] = WIN_StringToUTF8(pdidInstance->tszProductName);
|
||||
SYS_NumJoysticks++;
|
||||
|
||||
if (SYS_NumJoysticks >= MAX_JOYSTICKS)
|
||||
|
@ -338,8 +340,7 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
|||
const char *
|
||||
SDL_SYS_JoystickName(int index)
|
||||
{
|
||||
/***-> test for invalid index ? */
|
||||
return (SYS_Joystick[index].tszProductName);
|
||||
return SYS_JoystickNames[index];
|
||||
}
|
||||
|
||||
/* Function to open a joystick for use.
|
||||
|
@ -793,6 +794,15 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
|||
void
|
||||
SDL_SYS_JoystickQuit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SDL_arraysize(SYS_JoystickNames); ++i) {
|
||||
if (SYS_JoystickNames[i]) {
|
||||
SDL_free(SYS_JoystickNames[i]);
|
||||
SYS_JoystickNames[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
IDirectInput_Release(dinput);
|
||||
dinput = NULL;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
* with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
|
||||
* let it return 0 events. */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0700 /* Need version 7 for force feedback. */
|
||||
#include <dinput.h>
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
|
||||
/* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <mmsystem.h>
|
||||
#include <regstr.h>
|
||||
|
||||
|
|
|
@ -26,110 +26,45 @@
|
|||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* System dependent library loading routines */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
|
||||
void *
|
||||
SDL_LoadObject(const char *sofile)
|
||||
{
|
||||
void *handle = NULL;
|
||||
const char *loaderror = "Unknown error";
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
char errbuf[512];
|
||||
|
||||
wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
|
||||
wchar_t *sofile_t = SDL_malloc((MAX_PATH + 1) * sizeof(wchar_t));
|
||||
|
||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t,
|
||||
MAX_PATH);
|
||||
handle = (void *) LoadLibrary(sofile_t);
|
||||
LPTSTR tstr = WIN_UTF8ToString(sofile);
|
||||
void *handle = (void *) LoadLibrary(tstr);
|
||||
SDL_free(tstr);
|
||||
|
||||
/* Generate an error message if all loads failed */
|
||||
if (handle == NULL) {
|
||||
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM),
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
errbuf_t, SDL_arraysize(errbuf), NULL);
|
||||
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
|
||||
loaderror = errbuf;
|
||||
char errbuf[512];
|
||||
SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
|
||||
SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf));
|
||||
WIN_SetError(errbuf);
|
||||
}
|
||||
|
||||
SDL_free(sofile_t);
|
||||
SDL_free(errbuf_t);
|
||||
|
||||
#else /*if defined(__WIN32__) */
|
||||
char errbuf[512];
|
||||
|
||||
handle = (void *) LoadLibrary(sofile);
|
||||
|
||||
/* Generate an error message if all loads failed */
|
||||
if (handle == NULL) {
|
||||
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM),
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
errbuf, SDL_arraysize(errbuf), NULL);
|
||||
loaderror = errbuf;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (handle == NULL) {
|
||||
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
|
||||
}
|
||||
return (handle);
|
||||
return handle;
|
||||
}
|
||||
|
||||
void *
|
||||
SDL_LoadFunction(void *handle, const char *name)
|
||||
{
|
||||
void *symbol = NULL;
|
||||
const char *loaderror = "Unknown error";
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
char errbuf[512];
|
||||
int length = SDL_strlen(name);
|
||||
|
||||
wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
|
||||
wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
|
||||
|
||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length + 1);
|
||||
|
||||
symbol = (void *) GetProcAddress((HMODULE) handle, name_t);
|
||||
if (symbol == NULL) {
|
||||
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM),
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
errbuf_t, SDL_arraysize(errbuf), NULL);
|
||||
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
|
||||
loaderror = errbuf;
|
||||
}
|
||||
|
||||
SDL_free(name_t);
|
||||
SDL_free(errbuf_t);
|
||||
|
||||
#else /*if defined(WIN32) */
|
||||
char errbuf[512];
|
||||
|
||||
symbol = (void *) GetProcAddress((HMODULE) handle, name);
|
||||
if (symbol == NULL) {
|
||||
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM),
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
errbuf, SDL_arraysize(errbuf), NULL);
|
||||
loaderror = errbuf;
|
||||
}
|
||||
#ifdef _WIN32_WCE
|
||||
LPTSTR tstr = WIN_UTF8ToString(name);
|
||||
void *symbol = (void *) GetProcAddress((HMODULE) handle, tstr);
|
||||
SDL_free(tstr);
|
||||
#else
|
||||
void *symbol = (void *) GetProcAddress((HMODULE) handle, name);
|
||||
#endif
|
||||
|
||||
if (symbol == NULL) {
|
||||
SDL_SetError("Failed loading %s: %s", name, loaderror);
|
||||
char errbuf[512];
|
||||
SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
|
||||
SDL_strlcat(errbuf, name, SDL_arraysize(errbuf));
|
||||
WIN_SetError(errbuf);
|
||||
}
|
||||
return (symbol);
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
#ifndef SDL_POWER_DISABLED
|
||||
#ifdef SDL_POWER_WINDOWS
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_power.h"
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
|
||||
#if defined(__WIN32__) && !defined(_WIN32_WCE)
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
|
||||
/* Note this isn't thread-safe! */
|
||||
|
||||
|
@ -41,12 +40,12 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
|||
{
|
||||
if (!overwrite) {
|
||||
char ch = 0;
|
||||
const size_t len = GetEnvironmentVariable(name, &ch, sizeof (ch));
|
||||
const size_t len = GetEnvironmentVariableA(name, &ch, sizeof (ch));
|
||||
if (len > 0) {
|
||||
return 0; /* asked not to overwrite existing value. */
|
||||
}
|
||||
}
|
||||
if (!SetEnvironmentVariable(name, *value ? value : NULL)) {
|
||||
if (!SetEnvironmentVariableA(name, *value ? value : NULL)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -59,7 +58,7 @@ SDL_getenv(const char *name)
|
|||
size_t bufferlen;
|
||||
|
||||
bufferlen =
|
||||
GetEnvironmentVariable(name, SDL_envmem, (DWORD) SDL_envmemlen);
|
||||
GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
|
||||
if (bufferlen == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -70,7 +69,7 @@ SDL_getenv(const char *name)
|
|||
}
|
||||
SDL_envmem = newmem;
|
||||
SDL_envmemlen = bufferlen;
|
||||
GetEnvironmentVariable(name, SDL_envmem, (DWORD) SDL_envmemlen);
|
||||
GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
|
||||
}
|
||||
return SDL_envmem;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
/* Mutex functions using the Win32 API */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_mutex.h"
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
/* Semaphore functions using the Win32 API */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_thread.h"
|
||||
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
typedef HANDLE SYS_ThreadHandle;
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
and it is not clear how to handle a mixture of WCE semaphores and normal
|
||||
events and mutexes. */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "win_ce_semaphore.h"
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
#ifdef SDL_TIMER_WINCE
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <mmsystem.h>
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
#ifdef SDL_TIMER_WINDOWS
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <mmsystem.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "SDL_video.h"
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
#include "../../SDL_android.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef int (*PFNGXResume)();
|
|||
typedef struct
|
||||
{
|
||||
// gx.dll
|
||||
HMODULE hGapiLib;
|
||||
void* hGapiLib;
|
||||
PFNGXOpenDisplay GXOpenDisplay;
|
||||
PFNGXCloseDisplay GXCloseDisplay;
|
||||
PFNGXBeginDraw GXBeginDraw;
|
||||
|
@ -251,7 +251,7 @@ SDL_RenderDriver RAW_RenderDriver = {
|
|||
|
||||
int WINCE_Available(void)
|
||||
{
|
||||
HMODULE render_gapi;
|
||||
void* render_gapi;
|
||||
const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
|
||||
|
||||
// raw check
|
||||
|
@ -267,10 +267,10 @@ int WINCE_Available(void)
|
|||
if(preferably && 0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0 != render_raw;
|
||||
|
||||
// gapi check
|
||||
render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll"));
|
||||
render_gapi = SDL_LoadObject("\\Windows\\gx.dll");
|
||||
if(0 == render_gapi)
|
||||
render_gapi = LoadLibrary(TEXT("gx.dll"));
|
||||
FreeLibrary(render_gapi);
|
||||
render_gapi = SDL_LoadObject("gx.dll");
|
||||
SDL_UnloadObject(render_gapi);
|
||||
|
||||
if(preferably && 0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0 != render_gapi;
|
||||
|
||||
|
@ -280,7 +280,7 @@ int WINCE_Available(void)
|
|||
void WINCE_AddRenderDriver(_THIS)
|
||||
{
|
||||
HDC hdc;
|
||||
HMODULE render_gapi;
|
||||
void* render_gapi;
|
||||
int render_raw, ii;
|
||||
const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
|
||||
|
||||
|
@ -295,12 +295,12 @@ void WINCE_AddRenderDriver(_THIS)
|
|||
render_raw = 1;
|
||||
|
||||
// gapi check
|
||||
render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll"));
|
||||
render_gapi = SDL_LoadObject("\\Windows\\gx.dll");
|
||||
if(0 == render_gapi)
|
||||
render_gapi = LoadLibrary(TEXT("gx.dll"));
|
||||
render_gapi = SDL_LoadObject("gx.dll");
|
||||
|
||||
if(render_gapi)
|
||||
FreeLibrary(render_gapi);
|
||||
SDL_UnloadObject(render_gapi);
|
||||
|
||||
for(ii = 0; ii < _this->num_displays; ++ii)
|
||||
{
|
||||
|
@ -885,15 +885,15 @@ int GAPI_Init(WINCE_RenderData* data, HWND hwnd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
data->gapi->hGapiLib = LoadLibrary(TEXT("\\Windows\\gx.dll"));
|
||||
data->gapi->hGapiLib = SDL_LoadObject("\\Windows\\gx.dll");
|
||||
if(0 == data->gapi->hGapiLib)
|
||||
{
|
||||
data->gapi->hGapiLib = LoadLibrary(TEXT("gx.dll"));
|
||||
data->gapi->hGapiLib = SDL_LoadObject("gx.dll");
|
||||
if(0 == data->gapi->hGapiLib) return 0;
|
||||
}
|
||||
|
||||
// load gapi library
|
||||
#define LINK(type,name,import) name=(PFN##type)GetProcAddress(data->gapi->hGapiLib,TEXT(import))
|
||||
#define LINK(type,name,import) name=(PFN##type)SDL_LoadFunction(data->gapi->hGapiLib,import)
|
||||
LINK(GXOpenDisplay, data->gapi->GXOpenDisplay, "?GXOpenDisplay@@YAHPAUHWND__@@K@Z");
|
||||
LINK(GXCloseDisplay, data->gapi->GXCloseDisplay, "?GXCloseDisplay@@YAHXZ");
|
||||
LINK(GXBeginDraw, data->gapi->GXBeginDraw, "?GXBeginDraw@@YAPAXXZ");
|
||||
|
@ -1005,7 +1005,7 @@ void GAPI_Quit(WINCE_RenderData* data)
|
|||
if(data->gapi)
|
||||
{
|
||||
if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay();
|
||||
if(data->gapi->hGapiLib) FreeLibrary(data->gapi->hGapiLib);
|
||||
if(data->gapi->hGapiLib) SDL_UnloadObject(data->gapi->hGapiLib);
|
||||
|
||||
SDL_free(data->gapi);
|
||||
data->gapi = NULL;
|
||||
|
|
|
@ -312,15 +312,15 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd)
|
|||
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");
|
||||
videodata->ime_himm32 = SDL_LoadObject("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");
|
||||
videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC");
|
||||
videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMC");
|
||||
videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMCC");
|
||||
videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMCC");
|
||||
|
||||
IME_SetWindow(videodata, hwnd);
|
||||
videodata->ime_himc = ImmGetContext(hwnd);
|
||||
|
@ -383,7 +383,7 @@ IME_Quit(SDL_VideoData *videodata)
|
|||
videodata->ime_hwnd_main = 0;
|
||||
videodata->ime_himc = 0;
|
||||
if (videodata->ime_himm32) {
|
||||
FreeLibrary(videodata->ime_himm32);
|
||||
SDL_UnloadObject(videodata->ime_himm32);
|
||||
videodata->ime_himm32 = 0;
|
||||
}
|
||||
if (videodata->ime_threadmgr) {
|
||||
|
@ -606,7 +606,7 @@ static void
|
|||
IME_SetupAPI(SDL_VideoData *videodata)
|
||||
{
|
||||
char ime_file[MAX_PATH + 1];
|
||||
HMODULE hime = 0;
|
||||
void* hime = 0;
|
||||
HKL hkl = 0;
|
||||
videodata->GetReadingString = 0;
|
||||
videodata->ShowReadingWindow = 0;
|
||||
|
@ -617,14 +617,14 @@ IME_SetupAPI(SDL_VideoData *videodata)
|
|||
if (ImmGetIMEFileNameA(hkl, ime_file, sizeof(ime_file) - 1) <= 0)
|
||||
return;
|
||||
|
||||
hime = LoadLibraryA(ime_file);
|
||||
hime = SDL_LoadObject(ime_file);
|
||||
if (!hime)
|
||||
return;
|
||||
|
||||
videodata->GetReadingString = (UINT (WINAPI *)(HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT))
|
||||
GetProcAddress(hime, "GetReadingString");
|
||||
SDL_LoadFunction(hime, "GetReadingString");
|
||||
videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL))
|
||||
GetProcAddress(hime, "ShowReadingWindow");
|
||||
SDL_LoadFunction(hime, "ShowReadingWindow");
|
||||
|
||||
if (videodata->ShowReadingWindow) {
|
||||
HIMC himc = ImmGetContext(videodata->ime_hwnd_current);
|
||||
|
|
|
@ -101,7 +101,7 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
|||
!_this->gl_data->wglDeleteContext ||
|
||||
!_this->gl_data->wglMakeCurrent) {
|
||||
SDL_SetError("Could not retrieve OpenGL functions");
|
||||
FreeLibrary(handle);
|
||||
SDL_UnloadObject(handle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,19 +37,6 @@
|
|||
static int WIN_VideoInit(_THIS);
|
||||
static void WIN_VideoQuit(_THIS);
|
||||
|
||||
/* Sets an error message based on GetLastError() */
|
||||
void
|
||||
WIN_SetError(const char *prefix)
|
||||
{
|
||||
TCHAR buffer[1024];
|
||||
char *message;
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
|
||||
buffer, SDL_arraysize(buffer), NULL);
|
||||
message = WIN_StringToUTF8(buffer);
|
||||
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
|
||||
SDL_free(message);
|
||||
}
|
||||
|
||||
|
||||
/* Windows driver bootstrap functions */
|
||||
|
||||
|
@ -68,22 +55,22 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
|
|||
#if SDL_VIDEO_RENDER_D3D
|
||||
if (data->d3d) {
|
||||
IDirect3D9_Release(data->d3d);
|
||||
FreeLibrary(data->d3dDLL);
|
||||
SDL_UnloadObject(data->d3dDLL);
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_DDRAW
|
||||
if (data->ddraw) {
|
||||
data->ddraw->lpVtbl->Release(data->ddraw);
|
||||
FreeLibrary(data->ddrawDLL);
|
||||
SDL_UnloadObject(data->ddrawDLL);
|
||||
}
|
||||
#endif
|
||||
#ifdef _WIN32_WCE
|
||||
if(data->hAygShell) {
|
||||
FreeLibrary(data->hAygShell);
|
||||
SDL_UnloadObject(data->hAygShell);
|
||||
}
|
||||
#endif
|
||||
if (data->userDLL) {
|
||||
FreeLibrary(data->userDLL);
|
||||
SDL_UnloadObject(data->userDLL);
|
||||
}
|
||||
|
||||
SDL_free(device->driverdata);
|
||||
|
@ -115,24 +102,24 @@ WIN_CreateDevice(int devindex)
|
|||
device->driverdata = data;
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL"));
|
||||
data->d3dDLL = SDL_LoadObject("D3D9.DLL");
|
||||
if (data->d3dDLL) {
|
||||
IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
|
||||
|
||||
D3DCreate =
|
||||
(IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL,
|
||||
(IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL,
|
||||
"Direct3DCreate9");
|
||||
if (D3DCreate) {
|
||||
data->d3d = D3DCreate(D3D_SDK_VERSION);
|
||||
}
|
||||
if (!data->d3d) {
|
||||
FreeLibrary(data->d3dDLL);
|
||||
SDL_UnloadObject(data->d3dDLL);
|
||||
data->d3dDLL = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_RENDER_D3D */
|
||||
#if SDL_VIDEO_RENDER_DDRAW
|
||||
data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll"));
|
||||
data->ddrawDLL = SDL_LoadObject("ddraw.dll");
|
||||
if (data->ddrawDLL) {
|
||||
IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID,
|
||||
LPDIRECTDRAW FAR * lplpDD,
|
||||
|
@ -141,9 +128,9 @@ WIN_CreateDevice(int devindex)
|
|||
DDCreate =
|
||||
(IDirectDraw *
|
||||
(WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *))
|
||||
GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate"));
|
||||
SDL_LoadFunction(data->ddrawDLL, "DirectDrawCreate");
|
||||
if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) {
|
||||
FreeLibrary(data->ddrawDLL);
|
||||
SDL_UnloadObject(data->ddrawDLL);
|
||||
data->ddrawDLL = NULL;
|
||||
data->ddraw = NULL;
|
||||
}
|
||||
|
@ -151,19 +138,19 @@ WIN_CreateDevice(int devindex)
|
|||
#endif /* SDL_VIDEO_RENDER_DDRAW */
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
data->hAygShell = LoadLibrary(TEXT("\\windows\\aygshell.dll"));
|
||||
data->hAygShell = SDL_LoadObject("\\windows\\aygshell.dll");
|
||||
if(0 == data->hAygShell)
|
||||
data->hAygShell = LoadLibrary(TEXT("aygshell.dll"));
|
||||
data->hAygShell = SDL_LoadObject("aygshell.dll");
|
||||
data->SHFullScreen = (0 != data->hAygShell ?
|
||||
(PFNSHFullScreen) GetProcAddress(data->hAygShell, TEXT("SHFullScreen")) : 0);
|
||||
(PFNSHFullScreen) SDL_LoadFunction(data->hAygShell, "SHFullScreen") : 0);
|
||||
data->CoordTransform = NULL;
|
||||
#endif
|
||||
|
||||
data->userDLL = LoadLibrary(TEXT("USER32.DLL"));
|
||||
data->userDLL = SDL_LoadObject("USER32.DLL");
|
||||
if (data->userDLL) {
|
||||
data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) GetProcAddress(data->userDLL, TEXT("CloseTouchInputHandle"));
|
||||
data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) GetProcAddress(data->userDLL, TEXT("GetTouchInputInfo"));
|
||||
data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) GetProcAddress(data->userDLL, TEXT("RegisterTouchWindow"));
|
||||
data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
|
||||
data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
|
||||
data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
|
||||
}
|
||||
|
||||
/* Set the function pointers */
|
||||
|
|
|
@ -26,15 +26,7 @@
|
|||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#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>
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
|
||||
#include <msctf.h>
|
||||
|
@ -68,15 +60,8 @@
|
|||
#include "SDL_windowsopengl.h"
|
||||
#include "SDL_windowswindow.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_loadso.h"
|
||||
|
||||
#ifdef UNICODE
|
||||
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
|
||||
#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
|
||||
#else
|
||||
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
|
||||
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
|
||||
#endif
|
||||
extern void WIN_SetError(const char *prefix);
|
||||
|
||||
enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW };
|
||||
|
||||
|
@ -147,15 +132,15 @@ typedef struct SDL_VideoData
|
|||
int render;
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
HANDLE d3dDLL;
|
||||
void* d3dDLL;
|
||||
IDirect3D9 *d3d;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_DDRAW
|
||||
HANDLE ddrawDLL;
|
||||
void* ddrawDLL;
|
||||
IDirectDraw *ddraw;
|
||||
#endif
|
||||
#ifdef _WIN32_WCE
|
||||
HMODULE hAygShell;
|
||||
void* hAygShell;
|
||||
PFNSHFullScreen SHFullScreen;
|
||||
PFCoordTransform CoordTransform;
|
||||
#endif
|
||||
|
@ -164,7 +149,7 @@ typedef struct SDL_VideoData
|
|||
DWORD clipboard_count;
|
||||
|
||||
/* Touch input functions */
|
||||
HANDLE userDLL;
|
||||
void* userDLL;
|
||||
BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
|
||||
BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
|
||||
BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
|
||||
|
@ -199,7 +184,7 @@ typedef struct SDL_VideoData
|
|||
int ime_winheight;
|
||||
|
||||
HKL ime_hkl;
|
||||
HMODULE ime_himm32;
|
||||
void* 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue