Created a header file for system dependent API functions, and added SDL_iPhoneSetAnimationCallback()
This commit is contained in:
parent
6cd1ae105e
commit
a3bf8f0c71
9 changed files with 89 additions and 6 deletions
|
@ -78,7 +78,7 @@ Finally, if your application completely redraws the screen each frame, you may f
|
||||||
Notes -- Keyboard
|
Notes -- Keyboard
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
SDL for iPhone contains several additional functions related to keyboard visibility. These functions are not part of the SDL standard API, but are necessary for revealing and hiding the iPhone's virtual onscreen keyboard. You can use them in your own applications by including a copy of the SDL_uikitkeyboard.h header (located in src/video/uikit) in your project.
|
SDL for iPhone contains several additional functions related to keyboard visibility. These functions are not part of the SDL standard API, but are necessary for revealing and hiding the iPhone's virtual onscreen keyboard.
|
||||||
|
|
||||||
int SDL_iPhoneKeyboardShow(SDL_Window * window)
|
int SDL_iPhoneKeyboardShow(SDL_Window * window)
|
||||||
-- reveals the onscreen keyboard. Returns 0 on success and -1 on error.
|
-- reveals the onscreen keyboard. Returns 0 on success and -1 on error.
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
#include "SDL_power.h"
|
#include "SDL_power.h"
|
||||||
#include "SDL_render.h"
|
#include "SDL_render.h"
|
||||||
#include "SDL_rwops.h"
|
#include "SDL_rwops.h"
|
||||||
|
#include "SDL_system.h"
|
||||||
#include "SDL_thread.h"
|
#include "SDL_thread.h"
|
||||||
#include "SDL_timer.h"
|
#include "SDL_timer.h"
|
||||||
#include "SDL_version.h"
|
#include "SDL_version.h"
|
||||||
|
|
24
src/video/uikit/SDL_uikitkeyboard.h → include/SDL_system.h
Executable file → Normal file
24
src/video/uikit/SDL_uikitkeyboard.h → include/SDL_system.h
Executable file → Normal file
|
@ -19,9 +19,18 @@
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef sdl_uikitkeyboard_h
|
/**
|
||||||
#define sdl_uikitkeyboard_h
|
* \file SDL_system.h
|
||||||
|
*
|
||||||
|
* Include file for platform specific SDL API functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SDL_system_h
|
||||||
|
#define _SDL_system_h
|
||||||
|
|
||||||
|
#include "SDL_stdinc.h"
|
||||||
|
|
||||||
|
#include "begin_code.h"
|
||||||
/* Set up for C function definitions, even when using C++ */
|
/* Set up for C function definitions, even when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
|
@ -29,18 +38,27 @@ extern "C" {
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __IPHONEOS__
|
||||||
|
|
||||||
|
#include "SDL_video.h"
|
||||||
|
|
||||||
|
extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
||||||
|
|
||||||
extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_Window * window);
|
extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_Window * window);
|
||||||
extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_Window * window);
|
extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_Window * window);
|
||||||
extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_Window * window);
|
extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_Window * window);
|
||||||
extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_Window * window);
|
extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_Window * window);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
/* Ends C function definitions when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
}
|
}
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
#endif
|
#endif
|
||||||
|
#include "close_code.h"
|
||||||
|
|
||||||
#endif /* sdl_uikitkeyboard_h */
|
#endif /* _SDL_system_h */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -119,6 +119,6 @@ struct SDL_Touch {
|
||||||
#endif
|
#endif
|
||||||
#include "close_code.h"
|
#include "close_code.h"
|
||||||
|
|
||||||
#endif /* _SDL_mouse_h */
|
#endif /* _SDL_touch_h */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -108,6 +108,8 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
|
||||||
exit_status = SDL_main(forward_argc, forward_argv);
|
exit_status = SDL_main(forward_argc, forward_argv);
|
||||||
|
|
||||||
/* exit, passing the return status from the user's application */
|
/* exit, passing the return status from the user's application */
|
||||||
|
// We don't actually exit to support applications that do setup in
|
||||||
|
// their main function and then allow the Cocoa event loop to run.
|
||||||
// exit(exit_status);
|
// exit(exit_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,11 @@
|
||||||
|
|
||||||
/* format of depthRenderbuffer */
|
/* format of depthRenderbuffer */
|
||||||
GLenum depthBufferFormat;
|
GLenum depthBufferFormat;
|
||||||
|
|
||||||
|
id displayLink;
|
||||||
|
int animationInterval;
|
||||||
|
void (*animationCallback)(void*);
|
||||||
|
void *animationCallbackParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, retain, readonly) EAGLContext *context;
|
@property (nonatomic, retain, readonly) EAGLContext *context;
|
||||||
|
@ -66,6 +71,15 @@
|
||||||
|
|
||||||
- (void)updateFrame;
|
- (void)updateFrame;
|
||||||
|
|
||||||
|
- (void)setAnimationCallback:(int)interval
|
||||||
|
callback:(void (*)(void*))callback
|
||||||
|
callbackParam:(void*)callbackParam;
|
||||||
|
|
||||||
|
- (void)startAnimation;
|
||||||
|
- (void)stopAnimation;
|
||||||
|
|
||||||
|
- (void)doLoop:(id)sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -147,6 +147,41 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setAnimationCallback:(int)interval
|
||||||
|
callback:(void (*)(void*))callback
|
||||||
|
callbackParam:(void*)callbackParam
|
||||||
|
{
|
||||||
|
[self stopAnimation];
|
||||||
|
|
||||||
|
animationInterval = interval;
|
||||||
|
animationCallback = callback;
|
||||||
|
animationCallbackParam = callbackParam;
|
||||||
|
|
||||||
|
if (animationCallback)
|
||||||
|
[self startAnimation];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startAnimation
|
||||||
|
{
|
||||||
|
// CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed
|
||||||
|
// if the system version runtime check for CADisplayLink exists in -initWithCoder:.
|
||||||
|
|
||||||
|
displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doLoop:)];
|
||||||
|
[displayLink setFrameInterval:animationInterval];
|
||||||
|
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)stopAnimation
|
||||||
|
{
|
||||||
|
[displayLink invalidate];
|
||||||
|
displayLink = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)doLoop:(id)sender
|
||||||
|
{
|
||||||
|
animationCallback(animationCallbackParam);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setCurrentContext
|
- (void)setCurrentContext
|
||||||
{
|
{
|
||||||
[EAGLContext setCurrentContext:context];
|
[EAGLContext setCurrentContext:context];
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#if SDL_IPHONE_KEYBOARD
|
#if SDL_IPHONE_KEYBOARD
|
||||||
#import "keyinfotable.h"
|
#import "keyinfotable.h"
|
||||||
#import "SDL_uikitappdelegate.h"
|
#import "SDL_uikitappdelegate.h"
|
||||||
#import "SDL_uikitkeyboard.h"
|
|
||||||
#import "SDL_uikitwindow.h"
|
#import "SDL_uikitwindow.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,20 @@ UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam)
|
||||||
|
{
|
||||||
|
SDL_WindowData *data = window ? (SDL_WindowData *)window->driverdata : NULL;
|
||||||
|
|
||||||
|
if (!data || !data->view) {
|
||||||
|
SDL_SetError("Invalid window or view not set");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data->view setAnimationCallback:interval callback:callback callbackParam:callbackParam];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue