Skip to content

Commit

Permalink
Fixed inconsistency between sf::Touch::getPosition and touch events.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase W committed Apr 29, 2015
1 parent e017454 commit 653c0fd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/SFML/Window/iOS/SFAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ - (void)setVirtualKeyboardVisible:(bool)visible
////////////////////////////////////////////////////////////
- (void)notifyTouchBegin:(unsigned int)index atPosition:(sf::Vector2i)position;
{
position.x *= backingScaleFactor;
position.y *= backingScaleFactor;

// save the touch position
if (index >= touchPositions.size())
touchPositions.resize(index + 1, sf::Vector2i(-1, -1));
Expand All @@ -253,8 +256,8 @@ - (void)notifyTouchBegin:(unsigned int)index atPosition:(sf::Vector2i)position;
sf::Event event;
event.type = sf::Event::TouchBegan;
event.touch.finger = index;
event.touch.x = position.x * backingScaleFactor;
event.touch.y = position.y * backingScaleFactor;
event.touch.x = position.x;
event.touch.y = position.y;
sfWindow->forwardEvent(event);
}
}
Expand All @@ -263,6 +266,9 @@ - (void)notifyTouchBegin:(unsigned int)index atPosition:(sf::Vector2i)position;
////////////////////////////////////////////////////////////
- (void)notifyTouchMove:(unsigned int)index atPosition:(sf::Vector2i)position;
{
position.x *= backingScaleFactor;
position.y *= backingScaleFactor;

// save the touch position
if (index >= touchPositions.size())
touchPositions.resize(index + 1, sf::Vector2i(-1, -1));
Expand All @@ -274,8 +280,8 @@ - (void)notifyTouchMove:(unsigned int)index atPosition:(sf::Vector2i)position;
sf::Event event;
event.type = sf::Event::TouchMoved;
event.touch.finger = index;
event.touch.x = position.x * backingScaleFactor;
event.touch.y = position.y * backingScaleFactor;
event.touch.x = position.x;
event.touch.y = position.y;
sfWindow->forwardEvent(event);
}
}
Expand Down

0 comments on commit 653c0fd

Please sign in to comment.