Can you spot what I'm doing wrong? DirectXTK problem

Started by
-1 comments, last by darcmagik 7 years, 11 months ago

Hello everybody I'm back again with some more interesting problems that I need help solving. So I have moved forward with my engine and I'm working on the Input system for it I had Input from a keyboard working before and decided that it was time to add support for a game controller. When I started working on this I also decided to change my input system so that it would be easier for me to change controls and to allow for Change in Key bindings in an options menu.

I'm running into a very interesting bug the reason why it is interesting to me is that the code kinda works, it receives the input commands it processes them for me. Keyboard Commands get handled perfectly with no issues. But when it comes to the game pad controls I'm getting some abnormalities. So if I setup my code for checking for Directional pad presses like this:


if (tracker.dpadUp == GamePad::ButtonStateTracker::PRESSED && ((*commandIterator)->getGamePadDpadBinding() == Up))
        (*commandIterator)->execute(true);

else if (tracker.dpadUp == GamePad::ButtonStateTracker::RELEASED && ((*commandIterator)->getGamePadDpadBinding() == Up))
	(*commandIterator)->execute(false);

if (tracker.dpadDown == GamePad::ButtonStateTracker::PRESSED && ((*commandIterator)->getGamePadDpadBinding() == Down))
	(*commandIterator)->execute(true);

else if (tracker.dpadDown == GamePad::ButtonStateTracker::RELEASED && ((*commandIterator)->getGamePadDpadBinding() == Down))
	(*commandIterator)->execute(false);

if (tracker.dpadLeft == GamePad::ButtonStateTracker::PRESSED && ((*commandIterator)->getGamePadDpadBinding() == Left))
	(*commandIterator)->execute(true);

else if (tracker.dpadLeft == GamePad::ButtonStateTracker::RELEASED && ((*commandIterator)->getGamePadDpadBinding() == Left))
	(*commandIterator)->execute(false);

if (tracker.dpadRight == GamePad::ButtonStateTracker::PRESSED && ((*commandIterator)->getGamePadDpadBinding() == Right))
	(*commandIterator)->execute(true);

else if (tracker.dpadRight == GamePad::ButtonStateTracker::RELEASED && ((*commandIterator)->getGamePadDpadBinding() == Right))
	(*commandIterator)->execute(false);

It will process DPad PRESSED lines correctly but will ignore the RELEASED lines but all directions will work. Now if I change it to this:


if (tracker.dpadUp == GamePad::ButtonStateTracker::PRESSED && ((*commandIterator)->getGamePadDpadBinding() == Up))
	(*commandIterator)->execute(true);

else if (tracker.dpadUp == GamePad::ButtonStateTracker::UP && ((*commandIterator)->getGamePadDpadBinding() == Up))
	(*commandIterator)->execute(false);

if (tracker.dpadDown == GamePad::ButtonStateTracker::PRESSED && ((*commandIterator)->getGamePadDpadBinding() == Down))
	(*commandIterator)->execute(true);

else if (tracker.dpadDown == GamePad::ButtonStateTracker::UP && ((*commandIterator)->getGamePadDpadBinding() == Down))
	(*commandIterator)->execute(false);

if (tracker.dpadLeft == GamePad::ButtonStateTracker::PRESSED && ((*commandIterator)->getGamePadDpadBinding() == Left))
	(*commandIterator)->execute(true);

else if (tracker.dpadLeft == GamePad::ButtonStateTracker::UP && ((*commandIterator)->getGamePadDpadBinding() == Left))
	(*commandIterator)->execute(false);

if (tracker.dpadRight == GamePad::ButtonStateTracker::PRESSED && ((*commandIterator)->getGamePadDpadBinding() == Right))
	(*commandIterator)->execute(true);

else if (tracker.dpadRight == GamePad::ButtonStateTracker::UP && ((*commandIterator)->getGamePadDpadBinding() == Right))
	(*commandIterator)->execute(false);

It recognizes both states PRESSED and UP and if I put a break point I can see that it catches on both cases PRESSED and UP but it ignores whatever the first action is like for example I have it setup so that if Left is Pressed it will scroll the map Left and if Right is pressed it scrolls Right.

If I step through the code it triggers on the LEFT it calls the execute method which calls the callback function that handles moving the map correctly but it will not move it. I'm stumped on this one I've spent probably close to 5 hours trying to solve this issue and I know it is probably something simple that I'm just missing which is why I'm hoping that a fresh set of eyes will spot the bug. So please help.

If you need more code related to the issue to understand it please ask.

Darcmagik

Of all the things I've lost I miss my mind the most.

This topic is closed to new replies.

Advertisement