figuerres wrote:
what I have so far is that i'd have to do some kind of assembly with MDX 1.1 and then make that work with XNA.
Isn't it simpler than that?
Reading the gamepad controller:
// Check the current state of Player One.
GamePadState currentState = GamePad.GetState( PlayerIndex.One );
// Process input only if connected and if the packet numbers differ.
if (currentState.IsConnected == true &&
currentState.PacketNumber != m_PreviousGamePadState.PacketNumber)
{
if (currentState.Buttons.A == ButtonState.Pressed &&
m_PreviousGamePadState.Buttons.A == ButtonState.Released)
{
// Button A has been pressed.
GamePad.SetVibration( PlayerIndex.One, 1.0f, 1.0f );
}
else if (currentState.Buttons.A == ButtonState.Released &&
m_PreviousGamePadState.Buttons.A == ButtonState.Pressed)
{
// Button A has been released.
GamePad.SetVibration( PlayerIndex.One, 0.0f, 0.0f );
}
// When finished with differences, update PreviousGamePadState.
m_PreviousGamePadState = currentState;
}
Reading the mouse:
MouseState current_mouse = Mouse.GetState();
// The mouse x and y positions are returned relative to the
// top-left of the game window.
m_MouseX = current_mouse.X;
m_MouseY = current_mouse.Y;
Reading the keyboard:
KeyboardState currentState = Keyboard.GetState();
Keys[] currentKeys = currentState.GetPressedKeys();
// First loop, looking for keys just pressed.
for (int currentKey = 0; currentKey < currentKeys.Length; currentKey++)
{
bool found = false;
for (int previousKey = 0; previousKey < m_aKeysHeldDown.Length; previousKey++)
{
if (currentKeys[currentKey] == m_aKeysHeldDown[previousKey])
{
// The key was pressed both this frame and last; ignore.
found = true;
break;
}
}
if (!found)
{
// The key was pressed this frame, but not last frame; it was just pressed.
m_lKeysPressedThisFrame.Add( currentKeys[currentKey] );
}
}
// Second loop, looking for keys just released.
for (int previousKey = 0; previousKey < m_aKeysHeldDown.Length; previousKey++)
{
bool found = false;
for (int currentKey = 0; currentKey < currentKeys.Length; currentKey++)
{
if (m_aKeysHeldDown[previousKey] == currentKeys[currentKey])
{
// The key was pressed both this frame and last; ignore.
found = true;
break;
}
}
if (!found)
{
// The key was pressed last frame, but not this frame; it was just released.
m_lKeysReleasedThisFrame.Add( m_aKeysHeldDown[previousKey] );
}
}
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.