Browse Source

added pointerCount to MouseEvent,

some   /* comments */
pull/527/head
nodoteve 5 years ago
parent
commit
edb96ea4d2
  1. 72
      .vscode/settings.json
  2. 17
      src/Magnum/Platform/AndroidApplication.cpp
  3. 10
      src/Magnum/Platform/AndroidApplication.h

72
.vscode/settings.json vendored

@ -0,0 +1,72 @@
{
"files.associations": {
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
}

17
src/Magnum/Platform/AndroidApplication.cpp

@ -287,12 +287,17 @@ std::int32_t AndroidApplication::inputEvent(android_app* state, AInputEvent* eve
// always >= 1 // always >= 1
const std::size_t pointerCount = AMotionEvent_getPointerCount(event); const std::size_t pointerCount = AMotionEvent_getPointerCount(event);
// Get the persistent id from the index (for what if we have a pointerIndex?) // Get the persistent id from the index
// (for what if we have a pointerIndex?
// They are a bit different.
// Pointer id saves the order of touch events,
// so if you would _release_ them in various orders,
// the 'pointerId' will have the value of initial 'pointerIndex', which might be useful.
// Btw, somehow 'pointerId' does not tell you the last released touch initial index)
std::int32_t pointerId = AMotionEvent_getPointerId(event, pointerIndex); std::int32_t pointerId = AMotionEvent_getPointerId(event, pointerIndex);
// I suppose pointerId less or eq to pointerIndex max val
// pointerId = (pointerId < 0 ? 0 : (size_t)pointerId); //MouseMoveEvent does not support id for now, but it probably should (see AMOTION_EVENT_ACTION_MOVE)
if(pointerId >= arraySize(app._previousMouseMovePosition)) if(pointerId >= arraySize(app._previousMouseMovePosition))
Containers::arrayAppend(app._previousMouseMovePosition, Containers::arrayAppend(app._previousMouseMovePosition,
@ -302,7 +307,7 @@ std::int32_t AndroidApplication::inputEvent(android_app* state, AInputEvent* eve
app._previousMouseMovePosition[pointerId] = {Int(AMotionEvent_getX(event, pointerIndex)), app._previousMouseMovePosition[pointerId] = {Int(AMotionEvent_getX(event, pointerIndex)),
Int(AMotionEvent_getY(event, pointerIndex))}; Int(AMotionEvent_getY(event, pointerIndex))};
MouseEvent e(event, pointerIndex, pointerId); MouseEvent e(event, pointerIndex, pointerId, pointerCount);
action == AMOTION_EVENT_ACTION_POINTER_DOWN ? action == AMOTION_EVENT_ACTION_POINTER_DOWN ?
app.mousePressEvent(e) : app.mouseReleaseEvent(e); app.mousePressEvent(e) : app.mouseReleaseEvent(e);
return e.isAccepted() ? 1 : 0; return e.isAccepted() ? 1 : 0;

10
src/Magnum/Platform/AndroidApplication.h

@ -815,6 +815,7 @@ class AndroidApplication::MouseEvent: public InputEvent {
} }
/** @brief Pointer Index Do we need both of them? /** @brief Pointer Index Do we need both of them?
* Do we really need brief descriptions for index, id, count?
* Index != Id * Index != Id
*/ */
std::size_t pointerIndex() const { return _pointerIndex; } std::size_t pointerIndex() const { return _pointerIndex; }
@ -824,14 +825,19 @@ class AndroidApplication::MouseEvent: public InputEvent {
*/ */
std::size_t pointerId() const { return _pointerId; } std::size_t pointerId() const { return _pointerId; }
/** @brief Pointer count */
std::size_t pointerCount() const { return _pointerCount; }
private: private:
// Did it almost like MouseMoveEvent with _relativePosition // Did it almost like MouseMoveEvent with _relativePosition
explicit MouseEvent(AInputEvent* event, std::size_t pointerIndex = 0, std::int32_t pointerId = 0): explicit MouseEvent(AInputEvent* event, std::size_t pointerIndex = 0, std::int32_t pointerId = 0, std::size_t pointerCount = 1):
/* why not {}, but () instead? */ InputEvent(event), /* why not {}, but () instead? */ InputEvent(event),
_pointerId{pointerId},_pointerIndex{pointerIndex} {} _pointerId{pointerId},_pointerIndex{pointerIndex},_pointerCount{pointerCount} {}
const std::int32_t _pointerId; const std::int32_t _pointerId;
const std::size_t _pointerIndex; const std::size_t _pointerIndex;
const std::size_t _pointerCount;
}; };
/** /**

Loading…
Cancel
Save