BsOISPlugin.cpp 1.4 KB

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