jME3 Temporarily removing inputs [Resolved]

Hello!



What’s the best way of going about temporarily removing an input or inputs?



What I was attempting to do was remove the “toggleRotate” mapping for the ChaseCamera, and add the same mapping back, with only the right mouse button as it’s trigger so I could free up the left mouse button. However, simply calling inputManager.addMapping(“toggleRotate”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT)) did not restore the functionality.



On this same note then, how would one go about temporarily suspending a set of inputs say, for the duration of a cutscene where all you’d need is one button to progress text (if even that)?



Hoping this doesn’t require flopping entire listeners around XD



Thanks!

~FlaH

Look at the source of SimpleApplication. You have to specify the flycam as listener to the mapping, not add a new mapping.

Hello again!



Ah I understand. For some reason it didn’t occur to me that deleting the mapping also took it out of the listener. I should have realized that was the case! XD



Below is what I ended up with for reference. Might come in handy for someone else someday. ~ Basically what this does is just remove the click to rotate functionality of the chase camera for both the left and right mouse buttons, and then adds back in the right mouse button for that functionality. Thus, freeing up the left mouse button for whatever you have planned.



Thanks Normen!



[java]

inputManager.deleteMapping(“toggleRotate”);

inputManager.addMapping(“toggleRotate”, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));

inputManager.addListener(chaseCam, “toggleRotate”);

inputManager.addMapping(“interact”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));



inputManager.addListener(mouseButtonListener, new String[]{“interact”});

[/java]



[java]

private ActionListener mouseButtonListener = new ActionListener() {

public void onAction(String name, boolean keyPressed, float tpf) {

if(name.equals(“interact”) && keyPressed) {

if(mouseHoverTarget != null) {

mouseHoverTarget.performInteraction();

}

}

}

};

[/java]

Actually you just need to remove the listener to that mapping, not the mapping itself.

Hello!



Oh? Is there a way to snipe the mapping like that? All I saw was the removeListener(listener) and deleteMapping(string mapping) methods, unless I’m so far behind on builds that I’m missing something ;p If I remove the listener I’d lose the functionality of the chasecam altogether so I know that’s not it…



~FlaH

Or…i could just remove the mapping on the left button, 2 buttons to rotate the view is one too much…

And allow the user to easily choose which button will rotate the view…

Blame world of warcraft…i played for too long and just earned bad habits :stuck_out_tongue:

hah. Ah well.



I was actually debating on modifying the chaseCam early as it didn’t have many features when I first used it, but I thought I’d just handle that later. Now, I’m glad I did since the chaseCam is pretty darn featured out now :smiley: So the main reason I didn’t want to go in there myself was the fear of accidentally missing out on more awesomeness on updates! =p I played around with the smooth motion effects a few days ago and thought it was pretty neat. I need to nail down what I want to do with the camera in-game, but it’s likely I’ll make use of that.



Thanks guys!

~FlaH