Improved ToString implementation
authorStefanos A. <stapostol@gmail.com>
Tue, 24 Dec 2013 16:06:39 +0000 (17:06 +0100)
committerStefanos A. <stapostol@gmail.com>
Tue, 24 Dec 2013 16:06:39 +0000 (17:06 +0100)
Source/OpenTK/Input/GamePadButtons.cs
Source/OpenTK/Input/GamePadThumbSticks.cs
Source/OpenTK/Input/GamePadTriggers.cs
Source/OpenTK/Input/Joystick.cs
Source/OpenTK/Input/JoystickState.cs

index aeb97b5..c13a9f0 100644 (file)
@@ -109,19 +109,7 @@ namespace OpenTK.Input
 
         public override string ToString()
         {
-            return String.Format(
-                "{{{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}}}",
-                A == ButtonState.Pressed ? "A" : String.Empty,
-                B == ButtonState.Pressed ? "B" : String.Empty,
-                X == ButtonState.Pressed ? "X" : String.Empty,
-                Y == ButtonState.Pressed ? "Y" : String.Empty,
-                LeftShoulder == ButtonState.Pressed ? "L" : String.Empty,
-                RightShoulder == ButtonState.Pressed ? "R" : String.Empty,
-                Back == ButtonState.Pressed ? " Back" : String.Empty,
-                Start == ButtonState.Pressed ? " Start" : String.Empty,
-                BigButton == ButtonState.Pressed ? " Big" : String.Empty,
-                LeftStick == ButtonState.Pressed ? " LStick" : String.Empty,
-                RightStick == ButtonState.Pressed ? " RStick" : String.Empty);
+            return Convert.ToString((int)buttons, 2).PadLeft(10, '0');
         }
 
         public override int GetHashCode()
index 59eb4ee..63838c6 100644 (file)
@@ -73,8 +73,8 @@ namespace OpenTK.Input
         public override string ToString()
         {
             return String.Format(
-                "{{Left: {0}; Right: {1}}}",
-                Left, Right);
+                "{{Left: ({0:f4}; {1:f4}); Right: ({2:f4}; {3:f4})}}",
+                Left.X, Left.Y, Right.X, Right.Y);
         }
 
         public override int GetHashCode()
index ecff49c..0e505d8 100644 (file)
@@ -69,7 +69,7 @@ namespace OpenTK.Input
         public override string ToString()
         {
             return String.Format(
-                "{{Left: {0}; Right: {1}}}",
+                "{{Left: {0:f2}; Right: {1:f2}}}",
                 Left, Right);
         }
 
index 0458abe..378b11f 100644 (file)
@@ -47,5 +47,10 @@ namespace OpenTK.Input
         {
             return implementation.GetState(index);
         }
+
+        //public string GetName(int index)
+        //{
+        //    return implementation.GetName(index);
+        //}
     }
 }
index 1b2a129..e14ac2d 100644 (file)
@@ -41,7 +41,7 @@ namespace OpenTK.Input
         internal const int MaxAxes = 10;
         internal const int MaxButtons = 32;
 
-        const float ConversionFactor = 1.0f / (short.MaxValue + 1);
+        const float ConversionFactor = 1.0f / (short.MaxValue + 0.5f);
 
         unsafe fixed short axes[MaxAxes];
         int buttons;
@@ -94,12 +94,12 @@ namespace OpenTK.Input
             for (int i = 0; i < MaxAxes; i++)
             {
                 sb.Append(" ");
-                sb.Append(GetAxis(i));
+                sb.Append(String.Format("{0:f4}", GetAxis(i)));
             }
             return String.Format(
                 "{{Axes:{0}; Buttons: {1}; IsConnected: {2}}}",
                 sb.ToString(),
-                Convert.ToString((int)buttons, 2),
+                Convert.ToString((int)buttons, 2).PadLeft(16, '0'),
                 IsConnected);
         }