/InputSystem/Tests/WiiMote.cs
C# | 80 lines | 66 code | 2 blank | 12 comment | 4 complexity | ce53ffb142222a8d93d1f7b6e692176f MD5 | raw file
Possible License(s): Apache-2.0
- using Delta.Engine;
- using Delta.Rendering.Basics.Fonts;
- using Delta.Utilities.Datatypes;
- using NUnit.Framework;
-
- namespace Delta.InputSystem.Tests
- {
- /// <summary>
- /// Testing the WiiMote device.
- /// </summary>
- internal class WiiMote
- {
- #region CheckWiiMoteStates (Static)
- /// <summary>
- /// Check WiiMote states
- /// </summary>
- [Test, Category("Visual")]
- public static void CheckWiiMoteStates()
- {
- Application.Start(delegate
- {
- Font.Default.Draw(
- "GamePad IsConnected " + Input.GamePad.IsConnected,
- Rectangle.FromCenter(new Point(0.5f, 0.45f), Size.Half));
- Font.Default.Draw(
- "A " + Input.GamePad.GetState(InputButton.GamePadA),
- Rectangle.FromCenter(new Point(0.5f, 0.50f), Size.Half));
- // Also rumble if the A button was pressed
- if (Input.GamePad.UpIsPressed)
- {
- Input.GamePad.Rumble(0.0f, 0.0f);
- }
- Font.Default.Draw(
- "B " + Input.GamePad.GetState(InputButton.GamePadB),
- Rectangle.FromCenter(new Point(0.5f, 0.55f), Size.Half));
- Font.Default.Draw(
- "Accelerometer Position" + Input.Accelerometer.Position.ToString(),
- Rectangle.FromCenter(new Point(0.5f, 0.60f), Size.Half));
- // Move the cursor left or right to check the cursor
- Font.Default.Draw(
- "Cursor Position" + Input.GamePad.Position.ToString(),
- Rectangle.FromCenter(new Point(0.5f, 0.65f), Size.Half));
- });
- }
- #endregion
-
- #region CheckRummble (Static)
- /// <summary>
- /// Check if the device rumbles and stops rumbling if certain keys are
- /// pressed
- /// </summary>
- [Test, Category("Visual")]
- public static void CheckRummble()
- {
- Application.Start(delegate
- {
- if (Input.GamePad.IsConnected)
- {
- Font.Default.Draw(
- "Press 'A' to Rumble and release and 'B' to stop rumbling",
- Rectangle.FromCenter(new Point(0.5f, 0.45f), Size.Half));
- if (Input.GamePad.IsPressed(InputButton.GamePadA))
- {
- Input.GamePad.Rumble(5.0f, 5.0f);
- }
- if (Input.GamePad.IsPressed(InputButton.GamePadB))
- {
- Input.GamePad.Rumble(false);
- }
- }
- else
- {
- Font.Default.Draw("Wii not connected!",
- Rectangle.FromCenter(new Point(0.5f, 0.45f), Size.Half));
- }
- });
- }
- #endregion
- }
- }