BsOISPlugin.cpp 1.0 KB

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