I’ve been poking around for a week or so trying to decide if I want to use Panda3d or Ogre as a game engine for a project I’ve had in my mind for over a year, but haven’t had the time/inclination to actual go about creating it. I started piddling around with Panda yesterday by editing the samples when I ran across a disheartening disability within the core of Panda’s abilities.
As the subject may have given it away… There is no distinction between numeric keypad entry and standard qwerty numeric input (that I’m currently aware of). It doesn’t seem like this would be terribly hard to implement beings that they send different key codes when used. Either I have made a grave oversight or (in my opinion) the functionality of Panda’s keyboard input system is at a disadvantage.
I’ve searched the forums, but nothing of value was found. Does anyone know of a work-around for this? I want the normal keyboard numbers to be used for a macro system, the numpad to be used for character movement, and the arrows for camera orbit.
Is there a way to hi-jack the iostream and extrapolate a new data reference for numpad input?
I apologize that my first post is of such a seemingly negative attitude toward Panda.
I assume you mean in Windows? We use MapVirtualKey() to interpret the keycode on Windows, and that function does indeed collapse the distinction between the numeric keypad and the primary number buttons.
One obvious workaround is just to press the “num lock” key, which turns the numeric keypad into the arrow keys.
We have talked about reworking the keyboard handling for a future release of Panda, for reasons such as this. It wouldn’t be hard to put a bit of custom code in yourself, if all you wanted was to add some code to intercept the numeric keypad before it went through MapVirtualKey().
Of course, not all keyboards even have a numeric keypad (particularly not laptops), so depending on the range of hardware you want to make your application available to, you might want to consider your keyboard design carefully.
Mmmm… I may be under the false assumption that we were both talking about a workaround within Panda itself and not writing a custom IO script for Panda.
I was talking about making a change within Panda. In panda/src/windisplay/winGraphicsWindow.cxx, you can find the call to MapVirtualKey(). Before this call you can see a special-case handling of a number of special keys like F1 etc. It would be easy to add all of the numeric keypad keys to this special-case list.
But, really, is it so bad to press the num lock key?
The controls would use almost all of the numpad actually. With the ability to bind literally anything across the keyboard to other functions as well. Thanks for pointing me in the right direction.
Nothing has to be changed within ButtonHandle or KeyboardButton?
Edit: I did a search for them and found the ButtonRegistry section.
Am I correct in assuming that making special cases before MapVirtualKey() and then making register_button calls within KeyboardButton.cxx/KeyboardButton.h will suffice?
Sorry if I’m coming off as a newbie. I haven’t tackled a substantial coding endeavour since I was a CSC major in 2005… I’m fairly rusty, but it’s coming back.
The easiest way to diagnose this is to enable verbose message logging with base.toggleVerbose(). Then press some keys and see what messages are actually generated. For instance, when you press shift-0 you should able to see the ‘shift-0’ event generated. Then check to see what is actually generated when you press shift-numpad_0.
Seeing the actual message generated should give you some insight.