3dgs button logging

Posted By: gamers

3dgs button logging - 11/09/16 11:25

Hi everyone,
I want to save log files in my project. I want to save duration of use; button show time and button click time logs, also log time between them.
How can I do this?
Posted By: Reconnoiter

Re: 3dgs button logging - 11/09/16 14:50

Hi gamers,

For automatically logging general startup and usage info use diag_mode (diag_mode = 1; or diag_mode = 2; , see the manual for this).

Besides that, you can manually create log files by simply writing to a text file (in the manual see Engine Functions -> File Manipulation and than file_str_write etc). Under Engine Variables see 'Time' and 'Statistics' for usefull info for logging/debugging. I am not sure how to get 'button show time' or 'button click time', maybe 'time_panels' or 'time_actions' if you dont have other functions running on the background. Or calculate it manually ofcourse.
(note from the manual for statistic variables: "This variable is valid for the topmost view and only available in the development version, not in the release version.")

Does that help?
Posted By: gamers

Re: 3dgs button logging - 11/13/16 13:00

Hi Reconnoiter,
Thanks for reply,
Is there any tutorial to create this system you know?
Posted By: Reconnoiter

Re: 3dgs button logging - 11/13/16 16:24

Hi gamers,

Not really that I know off (you could check AUM magazine ofcourse, see left bar of this site). Besides that you could check how long a panel (which contains the button object) is visible and store that somewhere. As for 'button click time', I dont entirely get what you mean with this but maybe store the time in your button function increase the time (in a loop) till the user released the left mouse button (mouse_left).
What is it your are trying to accomplish?

Also you use the variable 'total_secs' to save duration of total use of the application.
Posted By: gamers

Re: 3dgs button logging - 11/14/16 08:07

Hi Reconnoiter,
I want to save keystroke counts in a log file, especially for some keys such as key a and key l. Also I want to save the data that while a panel appears and users click a key to close this panel screen and I want to save time these two between events (panel appears time --> keystroke to close panel time).
Posted By: Reconnoiter

Re: 3dgs button logging - 11/14/16 11:03

Oh keystrokes, I thought with button you meant literally the button element which panels can have.
To check which key the user pressed last use 'key_lastpressed'. See the manual for more info (Engine Variables -> Input/output -> Keyboard -> key_lastpressed).

Quote:
Also I want to save the data that while a panel appears and users click a key to close this panel screen and I want to save time these two between events (panel appears time --> keystroke to close panel time).
, there are a few ways. First you will have to know when the panel is shown. Most easiest is to just check in a while loop (like the one from your Main function) if the panel is shown, and when shown begin a timer till the panel is closed. When the panel is closed you can save the timer variable somewhere. Example:

Code:
function Main () {
   ....
  var timer = 0;

while (1) {
 ...
 if (is(myPanel, SHOW)) {
    timer += time_step / 16; //add 1 point per sec
 }
 else { //panel is not shown?
   if (timer > 0) { //timer was started and panel is closed?
     ....save timer variable somewhere...
     timer = 0; //reset
   }
 }

 wait(1);
}

}

Posted By: txesmi

Re: 3dgs button logging - 11/15/16 06:06

Hi,
I would use acknex log file.

Code:
#include <acknex.h>

STRING *strDiag = "#128";

void keyLog ( var _key )
{
	str_cpy ( strDiag, "" );
	str_cat_num ( strDiag, "\n%06.0f", total_ticks );
	str_cat_num ( strDiag, " (%03.0f) ", _key );
	STRING *_strKey = str_for_key ( NULL, _key );
	if ( _strKey )
	{
		str_cat ( strDiag, _strKey );
		str_cat ( strDiag, " " );
	}
	str_cat ( strDiag, "hit" );
	diag ( strDiag->chars );
	
	var _timer = total_ticks;
	while ( key_pressed ( _key ) )
		wait(1);
	var _secs = ( total_ticks - _timer ) / 16;
	
	str_cpy ( strDiag, "" );
	str_cat_num ( strDiag, "\n%06.0f", total_ticks );
	str_cat_num ( strDiag, " (%03.0f) ", _key );
	_strKey = str_for_key ( NULL, _key );
	if ( _strKey )
	{
		str_cat ( strDiag, _strKey );
		str_cat ( strDiag, " " );
	}
	str_cat_num ( strDiag, "released, %.3f seconds held", _secs );
	diag ( strDiag->chars );
}

void main ()
{
	var lastOld = key_lastpressed;
	while ( 1 )
	{
		if ( lastOld != key_lastpressed )
		{
			keyLog ( key_lastpressed );
			lastOld = key_lastpressed;
		}
		wait(1);
	}
}



Salud!
Posted By: gamers

Re: 3dgs button logging - 11/17/16 11:02

Thanks for replies, yo're wonderful laugh
© 2024 lite-C Forums