# HG changeset patch # User Xeli # Date 1313437527 -7200 # Node ID 50650032c251aec277ca68b00e1a3ad16b566c4f # Parent 73f2fec65257053f765621901fc9fbaf45b51e80 Zoom and moving the camera now works with SDL_FINGER* events diff -r 73f2fec65257 -r 50650032c251 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Thu Aug 11 15:03:21 2011 +0200 +++ b/hedgewars/SDLh.pas Mon Aug 15 21:45:27 2011 +0200 @@ -567,6 +567,19 @@ {$ENDIF} end; + SDL_TouchID = Int32; + SDL_FingerID = Int32; + + TSDL_TouchFingerEvent = record + type_: UInt32; + windowId: UInt32; + touchId: SDL_TouchID; + fingerId: SDL_FingerID; + state, padding1, padding2, padding3: UInt8; + x,y: UInt16; + dx,dy: Int16; + pressure: UInt16; + end; //TODO: implement SDL_TouchButtonEvent, SDL_MultiGestureEvent, SDL_DollarGestureEvent TSDL_QuitEvent = record @@ -603,6 +616,9 @@ SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); + SDL_FINGERMOTION, + SDL_FINGERUP, + SDL_FINGERDOWN:(tfinger: TSDL_TouchFingerEvent); SDL_QUITEV: (quit: TSDL_QuitEvent); SDL_USEREVENT: (user: TSDL_UserEvent); //TODO: implement other events diff -r 73f2fec65257 -r 50650032c251 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Thu Aug 11 15:03:21 2011 +0200 +++ b/hedgewars/hwengine.pas Mon Aug 15 21:45:27 2011 +0200 @@ -31,7 +31,7 @@ uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uRandom, uLandTexture, uCollisions, - sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted {$IFDEF ANDROID}, GLUnit {$ENDIF}; + sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted,uTouch {$IFDEF ANDROID}, GLUnit {$ENDIF}; {$IFDEF HWLIBRARY} procedure initEverything(complete:boolean); @@ -169,9 +169,9 @@ cHasFocus:= true; onFocusStateChanged() end; - SDL_FINGERDOWN: WriteToConsole('finger down'); - SDL_FINGERMOTION: WriteToConsole('finger is moving'); - SDL_FINGERUP: WriteToConsole('finger up'); + SDL_FINGERMOTION: onTouchMotion(event.tfinger.x, event.tfinger.y,event.tfinger.dx, event.tfinger.dy, event.tfinger.fingerId); + SDL_FINGERDOWN: onTouchDown(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId); + SDL_FINGERUP: onTouchUp(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId); {$ELSE} KeyPressChat(event.key.keysym.unicode); SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then wheelDown:= true; @@ -253,7 +253,6 @@ cLogfileBase:= 'game'; initEverything(true); - WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); AddFileLog('Prefix: "' + PathPrefix +'"'); AddFileLog('UserPrefix: "' + UserPathPrefix +'"'); @@ -365,6 +364,7 @@ {$IFDEF ANDROID} GLUnit.init; {$ENDIF} + uTouch.initModule; uAI.initModule; //uAIActions does not need initialization //uAIAmmoTests does not need initialization diff -r 73f2fec65257 -r 50650032c251 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Thu Aug 11 15:03:21 2011 +0200 +++ b/hedgewars/uConsts.pas Mon Aug 15 21:45:27 2011 +0200 @@ -156,7 +156,7 @@ // do not change this value cDefaultZoomLevel = 2.0; -{$IFDEF IPHONEOS} +{$IFDEF MOBILE} cMaxZoomLevel = 0.5; cMinZoomLevel = 3.5; cZoomDelta = 0.20; @@ -166,6 +166,8 @@ cZoomDelta = 0.25; {$ENDIF} + cMinMaxZoomLevelDelta = cMaxZoomLevel - cMinZoomLevel; + cSendEmptyPacketTime = 1000; trigTurns = $80000001; diff -r 73f2fec65257 -r 50650032c251 project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.c --- a/project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.c Thu Aug 11 15:03:21 2011 +0200 +++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.c Mon Aug 15 21:45:27 2011 +0200 @@ -27,7 +27,7 @@ #include "../../events/SDL_touch_c.h" #include "SDL_androidtouch.h" - +#include "stdlib.h" #define ACTION_DOWN 0 #define ACTION_UP 1 @@ -38,7 +38,7 @@ #define ACTION_POINTER_UP 6 -void Android_OnTouch(int action, int pointerId, float x, float y, float p) +void Android_OnTouch(int action, SDL_FingerID pointerId, float x, float y, float p) { if (!Android_Window) { return; @@ -61,7 +61,6 @@ if(SDL_AddTouch(&touch, "") < 0) return; } - switch(action){ case ACTION_DOWN: case ACTION_POINTER_DOWN: diff -r 73f2fec65257 -r 50650032c251 project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.h --- a/project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.h Thu Aug 11 15:03:21 2011 +0200 +++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.h Mon Aug 15 21:45:27 2011 +0200 @@ -23,6 +23,6 @@ #include "SDL_androidvideo.h" -extern void Android_OnTouch(int action, int pointerId, float x, float y, float p); +extern void Android_OnTouch(int action, SDL_FingerID pointerId, float x, float y, float p); /* vi: set ts=4 sw=4 expandtab: */ diff -r 73f2fec65257 -r 50650032c251 project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/TouchInterface/TouchInterface.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/TouchInterface/TouchInterface.java Thu Aug 11 15:03:21 2011 +0200 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/TouchInterface/TouchInterface.java Mon Aug 15 21:45:27 2011 +0200 @@ -40,7 +40,8 @@ int actionCode = action & MotionEvent.ACTION_MASK; for (int i = 0; i < event.getPointerCount(); i++) { - SDLActivity.onNativeTouch(actionCode, event.getPointerId(i), event.getX(i), event.getY(i), event.getPressure(i)); + SDLActivity.onNativeTouch(actionCode, event.getPointerId(i), (int)event.getX(i), (int)event.getY(i), event.getPressure(i)); +// Log.d("Android", String.format("x=%f, y=%f, pntr=%d", event.getX(i), event.getY(i), event.getPointerId(i))); } return true; }