--- a/cocoaTouch/SDLOverrides/SDL_uikitview.h Thu Feb 04 22:34:21 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitview.h Fri Feb 05 00:43:56 2010 +0000
@@ -56,7 +56,12 @@
// see initWithFrame for why "+"
+(void) attackButtonPressed;
-+(void) attackButtonReleased;
++(void) buttonsReleased;
++(void) walkingLeft;
++(void) walkingRight;
++(void) movingUp;
++(void) movingDown;
++(void) chatBegin;
#if SDL_IPHONE_KEYBOARD
- (void)showKeyboard;
--- a/cocoaTouch/SDLOverrides/SDL_uikitview.m Thu Feb 04 22:34:21 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitview.m Fri Feb 05 00:43:56 2010 +0000
@@ -66,20 +66,50 @@
self.multipleTouchEnabled = YES;
// custom code
- attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260,50)];
+ // the coordinate system is still like in Portrait even though everything is rotated
+ attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260, 50)];
[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal];
[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateHighlighted];
[attackButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchDown];
- [attackButton addTarget:[self superclass] action:@selector(attackButtonReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
- [self addSubview:attackButton];
+ [attackButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
+ //[self addSubview:attackButton];
- menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 480, 30,50)];
+ menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 480, 30, 50)];
[menuButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal];
[menuButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchUpInside];
- [menuButton addTarget:[self superclass] action:@selector(attackButtonReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
- [self addSubview:menuButton];
+ [menuButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
+ //[self addSubview:menuButton];
+
+ UIButton *walkLeftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
+ [walkLeftButton addTarget:[self superclass] action:@selector(walkingLeft) forControlEvents:UIControlEventTouchDown];
+ [walkLeftButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
+ [self insertSubview:walkLeftButton atIndex:0];
+ [walkLeftButton release];
+
+ UIButton *walkRightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 380, 320, 100)];
+ [walkRightButton addTarget:[self superclass] action:@selector(walkingRight) forControlEvents:UIControlEventTouchDown];
+ [walkRightButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
+ [self insertSubview:walkRightButton atIndex:0];
+ [walkRightButton release];
-
+ UIButton *moveDownButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, 70, 280)];
+ [moveDownButton addTarget:[self superclass] action:@selector(movingDown) forControlEvents:UIControlEventTouchDown];
+ [moveDownButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
+ [self insertSubview:moveDownButton atIndex:0];
+ [moveDownButton release];
+
+ UIButton *moveUpButton = [[UIButton alloc] initWithFrame:CGRectMake(250, 100, 70, 280)];
+ [moveUpButton addTarget:[self superclass] action:@selector(movingUp) forControlEvents:UIControlEventTouchDown];
+ [moveUpButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
+ [self insertSubview:moveUpButton atIndex:0];
+ [moveUpButton release];
+
+ //dummy button used to test chat
+ UIButton *chatButton = [[UIButton alloc] initWithFrame:CGRectMake(70, 100, 250, 280)];
+ [chatButton addTarget:[self superclass] action:@selector(chatBegin) forControlEvents:UIControlEventTouchDown];
+ [self insertSubview:chatButton atIndex:0];
+ [chatButton release];
+
return self;
}
@@ -101,18 +131,39 @@
}
#pragma mark -
-#pragma mark Superclass methods
+#pragma mark Superclass methods to call Pascal code
+(void) attackButtonPressed {
HW_shoot();
}
-+(void) attackButtonReleased {
++(void) buttonsReleased {
HW_allKeysUp();
}
++(void) walkingLeft {
+ HW_walkLeft();
+}
+
++(void) walkingRight {
+ HW_walkRight();
+}
+
++(void) movingUp {
+ HW_aimUp();
+}
+
++(void) movingDown {
+ HW_aimDown();
+}
+
++(void) chatBegin {
+ HW_chat();
+ SDL_iPhoneKeyboardShow([SDLUIKitDelegate sharedAppDelegate].uiwindow);
+}
+
#pragma mark -
#pragma mark Custom SDL_UIView input handling
-#define kMinimumPinchDelta 40
+#define kMinimumPinchDelta 50
#define kMinimumGestureLength 10
#define kMaximumVariance 3
@@ -175,6 +226,7 @@
initialDistanceForPinching = 0;
switch ([touch tapCount]) {
case 1:
+ NSLog(@"X:%d Y:%d", (int) gestureStartPoint.x, gestureStartPoint.y );
SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window,
(int)gestureStartPoint.y, 320 - (int)gestureStartPoint.x);
HW_click();
--- a/cocoaTouch/otherSrc/PascalImports.h Thu Feb 04 22:34:21 2010 +0000
+++ b/cocoaTouch/otherSrc/PascalImports.h Fri Feb 05 00:43:56 2010 +0000
@@ -37,6 +37,9 @@
void HW_aimDown(void);
void HW_shoot(void);
+ void HW_chat(void);
+ void HW_tab(void);
+
#ifdef __cplusplus
}
#endif
--- a/hedgewars/PascalExports.pas Thu Feb 04 22:34:21 2010 +0000
+++ b/hedgewars/PascalExports.pas Fri Feb 05 00:43:56 2010 +0000
@@ -39,7 +39,8 @@
procedure HW_aimDown; cdecl; export;
procedure HW_shoot; cdecl; export;
procedure HW_whereIsHog; cdecl; export;
-
+procedure HW_chat; cdecl; export;
+procedure HW_tab; cdecl; export;
{$ENDIF}
implementation
@@ -78,11 +79,8 @@
procedure HW_allKeysUp; cdecl; export;
begin
- upKey:= false;
- downKey:= false;
- leftKey:= false;
- rightKey:= false;
- spaceKey:= false;
+ // set all keys to released
+ init_uKeys();
end;
procedure HW_walkLeft; cdecl; export;
@@ -110,6 +108,16 @@
spaceKey:= true;
end;
+procedure HW_chat; cdecl; export;
+begin
+ chatAction:= true;
+end;
+
+procedure HW_tab; cdecl; export;
+begin
+ switchAction:= true;
+end;
+
procedure HW_whereIsHog; cdecl; export;
//var Xcoord, Ycoord: LongInt;
begin
--- a/hedgewars/uKeys.pas Thu Feb 04 22:34:21 2010 +0000
+++ b/hedgewars/uKeys.pas Fri Feb 05 00:43:56 2010 +0000
@@ -46,6 +46,18 @@
var hideAmmoMenu: boolean;
wheelUp: boolean;
wheelDown: boolean;
+
+ ControllerNumControllers: Integer;
+ ControllerEnabled: Integer;
+ ControllerNumAxes: array[0..5] of Integer;
+ //ControllerNumBalls: array[0..5] of Integer;
+ ControllerNumHats: array[0..5] of Integer;
+ ControllerNumButtons: array[0..5] of Integer;
+ ControllerAxes: array[0..5] of array[0..19] of Integer;
+ //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer;
+ ControllerHats: array[0..5] of array[0..19] of Byte;
+ ControllerButtons: array[0..5] of array[0..19] of Byte;
+
{$IFDEF IPHONEOS}
leftClick: boolean;
middleClick: boolean;
@@ -60,20 +72,14 @@
spaceKey: boolean;
enterKey: boolean;
tabKey: boolean;
+
+ chatAction: boolean;
+ switchAction: boolean;
theJoystick: PSDL_Joystick;
+
+procedure setiPhoneBinds;
{$ENDIF}
- ControllerNumControllers: Integer;
- ControllerEnabled: Integer;
- ControllerNumAxes: array[0..5] of Integer;
- //ControllerNumBalls: array[0..5] of Integer;
- ControllerNumHats: array[0..5] of Integer;
- ControllerNumButtons: array[0..5] of Integer;
- ControllerAxes: array[0..5] of array[0..19] of Integer;
- //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer;
- ControllerHats: array[0..5] of array[0..19] of Byte;
- ControllerButtons: array[0..5] of array[0..19] of Byte;
-
implementation
uses uTeams, uConsole, uMisc, uStore;
const KeyNumber = 1024;
@@ -129,28 +135,9 @@
tkbdn[5]:= ord(wheelUp);
wheelUp:= false;
wheelDown:= false;
+
{$IFDEF IPHONEOS}
-tkbdn[1]:= ord(leftClick);
-tkbdn[2]:= ord(middleClick);
-tkbdn[3]:= ord(rightClick);
-leftClick:= false;
-middleClick:= false;
-rightClick:= false;
-
-tkbdn[23]:= ord(upKey);
-tkbdn[24]:= ord(downKey);
-tkbdn[25]:= ord(leftKey);
-tkbdn[26]:= ord(rightKey);
-
-tkbdn[ 8]:= ord(backspaceKey);
-tkbdn[ 9]:= ord(tabKey);
-tkbdn[13]:= ord(enterKey);
-tkbdn[32]:= ord(spaceKey);
-
-tabKey:= false;
-enterKey:= false;
-backspaceKey:= false;
-
+setiPhoneBinds();
{$ENDIF}
// Controller(s)
@@ -221,33 +208,14 @@
{$ENDIF}
tkbdn[2]:= ((k shr 1) and 1);
-// mouse wheels (see event loop in project file)
+// mouse wheels
tkbdn[4]:= ord(wheelDown);
tkbdn[5]:= ord(wheelUp);
wheelUp:= false;
wheelDown:= false;
{$IFDEF IPHONEOS}
-tkbdn[1]:= ord(leftClick);
-tkbdn[2]:= ord(middleClick);
-tkbdn[3]:= ord(rightClick);
-leftClick:= false;
-middleClick:= false;
-rightClick:= false;
-
-tkbdn[23]:= ord(upKey);
-tkbdn[24]:= ord(downKey);
-tkbdn[25]:= ord(leftKey);
-tkbdn[26]:= ord(rightKey);
-
-tkbdn[ 8]:= ord(backspaceKey);
-tkbdn[ 9]:= ord(tabKey);
-tkbdn[13]:= ord(enterKey);
-tkbdn[32]:= ord(spaceKey);
-
-tabKey:= false;
-enterKey:= false;
-backspaceKey:= false;
+setiPhoneBinds();
{$ENDIF}
// Controller(s)
@@ -330,19 +298,6 @@
end;
end;
-{$IFDEF IPHONEOS}
-DefaultBinds[ 1]:= '/put';
-DefaultBinds[ 3]:= 'ammomenu';
-DefaultBinds[ 8]:= 'hjump';
-DefaultBinds[ 9]:= 'switch';
-DefaultBinds[ 13]:= 'ljump';
-DefaultBinds[ 23]:= '+up';
-DefaultBinds[ 24]:= '+down';
-DefaultBinds[ 25]:= '+left';
-DefaultBinds[ 26]:= '+right';
-DefaultBinds[ 32]:= '+attack';
-{$ENDIF}
-
DefaultBinds[ 27]:= 'quit';
DefaultBinds[ 96]:= 'history';
DefaultBinds[127]:= 'rotmask';
@@ -366,19 +321,67 @@
DefaultBinds[KeyNameToCode('f12')]:= 'fullscr';
-SetDefaultBinds
+{$IFDEF IPHONEOS}
+DefaultBinds[ 1]:= '/put';
+DefaultBinds[ 3]:= 'ammomenu';
+DefaultBinds[ 8]:= 'hjump';
+DefaultBinds[ 9]:= 'switch';
+DefaultBinds[13]:= 'ljump';
+DefaultBinds[23]:= '+up';
+DefaultBinds[24]:= '+down';
+DefaultBinds[25]:= '+left';
+DefaultBinds[26]:= '+right';
+DefaultBinds[32]:= '+attack';
+DefaultBinds[44]:= 'chat';
+{$ENDIF}
+
+SetDefaultBinds();
end;
procedure SetBinds(var binds: TBinds);
begin
-CurrentBinds:= binds;
+ CurrentBinds:= binds;
end;
procedure SetDefaultBinds;
begin
-CurrentBinds:= DefaultBinds
+ CurrentBinds:= DefaultBinds;
end;
+{$IFDEF IPHONEOS}
+procedure setiPhoneBinds;
+// set to false the keys that only need one stoke
+begin
+ tkbdn[1]:= ord(leftClick);
+ tkbdn[2]:= ord(middleClick);
+ tkbdn[3]:= ord(rightClick);
+
+ tkbdn[23]:= ord(upKey);
+ tkbdn[24]:= ord(downKey);
+ tkbdn[25]:= ord(leftKey);
+ tkbdn[26]:= ord(rightKey);
+
+ tkbdn[ 8]:= ord(backspaceKey);
+ tkbdn[ 9]:= ord(tabKey);
+ tkbdn[13]:= ord(enterKey);
+ tkbdn[32]:= ord(spaceKey);
+
+ tkbdn[44]:= ord(chatAction);
+ //tkbdn[100]:= ord(switchAction);
+
+ leftClick:= false;
+ middleClick:= false;
+ rightClick:= false;
+
+ tabKey:= false;
+ enterKey:= false;
+ backspaceKey:= false;
+
+ chatAction:= false;
+ //switchAction:= false;
+end;
+{$ENDIF}
+
procedure FreezeEnterKey;
begin
tkbd[13]:= 1;
@@ -451,9 +454,9 @@
procedure ControllerClose;
var j: Integer;
begin
-if ControllerEnabled > 0 then
- for j:= 0 to pred(ControllerNumControllers) do
- SDL_JoystickClose(Controller[j]);
+ if ControllerEnabled > 0 then
+ for j:= 0 to pred(ControllerNumControllers) do
+ SDL_JoystickClose(Controller[j]);
end;
procedure ControllerAxisEvent(joy, axis: Byte; value: Integer);
@@ -477,6 +480,7 @@
wheelUp:= false;
wheelDown:= false;
{$IFDEF IPHONEOS}
+ // this function is called by HW_allKeysUp so be careful
leftClick:= false;
middleClick:= false;
rightClick:= false;
@@ -490,6 +494,9 @@
spaceKey:= false;
enterKey:= false;
tabKey:= false;
+
+ chatAction:= false;
+ switchAction:= false;
{$ENDIF}
end;