Skip to content

Commit f9b5d22

Browse files
committed
SDL 9901:c9cae280468f
1 parent 19e50f4 commit f9b5d22

39 files changed

Lines changed: 1066 additions & 236 deletions

include/SDL_config_iphoneos.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@
115115
/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
116116
#define SDL_HAPTIC_DUMMY 1
117117

118+
/* Enable MFi joystick support */
119+
#define SDL_JOYSTICK_MFI 1
120+
118121
/* Enable Unix style SO loading */
119-
/* Technically this works, but it violates the iPhone developer agreement */
122+
/* Technically this works, but violates the iOS dev agreement prior to iOS 8 */
120123
/* #define SDL_LOADSO_DLOPEN 1 */
121124

122125
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
@@ -148,9 +151,6 @@
148151
/* enable iOS extended launch screen */
149152
#define SDL_IPHONE_LAUNCHSCREEN 1
150153

151-
/* enable joystick subsystem */
152-
#define SDL_JOYSTICK_DISABLED 0
153-
154154
/* Set max recognized G-force from accelerometer
155155
See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
156156
*/

include/SDL_events.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ typedef enum
9494
SDL_KEYUP, /**< Key released */
9595
SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
9696
SDL_TEXTINPUT, /**< Keyboard text input */
97+
SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an
98+
input language or keyboard layout change.
99+
*/
97100

98101
/* Mouse events */
99102
SDL_MOUSEMOTION = 0x400, /**< Mouse moved */

include/SDL_hints.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ extern "C" {
185185
*/
186186
#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR"
187187

188+
/**
189+
* \brief A variable controlling whether the X11 _NET_WM_PING protocol should be supported.
190+
*
191+
* This variable can be set to the following values:
192+
* "0" - Disable _NET_WM_PING
193+
* "1" - Enable _NET_WM_PING
194+
*
195+
* By default SDL will use _NET_WM_PING, but for applications that know they
196+
* will not always be able to respond to ping requests in a timely manner they can
197+
* turn it off to avoid the window manager thinking the app is hung.
198+
* The hint is checked in CreateWindow.
199+
*/
200+
#define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING"
201+
188202
/**
189203
* \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden
190204
*

include/SDL_joystick.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ typedef struct {
7171

7272
typedef Sint32 SDL_JoystickID;
7373

74+
typedef enum
75+
{
76+
SDL_JOYSTICK_POWER_UNKNOWN = -1,
77+
SDL_JOYSTICK_POWER_EMPTY,
78+
SDL_JOYSTICK_POWER_LOW,
79+
SDL_JOYSTICK_POWER_MEDIUM,
80+
SDL_JOYSTICK_POWER_FULL,
81+
SDL_JOYSTICK_POWER_WIRED,
82+
SDL_JOYSTICK_POWER_MAX
83+
} SDL_JoystickPowerLevel;
7484

7585
/* Function prototypes */
7686
/**
@@ -242,6 +252,11 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
242252
*/
243253
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
244254

255+
/**
256+
* Return the battery level of this joystick
257+
*/
258+
extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick);
259+
245260

246261
/* Ends C function definitions when using C++ */
247262
#ifdef __cplusplus

include/SDL_revision.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#define SDL_REVISION "hg-9871:381981a8adb6"
2-
#define SDL_REVISION_NUMBER 9871
1+
#define SDL_REVISION "hg-9901:c9cae280468f"
2+
#define SDL_REVISION_NUMBER 9901

src/core/android/SDL_android.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ static jclass mActivityClass;
7171

7272
/* method signatures */
7373
static jmethodID midGetNativeSurface;
74-
static jmethodID midFlipBuffers;
7574
static jmethodID midAudioInit;
7675
static jmethodID midAudioWriteShortBuffer;
7776
static jmethodID midAudioWriteByteBuffer;
@@ -119,8 +118,6 @@ JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls)
119118

120119
midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
121120
"getNativeSurface","()Landroid/view/Surface;");
122-
midFlipBuffers = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
123-
"flipBuffers","()V");
124121
midAudioInit = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
125122
"audioInit", "(IZZI)I");
126123
midAudioWriteShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
@@ -134,7 +131,7 @@ JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls)
134131

135132
bHasNewData = SDL_FALSE;
136133

137-
if(!midGetNativeSurface || !midFlipBuffers || !midAudioInit ||
134+
if (!midGetNativeSurface || !midAudioInit ||
138135
!midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit || !midPollInputDevices) {
139136
__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
140137
}
@@ -267,11 +264,6 @@ JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeSurfaceDestroyed(
267264

268265
}
269266

270-
JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_nativeFlipBuffers(JNIEnv* env, jclass jcls)
271-
{
272-
SDL_GL_SwapWindow(Android_Window);
273-
}
274-
275267
/* Keydown */
276268
JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeKeyDown(
277269
JNIEnv* env, jclass jcls, jint keycode)
@@ -478,12 +470,6 @@ ANativeWindow* Android_JNI_GetNativeWindow(void)
478470
return anw;
479471
}
480472

481-
void Android_JNI_SwapWindow(void)
482-
{
483-
JNIEnv *mEnv = Android_JNI_GetEnv();
484-
(*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midFlipBuffers);
485-
}
486-
487473
void Android_JNI_SetActivityTitle(const char *title)
488474
{
489475
jmethodID mid;
@@ -788,6 +774,10 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
788774
/* Try fallback to APK expansion files */
789775
mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
790776
"openAPKExpansionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
777+
if (!mid) {
778+
SDL_SetError("No openAPKExpansionInputStream() in Java class");
779+
goto failure; /* Java class is missing the required method */
780+
}
791781
inputStream = (*mEnv)->CallObjectMethod(mEnv, context, mid, fileNameJString);
792782

793783
/* Exception is checked first because it always needs to be cleared.

src/core/android/SDL_android.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ extern "C" {
3333
#include "SDL_rect.h"
3434

3535
/* Interface from the SDL library into the Android Java activity */
36-
/* extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples);
37-
extern SDL_bool Android_JNI_DeleteContext(void); */
38-
extern void Android_JNI_SwapWindow(void);
3936
extern void Android_JNI_SetActivityTitle(const char *title);
4037
extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
4138
extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
@@ -64,7 +61,7 @@ SDL_bool Android_JNI_HasClipboardText(void);
6461

6562
/* Power support */
6663
int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent);
67-
64+
6865
/* Joystick support */
6966
void Android_JNI_PollInputDevices(void);
7067

src/core/windows/SDL_xinput.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
XInputGetState_t SDL_XInputGetState = NULL;
3030
XInputSetState_t SDL_XInputSetState = NULL;
3131
XInputGetCapabilities_t SDL_XInputGetCapabilities = NULL;
32+
XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation = NULL;
3233
DWORD SDL_XInputVersion = 0;
3334

3435
static HANDLE s_pXInputDLL = 0;
@@ -55,6 +56,7 @@ WIN_LoadXInputDLL(void)
5556
SDL_XInputGetState = (XInputGetState_t)XInputGetState;
5657
SDL_XInputSetState = (XInputSetState_t)XInputSetState;
5758
SDL_XInputGetCapabilities = (XInputGetCapabilities_t)XInputGetCapabilities;
59+
SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)XInputGetBatteryInformation;
5860

5961
/* XInput 1.4 ships with Windows 8 and 8.1: */
6062
SDL_XInputVersion = (1 << 16) | 4;
@@ -108,6 +110,7 @@ WIN_LoadXInputDLL(void)
108110
}
109111
SDL_XInputSetState = (XInputSetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputSetState");
110112
SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetCapabilities");
113+
SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress( (HMODULE)s_pXInputDLL, "XInputGetBatteryInformation" );
111114
if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {
112115
WIN_UnloadXInputDLL();
113116
return -1;

src/core/windows/SDL_xinput.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,29 @@
7676
#define XINPUT_GAMEPAD_GUIDE 0x0400
7777
#endif
7878

79+
#ifndef BATTERY_DEVTYPE_GAMEPAD
80+
#define BATTERY_DEVTYPE_GAMEPAD 0x00
81+
#endif
82+
#ifndef BATTERY_TYPE_WIRED
83+
#define BATTERY_TYPE_WIRED 0x01
84+
#endif
85+
86+
#ifndef BATTERY_TYPE_UNKNOWN
87+
#define BATTERY_TYPE_UNKNOWN 0xFF
88+
#endif
89+
#ifndef BATTERY_LEVEL_EMPTY
90+
#define BATTERY_LEVEL_EMPTY 0x00
91+
#endif
92+
#ifndef BATTERY_LEVEL_LOW
93+
#define BATTERY_LEVEL_LOW 0x01
94+
#endif
95+
#ifndef BATTERY_LEVEL_MEDIUM
96+
#define BATTERY_LEVEL_MEDIUM 0x02
97+
#endif
98+
#ifndef BATTERY_LEVEL_FULL
99+
#define BATTERY_LEVEL_FULL 0x03
100+
#endif
101+
79102
/* typedef's for XInput structs we use */
80103
typedef struct
81104
{
@@ -95,6 +118,12 @@ typedef struct
95118
XINPUT_GAMEPAD_EX Gamepad;
96119
} XINPUT_STATE_EX;
97120

121+
typedef struct _XINPUT_BATTERY_INFORMATION
122+
{
123+
BYTE BatteryType;
124+
BYTE BatteryLevel;
125+
} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
126+
98127
/* Forward decl's for XInput API's we load dynamically and use if available */
99128
typedef DWORD (WINAPI *XInputGetState_t)
100129
(
@@ -115,17 +144,26 @@ typedef DWORD (WINAPI *XInputGetCapabilities_t)
115144
XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */
116145
);
117146

147+
typedef DWORD (WINAPI *XInputGetBatteryInformation_t)
148+
(
149+
_In_ DWORD dwUserIndex,
150+
_In_ BYTE devType,
151+
_Out_ XINPUT_BATTERY_INFORMATION *pBatteryInformation
152+
);
153+
118154
extern int WIN_LoadXInputDLL(void);
119155
extern void WIN_UnloadXInputDLL(void);
120156

121157
extern XInputGetState_t SDL_XInputGetState;
122158
extern XInputSetState_t SDL_XInputSetState;
123159
extern XInputGetCapabilities_t SDL_XInputGetCapabilities;
160+
extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation;
124161
extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
125162

126163
#define XINPUTGETSTATE SDL_XInputGetState
127164
#define XINPUTSETSTATE SDL_XInputSetState
128165
#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities
166+
#define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation
129167

130168
#endif /* HAVE_XINPUT_H */
131169

src/dynapi/SDL_dynapi_overrides.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,3 +594,4 @@
594594
#define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL
595595
#define SDL_GetGrabbedWindow SDL_GetGrabbedWindow_REAL
596596
#define SDL_SetWindowsMessageHook SDL_SetWindowsMessageHook_REAL
597+
#define SDL_JoystickCurrentPowerLevel SDL_JoystickCurrentPowerLevel_REAL

0 commit comments

Comments
 (0)