Page 1 of 1

Posted: 20 Apr 2015, 16:41
by 23fx23
I would ideally need a mouse delta for several stuff. (on mtcontrol type module)
i dlike to see while moving if going left or right (and later maybe acceleration, so delta seems the best variable)

I will investigate and repport my finds but I was wondering what would be most efficient stategy to get it, in terms of cpu and easyness.

sounds not the best way to make process active just for this, but maybe it's the only way to go?,
or maybe make/set a 'physical' parameter and compare would work. will try.

could there be a trick code im not aware of, to directly get this on the ::onmove callback without process or setting a param?

any global ideas?

Posted: 20 Apr 2015, 16:53
by 23fx23
sry never mind found a way to go.^^
if interested in (maybe not the best way but works)

created static float vars prevX and deta, at top of code. init them booth at 0 on ::onMouseDown

then in :: onMouseMove code looks like:

delta = X - prevX;

if (delta !=0)
{
DELTA_LOCK_DIR = (delta > 0);
prevX = X;
}

sdkTraceInt(DELTA_LOCK_DIR);

Posted: 22 Apr 2015, 17:54
by martignasse
you can check the GranulatorModule.cpp, it do exactly that

try to avoid global static variable, as they can collide if you have more that one module instance. Prefer class member variable

Posted: 22 Apr 2015, 19:08
by 23fx23
i was wondering that and was about to ask, tahnks 4 the clue!
how i missed that in the exemple, have definitely to recheck them all ;)
i first made tons of static stuff in top of made code^^, now i put them all in header without static