Permalink
Browse files

Merge pull request #947 from WaaghMan/develop3d

Small fixes for input and storage
  • Loading branch information...
2 parents 0e70446 + 769e90e commit 8bcad3742ce48dc55463d20f6991cdf3ff51135d @KonajuGames KonajuGames committed Nov 19, 2012
@@ -66,201 +66,118 @@ static Settings Settings
}
}
- static void AutoConfig ()
- {
- Init();
- if (!sdl) return;
- Console.WriteLine("Number of joysticks: " + Sdl.SDL_NumJoysticks());
- int numSticks = Sdl.SDL_NumJoysticks();
- for (int x = 0; x < numSticks; x++) {
-
- PadConfig pc = new PadConfig(Sdl.SDL_JoystickName(x), 0);
- devices[x] = Sdl.SDL_JoystickOpen (pc.Index);
-
- int numbuttons = Sdl.SDL_JoystickNumButtons(devices[x]);
- Console.WriteLine("Number of buttons for joystick: " + x + " - " + numbuttons);
-
- for (int b = 0; b < numbuttons; b++) {
- //pc
- }
-
- if (Sdl.SDL_JoystickName(x).Contains("Microsoft")
- || Sdl.SDL_JoystickName(x).Contains("潃瑮潲汬牥⠠托硯㌠〶圠物汥獥⁳敒散癩牥映牯圠湩潤獷)")
- || (Sdl.SDL_JoystickName(x).Contains("X-Box") || Sdl.SDL_JoystickName(x).Contains("Xbox")))
- {
- pc.Button_A.ID = 0;
- pc.Button_A.Type = InputType.Button;
-
- pc.Button_B.ID = 1;
- pc.Button_B.Type = InputType.Button;
-
- pc.Button_X.ID = 2;
- pc.Button_X.Type = InputType.Button;
-
- pc.Button_Y.ID = 3;
- pc.Button_Y.Type = InputType.Button;
-
- pc.Button_Back.ID = 6;
- pc.Button_Back.Type = InputType.Button;
-
- pc.Button_Start.ID = 7;
- pc.Button_Start.Type = InputType.Button;
-
- pc.Button_LB.ID = 4;
- pc.Button_LB.Type = InputType.Button;
-
- pc.Button_RB.ID = 5;
- pc.Button_RB.Type = InputType.Button;
-
- pc.LeftStick.X.Negative.ID = 0;
- pc.LeftStick.X.Negative.Type = InputType.Axis;
- pc.LeftStick.X.Negative.Negative = true;
-
- pc.LeftStick.X.Positive.ID = 0;
- pc.LeftStick.X.Positive.Type = InputType.Axis;
- pc.LeftStick.X.Positive.Negative = false;
-
- pc.LeftStick.Y.Negative.ID = 1;
- pc.LeftStick.Y.Negative.Type = InputType.Axis;
- pc.LeftStick.Y.Negative.Negative = true;
-
- pc.LeftStick.Y.Positive.ID = 1;
- pc.LeftStick.Y.Positive.Type = InputType.Axis;
- pc.LeftStick.Y.Positive.Negative = false;
-
-
- pc.RightStick.Y.Negative.ID = 3;
- pc.RightStick.Y.Negative.Type = InputType.Axis;
- pc.RightStick.Y.Negative.Negative = true;
-
- pc.RightStick.Y.Positive.ID = 3;
- pc.RightStick.Y.Positive.Type = InputType.Axis;
- pc.RightStick.Y.Positive.Negative = false;
-
- pc.RightStick.X.Negative.ID = 4;
- pc.RightStick.X.Negative.Type = InputType.Axis;
- pc.RightStick.X.Negative.Negative = true;
-
- pc.RightStick.X.Positive.ID = 4;
- pc.RightStick.X.Positive.Type = InputType.Axis;
- pc.RightStick.X.Positive.Negative = false;
-
- pc.Dpad.Up.ID = 0;
- pc.Dpad.Up.Type = InputType.PovUp;
+ static void AutoConfig()
+ {
+ Init();
+ if (!sdl) return;
+#if DEBUG
+ Console.WriteLine("Number of joysticks: " + Sdl.SDL_NumJoysticks());
+#endif
+ int numSticks = Sdl.SDL_NumJoysticks();
+ for (int x = 0; x < numSticks; x++)
+ {
- pc.Dpad.Down.ID = 0;
- pc.Dpad.Down.Type = InputType.PovDown;
+ PadConfig pc = new PadConfig(Sdl.SDL_JoystickName(x), x);
+ devices[x] = Sdl.SDL_JoystickOpen(pc.Index);
- pc.Dpad.Left.ID = 0;
- pc.Dpad.Left.Type = InputType.PovLeft;
+ pc.Button_A.ID = 0;
+ pc.Button_A.Type = InputType.Button;
- pc.Dpad.Right.ID = 0;
- pc.Dpad.Right.Type = InputType.PovRight;
+ pc.Button_B.ID = 1;
+ pc.Button_B.Type = InputType.Button;
- pc.LeftTrigger.ID = 2;
- pc.LeftTrigger.Type = InputType.Axis;
- pc.LeftTrigger.Negative = false;
+ pc.Button_X.ID = 2;
+ pc.Button_X.Type = InputType.Button;
- pc.RightTrigger.ID = 2;
- pc.RightTrigger.Type = InputType.Axis;
- pc.RightTrigger.Negative = true;
-
- // Suggestion: Xbox Guide button <=> BigButton
- //pc.BigButton.ID = 8;
- //pc.BigButton.Type = InputType.Button;
+ pc.Button_Y.ID = 3;
+ pc.Button_Y.Type = InputType.Button;
- pc.LeftStick.Press.ID = 9;
- pc.LeftStick.Press.Type = InputType.Button;
+ pc.Button_LB.ID = 4;
+ pc.Button_LB.Type = InputType.Button;
- pc.RightStick.Press.ID = 10;
- pc.RightStick.Press.Type = InputType.Button;
- }
- else
- {
- //pc.Button_A = new Input();
- pc.Button_A.ID = 0;
- pc.Button_A.Type = InputType.Button;
+ pc.Button_RB.ID = 5;
+ pc.Button_RB.Type = InputType.Button;
- pc.Button_B.ID = 1;
- pc.Button_B.Type = InputType.Button;
+ pc.Button_Back.ID = 6;
+ pc.Button_Back.Type = InputType.Button;
- pc.Button_X.ID = 2;
- pc.Button_X.Type = InputType.Button;
+ pc.Button_Start.ID = 7;
+ pc.Button_Start.Type = InputType.Button;
- pc.Button_Y.ID = 3;
- pc.Button_Y.Type = InputType.Button;
+ pc.LeftStick.Press.ID = 8;
+ pc.LeftStick.Press.Type = InputType.Button;
- pc.Button_Back.ID = 8;
- pc.Button_Back.Type = InputType.Button;
+ pc.RightStick.Press.ID = 9;
+ pc.RightStick.Press.Type = InputType.Button;
- pc.Button_Start.ID = 9;
- pc.Button_Start.Type = InputType.Button;
+ pc.LeftStick.X.Negative.ID = 0;
+ pc.LeftStick.X.Negative.Type = InputType.Axis;
+ pc.LeftStick.X.Negative.Negative = true;
- pc.Button_LB.ID = 4;
- pc.Button_LB.Type = InputType.Button;
+ pc.LeftStick.X.Positive.ID = 0;
+ pc.LeftStick.X.Positive.Type = InputType.Axis;
+ pc.LeftStick.X.Positive.Negative = false;
- pc.Button_RB.ID = 5;
- pc.Button_RB.Type = InputType.Button;
+ pc.LeftStick.Y.Negative.ID = 1;
+ pc.LeftStick.Y.Negative.Type = InputType.Axis;
+ pc.LeftStick.Y.Negative.Negative = true;
- pc.LeftStick.X.Negative.Type = InputType.Axis;
- pc.LeftStick.X.Negative.Negative = true;
- pc.LeftStick.X.Positive.Type = InputType.Axis;
- pc.LeftStick.X.Positive.Negative = false;
+ pc.LeftStick.Y.Positive.ID = 1;
+ pc.LeftStick.Y.Positive.Type = InputType.Axis;
+ pc.LeftStick.Y.Positive.Negative = false;
- pc.LeftStick.Y.Negative.ID = 1;
- pc.LeftStick.Y.Negative.Type = InputType.Axis;
- pc.LeftStick.Y.Negative.Negative = true;
+ pc.RightStick.Y.Negative.ID = 3;
+ pc.RightStick.Y.Negative.Type = InputType.Axis;
+ pc.RightStick.Y.Negative.Negative = true;
- pc.LeftStick.Y.Positive.ID = 1;
- pc.LeftStick.Y.Positive.Type = InputType.Axis;
- pc.LeftStick.Y.Positive.Negative = false;
+ pc.RightStick.Y.Positive.ID = 3;
+ pc.RightStick.Y.Positive.Type = InputType.Axis;
+ pc.RightStick.Y.Positive.Negative = false;
- //pc.RightStick.X.Negative.Type = InputType.Axis;
- //pc.RightStick.X.Negative.Negative = true;
- //pc.RightStick.X.Positive.Type = InputType.Axis;
- //pc.RightStick.X.Positive.Negative = false;
+ pc.RightStick.X.Negative.ID = 4;
+ pc.RightStick.X.Negative.Type = InputType.Axis;
+ pc.RightStick.X.Negative.Negative = true;
- //pc.RightStick.Y.Negative.ID = 1;
- //pc.RightStick.Y.Negative.Type = InputType.Axis;
- //pc.RightStick.Y.Negative.Negative = true;
+ pc.RightStick.X.Positive.ID = 4;
+ pc.RightStick.X.Positive.Type = InputType.Axis;
+ pc.RightStick.X.Positive.Negative = false;
- //pc.RightStick.Y.Positive.ID = 1;
- //pc.RightStick.Y.Positive.Type = InputType.Axis;
- //pc.RightStick.Y.Positive.Negative = false;
+ pc.Dpad.Up.ID = 0;
+ pc.Dpad.Up.Type = InputType.PovUp;
- pc.Dpad.Up.ID = 0;
- pc.Dpad.Up.Type = InputType.PovUp;
+ pc.Dpad.Down.ID = 0;
+ pc.Dpad.Down.Type = InputType.PovDown;
- pc.Dpad.Down.ID = 0;
- pc.Dpad.Down.Type = InputType.PovDown;
+ pc.Dpad.Left.ID = 0;
+ pc.Dpad.Left.Type = InputType.PovLeft;
- pc.Dpad.Left.ID = 0;
- pc.Dpad.Left.Type = InputType.PovLeft;
+ pc.Dpad.Right.ID = 0;
+ pc.Dpad.Right.Type = InputType.PovRight;
- pc.Dpad.Right.ID = 0;
- pc.Dpad.Right.Type = InputType.PovRight;
+ pc.LeftTrigger.ID = 2;
+ pc.LeftTrigger.Type = InputType.Axis;
+ pc.LeftTrigger.Negative = false;
- //pc.LeftTrigger.ID = 6;
- //pc.LeftTrigger.Type = InputType.Button;
+ pc.RightTrigger.ID = 2;
+ pc.RightTrigger.Type = InputType.Axis;
+ pc.RightTrigger.Negative = true;
- pc.RightTrigger.ID = 7;
- pc.RightTrigger.Type = InputType.Button;
- }
+ // Suggestion: Xbox Guide button <=> BigButton
+ //pc.BigButton.ID = 8;
+ //pc.BigButton.Type = InputType.Button;
- int numaxes = Sdl.SDL_JoystickNumAxes(devices[x]);
- Console.WriteLine("Number of axes for joystick: " + x + " - " + numaxes);
+#if DEBUG
+ int numbuttons = Sdl.SDL_JoystickNumButtons(devices[x]);
+ Console.WriteLine("Number of buttons for joystick: " + x + " - " + numbuttons);
- for (int a = 0; a < numaxes; a++) {
- //pc.LeftStick = new Stick();
- }
+ int numaxes = Sdl.SDL_JoystickNumAxes(devices[x]);
+ Console.WriteLine("Number of axes for joystick: " + x + " - " + numaxes);
- int numhats = Sdl.SDL_JoystickNumHats(devices[x]);
- Console.WriteLine("Number of PovHats for joystick: " + x + " - " + numhats);
+ int numhats = Sdl.SDL_JoystickNumHats(devices[x]);
+ Console.WriteLine("Number of PovHats for joystick: " + x + " - " + numhats);
+#endif
- for (int h = 0; h < numhats; h++) {
- //pc
- }
- settings[x] = pc;
+ settings[x] = pc;
}
}
@@ -127,7 +127,10 @@ private void SetData(int offset, int rows, int columns, object data)
if (data is float)
bytes = BitConverter.GetBytes((float)data);
- else
+ else if (data is int)
+ // Integer values are treated as floats after the shader is converted, so we convert them.
+ bytes = BitConverter.GetBytes((float)((int)data));
+ else
bytes = BitConverter.GetBytes(((float[])data)[0]);
Buffer.BlockCopy(bytes, 0, _buffer, offset, elementSize);
@@ -136,7 +139,6 @@ private void SetData(int offset, int rows, int columns, object data)
// Take care of the single copy case!
else if (rows == 1 || (rows == 4 && columns == 4))
Buffer.BlockCopy(data as Array, 0, _buffer, offset, rows * columns * elementSize);
-
else
{
var source = data as Array;
@@ -168,9 +170,9 @@ private void SetParameter(int offset, EffectParameter param)
switch (param.ParameterType)
{
case EffectParameterType.Single:
- SetData(offset, param.RowCount, param.ColumnCount, param.Data);
+ case EffectParameterType.Int32:
+ SetData(offset, param.RowCount, param.ColumnCount, param.Data);
break;
-
default:
throw new NotImplementedException("Not supported!");
}
@@ -135,11 +135,11 @@ internal StorageContainer(StorageDevice device, string name, PlayerIndex? player
var playerSave = string.Empty;
if (playerIndex.HasValue) {
- playerSave = Path.Combine(root,"Player" + (int)playerIndex.Value);
+ playerSave = Path.Combine(_storagePath, "Player" + (int)playerIndex.Value);
}
if (!string.IsNullOrEmpty(playerSave))
- _storagePath = Path.Combine(root,"Player" + (int)playerIndex);
+ _storagePath = Path.Combine(_storagePath, "Player" + (int)playerIndex);
// Create the "device" if need be
#if WINRT
@@ -359,14 +359,18 @@ public StorageContainer EndOpenContainer (IAsyncResult result)
StorageContainer returnValue = null;
try {
// Retrieve the delegate.
- var asyncResult = result.AsyncState as OpenContainerAsynchronous;
+ AsyncResult asyncResult = result as AsyncResult;
+ if (asyncResult != null)
+ {
+ var asyncDelegate = asyncResult.AsyncDelegate as OpenContainerAsynchronous;
- // Wait for the WaitHandle to become signaled.
- result.AsyncWaitHandle.WaitOne ();
+ // Wait for the WaitHandle to become signaled.
+ result.AsyncWaitHandle.WaitOne();
- // Call EndInvoke to retrieve the results.
- if (asyncResult != null)
- returnValue = asyncResult.EndInvoke(result);
+ // Call EndInvoke to retrieve the results.
+ if (asyncDelegate != null)
+ returnValue = asyncDelegate.EndInvoke(result);
+ }
} finally {
// Close the wait handle.
result.AsyncWaitHandle.Dispose ();

0 comments on commit 8bcad37

Please sign in to comment.