Removed love.touch.getTouchCount and love.touch.getTouch. Added love.touch.getTouchIDs and love.touch.getPosition.

love.touch.getTouchIDs returns an array of all currently active touch IDs. love.touch.getPosition takes an active touch ID and returns the current position of that touch.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2015-02-17 18:33:59 -04:00
parent 482b61187f
commit 77d90e2260
5 changed files with 44 additions and 37 deletions
+14 -14
View File
@@ -30,25 +30,25 @@ namespace touch
namespace sdl
{
int Touch::getTouchCount() const
std::vector<int64> Touch::getTouchIDs() const
{
return (int) touches.size();
std::vector<int64> ids;
ids.reserve(touches.size());
for (const auto &touch : touches)
ids.push_back(touch.first);
return ids;
}
Touch::TouchInfo Touch::getTouch(int index) const
void Touch::getPosition(int64 id, double &x, double &y) const
{
if (index < 0)
throw love::Exception("Invalid touch index: %d", index);
const auto it = touches.find(id);
if (it == touches.end())
throw love::Exception("Invalid active touch ID: %d", id);
std::map<int64, TouchInfo>::const_iterator it = touches.begin();
for (int i = 0; i < index; i++)
{
if (++it == touches.end())
throw love::Exception("Invalid touch index: %d", index);
}
return it->second;
x = it->second.x;
y = it->second.y;
}
const char *Touch::getName() const
+2 -2
View File
@@ -43,8 +43,8 @@ public:
virtual ~Touch() {}
virtual int getTouchCount() const;
virtual TouchInfo getTouch(int index) const;
virtual std::vector<int64> getTouchIDs() const;
virtual void getPosition(int64 id, double &x, double &y) const;
// Implements Module.
virtual const char *getName() const;