Keyboard input
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 01:35, xxxxxxxx wrote:
Hi Lennart.
This doesn't seem to work either. I thought the whole point of these keyboard and mouse functions is that you don't need to use the GetInputState() as msg is already the container with all the input data.
Phil -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 03:16, xxxxxxxx wrote:
If you want to replicate the CTRL+move behavior, here's how to do it:
def MouseInput(self, doc, data, bd, win, msg) : if msg[c4d.BFM_INPUT_QUALIFIER]&c4d.QCTRL: print "CTRL Qualifier" if msg.GetLong(c4d.BFM_INPUT_CHANNEL)==c4d.BFM_INPUT_MOUSELEFT: print "Begin Mouse Left Pressed" while True: bc = c4d.BaseContainer() if gui.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, bc) : if bc.GetLong(c4d.BFM_INPUT_CHANNEL)==c4d.BFM_INPUT_MOUSELEFT: if not bc.GetBool(c4d.BFM_INPUT_VALUE) : break print "End Mouse Left Pressed" return True return False
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 03:29, xxxxxxxx wrote:
Hi Yannick thank you very much for your effort.
You're absolutely right this simulates exactly the cloning behavior and it's really good to know where to put these queries.
But I'm guessing it is just not possible to get the qualifier key working alone like a normal key (as I need to change the visual feedback before the mousebutton is clicked), as Scott suggested.
Sorry for all the trouble, I guess I will put some kind of gizmo in the viewport and when clicked it will change the mode.
Thanks again
Phil -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 03:57, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I'm almost on giving up on CTRL or SHIFT and thought why not use a character key. Problem is I don't know how to check it. The SDK says >BFM_INPUT_CHANNEL
LONG
The channel contains the key or button ('A' means A, KEY_F1 means F1)F1, F2, and so on work without problem, a character not so much. I tried c4d.A, not working, I tried it as a string 'A', and I'm running out of ideas
In the case of a key pressed, the channel returned is an integer value containing the ASCII code of the key.
In Python we can call ord()/unichr() to convert a key code from/to its character. Here's some code:def KeyboardInput(self, doc, data, bd, win, msg) : channel = msg.GetLong(c4d.BFM_INPUT_CHANNEL) if channel<128: # ascii key code chr = str(unichr(channel)) print chr if chr=='B': return True else: #see KEY_ enum print channel return False
Also, only return True if you really used the event. So if you return False the event is passed along and not blocked.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 04:07, xxxxxxxx wrote:
Originally posted by xxxxxxxx
But I'm guessing it is just not possible to get the qualifier key working alone like a normal key (as I need to change the visual feedback before the mousebutton is clicked), as Scott suggested.
Yes, CTRL and SHIFT qualifiers are not 'normal' keys and are processed in a different way by CINEMA in plugins input events.
Qualifiers are meant to be used in association with other keys. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 04:27, xxxxxxxx wrote:
Alright, then I'm giving up on that thought, nevertheless the character-key-stuff will be really helpful.
Thanks again for all the effort.
Phil -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 08:55, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Yes, CTRL and SHIFT qualifiers are not 'normal' keys and are processed in a different way by CINEMA in plugins input events.
Qualifiers are meant to be used in association with other keys.Could you please offer an explanation why this was changed from the way C++ qualifiers work Yannick?
In C++ we can use the qualifier keys all by themselves without needing to press a second key.
In my own personal opinion...I really like that. And I find it rather annoying that it's not doable within python plugins.
But maybe I'm missing the down side of having it set up this way.There must be a reason (benefit) why Sebastian decided to deviate from the C++ SDK implementation of the qualifiers. Could you please tell us what that reasoning(benefit?) is for changing it?
Thanks,
-ScottA -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 09:37, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Could you please offer an explanation why this was changed from the way C++ qualifiers work Yannick?
In C++ we can use the qualifier keys all by themselves without needing to press a second key.
In my own personal opinion...I really like that. And I find it rather annoying that it's not doable within python plugins.
But maybe I'm missing the down side of having it set up this way.I don't see any difference between qualifiers in C++ and Python plugins.
In both C++ and Python we have to press a second key/mouse button to enter KeyboardInput()/MouseInput().
Do you have some code showing this? I have seen the code posted by Scott above but the behavior is the same. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 10:04, xxxxxxxx wrote:
I'm referring to just the keyboard actions by themselves.
Not combined with mouse events. **C++ plugin version**
When we press the Ctrl key all by itself. We get a return returnGetInputState(BFM_INPUT_KEYBOARD, BFM_INPUT_CHANNEL, msg); if(msg.GetLong(BFM_INPUT_QUALIFIER) & QCTRL) { GePrint("You pushed the ctrl key"); }
Python plugin version.
When we press the Ctrl key all by itself. We do not get a return.
We only get a return if another key besides the Ctrl key is pressedc4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.BFM_INPUT_CHANNEL, msg) if msg.GetLong(c4d.BFM_INPUT_QUALIFIER) & c4d.QCTRL: print "You pushed the ctrl key"
What makes this whole thing even more strange to me is that if you use this code in a python script or python tag instead of a plugin. The Ctrl key works like the C++ implementation. Meaning..You don't have to hold down a second key to get a result when the Ctrl key is pressed all by itself.
So just in python.
What I'm seeing is that we have two different qualifier behaviors occurring. Depending on whether it's used in a plugin situation. Or in a script or python tag situation. Using the same code.
Is this a bug? Or is it intentional for some reason?-ScottA
*Edit
Just for sake of full clarity. Here's the python tag code I'm using.
With the timeline running. I get a return from pressing just the Ctrl key by itself.
While in a python plugin scenario. This does not return anything unless a second key is pressed.
This is the same code as the python plugin code. Except of course I have to create the container by hand.import c4d def main() : msg = c4d.BaseContainer() c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.BFM_INPUT_CHANNEL, msg) if msg.GetLong(c4d.BFM_INPUT_QUALIFIER) & c4d.QCTRL: print "You pushed the ctrl key"
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 11:01, xxxxxxxx wrote:
I can't confirm this. In both C++ and Python plugins the behavior is the same: KeyboardInput() is never called when we just press CTRL or SHIFT.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 11:36, xxxxxxxx wrote:
Are using R14 to test this Yannick?
I just tested the code in a python tag in the R14 demo. And indeed it doesn't seem to work the same way as in R12&R13.
Maybe that's why we're getting different results?I still haven't used R14 that much yet. So I'm not very familiar with it. But from what I understand. Maxon changed the Ctrl key options a lot in R14 compared to earlier versions.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 11:58, xxxxxxxx wrote:
I'm using R14 and I can confirm it works on a python tag, although only when I hit the play-button in the timeline.
Phil -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 12:17, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I'm using R14 and I can confirm it works on a python tag, although only when I hit the play-button in the timeline.
Yes your code works.
We're talking about completely different things.
I'm talking about plugins with keyboard or mouse input events == ToolData, ObjectData etc. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 13:55, xxxxxxxx wrote:
I apologize for the confusion guys.
I'm finding out that that the qualifier behaviors change a lot depending upon the specific case they are used in. And not really so much a Python vs. C++ differences kind of thing as I thought.This is what I've found:
Python Scripts and Both Python & C++ tags:
Only the Ctrl key needs to be pressed to get a return. No second key needed.Plugins (tool, object,etc..) Both Python & C++
The Ctrl key needs a second key to get a returnPlugins (GeDialog) C++ and Python
When a button or other gizmo is being pressed or activated...Only the Ctrl key needs to be pressed to get a return. No second key needed.I had no idea the qualifiers behaviors changed so much. Depending on the specific type of script, tag, or plugin they are used in.
Sorry for any confusion I may have caused.
I had no idea they worked like this.-ScottA