Jump to content

  • Log In with Google      Sign In   
  • Create Account


Input handling system


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Wrath87   Members   -  Reputation: 110

Like
0Likes
Like

Posted 04 July 2012 - 01:49 PM

Greetings,

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));break;}[/source]
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; InputFactory(void);public: static InputFactory* GetInstance(void); IHandler* CreateHandler(HandlerType hType = HandlerType::MouseHandler); ~InputFactory(void)};class IHandler{ friend class InputFactory;protected: struct Event { private: EventType eType; void (*Handler)(MappedKey mKey, State* hState); };private: std::queue<Event> Interactions;public: void RegisterEvent(EventType eType = EventType::MouseEvent, ...); void ProcessEvent(void);};[/source]
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, 04 July 2012 - 01:50 PM.


Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 15067

Like
0Likes
Like

Posted 04 July 2012 - 02:54 PM

Assuming you're talking about this article, why do you think you can't apply it to your situation?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS