Jump to content
  • Advertisement
Sign in to follow this  

Input handling system

This topic is 2146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I know there has been qute a few topics like this but none of them turned out to be useful for my case. I'm in the middle of the development of my simple engine but I'm struggling with creating a fast reliable input manager. To illustrate my case let me show you my choose of design.

Main Entry -> Instantiates a SystemClass that encapsulates the following factories:

  • InputManager
  • GraphicsManager - Handles Direct3D related code.

    • CameraManager
    • TextureManager
    • EffectManader
    • LightManager
    • MeshManager
    • TimerManager
    • Demo Projects - Derives from DirectXManager

      To handle user input I'm using the WINAPI Message handler like:
      [source lang="cpp"]LRESULT CALLBACK SystemClass::MsgHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
      switch (uMsg)
      case WM_KEYDOWN:
      case WM_KEYUP:

      case WM_LBUTTONDOWN:
      case WM_MBUTTONDOWN:
      case WM_RBUTTONDOWN:

      case WM_LBUTTONUP:
      case WM_MBUTTONUP:
      case WM_RBUTTONUP:

      case WM_MOUSEMOVE:
      m_GraphicsHandler->OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
      You can see the basic idea. The GraphicsHandler has the necessary functions which handles the user Events. My last attempt was something like this:

      [source lang="cpp"]class InputFactory
      static InputFactory* Instance;
      static InputFactory* GetInstance(void);
      IHandler* CreateHandler(HandlerType hType = HandlerType::MouseHandler);


      class IHandler
      friend class InputFactory;
      struct Event
      EventType eType;
      void (*Handler)(MappedKey mKey, State* hState);
      std::queue<Event> Interactions;
      void RegisterEvent(EventType eType = EventType::MouseEvent, ...);
      void ProcessEvent(void);
      I think you get the main idea. My problem with this approach is that it's way too complex and hard to add new features. Not to mention that to modify the keybindings it's a nightmare. I found an article about inputmanager here on gamedev.net but I can't apply it to my case. Edited by Wrath87

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!