InputDummy.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Input/Input.h>
  6. #include <AnKi/Core/NativeWindow.h>
  7. namespace anki {
  8. Error Input::newInstance(AllocAlignedCallback allocCallback, void* allocCallbackUserData, NativeWindow* nativeWindow,
  9. Input*& input)
  10. {
  11. ANKI_ASSERT(allocCallback && nativeWindow);
  12. Input* ainput = static_cast<Input*>(allocCallback(allocCallbackUserData, nullptr, sizeof(Input), alignof(Input)));
  13. callConstructor(*ainput);
  14. ainput->m_pool.init(allocCallback, allocCallbackUserData);
  15. ainput->m_nativeWindow = nativeWindow;
  16. input = ainput;
  17. return Error::kNone;
  18. }
  19. void Input::deleteInstance(Input* input)
  20. {
  21. if(input)
  22. {
  23. AllocAlignedCallback callback = input->m_pool.getAllocationCallback();
  24. void* userData = input->m_pool.getAllocationCallbackUserData();
  25. callDestructor(*input);
  26. callback(userData, input, 0, 0);
  27. }
  28. }
  29. Error Input::handleEvents()
  30. {
  31. if(m_lockCurs)
  32. {
  33. moveCursor(Vec2(0.0f));
  34. }
  35. return Error::kNone;
  36. }
  37. void Input::moveCursor(const Vec2& posNdc)
  38. {
  39. m_mousePosNdc = posNdc;
  40. m_mousePosWin.x() = U32(F32(m_nativeWindow->getWidth()) * (posNdc.x() * 0.5f + 0.5f));
  41. m_mousePosWin.y() = U32(F32(m_nativeWindow->getHeight()) * (-posNdc.y() * 0.5f + 0.5f));
  42. }
  43. void Input::hideCursor([[maybe_unused]] Bool hide)
  44. {
  45. // Nothing
  46. }
  47. Bool Input::hasTouchDevice() const
  48. {
  49. return false;
  50. }
  51. } // end namespace anki