modified controller class to support more than one controller

This commit is contained in:
Alexander Eckart committed 2013-05-04 17:20:43 +02:00
1 parent 40c470c184
commit 29212e4c81
4 files changed
+69 -14

No files matched your search

@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@@ -25,7 +25,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
Binary file not shown.
+67 -12
View File
@@ -17,6 +17,9 @@
// */ // */
#endregion #endregion
using System;
using System.Collections.Generic;
using Vocaluxe.Lib.Input; using Vocaluxe.Lib.Input;
using Vocaluxe.Lib.Input.WiiMote; using Vocaluxe.Lib.Input.WiiMote;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -25,54 +28,106 @@ namespace Vocaluxe.Base
{ {
static class CController static class CController
{ {
private static IController _Controller; private static List<IController> _Controller;
private static List<SKeyEvent> _KeysPool;
private static List<SMouseEvent> _MousePool;
public static void Init() public static void Init()
{ {
_Controller = new CWiiMote(); _Controller = new List<IController>();
_KeysPool = new List<SKeyEvent>();
_MousePool = new List<SMouseEvent>();
_Controller.Init(); _Controller.Add(new CWiiMote());
foreach (IController controller in _Controller)
{
controller.Init();
}
} }
public static void Close() public static void Close()
{ {
_Controller.Close(); foreach (IController controller in _Controller)
_Controller = null; {
controller.Close();
}
_Controller = new List<IController>();
} }
public static void Connect() public static void Connect()
{ {
_Controller.Connect(); foreach (IController controller in _Controller)
{
controller.Connect();
}
} }
public static void Disconnect() public static void Disconnect()
{ {
_Controller.Disconnect(); foreach (IController controller in _Controller)
{
controller.Disconnect();
}
} }
public static bool IsConnected() public static bool IsConnected()
{ {
return _Controller.IsConnected(); //return _Controller.IsConnected();
return false; //should be changed
} }
public static void Update() public static void Update()
{ {
_Controller.Update(); foreach (IController controller in _Controller)
{
controller.Update();
SKeyEvent ke = new SKeyEvent();
while (controller.PollKeyEvent(ref ke))
{
_KeysPool.Add(ke);
}
SMouseEvent me = new SMouseEvent();
while (controller.PollMouseEvent(ref me))
{
_MousePool.Add(me);
}
}
} }
public static bool PollKeyEvent(ref SKeyEvent keyEvent) public static bool PollKeyEvent(ref SKeyEvent keyEvent)
{ {
return _Controller.PollKeyEvent(ref keyEvent); if (_KeysPool.Count > 0)
{
keyEvent = _KeysPool[0];
_KeysPool.RemoveAt(0);
return true;
}
return false;
} }
public static bool PollMouseEvent(ref SMouseEvent mouseEvent) public static bool PollMouseEvent(ref SMouseEvent mouseEvent)
{ {
return _Controller.PollMouseEvent(ref mouseEvent); if (_MousePool.Count > 0)
{
mouseEvent = _MousePool[0];
_MousePool.RemoveAt(0);
return true;
}
return false;
} }
public static void SetRumble(float duration) public static void SetRumble(float duration)
{ {
_Controller.SetRumble(duration); foreach (IController controller in _Controller)
{
controller.SetRumble(duration);
}
} }
} }
} }