diff options
author | Anton Yabchinskiy <arn@bestmx.ru> | 2015-02-17 15:57:24 +0300 |
---|---|---|
committer | Anton Yabchinskiy <arn@bestmx.ru> | 2015-02-17 15:57:24 +0300 |
commit | e024ff89b224f803fe335efa95d3e99bffc3423f (patch) | |
tree | 84ca5323c97ef24cfcae202447ac6967783e9248 /platform | |
parent | 6f93e6812edaf6c8c79c28dadbe5f1c4a8ced93e (diff) | |
parent | 2bea642583efeb68886e71950384f297f2d7ee12 (diff) |
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'platform')
-rw-r--r-- | platform/iphone/app_delegate.mm | 19 | ||||
-rwxr-xr-x | platform/iphone/gl_view.h | 8 | ||||
-rwxr-xr-x | platform/iphone/gl_view.mm | 32 | ||||
-rw-r--r-- | platform/isim/detect.py | 2 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 13 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 67 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 1 | ||||
-rw-r--r-- | platform/x11/detect.py | 28 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 6 |
9 files changed, 143 insertions, 33 deletions
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 6ca54286ba..fe11b672ac 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -84,13 +84,11 @@ static int frame_count = 0; switch (frame_count) { case 0: { - - int backingWidth; - int backingHeight; - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); - - iphone_main(backingWidth, backingHeight, gargc, gargv); + int backingWidth; + int backingHeight; + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + OS::VideoMode vm; vm.fullscreen = true; @@ -198,6 +196,13 @@ static int frame_count = 0; //glView.autoresizesSubviews = YES; //[glView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth]; + int backingWidth; + int backingHeight; + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + + iphone_main(backingWidth, backingHeight, gargc, gargv); + view_controller = [[ViewController alloc] init]; view_controller.view = glView; window.rootViewController = view_controller; diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h index 8ae7c2f87d..a5b1b8731f 100755 --- a/platform/iphone/gl_view.h +++ b/platform/iphone/gl_view.h @@ -34,6 +34,8 @@ #import <MediaPlayer/MediaPlayer.h> #import <AVFoundation/AVFoundation.h> +#define USE_CADISPLAYLINK 1 //iOS version 3.1+ is required + @protocol GLViewDelegate; @interface GLView : UIView<UIKeyInput> @@ -51,8 +53,14 @@ // OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) GLuint depthRenderbuffer; +#if USE_CADISPLAYLINK + // CADisplayLink available on 3.1+ synchronizes the animation timer & drawing with the refresh rate of the display, only supports animation intervals of 1/60 1/30 & 1/15 + CADisplayLink *displayLink; +#else // An animation timer that, when animation is started, will periodically call -drawView at the given rate. NSTimer *animationTimer; +#endif + NSTimeInterval animationInterval; // Delegate to do our drawing, called by -drawView, which can be called manually or via the animation timer. diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index bee01d3c72..0625361b96 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -413,7 +413,19 @@ static void clear_touches() { return; active = TRUE; printf("start animation!\n"); +#if USE_CADISPLAYLINK + // Approximate frame rate + // assumes device refreshes at 60 fps + int frameInterval = (int) floor(animationInterval * 60.0f); + + displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)]; + [displayLink setFrameInterval:frameInterval]; + + // Setup DisplayLink in main thread + [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; +#else animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; +#endif if (video_playing) { @@ -427,8 +439,13 @@ static void clear_touches() { return; active = FALSE; printf("******** stop animation!\n"); +#if USE_CADISPLAYLINK + [displayLink invalidate]; + displayLink = nil; +#else [animationTimer invalidate]; animationTimer = nil; +#endif clear_touches(); if (video_playing) @@ -441,7 +458,11 @@ static void clear_touches() { { animationInterval = interval; +#if USE_CADISPLAYLINK + if(displayLink) +#else if(animationTimer) +#endif { [self stopAnimation]; [self startAnimation]; @@ -451,6 +472,17 @@ static void clear_touches() { // Updates the OpenGL view when the timer fires - (void)drawView { +#if USE_CADISPLAYLINK + // Pause the CADisplayLink to avoid recursion + [displayLink setPaused: YES]; + + // Process all input events + while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource); + + // We are good to go, resume the CADisplayLink + [displayLink setPaused: NO]; +#endif + if (!active) { printf("draw view not active!\n"); return; diff --git a/platform/isim/detect.py b/platform/isim/detect.py index 8d60e30d25..bd0fd2fea3 100644 --- a/platform/isim/detect.py +++ b/platform/isim/detect.py @@ -22,7 +22,7 @@ def get_opts(): return [ ('ISIMPLATFORM', 'name of the iphone platform', 'iPhoneSimulator'), ('ISIMPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Platforms/${ISIMPLATFORM}.platform'), - ('ISIMSDK', 'path to the iphone SDK', '$ISIMPATH/Developer/SDKs/${ISIMPLATFORM}7.1.sdk'), + ('ISIMSDK', 'path to the iphone SDK', '$ISIMPATH/Developer/SDKs/${ISIMPLATFORM}.sdk'), ('game_center', 'Support for game center', 'yes'), ('store_kit', 'Support for in-app store', 'yes'), ('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'), diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 5bc47a74c1..af2552496b 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1093,8 +1093,19 @@ void OS_OSX::warp_mouse_pos(const Point2& p_to) { mouse_y = p_to.y; } else{ //set OS position - CGPoint lMouseWarpPos = {p_to.x, p_to.y}; + /* this code has not been tested, please be a kind soul and fix it if it fails! */ + + //local point in window coords + NSPoint localPoint = { p_to.x, p_to.y }; + + NSPoint pointInWindow = [window_view convertPoint:localPoint toView:nil]; + NSPoint pointOnScreen = [[window_view window] convertRectToScreen:(CGRect){.origin=pointInWindow}]; + + //point in scren coords + CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y}; + + //do the warping CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0); CGAssociateMouseAndMouseCursorPosition(false); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 4fa061886d..13f2c32e77 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -54,6 +54,8 @@ #include "io/marshalls.h" #include "shlobj.h" +#include <regstr.h> + static const WORD MAX_CONSOLE_LINES = 1500; extern "C" { @@ -593,10 +595,11 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { ERR_BREAK(key_event_pos >= KEY_EVENT_BUFFER_SIZE); + // Make sure we don't include modifiers for the modifier key itself. KeyEvent ke; - ke.mod_state.shift=shift_mem; - ke.mod_state.alt=alt_mem; - ke.mod_state.control=control_mem; + ke.mod_state.shift= (wParam != VK_SHIFT) ? shift_mem : false; + ke.mod_state.alt= (! (wParam == VK_MENU && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN))) ? alt_mem : false; + ke.mod_state.control= (wParam != VK_CONTROL) ? control_mem : false; ke.mod_state.meta=meta_mem; ke.uMsg=uMsg; @@ -684,6 +687,48 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { } + +String OS_Windows::get_joystick_name(int id, JOYCAPS jcaps) +{ + char buffer [256]; + char OEM [256]; + HKEY hKey; + DWORD sz; + int res; + + _snprintf(buffer, sizeof(buffer), "%s\\%s\\%s", + REGSTR_PATH_JOYCONFIG, jcaps.szRegKey, + REGSTR_KEY_JOYCURR ); + res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey); + if (res != ERROR_SUCCESS) + { + res = RegOpenKeyEx(HKEY_CURRENT_USER, buffer, 0, KEY_QUERY_VALUE, &hKey); + if (res != ERROR_SUCCESS) + return ""; + } + + sz = sizeof(OEM); + _snprintf( buffer, sizeof(buffer), "Joystick%d%s", id + 1, REGSTR_VAL_JOYOEMNAME); + res = RegQueryValueEx ( hKey, buffer, 0, 0, (LPBYTE) OEM, &sz); + RegCloseKey ( hKey ); + if (res != ERROR_SUCCESS) + return ""; + + _snprintf( buffer, sizeof(buffer), "%s\\%s", REGSTR_PATH_JOYOEM, OEM); + res = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey); + if (res != ERROR_SUCCESS) + return ""; + + sz = sizeof(buffer); + res = RegQueryValueEx(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE) buffer, + &sz); + RegCloseKey(hKey); + if (res != ERROR_SUCCESS) + return ""; + + return String(buffer); +} + void OS_Windows::probe_joysticks() { static uint32_t last_attached = 0; @@ -725,7 +770,13 @@ void OS_Windows::probe_joysticks() { JOYCAPS jcaps; MMRESULT res = joyGetDevCaps(JOYSTICKID1 + i, &jcaps, sizeof(jcaps)); if (res == JOYERR_NOERROR) { - joy.name = jcaps.szPname; + String name = get_joystick_name(JOYSTICKID1 + i, jcaps); + if ( name == "") + joy.name = jcaps.szPname; + else + joy.name = name; + + }; }; @@ -1381,9 +1432,13 @@ void OS_Windows::warp_mouse_pos(const Point2& p_to) { old_y=p_to.y; } else { - SetCursorPos(p_to.x, p_to.y); - } + POINT p; + p.x=p_to.x; + p.y=p_to.y; + ClientToScreen(hWnd,&p); + SetCursorPos(p.x,p.y); + } } Point2 OS_Windows::get_mouse_pos() const { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 20993c6419..210e25d2d6 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -187,6 +187,7 @@ protected: void probe_joysticks(); void process_joysticks(); void process_key_events(); + String get_joystick_name( int id, JOYCAPS jcaps); struct ProcessInfo { diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 6c1ca670f0..b4e766958c 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -71,24 +71,23 @@ def configure(env): else: env["bits"]="32" - env.Append(CPPPATH=['#platform/x11']) if (env["use_llvm"]=="yes"): - env["CC"]="clang" - env["CXX"]="clang++" - env["LD"]="clang++" - if (env["use_sanitizer"]=="yes"): - env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer']) - env.Append(LINKFLAGS=['-fsanitize=address']) - env.extra_suffix=".llvms" - else: - env.extra_suffix=".llvm" + if 'clang++' not in env['CXX']: + env["CC"]="clang" + env["CXX"]="clang++" + env["LD"]="clang++" + env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) + env.extra_suffix=".llvm" + if (env["colored"]=="yes"): if sys.stdout.isatty(): env.Append(CXXFLAGS=["-fcolor-diagnostics"]) - - + if (env["use_sanitizer"]=="yes"): + env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer']) + env.Append(LINKFLAGS=['-fsanitize=address']) + env.extra_suffix+="s" #if (env["tools"]=="no"): # #no tools suffix @@ -146,11 +145,6 @@ def configure(env): env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu']) - if (env["CXX"]=="clang++"): - env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) - env["CC"]="clang" - env["LD"]="clang++" - import methods env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 156bdb8330..39c171a08d 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -480,8 +480,12 @@ void OS_X11::warp_mouse_pos(const Point2& p_to) { last_mouse_pos=p_to; } else { + /*XWindowAttributes xwa; + XGetWindowAttributes(x11_display, x11_window, &xwa); + printf("%d %d\n", xwa.x, xwa.y); needed? */ + XWarpPointer(x11_display, None, x11_window, - 0,0,0,0, (int)p_to.x, (int)p_to.y); + 0,0,0,0, (int)p_to.x , (int)p_to.y); } } |