Romain TISSERAND wrote:
Hello,
>
I agree this is something essential.
>
On our side, we have hooked SDL input support into a custom Win32 main loop, it does the job (Game running with gamepad, mouse, keyboard on win32) but the design is ugly.
Plus relying on SDL is probably the lazy options, and adds a fat dependency to Cocos-2D-X.
>
Any other ideas/suggestions ?
This is indeed something essential if Cocos2dx wants to promote themselves as being able to create desktop games. I was thinking about using some media framework such as SDL or SFML (http://www.sfml-dev.org/). However I did not like the idea of adding another framework in to the game. As you mentioned, it’s not the best design and shouldn’t really be necessary in the first place! I was learning towards using SFML since it is divided neatly into five modules. Since they are independent, I could just package the one module that deals with input with my game, cutting out 4/5’s of the framework in my build. Again I shouldn’t be having to rely on another media framework, but it should work.
I was then thinking, for windows games at least, of using DirectInput (http://msdn.microsoft.com/en-us/library/windows/desktop/ee416853(v=vs.85).aspx) for joystick support and this (http://msdn.microsoft.com/en-us/library/windows/desktop/ms632585(v=vs.85).aspx) for mouse and keyboard support. Excuse my ignorance as I have not looked into it too much, but it may seem too low level and too much hard work to implement these with Cocos2dx. I’m still not sure about this approach, though.
Hugo Souza wrote:
Yesterday I asked a similar question, but specifically about a callback function for mouse movement, and got not reply. Asking on other forums, I confirmed what I had discovered from digging the code, there isn’t a way to do it. It seems that, since Cocos is aimed for mobile platforms, some standard concepts from Desktop (such as a pointer/mouse) aren’t implemented. For mouse movement (and I suppose, for keyboard/gamepad/joystick) you could try using the update()/sheduleUpdate() (which is what I’m using). It’s not the as some function being called upon user input, but it’s the best you can get at this point without making changes to the default WinProc function.
I understand that Cocos2d is aimed at mobile platforms, but I was not expecting a huge lack of nearly compulsory features was surprising. I honestly took user input functionality for granted, and just assumed it was implemented. Don’t get me wrong, it’s still a great engine, but I was disappointed, as well as surprised, in this area.
Sorry to both that I will not be able to contribute in the WindowProc conversation, as I have not yet started developing on this engine and therefore have no knowledge on this, just yet. I hope steps are made in the right direction.