2
0

CmOISPlugin.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "CmOISPrerequisites.h"
  2. #include "CmInputHandlerOIS.h"
  3. #include "CmRenderWindow.h"
  4. #include "CmApplication.h"
  5. #include "CmInput.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Returns a name of the plugin.
  10. */
  11. extern "C" BS_OIS_EXPORT const String& getPluginName()
  12. {
  13. static String pluginName = "OISInput";
  14. return pluginName;
  15. }
  16. /**
  17. * @brief Entry point to the plugin. Called by the engine when the plugin is loaded.
  18. */
  19. extern "C" BS_OIS_EXPORT void* loadPlugin()
  20. {
  21. RenderWindowPtr primaryWindow = gApplication().getPrimaryWindow();
  22. if (primaryWindow == nullptr)
  23. assert(false && "Unable to get window handle. No active window exists!");
  24. UINT64 windowId = 0;
  25. primaryWindow->getCustomAttribute("WINDOW", &windowId);
  26. // TODO - Window handles in Windows are 64 bits when compiled as x64, but OIS only accepts a 32bit value. Is this okay?
  27. std::shared_ptr<RawInputHandler> inputHandler = cm_shared_ptr<InputHandlerOIS>((UINT32)windowId);
  28. gInput()._registerRawInputHandler(inputHandler);
  29. return nullptr;
  30. }
  31. }