Jump to content

[SOLVED] Bugs in InputDeviceMouse?


photo

Recommended Posts

I created some mouse actions in my xml file like this:

 

<action name="mouseLeft">

<input device="Mouse" state="LEFT"/>

</action>

 

The corresponding action_def looks like this:

 

<action_def name="mouseLeft" min="0" max="1" neutral="0" type="state"/>

 

When debugging, I have found that when InputDeviceMouse::getState is called, the value for i passed in is 0.

 

If you look at the logic, it is going to return here:

 

if (i==0) return float(engine.controls.getMouseDX());

 

So first off, it seems the LEFT button is mapped to 0, but the left axis is also mapped to 0.

 

A second problem is this line:

 

if (i < NUM_BUTTONS) {

 

I think you were intending to offset the ids for the buttons by 2, to make room for the axes.

 

So the above line should be this:

 

if (i < NUM_BUTTONS+2){

 

likewise, the lines below that also appear to be problems, anywhere where it uses 1 << i, it seems like it should be 1 << (i-2) to me.

 

Note that in other code, it properly does subtract from i before shifting it.  Such as in getStateName:

 

return engine.app.getMouseButtonName(1 << (i - NUM_AXES));

 

 

 

 

Link to comment

Oh, I now see that it first subtracts NUM_AXES from i before going into that code.

 

So the code is correct, but the problem still remains that both the LEFT button and the x axis are mapped to the same input.

Link to comment

Ok sorry, I figured this out.  I was assuming that we entered the string it prints out in the control_setup_window into the state field in the xml file.  However, it looks like we're just supposed to enter in the integer id that the code is looking for.

 

Problem is, it's really hard to know what that id is without debugging the code first.

 

It'd be great if that was listed in the docs somewhere.  Or even better, in the next version we could enter something human-readable into that state field, like state="left" instead of state="2".  The way it currently is almost makes those xml files pointless since the idea of having the xml file is a convenient place to edit mappings for a non-programmer, but you don't know what those mappings are unless you're a programmer and can debug it.

Link to comment
×
×
  • Create New...