src/video/uikit/SDL_uikitevents.m
author Sam Lantinga
Fri, 27 Jan 2017 06:05:50 -0800
changeset 10856 486aa38c6a88
parent 10737 3406a0f8b041
child 11811 5d94cb6b24d3
permissions -rw-r--r--
Added Thrustmaster Wheel FFB entry to the list of wheels
slouken@2765
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@10737
     3
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
slouken@2765
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2765
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2765
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2765
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@2765
    22
slouken@6044
    23
#if SDL_VIDEO_DRIVER_UIKIT
slouken@6044
    24
slouken@2765
    25
#include "../../events/SDL_events_c.h"
slouken@2765
    26
slouken@2765
    27
#include "SDL_uikitvideo.h"
slouken@2765
    28
#include "SDL_uikitevents.h"
slime73@10141
    29
#include "SDL_uikitopengles.h"
slouken@2765
    30
slouken@2765
    31
#import <Foundation/Foundation.h>
slouken@2765
    32
slouken@6346
    33
static BOOL UIKit_EventPumpEnabled = YES;
slouken@6346
    34
slouken@6346
    35
void
slouken@6346
    36
SDL_iPhoneSetEventPump(SDL_bool enabled)
slouken@6346
    37
{
slouken@6346
    38
    UIKit_EventPumpEnabled = enabled;
slouken@6346
    39
}
slouken@6346
    40
slouken@2765
    41
void
slouken@2765
    42
UIKit_PumpEvents(_THIS)
slouken@2765
    43
{
slime73@9487
    44
    if (!UIKit_EventPumpEnabled) {
slouken@6346
    45
        return;
slime73@9487
    46
    }
slouken@6346
    47
slouken@7284
    48
    /* Let the run loop run for a short amount of time: long enough for
slouken@7284
    49
       touch events to get processed (which is important to get certain
slouken@7284
    50
       elements of Game Center's GKLeaderboardViewController to respond
slouken@7284
    51
       to touch input), but not long enough to introduce a significant
slouken@7284
    52
       delay in the rest of the app.
slouken@7284
    53
    */
slouken@7284
    54
    const CFTimeInterval seconds = 0.000002;
dludwig@6857
    55
slouken@7284
    56
    /* Pump most event types. */
slouken@7284
    57
    SInt32 result;
slouken@7284
    58
    do {
slouken@10315
    59
        result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, TRUE);
slouken@7284
    60
    } while (result == kCFRunLoopRunHandledSource);
dludwig@6857
    61
slouken@10315
    62
    /* Make sure UIScrollView objects scroll properly. */
slouken@10315
    63
    do {
slouken@10315
    64
        result = CFRunLoopRunInMode((CFStringRef)UITrackingRunLoopMode, seconds, TRUE);
slouken@10315
    65
    } while(result == kCFRunLoopRunHandledSource);
slouken@10315
    66
slime73@10141
    67
    /* See the comment in the function definition. */
slime73@10141
    68
    UIKit_GL_RestoreCurrentContext();
slouken@2765
    69
}
slouken@2765
    70
slouken@6044
    71
#endif /* SDL_VIDEO_DRIVER_UIKIT */
slouken@6044
    72
slouken@2765
    73
/* vi: set ts=4 sw=4 expandtab: */