mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-05-08 19:32:39 +08:00
Reapply DOSBox-X specific patches to SDL2 library
This commit is contained in:
parent
b1de9c5ff4
commit
fcf88b8753
@ -1620,22 +1620,16 @@ CheckNoErrorDeprecatedDeclarationsWerror()
|
||||
dnl See if GCC's -Wdeclaration-after-statement is supported.
|
||||
dnl This lets us catch things that would fail on a C89 compiler when using
|
||||
dnl a modern GCC.
|
||||
dnl EDIT 2023/04/01 DOSBox-X: We don't care about ancient compilers. A compiler
|
||||
dnl that old doesn't support C++ and even if it did, it wouldn't be new enough
|
||||
dnl for this code base. We have to disable this because this is preventing
|
||||
dnl DOSBox-X from compiling with the latest XCode on ARM-based Macbooks because
|
||||
dnl the *.m files have variable declarations after statements. At no point is
|
||||
dnl this code going to compile itself like it's 1993. Come on guys. --J.C.
|
||||
CheckDeclarationAfterStatement()
|
||||
{
|
||||
AC_MSG_CHECKING(for GCC -Wdeclaration-after-statement option)
|
||||
have_gcc_declaration_after_statement=no
|
||||
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$save_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
int x = 0;
|
||||
]],[])], [have_gcc_declaration_after_statement=yes],[])
|
||||
AC_MSG_RESULT($have_gcc_declaration_after_statement)
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
if test x$have_gcc_declaration_after_statement = xyes; then
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement"
|
||||
fi
|
||||
dnl We don't care about C89 compilers.
|
||||
true
|
||||
}
|
||||
|
||||
dnl See if GCC's -Wall is supported.
|
||||
|
@ -299,6 +299,9 @@ typedef unsigned int uintptr_t;
|
||||
#define SDL_VIDEO_RENDER_D3D12 1
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__) && (defined(__arm__) || defined(__arm64__) || defined(_M_ARM) || defined(_M_ARM64))
|
||||
#define NO_OPENGL /* Don't enable for DOSBox-X on Windows ARM */
|
||||
#else
|
||||
/* Enable OpenGL support */
|
||||
#ifndef SDL_VIDEO_OPENGL
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
@ -318,6 +321,7 @@ typedef unsigned int uintptr_t;
|
||||
#ifndef SDL_VIDEO_OPENGL_EGL
|
||||
#define SDL_VIDEO_OPENGL_EGL 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Enable Vulkan support */
|
||||
#define SDL_VIDEO_VULKAN 1
|
||||
|
@ -208,6 +208,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
|
||||
* \sa SDL_GetScancodeName
|
||||
*/
|
||||
extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IM_Composition(int more); // Added for DOSBox-X
|
||||
|
||||
/**
|
||||
* Get a human-readable name for a key.
|
||||
|
@ -143,6 +143,12 @@
|
||||
#define main SDL_main
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define SDL_MAIN_NOEXCEPT noexcept(false) // Added for DOSBox-X
|
||||
#else
|
||||
#define SDL_MAIN_NOEXCEPT // Added for DOSBox-X
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -152,8 +158,8 @@ extern "C" {
|
||||
* The prototype for the application's main() function
|
||||
*/
|
||||
typedef int (*SDL_main_func)(int argc, char *argv[]);
|
||||
extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
|
||||
|
||||
//extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
|
||||
extern SDLMAIN_DECLSPEC int SDL_main(int argc, char* argv[]) SDL_MAIN_NOEXCEPT; // Changed for DOSBox-X
|
||||
|
||||
/**
|
||||
* Circumvent failure of SDL_Init() when not using SDL_main() as an entry
|
||||
|
@ -36,6 +36,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This is the DOSBox-X's modified SDL 2.x with IME support, not the general library */
|
||||
#define SDL_DOSBOX_X_IME 1
|
||||
|
||||
/**
|
||||
* Information about the version of SDL in use.
|
||||
*
|
||||
|
@ -368,9 +368,13 @@ static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE *pXIn
|
||||
|
||||
SDL_PrivateJoystickAxis(joystick, 0, pXInputState->Gamepad.sThumbLX);
|
||||
SDL_PrivateJoystickAxis(joystick, 1, ~pXInputState->Gamepad.sThumbLY);
|
||||
SDL_PrivateJoystickAxis(joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768);
|
||||
SDL_PrivateJoystickAxis(joystick, 3, pXInputState->Gamepad.sThumbRX);
|
||||
SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY);
|
||||
//SDL_PrivateJoystickAxis(joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768);
|
||||
//SDL_PrivateJoystickAxis(joystick, 3, pXInputState->Gamepad.sThumbRX);
|
||||
//SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY);
|
||||
// Fixes for DOSBox-X
|
||||
SDL_PrivateJoystickAxis(joystick, 2, pXInputState->Gamepad.sThumbRX);
|
||||
SDL_PrivateJoystickAxis(joystick, 3, ~pXInputState->Gamepad.sThumbRY);
|
||||
SDL_PrivateJoystickAxis(joystick, 4, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768);
|
||||
SDL_PrivateJoystickAxis(joystick, 5, ((int)pXInputState->Gamepad.bRightTrigger * 257) - 32768);
|
||||
|
||||
for (button = 0; button < (Uint8)SDL_arraysize(s_XInputButtons); ++button) {
|
||||
|
@ -33,11 +33,30 @@
|
||||
/*#define DEBUG_IME NSLog */
|
||||
#define DEBUG_IME(...)
|
||||
|
||||
#if 1 // inserted for DOSBox-X
|
||||
@interface IMETextView : NSView
|
||||
@property (nonatomic, copy) NSAttributedString *text;
|
||||
@end
|
||||
|
||||
@implementation IMETextView
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
CGSize size;
|
||||
[super drawRect:dirtyRect];
|
||||
size = [_text size];
|
||||
[[NSColor whiteColor] set];
|
||||
NSRectFill(self.bounds);
|
||||
[_text drawInRect:CGRectMake(0, 0, size.width, size.height)];
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SDLTranslatorResponder : NSView <NSTextInputClient> {
|
||||
NSString *_markedText;
|
||||
NSRange _markedRange;
|
||||
NSRange _selectedRange;
|
||||
SDL_Rect _inputRect;
|
||||
IMETextView *_markedLabel; // inserted for DOSBox-X
|
||||
}
|
||||
- (void)doCommandBySelector:(SEL)myselector;
|
||||
- (void)setInputRect:(const SDL_Rect *)rect;
|
||||
@ -72,6 +91,8 @@
|
||||
}
|
||||
|
||||
SDL_SendKeyboardText(str);
|
||||
[_markedLabel setHidden:YES]; // inserted for DOSBox-X
|
||||
_markedLabel.text = nil; // inserted for DOSBox-X
|
||||
}
|
||||
|
||||
- (void)doCommandBySelector:(SEL)myselector
|
||||
@ -97,9 +118,21 @@
|
||||
return _selectedRange;
|
||||
}
|
||||
|
||||
static SDL_bool ime_incompos = 0; // inserted for DOSBox-X
|
||||
static long end_ticks = 0; // inserted for DOSBox-X
|
||||
|
||||
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange
|
||||
{
|
||||
if ([aString isKindOfClass:[NSAttributedString class]]) {
|
||||
#if 1 // inserted for DOSBox-X
|
||||
CGSize size;
|
||||
[aString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:_inputRect.h] range:NSMakeRange(0, [aString length])];
|
||||
_markedLabel.text = aString;
|
||||
size = [aString size];
|
||||
[_markedLabel setFrameSize:size];
|
||||
[_markedLabel setHidden:NO];
|
||||
[_markedLabel setNeedsDisplay:YES];
|
||||
#endif
|
||||
aString = [aString string];
|
||||
}
|
||||
|
||||
@ -124,11 +157,34 @@
|
||||
|
||||
- (void)unmarkText
|
||||
{
|
||||
_markedText = nil;
|
||||
|
||||
//[_markedText release]; // Maybe required for DOSBox-X
|
||||
_markedText = nil;
|
||||
[_markedLabel setHidden:YES]; // inserted for DOSBox-X
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
}
|
||||
|
||||
#if 1 // inserted for DOSBox-X
|
||||
#define IME_END_CR_WAIT 25
|
||||
SDL_bool SDL_IM_Composition(int more) {
|
||||
return ime_incompos||(end_ticks&&(TickCount()-end_ticks<IME_END_CR_WAIT*more)) ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
static int GetEnableIME()
|
||||
{
|
||||
TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
|
||||
CFBooleanRef ret = (CFBooleanRef)TISGetInputSourceProperty(is, kTISPropertyInputSourceIsASCIICapable);
|
||||
return CFBooleanGetValue(ret) ? 0 : 1;
|
||||
}
|
||||
|
||||
- (void)keyboardInputSourceChanged:(NSNotification *)notification
|
||||
{
|
||||
if(!GetEnableIME()) {
|
||||
[_markedLabel setHidden:YES];
|
||||
[[NSTextInputContext currentInputContext] discardMarkedText];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange
|
||||
{
|
||||
NSWindow *window = [self window];
|
||||
@ -145,6 +201,18 @@
|
||||
aRange.location, aRange.length, windowHeight,
|
||||
NSStringFromRect(rect));
|
||||
|
||||
#if 1 // inserted for DOSBox-X
|
||||
if(!_markedLabel) {
|
||||
_markedLabel = [[IMETextView alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
|
||||
[[[self window] contentView] addSubview:_markedLabel];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardInputSourceChanged:)
|
||||
name:NSTextInputContextKeyboardSelectionDidChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
[_markedLabel setFrameOrigin: NSMakePoint(_inputRect.x, windowHeight - _inputRect.y)];
|
||||
#endif
|
||||
|
||||
rect = [window convertRectToScreen:rect];
|
||||
|
||||
return rect;
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include <oleauto.h>
|
||||
|
||||
#ifndef SDL_DISABLE_WINDOWS_IME
|
||||
static Uint32 end_ticks = 0; // added for DOSBox-X
|
||||
static SDL_bool ime_incompos; // added for DOSBox-X
|
||||
static void IME_Init(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Enable(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Disable(SDL_VideoData *videodata, HWND hwnd);
|
||||
@ -39,6 +41,18 @@ static void IME_Quit(SDL_VideoData *videodata);
|
||||
static SDL_bool IME_IsTextInputShown(SDL_VideoData *videodata);
|
||||
#endif /* !SDL_DISABLE_WINDOWS_IME */
|
||||
|
||||
#if 1 // Added for DOSBox-X
|
||||
SDL_bool SDL_IM_Composition(int more) {
|
||||
(void)more;
|
||||
#ifndef SDL_DISABLE_WINDOWS_IME
|
||||
#define IME_END_CR_WAIT 50
|
||||
return ime_incompos || end_ticks && (GetTickCount() - end_ticks < IME_END_CR_WAIT) ? SDL_TRUE : SDL_FALSE;
|
||||
#else
|
||||
return SDL_FALSE;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MAPVK_VK_TO_VSC
|
||||
#define MAPVK_VK_TO_VSC 0
|
||||
#endif
|
||||
@ -249,27 +263,18 @@ void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect)
|
||||
|
||||
himc = ImmGetContext(videodata->ime_hwnd_current);
|
||||
if (himc) {
|
||||
/* //reverted for DOSBox-X
|
||||
COMPOSITIONFORM cof;
|
||||
CANDIDATEFORM caf;
|
||||
|
||||
cof.dwStyle = CFS_RECT;
|
||||
cof.ptCurrentPos.x = videodata->ime_rect.x;
|
||||
cof.ptCurrentPos.y = videodata->ime_rect.y;
|
||||
cof.rcArea.left = videodata->ime_rect.x;
|
||||
cof.rcArea.right = (LONG)videodata->ime_rect.x + videodata->ime_rect.w;
|
||||
cof.rcArea.top = videodata->ime_rect.y;
|
||||
cof.rcArea.bottom = (LONG)videodata->ime_rect.y + videodata->ime_rect.h;
|
||||
ImmSetCompositionWindow(himc, &cof);
|
||||
|
||||
caf.dwIndex = 0;
|
||||
caf.dwStyle = CFS_EXCLUDE;
|
||||
caf.ptCurrentPos.x = videodata->ime_rect.x;
|
||||
caf.ptCurrentPos.y = videodata->ime_rect.y;
|
||||
caf.rcArea.left = videodata->ime_rect.x;
|
||||
caf.rcArea.right = (LONG)videodata->ime_rect.x + videodata->ime_rect.w;
|
||||
caf.rcArea.top = videodata->ime_rect.y;
|
||||
caf.rcArea.bottom = (LONG)videodata->ime_rect.y + videodata->ime_rect.h;
|
||||
ImmSetCandidateWindow(himc, &caf);
|
||||
*/
|
||||
COMPOSITIONFORM cf;
|
||||
cf.ptCurrentPos.x = videodata->ime_rect.x;
|
||||
cf.ptCurrentPos.y = videodata->ime_rect.y;
|
||||
cf.dwStyle = CFS_FORCE_POSITION;
|
||||
ImmSetCompositionWindow(himc, &cf);
|
||||
|
||||
ImmReleaseContext(videodata->ime_hwnd_current, himc);
|
||||
}
|
||||
@ -415,11 +420,14 @@ static void IME_Init(SDL_VideoData *videodata, HWND hwnd)
|
||||
videodata->ime_available = SDL_TRUE;
|
||||
IME_UpdateInputLocale(videodata);
|
||||
IME_SetupAPI(videodata);
|
||||
// Disabled because the candidate window will not be displayed. (for DOSBox-X)
|
||||
/*
|
||||
if (WIN_ShouldShowNativeUI()) {
|
||||
videodata->ime_uiless = SDL_FALSE;
|
||||
} else {
|
||||
videodata->ime_uiless = UILess_SetupSinks(videodata);
|
||||
}
|
||||
*/
|
||||
IME_UpdateInputLocale(videodata);
|
||||
IME_Disable(videodata, hwnd);
|
||||
}
|
||||
@ -1018,17 +1026,37 @@ SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, S
|
||||
case WM_INPUTLANGCHANGE:
|
||||
IME_InputLangChanged(videodata);
|
||||
break;
|
||||
#if 1 // added for DOSBox-X
|
||||
case WM_IME_CHAR:
|
||||
if(wParam == 0x20) {
|
||||
// enable IME input space
|
||||
PostMessage(hwnd, WM_KEYDOWN, 0x20, 0x390001);
|
||||
}
|
||||
else if(wParam == 0x3000) {
|
||||
// input Zenkaku space
|
||||
videodata->ime_composition[0] = 0x3000;
|
||||
videodata->ime_composition[1] = 0;
|
||||
IME_SendEditingEvent(videodata);
|
||||
IME_SendInputEvent(videodata);
|
||||
}
|
||||
trap = SDL_TRUE;
|
||||
break;
|
||||
#endif
|
||||
case WM_IME_SETCONTEXT:
|
||||
// Disabled because the string being converted will not be displayed. (for DOSBox-X)
|
||||
/*
|
||||
if (videodata->ime_uiless) {
|
||||
*lParam = 0;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
videodata->ime_suppress_endcomposition_event = SDL_FALSE;
|
||||
trap = SDL_TRUE;
|
||||
ime_incompos = 1; /* added for DOSBox-X */
|
||||
//trap = SDL_TRUE; /* disabled for DOSBox-X */
|
||||
break;
|
||||
case WM_IME_COMPOSITION:
|
||||
trap = SDL_TRUE;
|
||||
//trap = SDL_TRUE; /* disabled for DOSBox-X */
|
||||
himc = ImmGetContext(hwnd);
|
||||
if (*lParam & GCS_RESULTSTR) {
|
||||
videodata->ime_suppress_endcomposition_event = SDL_TRUE;
|
||||
@ -1047,6 +1075,7 @@ SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, S
|
||||
ImmReleaseContext(hwnd, himc);
|
||||
break;
|
||||
case WM_IME_ENDCOMPOSITION:
|
||||
ime_incompos = 0; /* added for DOSBox-X */
|
||||
videodata->ime_uicontext = 0;
|
||||
videodata->ime_composition[0] = 0;
|
||||
videodata->ime_readingstring[0] = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user