Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

GameFramework.MobileInputZone


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
/**
* MobileInputZone
* Controls how mobile input is handled
* Copyright 1998-2011 Epic Games, Inc. All Rights Reserved.
*/

class MobileInputZone extends object
	PerObjectConfig
	editinlinenew
	Config(Game)
	native;

/** Describes the type of zone */
enum EZoneType
{
	ZoneType_Button,
	ZoneType_Joystick,
	ZoneType_Trackball,
	ZoneType_Slider,
};

/**
 * Describes the state of the zone.                                                                     
 */
enum EZoneState
{
	ZoneState_Inactive,
	ZoneState_Activating,
	ZoneState_Active,
	ZoneState_Deactivating,
};

/** 
 * Describes the type of event that has occurred 
 */
enum EZoneTouchEvent
{
	ZoneEvent_Touch,
	ZoneEvent_Update,
	ZoneEvent_Stationary,
	ZoneEvent_UnTouch,
	ZoneEvent_Cancelled,
};

/**
 * Defines which way the zone slides                                                                     
 */
enum EZoneSlideType
{
	ZoneSlide_UpDown,
	ZoneSlide_LeftRight,
};

/**
 *  Structure to allow easy storage of UVs for a rendered image                                                                     
 */
struct native TextureUVs
{
	var() float U, V, UL, VL;

	// defaults to see something
	structdefaultproperties
	{
		UL=64.0f
		VL=64.0f
	}
};


/** What type of zone is this. */
var (Zone) config EZoneType Type;

/** Which touchpad this zone will respond to */
var (Zone) byte TouchpadIndex;

/** State of the zone */
var EZoneState State;

/** For button zones, the Caption property will be displayed in the center of the button */
var (Zone) config string Caption;

/** Input to send to input subsystem on event (vertical input for analog, can be NAME_None) */
var (Input) config name InputKey;

/** Input to send for horizontal analog input (can be NAME_None) */
var (Input) config name HorizontalInputKey;

/** Input to send for tap input (e.g. for tap-to-fire) */
var (Input) config name TapInputKey;

/** Input to send from a double tap */
var (Input) config name DoubleTapInputKey;

/** Multiplier to scale the analog vertical input by */
var (Input) config float VertMultiplier;

/** Multiplier to scale the analog horizontal input by */
var (Input) config float HorizMultiplier;

/** How much acceleration to apply to Trackball or Joystick movement (0.0 for none, no upper bounds) */
var (Input) config float Acceleration;

/** How much input smoothing to apply to Trackball or Joystick movement (0.0 for none, 1.0 for max) */
var (Input) config float Smoothing;

/** How much escape velocity to use for Trackball movement (0.0 for none, 1.0 for max) */
var (Input) config float EscapeVelocityStrength;

/** If true, this control will use it's "strength" to scale the movement of the pawn */
var (Input) config bool bScalePawnMovement;

/** Top left corner */
var (Bounds) config float X, Y;

/** Size of the zone */
var (Bounds) config float SizeX, SizeY;

/** Size of active Zone.  Note if it's set to 0, then SizeX/SizeY will be copied here.  
    This setting is used when you have a zone that has bCenterOnEvent set and defines the size of 
	zone when it's active  */
var (Bounds) config float ActiveSizeX, ActiveSizeY;

/** If any of the bReleative vars are true, then the corresponding X/Y/SizeX/SizeY will be consider a percentage of the viewport */
var (Bounds) config bool bRelativeX;
var (Bounds) config bool bRelativeY;
var (Bounds) config bool bRelativeSizeX;
var (Bounds) config bool bRelativeSizeY;

/** If this is true, then ActiveSizeY is relative to ActiveSizeX */
var (Bounds) config bool bActiveSizeYFromX;

/** If this is true, then SizeX is relative to SizeY */
var (Bounds) config bool bSizeYFromSizeX;

/** This is the scale factor you are authoring for. 2.0 is useful for Retina display resolution (960x640), 1.0 for iPads and older iPhones */
var (Bounds) config float AuthoredGlobalScale;

/** if true, then this zone will be centered around the original X value.  NOTE: X will be updated to reflect it's actual position */
var (bounds) config bool bCenterX;

/** if true, then this zone will be centered around the original Y value.  NOTE: Y will be updated to reflect it's actual position */
var (bounds) config bool bCenterY;

/** Border is an invisible region around the zone.  The border is included in hit determination. */
var (Bounds) config float Border;	


/** Do we draw anything on screen for this zone? */
var (Options) config bool bIsInvisible;

/** If true, then this double tap will be considered a quick press/release, other wise it's tap and hold */
var (Options) config bool bQuickDoubleTap;

/** If true, this zone will have it's "center" set when you touch it, otherwise the center will be set to the center of the zone */
var (Options) config bool bCenterOnEvent;

/** If bCenterOnEvent is enabled and this is non zero, the center position will be reset to it's initial center after this period of inactivity */
var (Options) config float ResetCenterAfterInactivityTime;

/** If true, the tilt zone will float within the SizeX/SizeY */
var (Options) config bool bFloatingTiltZone;

/** Determines what type of slide it is */
var (Options) config EZoneSlideType SlideType;

var (Options) config float TapDistanceConstraint;

/** If true, the zone will gracefully transition from Inactive to Active and vice-versus.  NOTE: transitions are strickly visual.  A
    zone becomes active or inactive the moment a touch is applied or removed */
var (Transitions) config bool bUseGentleTransitions;

/** How fast should a zone for from active to inactive */
var (Transitions) config float ActivateTime;

/** How fast a zone should go from inactive to active */
var (Transitions) config float DeactivateTime;

/** Unless enabled, the first movement delta for a trackball zone will be ignored.  This is useful for devices with inconsistent 'dead zones' for initial touch deltas, however this will reduce responsiveness of trackball drags slightly. */
var (Advanced) config bool bAllowFirstDeltaForTrackballZone;

/** Zone Rendering Parameters */

/** If true, the zone will render little guide lines for debugging */
var (Rendering) config bool bRenderGuides;

/** Holds the color to use when drawing images */
var (Rendering) config color RenderColor;

/** Holds the alpha value to use if the zone is inactive */
var (Rendering) config float InactiveAlpha;

/** This is a fixed adjustment that will be added to the zone's caption's X.  It's used to align fonts correctly */
var (Rendering) config float CaptionXAdjustment;

/** This is a fixed adjustment that will be added to the zone's caption's Y.  It's used to align fonts correctly */
var (Rendering) config float CaptionYAdjustment;

/** Override texture (for buttons, this is the texture when not clicked; for joystick/trackball, it's the background; for sliders, it's the slider) */
var (Rendering) Texture2D OverrideTexture1;

/** Ini-controlled string that will be looked up at runtime and hooked up to OverrideTexture1 */
var config string OverrideTexture1Name;

/** UVs for override texture 1 (in texel units) */
var (Rendering) config TextureUVs OverrideUVs1;

/** Override texture (for buttons, this is the texture when clicked; for joystick/trackball, it's the 'hat'; for sliders, it's unused) */
var (Rendering) Texture2D OverrideTexture2;

/** Ini-controlled string that will be looked up at runtime and hooked up to OverrideTexture2 */
var config string OverrideTexture2Name;

/** UVs for override texture 2 (in texel units) */
var (Rendering) config TextureUVs OverrideUVs2;

/** Holds the Initialize location where the zone was touched */
var Vector2D InitialLocation;

/** For Joystick and Trackball, this is where in the zone the user is currently holding down */
var Vector2D CurrentLocation;

/** For Joystick, this is the center of the analog zone to calculate the analog values from */
var Vector2D CurrentCenter;

/** For Joystick, the initial center position (used only when resetting the joystick back to it's center) */
var Vector2D InitialCenter;

/** For Joystick and Trackball, array of previous locations so that we can smooth input over frames */
var Vector2D PreviousLocations[6];

/** For Joystick and Trackball, array of previous movement time deltas so that we can smooth input over frames */
var float PreviousMoveDeltaTimes[6];

/** For Joystick and Trackball, how many previous locations we're currently storing */
var int PreviousLocationCount;

/** Used to calculate a double tap on this zone */
var float LastTouchTime;

/** How long since we last repeated a tap */
var float TimeSinceLastTapRepeat;

/** Fade opacity, used for certain transient effects */
var float AnimatingFadeOpacity;

/** A Reference back to the Player Input that controls this array Input zone */
var MobilePlayerInput InputOwner;

/** Holds the current transition time */
var float TransitionTime;

/** This will be true if this tap was a double tap.  It's required in order to make sure we release the DoubleTapInputKey if it was a tap and hold */
var bool bIsDoubleTapAndHold;

/** For Trackball, how much escape velocity is left to apply */
var Vector2D EscapeVelocity;

/** holds an list of MobileZone Sequence events associated with this zone */
var array<SeqEvent_MobileZoneBase> MobileSeqEventHandlers;

/** Holds cached versions of the last axis values */
var Vector2D LastAxisValues;

/** Used to track the amount of time a zone is active */
var float TotalActiveTime;

/** Holds the time this zone last went active */
var float LastWentActiveTime;


cpptext
{
	/**
	 * Processes a touch event
	 *
	 * @param DeltaTime		Much time has elapsed since the last processing
	 * @param Handle		The unique ID of this touch
	 * @param EventType		The type of event that occurred
	 * @param TouchLocation	Where on the device has the touch occurred.
	 * @param TouchDuration	How long since the touch started
	 * @param MoveDeltaTime	Time delta between the movement events the last time this touch moved
 	 */
	void virtual ProcessTouch(FLOAT DeltaTime, UINT Handle, EZoneTouchEvent EventType, FVector2D TouchLocation, FLOAT TouchTotalMoveDistance, FLOAT TouchDuration, FLOAT MoveDeltaTime);

	/**
	 * All zones that are in the active group get 'Ticked' at the end of the ProcessTouches event                                                                
	 *
	 * @param DeltaTime		Much time has elapsed since the last processing
	 */
	void virtual TickZone(FLOAT DeltaTime);

 	/**
	 * Applies any remaining escape velocity for this zone
	 *
	 * @param DeltaTime		Much time has elapsed since the last processing
	 */
	void ApplyEscapeVelocity( FLOAT DeltaTime );

	/**
	 * This function will iterate over the MobileSeqEventHandles array and cause them to be updated.  It get's called once per frame that the zone is active
	 */
	void UpdateListeners();

protected:
	/**
	 * Computes average location and movement time for the zone's active touch 
	 *
	 * @param	InTimeToAverageOver			How long a duration to average over (max)
	 * @param	OutSmoothedLocation			(Out) Average location
	 * @param	OutSmoothedMoveDeltaTime	(Out) Average movement delta time
	 */
	void ComputeSmoothedMovement( const FLOAT InTimeToAverageOver, FVector2D& OutSmoothedLocation, FLOAT& OutSmoothedMoveDeltaTime ) const;
}


/**
 * Called to activate a zone.
 */
native function ActivateZone();

/**
 * Called to deactivate a zone                                                                     
 */
native function DeactivateZone();

/**
 * A delegate that allows script to override the process.  We use delegates here
 *
 * @param Zone		The Mobile Input zone that triggered the delegate
 * @param Handle	The unique ID of this touch
 * @param EventType The type of event that occurred
 * @param Location	Where on the device has the touch occurred.
 * @returns true if we need to swallow the touch
*/

delegate bool OnProcessInputDelegate(MobileInputZone Zone, float DeltaTime, int Handle, EZoneTouchEvent EventType, Vector2D TouchLocation);


/**
 * A delegate that allows script to manage Tap events.
 *
 * @param Zone		The mobile Input zone that triggered the delegate
 * @param Location	Where on the device has the touch occurred.
 * @param EventType The type of event that occurred
 * @returns true if we need to swallow the tap
 */
delegate bool OnTapDelegate(MobileInputZone Zone, EZoneTouchEvent EventType, Vector2D TouchLocation);

/**
 * A delegate that allows script to manage Double Tap events.
 *
 * @param Zone		The mobile Input zone that triggered the delegate
 * @param Location	Where on the device has the touch occurred.
 * @param EventType The type of event that occurred
 * @returns true if we need to swallow the double tap
 */
delegate bool OnDoubleTapDelegate(MobileInputZone Zone, EZoneTouchEvent EventType, Vector2D TouchLocation);


/**
 * This is a delegate that allows script to get values of a slide zone. 
 *
 * @param Zone			The mobile Input zone that triggered the delegate
 * @param EventType		The type of event that occurred
 * @param SlideVlaue	Holds the offset value of the slides in a +/- range in pixels.  So 0 = Resting at normal.  
 * @param ViewportSize	Holds the size of the current viewport.
 */
delegate bool OnProcessSlide(MobileInputZone Zone, EZoneTouchEvent EventType, int SlideValue, Vector2D ViewportSize);

/**
 * Allows other actors to override the drawing of this zone.  Note this is called before the default drawing code 
 * and if it returns true, will abort the drawing sequence
 * 
 * @param Zone		 The mobile Input zone that triggered the delegate
 * @param Canvas	 The canvas to draw on
 * @returns true to stop the rendering
 */
delegate bool OnPreDrawZone(MobileInputZone Zone, Canvas Canvas);

/**
 * Allows other actors to supplement the drawing of this zone.  Note this is called after the default drawing code 
 * 
 * @param Zone		 The mobile Input zone that triggered the delegate
 * @param Canvas	 The canvas to draw on
 */
delegate OnPostDrawZone(MobileInputZone Zone, Canvas Canvas);


/**
 * Adds a new MobileInput Sequence Event to the handler list 
 *
 * @param NewHandler  The handler to add
 */
function AddKismetEventHandler(SeqEvent_MobileZoneBase NewHandler)
{
	local int i;

	//`log("ZONE: Adding Kismet handler " @ NewHandler.Name @ "for zone" @ name);

	// More sure this event handler isn't already in the array

	for (i=0;i<MobileSeqEventHandlers.Length;i++)
	{
		if (MobileSeqEventHandlers[i] == NewHandler)
		{
			return;	// Already Registered
		}
	}

	// Look though the array and see if there is an empty sport.  These empty sports
	// can occur when a kismet sequence is streamed out.

	for (i=0;i<MobileSeqEventHandlers.Length;i++)
	{
		if (MobileSeqEventHandlers[i] == none)
		{
			MobileSeqEventHandlers[i] = NewHandler;
			return;
		}
	}

	MobileSeqEventHandlers.AddItem(NewHandler);
}

defaultproperties
{
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: må 31-1-2011 18:27:14.000 - Creation time: ti 22-3-2011 19:57:08.163 - Created with UnCodeX