cocoaTouch/SDLOverrides/SDL_uikitview.m
author nemo
Sun, 14 Mar 2010 14:28:14 +0000
changeset 2984 f6834fc9fe7b
parent 2805 36a8cebb91e8
child 3006 da6023c2745b
permissions -rw-r--r--
Make underwater droplets more visible, add splash
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     1
/*
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     2
 SDL - Simple DirectMedia Layer
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     3
 Copyright (C) 1997-2009 Sam Lantinga
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     4
 
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     5
 This library is free software; you can redistribute it and/or
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     6
 modify it under the terms of the GNU Lesser General Public
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     7
 License as published by the Free Software Foundation; either
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     8
 version 2.1 of the License, or (at your option) any later version.
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     9
 
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    10
 This library is distributed in the hope that it will be useful,
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    13
 Lesser General Public License for more details.
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    14
 
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    15
 You should have received a copy of the GNU Lesser General Public
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    16
 License along with this library; if not, write to the Free Software
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    17
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    18
 
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    19
 Sam Lantinga, mods for Hedgewars by Vittorio Giovara
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    20
 slouken@libsdl.org, vittorio.giovara@gmail.com
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    21
 */
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    22
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
    23
#import "PascalImports.h"
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
    24
#import "CGPointUtils.h"
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    25
#import "SDL_uikitview.h"
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    26
#import "SDL_uikitappdelegate.h"
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    27
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    28
#if SDL_IPHONE_KEYBOARD
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    29
#import "SDL_keyboard_c.h"
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    30
#import "keyinfotable.h"
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    31
#import "SDL_uikitwindow.h"
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    32
#endif
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    33
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    34
@implementation SDL_uikitview
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    35
2689
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
    36
// they have to be global variables to allow showControls() to use them
2805
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
    37
//UIButton *attackButton, *menuButton;
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
    38
UIView *menuView;
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
    39
-(void) dealloc {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    40
#if SDL_IPHONE_KEYBOARD
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    41
	SDL_DelKeyboard(0);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    42
	[textField release];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    43
#endif
2805
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
    44
	if (menuView) [menuView release];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
    45
	//[menuButton release];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
    46
	//[attackButton release];
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    47
	[super dealloc];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    48
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    49
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    50
- (id)initWithFrame:(CGRect)frame {
2689
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
    51
	// the addTarget parameter for the buttons below is set like that because
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
    52
	// this object is inherited by SDL_openglesview.m which is the one allocated by SDL.
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
    53
	// We select this class with [self superclass] and call the selectors with "+" because
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
    54
	// they are superclass methods 
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
    55
	self = [super initWithFrame:frame];
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    56
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    57
#if SDL_IPHONE_KEYBOARD
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    58
	[self initializeKeyboard];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    59
#endif	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    60
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    61
	int i;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    62
	for (i=0; i<MAX_SIMULTANEOUS_TOUCHES; i++) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    63
        mice[i].id = i;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    64
		mice[i].driverdata = NULL;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    65
		SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    66
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    67
2724
601158aaa201 redo LANDSCAPE MODE in a saner way with lots of fps
koda
parents: 2714
diff changeset
    68
	self.multipleTouchEnabled = YES;
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
    69
	self.exclusiveTouch = YES;
2805
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
    70
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
    71
	
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
    72
	/*
2724
601158aaa201 redo LANDSCAPE MODE in a saner way with lots of fps
koda
parents: 2714
diff changeset
    73
	// custom code
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    74
	// the coordinate system is still like in Portrait even though everything is rotated
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    75
	attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260, 50)];
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    76
	[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal];
2705
2b5625c4ec16 fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents: 2701
diff changeset
    77
	[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateHighlighted];
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    78
	[attackButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchDown];
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    79
	[attackButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    80
	//[self addSubview:attackButton];
2689
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
    81
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    82
	menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 480, 30, 50)];
2689
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
    83
	[menuButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal];
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
    84
	[menuButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchUpInside];
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    85
	[menuButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    86
	//[self addSubview:menuButton];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    87
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    88
	UIButton *walkLeftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    89
	[walkLeftButton addTarget:[self superclass] action:@selector(walkingLeft) forControlEvents:UIControlEventTouchDown];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    90
	[walkLeftButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    91
	[self insertSubview:walkLeftButton atIndex:0];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    92
	[walkLeftButton release];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    93
	
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    94
	UIButton *walkRightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 380, 320, 100)];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    95
	[walkRightButton addTarget:[self superclass] action:@selector(walkingRight) forControlEvents:UIControlEventTouchDown];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    96
	[walkRightButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    97
	[self insertSubview:walkRightButton atIndex:0];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
    98
	[walkRightButton release];
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    99
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   100
	UIButton *moveDownButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, 70, 280)];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   101
	[moveDownButton addTarget:[self superclass] action:@selector(movingDown) forControlEvents:UIControlEventTouchDown];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   102
	[moveDownButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   103
	[self insertSubview:moveDownButton atIndex:0];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   104
	[moveDownButton release];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   105
	
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   106
	UIButton *moveUpButton = [[UIButton alloc] initWithFrame:CGRectMake(250, 100, 70, 280)];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   107
	[moveUpButton addTarget:[self superclass] action:@selector(movingUp) forControlEvents:UIControlEventTouchDown];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   108
	[moveUpButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   109
	[self insertSubview:moveUpButton atIndex:0];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   110
	[moveUpButton release];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   111
	
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   112
	//dummy button used to test chat
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   113
	UIButton *chatButton = [[UIButton alloc] initWithFrame:CGRectMake(70, 100, 250, 280)];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   114
	[chatButton addTarget:[self superclass] action:@selector(chatBegin) forControlEvents:UIControlEventTouchDown];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   115
	[self insertSubview:chatButton atIndex:0];
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   116
	[chatButton release];
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   117
	*/
2805
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   118
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   119
//(0,0) is the lower left corner
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   120
//x:[0-320]
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   121
//y:[0-480]
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   122
	UIButton *menuButton = [[UIButton alloc] initWithFrame:CGRectMake(256, 416, 64, 64)];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   123
	[menuButton addTarget:[self superclass] action:@selector(showMenu) forControlEvents:UIControlEventTouchDown];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   124
	[menuButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   125
	[self insertSubview:menuButton atIndex:0];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   126
	[menuButton release];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   127
	
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   128
	menuView = [[UIView alloc] initWithFrame:CGRectMake(320, 480, 150, 100)];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   129
	menuView.backgroundColor = [UIColor lightGrayColor];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   130
	[self insertSubview:menuView atIndex:1];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   131
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   132
	return self;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   133
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   134
2805
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   135
+(void) showMenu {
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   136
	HW_pause();
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   137
	
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   138
	[UIView beginAnimations:@"show menu" context:NULL];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   139
	[UIView setAnimationDuration:1];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   140
	
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   141
	menuView.frame = CGRectMake(170, 380, 150, 100);
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   142
	
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   143
	[UIView commitAnimations];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   144
}
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   145
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   146
+(void) hideMenu {
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   147
	[UIView beginAnimations:@"hide menu" context:NULL];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   148
	[UIView setAnimationDuration:1];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   149
	
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   150
	menuView.frame = CGRectMake(480, -70, 150, 100);
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   151
	
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   152
	[UIView commitAnimations];
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   153
	
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   154
	HW_pause();
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   155
}
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   156
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   157
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   158
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   159
#pragma mark -
2690
8e83c7e31720 move mixed functions in PascalExports
koda
parents: 2689
diff changeset
   160
#pragma mark Exported functions for FreePascal
8e83c7e31720 move mixed functions in PascalExports
koda
parents: 2689
diff changeset
   161
const char* IPH_getDocumentsPath() {
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   162
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   163
	NSString *documentsDirectory = [paths objectAtIndex: 0];
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   164
	return [documentsDirectory UTF8String];
2690
8e83c7e31720 move mixed functions in PascalExports
koda
parents: 2689
diff changeset
   165
}
8e83c7e31720 move mixed functions in PascalExports
koda
parents: 2689
diff changeset
   166
8e83c7e31720 move mixed functions in PascalExports
koda
parents: 2689
diff changeset
   167
void IPH_showControls (void) {
2689
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
   168
	NSLog(@"Showing controls");
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   169
	/*
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   170
	[UIView beginAnimations:nil context:NULL];
2689
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
   171
	[UIView setAnimationDuration:0.5];
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
   172
	attackButton.frame = CGRectMake(30, 430, 260, 50);
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
   173
	menuButton.frame = CGRectMake(0, 430, 30, 50);
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
   174
	[UIView commitAnimations];
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   175
	 */
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   176
}
2689
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
   177
dfda97c153a4 iphone overlay button animation
koda
parents: 2688
diff changeset
   178
#pragma mark -
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   179
#pragma mark Superclass methods to call Pascal code
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   180
+(void) attackButtonPressed {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   181
	HW_shoot();
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   182
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   183
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   184
+(void) buttonsReleased {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   185
	HW_allKeysUp();
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   186
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   187
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   188
+(void) walkingLeft {
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   189
	HW_walkLeft();
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   190
}
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   191
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   192
+(void) walkingRight {
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   193
	HW_walkRight();
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   194
}
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   195
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   196
+(void) movingUp {
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   197
	HW_aimUp();
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   198
}
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   199
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   200
+(void) movingDown {
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   201
	HW_aimDown();
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   202
}
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   203
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   204
+(void) chatBegin {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   205
	//TODO: implement a UITextScroll and put received chat lines in there
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   206
}
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   207
2805
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   208
+(void) pauseGame {
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   209
	HW_pause();
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   210
}
36a8cebb91e8 new menupage ingame for common actions
koda
parents: 2772
diff changeset
   211
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   212
#pragma mark -
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   213
#pragma mark Custom SDL_UIView input handling
2754
ad4f81fbfb76 touchinput works, invisible buttons added and initial support for chat
koda
parents: 2740
diff changeset
   214
#define kMinimumPinchDelta	50
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   215
#define kMinimumGestureLength	10
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   216
#define kMaximumVariance	3
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   217
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   218
// we override default touch input to implement our own gestures
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   219
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   220
	NSArray *twoTouches;
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   221
	UITouch *touch = [touches anyObject];
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   222
	
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   223
	switch ([touches count]) {
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   224
		case 1:
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   225
			gestureStartPoint = [touch locationInView:self];
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   226
			initialDistanceForPinching = 0;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   227
			switch ([touch tapCount]) {
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   228
				case 1:
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   229
					
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   230
					NSLog(@"X:%d Y:%d", (int)gestureStartPoint.x, (int)gestureStartPoint.y );
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   231
					SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, 
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   232
							      (int)gestureStartPoint.y, 320 - (int)gestureStartPoint.x);
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   233
					HW_click();
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   234
					break;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   235
				case 2:
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   236
					HW_ammoMenu();
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   237
					break;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   238
				default:
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   239
					break;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   240
			}
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   241
			break;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   242
		case 2:
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   243
			if (2 == [touch tapCount]) {
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   244
				HW_zoomReset();
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   245
			}
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   246
			
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   247
			// pinching
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   248
			twoTouches = [touches allObjects];
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   249
			UITouch *first = [twoTouches objectAtIndex:0];
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   250
			UITouch *second = [twoTouches objectAtIndex:1];
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   251
			initialDistanceForPinching = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   252
			break;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   253
		default:
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   254
			break;
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   255
	}
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   256
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   257
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   258
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   259
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   260
	initialDistanceForPinching = 0;
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   261
	gestureStartPoint.x = 0;
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   262
	gestureStartPoint.y = 0;
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   263
	HW_allKeysUp();
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   264
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   265
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   266
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   267
	// this can happen if the user puts more than 5 touches on the screen at once, or perhaps in other circumstances.
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   268
	// Usually (it seems) all active touches are canceled.
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   269
	[self touchesEnded:touches withEvent:event];
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   270
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   271
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   272
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   273
	NSArray *twoTouches;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   274
	CGPoint currentPosition;
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   275
	UITouch *touch = [touches anyObject];
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   276
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   277
	switch ([touches count]) {
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   278
		case 1:
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   279
			currentPosition = [touch locationInView:self];
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   280
			// panning
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   281
			SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, 
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   282
							(int)gestureStartPoint.y, 320 - (int)gestureStartPoint.x);
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   283
			// remember that we have x and y inverted
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   284
			/* temporarily disabling hog movements for camera panning testing
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   285
			CGFloat vertDiff = gestureStartPoint.x - currentPosition.x;
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   286
			CGFloat horizDiff = gestureStartPoint.y - currentPosition.y;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   287
			CGFloat deltaX = fabsf(vertDiff);
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   288
			CGFloat deltaY = fabsf(horizDiff);
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   289
			
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   290
			if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance) {
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   291
				NSLog(@"Horizontal swipe detected, begX:%f curX:%f", gestureStartPoint.x, currentPosition.x);
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   292
				if (horizDiff > 0) HW_walkLeft();
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   293
				else HW_walkRight();
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   294
			} else if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance){
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   295
				NSLog(@"Vertical swipe detected, begY:%f curY:%f", gestureStartPoint.y, currentPosition.y);
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   296
				if (vertDiff < 0) HW_aimUp();
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   297
				else HW_aimDown();
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   298
			}
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2725
diff changeset
   299
			*/
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   300
			break;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   301
		case 2:
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   302
			twoTouches = [touches allObjects];
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   303
			UITouch *first = [twoTouches objectAtIndex:0];
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   304
			UITouch *second = [twoTouches objectAtIndex:1];
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   305
			CGFloat currentDistanceOfPinching = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   306
			
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   307
			if (0 == initialDistanceForPinching) 
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   308
				initialDistanceForPinching = currentDistanceOfPinching;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   309
2738
bfccb2ec4334 new graphics from Tiy and frontend is loaded in landscape mode
koda
parents: 2734
diff changeset
   310
			if (currentDistanceOfPinching < initialDistanceForPinching + kMinimumPinchDelta)
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   311
				HW_zoomOut();
2738
bfccb2ec4334 new graphics from Tiy and frontend is loaded in landscape mode
koda
parents: 2734
diff changeset
   312
			else if (currentDistanceOfPinching > initialDistanceForPinching + kMinimumPinchDelta)
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   313
				HW_zoomIn();
2738
bfccb2ec4334 new graphics from Tiy and frontend is loaded in landscape mode
koda
parents: 2734
diff changeset
   314
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   315
			currentDistanceOfPinching = initialDistanceForPinching;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   316
			break;
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   317
		default:
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2724
diff changeset
   318
			break;
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   319
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   320
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   321
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   322
/*
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   323
#pragma mark -
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   324
#pragma mark Keyboard related functionality
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   325
#if SDL_IPHONE_KEYBOARD
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   326
// Is the iPhone virtual keyboard visible onscreen? 
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   327
- (BOOL)keyboardVisible {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   328
	return keyboardVisible;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   329
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   330
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   331
// Set ourselves up as a UITextFieldDelegate
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   332
- (void)initializeKeyboard {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   333
		
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   334
	textField = [[[UITextField alloc] initWithFrame: CGRectZero] autorelease];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   335
	textField.delegate = self;
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   336
	// placeholder so there is something to delete!
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   337
	textField.text = @" ";	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   338
	
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   339
	// set UITextInputTrait properties, mostly to defaults
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   340
	textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   341
	textField.autocorrectionType = UITextAutocorrectionTypeNo;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   342
	textField.enablesReturnKeyAutomatically = NO;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   343
	textField.keyboardAppearance = UIKeyboardAppearanceDefault;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   344
	textField.keyboardType = UIKeyboardTypeDefault;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   345
	textField.returnKeyType = UIReturnKeyDefault;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   346
	textField.secureTextEntry = NO;	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   347
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   348
	textField.hidden = YES;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   349
	keyboardVisible = NO;
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   350
	// add the UITextField (hidden) to our view
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   351
	[self addSubview: textField];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   352
	
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   353
	// create our SDL_Keyboard
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   354
	SDL_Keyboard keyboard;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   355
	SDL_zero(keyboard);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   356
	SDL_AddKeyboard(&keyboard, 0);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   357
	SDLKey keymap[SDL_NUM_SCANCODES];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   358
	SDL_GetDefaultKeymap(keymap);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   359
	SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   360
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   361
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   362
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   363
// reveal onscreen virtual keyboard
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   364
- (void)showKeyboard {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   365
	keyboardVisible = YES;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   366
	[textField becomeFirstResponder];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   367
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   368
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   369
// hide onscreen virtual keyboard
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   370
- (void)hideKeyboard {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   371
	keyboardVisible = NO;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   372
	[textField resignFirstResponder];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   373
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   374
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   375
// UITextFieldDelegate method.  Invoked when user types something.
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   376
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   377
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   378
	if ([string length] == 0) {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   379
		// it wants to replace text with nothing, ie a delete
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   380
		SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   381
		SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   382
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   383
	else {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   384
		// go through all the characters in the string we've been sent and convert them to key presses
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   385
		int i;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   386
		for (i=0; i<[string length]; i++) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   387
			
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   388
			unichar c = [string characterAtIndex: i];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   389
			
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   390
			Uint16 mod = 0;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   391
			SDL_scancode code;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   392
			
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   393
			if (c < 127) {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   394
				// figure out the SDL_scancode and SDL_keymod for this unichar
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   395
				code = unicharToUIKeyInfoTable[c].code;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   396
				mod  = unicharToUIKeyInfoTable[c].mod;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   397
			}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   398
			else {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   399
				// we only deal with ASCII right now
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   400
				code = SDL_SCANCODE_UNKNOWN;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   401
				mod = 0;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   402
			}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   403
			
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   404
			if (mod & KMOD_SHIFT) {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   405
				// If character uses shift, press shift down
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   406
				SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   407
			}
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   408
			// send a keydown and keyup even for the character
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   409
			SDL_SendKeyboardKey( 0, SDL_PRESSED, code);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   410
			SDL_SendKeyboardKey( 0, SDL_RELEASED, code);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   411
			if (mod & KMOD_SHIFT) {
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   412
				// If character uses shift, press shift back up
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   413
				SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   414
			}			
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   415
		}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   416
	}
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   417
	return NO; // don't allow the edit! (keep placeholder text there)
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   418
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   419
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   420
// Terminates the editing session
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   421
- (BOOL)textFieldShouldReturn:(UITextField*)_textField {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   422
	[self hideKeyboard];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   423
	return YES;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   424
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   425
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   426
#endif
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   427
*/
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   428
@end
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   429
/*
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   430
// iPhone keyboard addition functions
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   431
#if SDL_IPHONE_KEYBOARD
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   432
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   433
int SDL_iPhoneKeyboardShow(SDL_Window *window) {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   434
	SDL_WindowData *data;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   435
	SDL_uikitview *view;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   436
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   437
	if (NULL == window) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   438
		SDL_SetError("Window does not exist");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   439
		return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   440
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   441
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   442
	data = (SDL_WindowData *)window->driverdata;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   443
	view = data->view;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   444
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   445
	if (nil == view) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   446
		SDL_SetError("Window has no view");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   447
		return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   448
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   449
	else {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   450
		[view showKeyboard];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   451
		return 0;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   452
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   453
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   454
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   455
int SDL_iPhoneKeyboardHide(SDL_Window *window) {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   456
	SDL_WindowData *data;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   457
	SDL_uikitview *view;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   458
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   459
	if (NULL == window) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   460
		SDL_SetError("Window does not exist");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   461
		return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   462
	}	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   463
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   464
	data = (SDL_WindowData *)window->driverdata;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   465
	view = data->view;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   466
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   467
	if (NULL == view) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   468
		SDL_SetError("Window has no view");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   469
		return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   470
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   471
	else {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   472
		[view hideKeyboard];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   473
		return 0;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   474
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   475
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   476
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   477
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window *window) {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   478
	SDL_WindowData *data;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   479
	SDL_uikitview *view;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   480
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   481
	if (NULL == window) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   482
		SDL_SetError("Window does not exist");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   483
		return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   484
	}	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   485
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   486
	data = (SDL_WindowData *)window->driverdata;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   487
	view = data->view;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   488
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   489
	if (NULL == view) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   490
		SDL_SetError("Window has no view");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   491
		return 0;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   492
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   493
	else {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   494
		return view.keyboardVisible;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   495
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   496
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   497
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   498
int SDL_iPhoneKeyboardToggle(SDL_Window *window) {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   499
	SDL_WindowData *data;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   500
	SDL_uikitview *view;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   501
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   502
	if (NULL == window) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   503
		SDL_SetError("Window does not exist");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   504
		return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   505
	}	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   506
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   507
	data = (SDL_WindowData *)window->driverdata;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   508
	view = data->view;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   509
	
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   510
	if (NULL == view) {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   511
		SDL_SetError("Window has no view");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   512
		return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   513
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   514
	else {
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   515
		if (SDL_iPhoneKeyboardIsShown(window)) {
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   516
			SDL_iPhoneKeyboardHide(window);
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   517
		}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   518
		else {
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   519
			SDL_iPhoneKeyboardShow(window);
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   520
		}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   521
		return 0;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   522
	}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   523
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   524
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   525
#else
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   526
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2754
diff changeset
   527
// stubs, used if compiled without keyboard support
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   528
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   529
int SDL_iPhoneKeyboardShow(SDL_Window *window) {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   530
	SDL_SetError("Not compiled with keyboard support");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   531
	return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   532
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   533
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   534
int SDL_iPhoneKeyboardHide(SDL_Window *window) {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   535
	SDL_SetError("Not compiled with keyboard support");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   536
	return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   537
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   538
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   539
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window *window) {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   540
	return 0;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   541
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   542
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2705
diff changeset
   543
int SDL_iPhoneKeyboardToggle(SDL_Window *window) {
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   544
	SDL_SetError("Not compiled with keyboard support");
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   545
	return -1;
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   546
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   547
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   548
#endif /* SDL_IPHONE_KEYBOARD */