src/video/uikit/SDL_uikitview.m
author Sam Lantinga <slouken@libsdl.org>
Mon, 07 Mar 2011 09:58:21 -0800
changeset 5445 b2bcc3c36fa3
parent 5262 b530ef003506
child 5459 881d1e03e381
permissions -rw-r--r--
Enabled multi-touch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5262
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
     2
    SDL - Simple DirectMedia Layer
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
     3
    Copyright (C) 1997-2011 Sam Lantinga
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
     4
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
     5
    This library is free software; you can redistribute it and/or
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
     7
    License as published by the Free Software Foundation; either
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
     9
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    10
    This library is distributed in the hope that it will be useful,
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    13
    Lesser General Public License for more details.
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    14
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    16
    License along with this library; if not, write to the Free Software
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    18
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    19
    Sam Lantinga
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    20
    slouken@libsdl.org
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5218
diff changeset
    21
*/
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#import "SDL_uikitview.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
    25
#include "../../events/SDL_keyboard_c.h"
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
    26
#include "../../events/SDL_mouse_c.h"
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
    27
#include "../../events/SDL_touch_c.h"
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
    28
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#if SDL_IPHONE_KEYBOARD
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#import "keyinfotable.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#import "SDL_uikitappdelegate.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#import "SDL_uikitwindow.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#endif
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
@implementation SDL_uikitview
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
- (void)dealloc {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    38
    [super dealloc];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
- (id)initWithFrame:(CGRect)frame {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    43
    self = [super initWithFrame: frame];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    44
    
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
#if SDL_IPHONE_KEYBOARD
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    46
    [self initializeKeyboard];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    47
#endif    
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
    49
#ifdef FIXED_MULTITOUCH
5445
b2bcc3c36fa3 Enabled multi-touch
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    50
    self.multipleTouchEnabled = YES;
b2bcc3c36fa3 Enabled multi-touch
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    51
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    52
    SDL_Touch touch;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    53
    touch.id = 0; //TODO: Should be -1?
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
    54
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    55
    //touch.driverdata = SDL_malloc(sizeof(EventTouchData));
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    56
    //EventTouchData* data = (EventTouchData*)(touch.driverdata);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    57
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    58
    touch.x_min = 0;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    59
    touch.x_max = frame.size.width;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    60
    touch.native_xres = touch.x_max - touch.x_min;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    61
    touch.y_min = 0;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    62
    touch.y_max = frame.size.height;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    63
    touch.native_yres = touch.y_max - touch.y_min;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    64
    touch.pressure_min = 0;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    65
    touch.pressure_max = 1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    66
    touch.native_pressureres = touch.pressure_max - touch.pressure_min;
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
    67
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
    68
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    69
    touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
    70
#endif
4661
03dcb795c583 Merged changes from the main SDL codebase
Sam Lantinga <slouken@libsdl.org>
parents: 4660 4490
diff changeset
    71
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    72
    return self;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    78
    NSEnumerator *enumerator = [touches objectEnumerator];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    79
    UITouch *touch = (UITouch*)[enumerator nextObject];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    80
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    81
    //NSLog("Click");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    82
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    83
    if (touch) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    84
        CGPoint locationInView = [touch locationInView: self];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    85
            
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    86
        /* send moved event */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    87
        SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
4488
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
    88
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    89
        /* send mouse down event */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    90
        SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    91
    }
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
    92
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
    93
#ifdef FIXED_MULTITOUCH
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    94
    while(touch) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    95
      CGPoint locationInView = [touch locationInView: self];
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
    96
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
    97
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
    98
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
    99
      //FIXME: TODO: Using touch as the fingerId is potentially dangerous
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   100
      //It is also much more efficient than storing the UITouch pointer
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   101
      //and comparing it to the incoming event.
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   102
      SDL_SendFingerDown(touchId,(long)touch,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   103
                 SDL_TRUE,locationInView.x,locationInView.y,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   104
                 1);
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   105
#else
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   106
      int i;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   107
      for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   108
        if(finger[i] == NULL) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   109
          finger[i] = touch;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   110
          SDL_SendFingerDown(touchId,i,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   111
                 SDL_TRUE,locationInView.x,locationInView.y,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   112
                 1);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   113
          break;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   114
        }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   115
      }
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   116
#endif
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   117
      
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   118
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   119
      
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
   120
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   121
      touch = (UITouch*)[enumerator nextObject]; 
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   122
    }
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
   123
#endif
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   127
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   128
    NSEnumerator *enumerator = [touches objectEnumerator];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   129
    UITouch *touch = (UITouch*)[enumerator nextObject];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   130
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   131
    if (touch) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   132
        /* send mouse up */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   133
        SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   134
    }
4661
03dcb795c583 Merged changes from the main SDL codebase
Sam Lantinga <slouken@libsdl.org>
parents: 4660 4490
diff changeset
   135
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
   136
#ifdef FIXED_MULTITOUCH
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   137
    while(touch) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   138
      CGPoint locationInView = [touch locationInView: self];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   139
      
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   140
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   141
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   142
      SDL_SendFingerDown(touchId,(long)touch,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   143
                 SDL_FALSE,locationInView.x,locationInView.y,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   144
                 1);
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   145
#else
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   146
      int i;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   147
      for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   148
        if(finger[i] == touch) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   149
          SDL_SendFingerDown(touchId,i,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   150
                 SDL_FALSE,locationInView.x,locationInView.y,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   151
                 1);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   152
          break;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   153
        }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   154
      }
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   155
#endif
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
   156
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   157
      touch = (UITouch*)[enumerator nextObject]; 
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   158
    }
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
   159
#endif
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   163
    /*
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   164
        this can happen if the user puts more than 5 touches on the screen
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   165
        at once, or perhaps in other circumstances.  Usually (it seems)
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   166
        all active touches are canceled.
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   167
    */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   168
    [self touchesEnded: touches withEvent: event];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   172
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   173
    NSEnumerator *enumerator = [touches objectEnumerator];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   174
    UITouch *touch = (UITouch*)[enumerator nextObject];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   175
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   176
    if (touch) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   177
        CGPoint locationInView = [touch locationInView: self];
4488
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   178
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   179
        /* send moved event */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   180
        SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   181
    }
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
   182
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
   183
#ifdef FIXED_MULTITOUCH
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   184
    while(touch) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   185
      CGPoint locationInView = [touch locationInView: self];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   186
      
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   187
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   188
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   189
      SDL_SendTouchMotion(touchId,(long)touch,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   190
                  SDL_FALSE,locationInView.x,locationInView.y,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   191
                  1);
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   192
#else
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   193
      int i;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   194
      for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   195
        if(finger[i] == touch) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   196
          SDL_SendTouchMotion(touchId,i,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   197
                  SDL_FALSE,locationInView.x,locationInView.y,
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   198
                  1);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   199
          break;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   200
        }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   201
      }
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
   202
#endif
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
   203
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   204
      touch = (UITouch*)[enumerator nextObject]; 
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   205
    }
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
   206
#endif
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
/*
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   210
    ---- Keyboard related functionality below this line ----
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
*/
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
#if SDL_IPHONE_KEYBOARD
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
/* Is the iPhone virtual keyboard visible onscreen? */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
- (BOOL)keyboardVisible {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   216
    return keyboardVisible;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
/* Set ourselves up as a UITextFieldDelegate */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
- (void)initializeKeyboard {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   221
        
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   222
    textField = [[UITextField alloc] initWithFrame: CGRectZero];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   223
    textField.delegate = self;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   224
    /* placeholder so there is something to delete! */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   225
    textField.text = @" ";    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   226
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   227
    /* set UITextInputTrait properties, mostly to defaults */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   228
    textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   229
    textField.autocorrectionType = UITextAutocorrectionTypeNo;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   230
    textField.enablesReturnKeyAutomatically = NO;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   231
    textField.keyboardAppearance = UIKeyboardAppearanceDefault;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   232
    textField.keyboardType = UIKeyboardTypeDefault;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   233
    textField.returnKeyType = UIReturnKeyDefault;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   234
    textField.secureTextEntry = NO;    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   235
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   236
    textField.hidden = YES;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   237
    keyboardVisible = NO;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   238
    /* add the UITextField (hidden) to our view */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   239
    [self addSubview: textField];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   240
    [textField release];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
/* reveal onscreen virtual keyboard */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
- (void)showKeyboard {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   245
    keyboardVisible = YES;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   246
    [textField becomeFirstResponder];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
/* hide onscreen virtual keyboard */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
- (void)hideKeyboard {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   251
    keyboardVisible = NO;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   252
    [textField resignFirstResponder];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
/* UITextFieldDelegate method.  Invoked when user types something. */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   257
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   258
    if ([string length] == 0) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   259
        /* it wants to replace text with nothing, ie a delete */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   260
        SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   261
        SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   262
    }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   263
    else {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   264
        /* go through all the characters in the string we've been sent
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   265
           and convert them to key presses */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   266
        int i;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   267
        for (i=0; i<[string length]; i++) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   268
            
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   269
            unichar c = [string characterAtIndex: i];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   270
            
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   271
            Uint16 mod = 0;
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5134
diff changeset
   272
            SDL_Scancode code;
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   273
            
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   274
            if (c < 127) {
5218
572a73d71b5f Sheena pointed out that "scancode" and "keysym" are single words and shouldn't be camel-cased.
Sam Lantinga <slouken@libsdl.org>
parents: 5134
diff changeset
   275
                /* figure out the SDL_Scancode and SDL_keymod for this unichar */
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   276
                code = unicharToUIKeyInfoTable[c].code;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   277
                mod  = unicharToUIKeyInfoTable[c].mod;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   278
            }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   279
            else {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   280
                /* we only deal with ASCII right now */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   281
                code = SDL_SCANCODE_UNKNOWN;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   282
                mod = 0;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   283
            }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   284
            
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   285
            if (mod & KMOD_SHIFT) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   286
                /* If character uses shift, press shift down */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   287
                SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   288
            }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   289
            /* send a keydown and keyup even for the character */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   290
            SDL_SendKeyboardKey(SDL_PRESSED, code);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   291
            SDL_SendKeyboardKey(SDL_RELEASED, code);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   292
            if (mod & KMOD_SHIFT) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   293
                /* If character uses shift, press shift back up */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   294
                SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   295
            }            
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   296
        }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   297
    }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   298
    return NO; /* don't allow the edit! (keep placeholder text there) */
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
/* Terminates the editing session */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
- (BOOL)textFieldShouldReturn:(UITextField*)_textField {
5134
c63b901d97ab Fixed bug #1025 (iphone keyboard doesn't send 'return' and 'backspace' events)
Sam Lantinga <slouken@libsdl.org>
parents: 5132
diff changeset
   303
    SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   304
    [self hideKeyboard];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   305
    return YES;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
#endif
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
@end
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
/* iPhone keyboard addition functions */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
#if SDL_IPHONE_KEYBOARD
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 2940
diff changeset
   315
int SDL_iPhoneKeyboardShow(SDL_Window * window) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   316
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   317
    SDL_WindowData *data;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   318
    SDL_uikitview *view;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   319
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   320
    if (NULL == window) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   321
        SDL_SetError("Window does not exist");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   322
        return -1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   323
    }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   324
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   325
    data = (SDL_WindowData *)window->driverdata;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   326
    view = data->view;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   327
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   328
    if (nil == view) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   329
        SDL_SetError("Window has no view");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   330
        return -1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   331
    }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   332
    else {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   333
        [view showKeyboard];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   334
        return 0;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   335
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 2940
diff changeset
   338
int SDL_iPhoneKeyboardHide(SDL_Window * window) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   339
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   340
    SDL_WindowData *data;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   341
    SDL_uikitview *view;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   342
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   343
    if (NULL == window) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   344
        SDL_SetError("Window does not exist");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   345
        return -1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   346
    }    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   347
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   348
    data = (SDL_WindowData *)window->driverdata;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   349
    view = data->view;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   350
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   351
    if (NULL == view) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   352
        SDL_SetError("Window has no view");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   353
        return -1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   354
    }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   355
    else {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   356
        [view hideKeyboard];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   357
        return 0;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   358
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 2940
diff changeset
   361
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   362
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   363
    SDL_WindowData *data;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   364
    SDL_uikitview *view;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   365
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   366
    if (NULL == window) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   367
        SDL_SetError("Window does not exist");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   368
        return -1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   369
    }    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   370
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   371
    data = (SDL_WindowData *)window->driverdata;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   372
    view = data->view;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   373
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   374
    if (NULL == view) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   375
        SDL_SetError("Window has no view");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   376
        return 0;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   377
    }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   378
    else {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   379
        return view.keyboardVisible;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   380
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 2940
diff changeset
   383
int SDL_iPhoneKeyboardToggle(SDL_Window * window) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   384
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   385
    SDL_WindowData *data;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   386
    SDL_uikitview *view;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   387
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   388
    if (NULL == window) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   389
        SDL_SetError("Window does not exist");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   390
        return -1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   391
    }    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   392
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   393
    data = (SDL_WindowData *)window->driverdata;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   394
    view = data->view;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   395
    
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   396
    if (NULL == view) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   397
        SDL_SetError("Window has no view");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   398
        return -1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   399
    }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   400
    else {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   401
        if (SDL_iPhoneKeyboardIsShown(window)) {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   402
            SDL_iPhoneKeyboardHide(window);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   403
        }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   404
        else {
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   405
            SDL_iPhoneKeyboardShow(window);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   406
        }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   407
        return 0;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   408
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
#else
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   412
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   413
/* stubs, used if compiled without keyboard support */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   414
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 2940
diff changeset
   415
int SDL_iPhoneKeyboardShow(SDL_Window * window) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   416
    SDL_SetError("Not compiled with keyboard support");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   417
    return -1;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   418
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   419
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 2940
diff changeset
   420
int SDL_iPhoneKeyboardHide(SDL_Window * window) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   421
    SDL_SetError("Not compiled with keyboard support");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   422
    return -1;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   423
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   424
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 2940
diff changeset
   425
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   426
    return 0;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   427
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   428
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 2940
diff changeset
   429
int SDL_iPhoneKeyboardToggle(SDL_Window * window) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   430
    SDL_SetError("Not compiled with keyboard support");
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5081
diff changeset
   431
    return -1;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   432
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   433
5132
5f09cb749d75 Added vim spacing hints
Sam Lantinga <slouken@libsdl.org>
parents: 5131
diff changeset
   434
#endif /* SDL_IPHONE_KEYBOARD */
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   435
5132
5f09cb749d75 Added vim spacing hints
Sam Lantinga <slouken@libsdl.org>
parents: 5131
diff changeset
   436
/* vi: set ts=4 sw=4 expandtab: */