BsOISPlugin.cpp 1.3 KB

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