2013-07-18 16:18:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-01-11 02:55:51 +00:00
|
|
|
|
|
2013-11-04 01:39:19 +00:00
|
|
|
|
namespace BizHawk.Emulation.Common
|
2011-01-11 02:55:51 +00:00
|
|
|
|
{
|
2013-07-18 16:18:17 +00:00
|
|
|
|
// doesn't do what is desired
|
|
|
|
|
// http://connect.microsoft.com/VisualStudio/feedback/details/459307/extension-add-methods-are-not-considered-in-c-collection-initializers
|
|
|
|
|
/*
|
|
|
|
|
public static class UltimateMagic
|
|
|
|
|
{
|
|
|
|
|
public static void Add(this List<ControllerDefinition.FloatRange l, float Min, float Mid, float Max)
|
|
|
|
|
{
|
|
|
|
|
l.Add(new ControllerDefinition.FloatRange(Min, Mid, Max);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2011-08-08 23:35:13 +00:00
|
|
|
|
public class ControllerDefinition
|
|
|
|
|
{
|
2013-07-18 16:18:17 +00:00
|
|
|
|
public struct FloatRange
|
|
|
|
|
{
|
|
|
|
|
public readonly float Min;
|
|
|
|
|
public readonly float Max;
|
2013-12-07 00:53:06 +00:00
|
|
|
|
|
2013-07-18 16:18:17 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// default position
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly float Mid;
|
2013-12-07 00:53:06 +00:00
|
|
|
|
|
|
|
|
|
public FloatRange(float min, float mid, float max)
|
2013-07-18 16:18:17 +00:00
|
|
|
|
{
|
2013-12-07 00:53:06 +00:00
|
|
|
|
Min = min;
|
|
|
|
|
Mid = mid;
|
|
|
|
|
Max = max;
|
2013-07-18 16:18:17 +00:00
|
|
|
|
}
|
2013-12-07 00:53:06 +00:00
|
|
|
|
|
2013-07-18 16:18:17 +00:00
|
|
|
|
// for terse construction
|
|
|
|
|
public static implicit operator FloatRange(float[] f)
|
|
|
|
|
{
|
|
|
|
|
if (f.Length != 3)
|
2013-12-07 00:53:06 +00:00
|
|
|
|
{
|
2013-07-18 16:18:17 +00:00
|
|
|
|
throw new ArgumentException();
|
2013-12-07 00:53:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-18 16:18:17 +00:00
|
|
|
|
return new FloatRange(f[0], f[1], f[2]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-07 00:53:06 +00:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<string> BoolButtons { get; set; }
|
|
|
|
|
public List<string> FloatControls { get; private set; }
|
|
|
|
|
public List<FloatRange> FloatRanges { get; private set; }
|
|
|
|
|
|
2012-10-26 18:51:08 +00:00
|
|
|
|
public ControllerDefinition(ControllerDefinition source)
|
2013-12-07 00:53:06 +00:00
|
|
|
|
: this()
|
2012-10-26 18:51:08 +00:00
|
|
|
|
{
|
2013-11-04 03:12:50 +00:00
|
|
|
|
Name = source.Name;
|
2014-03-05 04:08:24 +00:00
|
|
|
|
BoolButtons.AddRange(source.BoolButtons);
|
|
|
|
|
FloatControls.AddRange(source.FloatControls);
|
|
|
|
|
FloatRanges.AddRange(source.FloatRanges);
|
2013-12-07 00:53:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ControllerDefinition()
|
|
|
|
|
{
|
|
|
|
|
BoolButtons = new List<string>();
|
|
|
|
|
FloatControls = new List<string>();
|
|
|
|
|
FloatRanges = new List<FloatRange>();
|
2012-10-26 18:51:08 +00:00
|
|
|
|
}
|
2011-08-08 23:35:13 +00:00
|
|
|
|
}
|
2011-01-11 02:55:51 +00:00
|
|
|
|
|
2011-08-08 23:35:13 +00:00
|
|
|
|
public interface IController
|
|
|
|
|
{
|
|
|
|
|
ControllerDefinition Type { get; }
|
2011-01-11 02:55:51 +00:00
|
|
|
|
|
2013-12-07 00:53:06 +00:00
|
|
|
|
// TODO - it is obnoxious for this to be here. must be removed.
|
2011-08-08 23:35:13 +00:00
|
|
|
|
bool this[string button] { get; }
|
2013-12-07 00:53:06 +00:00
|
|
|
|
|
|
|
|
|
// TODO - this can stay but it needs to be changed to go through the float
|
2011-08-08 23:35:13 +00:00
|
|
|
|
bool IsPressed(string button);
|
|
|
|
|
|
|
|
|
|
float GetFloat(string name);
|
|
|
|
|
}
|
2011-01-11 02:55:51 +00:00
|
|
|
|
}
|