Jump to content

Buffered input


photo

Recommended Posts

Currently we are using buffered input in order not to skip user input even when the frame rate drops.

So far we are successful by using the below functions. The user inputs are not skipped even when the FPS is below 5.

// Keyboard callbacks
engine.controls.setKeyPressCallback();
engine.controls.setKeyReleaseCallback();
// Mouse callbacks
engine.controls.setButtonPressCallback();
engine.controls.setButtonReleaseCallback();

 

 

But with the GUI widgets, the callbacks are only processed once per frame. That means many user inputs are skipped when the FPS drops.

To overcome this we are trying to use the first set of callback functions for GUI as well. Then do the hit test for the widgets and execute the callback accordingly. But in this case we don't want the Unigine GUI do any processing and callbacks.

1. Is there any way we can disable/enable the GUI processing from Unigine? In this case we'd like to get the raw input from Unigine and invoke the GUI callbacks explicitly. But we haven't yet figured out how to disable Unigine GUI from processing input.

 

2. This work around prevents us from using a lot of rich functionalities provided by the Unigine GUI. Is there a better way of doing this?

Link to comment

By default these functions (engine.controls.setKeyPressCallback() etc) return 0. If you want to handle input manually, they should return 1:

 

int callback() {
   return 1;
}

engine.controls.setButtonPressCallback("callback"); 

 

You can also disable callback handling on per widget basis. Use setCallbackEnabled() and runCallback(). For example:

 

widget.setCallbackEnabled(GUI_CLICKED,0);
widget.runCallback(GUI_CLICKED);

Link to comment

I tried running the callback manually by using:

widget.runCallback(GUI_CLICKED);

 

But as soon as I disable the widget's callback by

widget.setCallbackEnabled(GUI_CLICKED,0);

to prevent it from getting executed automatically by GUI, the runCallback() ceases to have any effect.

Link to comment
  • 3 weeks later...

But as soon as I disable the widget's callback by

widget.setCallbackEnabled(GUI_CLICKED,0);

to prevent it from getting executed automatically by GUI, the runCallback() ceases to have any effect.

You are right, sorry for the mislead. In this case, use the first suggested variant.

Link to comment
×
×
  • Create New...