//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace DarkWynter.Engine.Controllers
{
#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System.Diagnostics;
//using DarkWynter.Engine.ObjectLib;
//using DarkWynter.Engine.Menus;
//using Globals;
#endregion
///
/// Xbox analog event class for mapping an analog button/motion to an event
///
public class XboxAnalogControl
{
private float GAMEPAD_ROTATION_SCALE_Y = 0.03f;
private float GAMEPAD_ROTATION_SCALE_X = 0.03f;
// Time delay between key presses to avoid double input
private int KEY_TIMER_MAX_MILLI = 100;
private Stopwatch controlTimer = new Stopwatch();
///
/// On stick delegate type
///
/// Controller vector2 event arguments
public delegate void OnStickHandler(ControllerVec2EventArgs args);
private event OnStickHandler stick;
///
/// On trigger delegate type
///
/// Controller float event arguments
public delegate void OnTriggerHandler(ControllerFloatEventArgs args);
private event OnTriggerHandler trigger;
///
/// Type of control for this event
///
public XboxAnalogControlType controlType;
///
/// Stick constructor
///
/// Stick control type
/// Stick handler
/// Time delay between multiple invocations
public XboxAnalogControl(XboxAnalogControlType type, OnStickHandler onStickHandler, int timerValue)
{
controlType = type;
controlTimer.Start();
KEY_TIMER_MAX_MILLI = timerValue;
stick += new OnStickHandler(onStickHandler);
}
///
/// Trigger constructor
///
/// Trigger control type
/// Trigger handler
/// Time delay between multiple invocations
public XboxAnalogControl(XboxAnalogControlType type, OnTriggerHandler onTriggerHandler, int timerValue)
{
controlType = type;
controlTimer.Start();
KEY_TIMER_MAX_MILLI = timerValue;
trigger += new OnTriggerHandler(onTriggerHandler);
}
///
/// Update Method
///
/// Updated game pad state
/// Object Library
/// Menu System
public void Update(GamePadState gamePadState, ref List