Welcome to %s forums

BrainModular Users Forum

Login Register

Mouse Deta, best strategy to get?

Create your own modules in C++
Post Reply
23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 20 Apr 2015, 16:41

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?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 20 Apr 2015, 16:53

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);

martignasse
Site Admin
Posts: 611
Location: Lyon, FRANCE
Contact:

Unread post by martignasse » 22 Apr 2015, 17:54

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
Martin FLEURENT - Usine Developer - SDK maintainer

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 22 Apr 2015, 19:08

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

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests