User Tag List

Results 1 to 7 of 7

Thread: How can I make an instant-condition in Fusion?

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    AlanRuno's Avatar
    Join Date
    May 2013
    Posts
    344
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How can I make an instant-condition in Fusion?

    Hi!
    I've been developing a Phidgets extension for Fusion.
    It's going really good.

    In case you don't know what a Phidget is:
    https://www.phidgets.com/

    However I have a question regarding Windows Extension Development.
    How can I make an instant condition? Those conditions that appear green on the editor and are triggered immediately?

    Thanks in advance!

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleInstall CreatorInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Aug 2006
    Location
    France
    Posts
    1,240
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Hello,
    What SDK do you use ?

    You are a flag for condition param to says that is an event. To call event you need to call the function:
    Code:
    rdPtr->rRd->GenerateEvent(CONDITION_ID);


  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    AlanRuno's Avatar
    Join Date
    May 2013
    Posts
    344
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Xenon3000 View Post
    Hello,
    What SDK do you use ?

    You are a flag for condition param to says that is an event. To call event you need to call the function:
    Code:
    rdPtr->rRd->GenerateEvent(CONDITION_ID);

    Hey! Thanks for the response!
    Im using fusion 2.5 sdk
    How can i flag the condition as an event? I checked out the examples I might have missed that.
    what if I don't have rdPtr in scope inside the function triggered??

  4. #4
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    13,560
    Mentioned
    208 Post(s)
    Tagged
    3 Thread(s)
    Normal conditions have the EVFLAGS_ALWAYS flag. If you remove it, it's a triggered (green) condition. See the "Condition flags" topic in the SDK documentation.

    The Simple Control example provided in the SDK has an example of such a condition: CND_CHANGED. Check also how the condition has to be implemented:

    Code:
    long WINAPI DLLExport CndChanged(LPRDATA rdPtr, long param1, long param2)
    {
    	// Always TRUE if first condition
    	if (rdPtr->rHo.hoFlags & HOF_TRUEEVENT)
    		return TRUE;
    
    	// Otherwise true only if same loop number
        LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;
    	if ( rhPtr->rh4.rh4EventCount == rdPtr->dwLastChangedLoopNumber )
    		return TRUE;
    
    	return FALSE;
    }
    long WINAPI DLLExport CndChanged(LPRDATA rdPtr, long param1, long param2)
    {
    	// Always TRUE if first condition
    	if (rdPtr->rHo.hoFlags & HOF_TRUEEVENT)
    		return TRUE;
    
    	// Otherwise true only if same loop number
    	LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;
    	if ( rhPtr->rh4.rh4EventCount == rdPtr->dwLastChangedLoopNumber )
    		return TRUE;
    
    	return FALSE;
    }
    rh4EventCount is the current game loop number, dwLastChangedLoopNumber is the loop number when the event is triggered (stored in Runtime.cpp).

  5. #5
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    AlanRuno's Avatar
    Join Date
    May 2013
    Posts
    344
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Yves View Post
    Normal conditions have the EVFLAGS_ALWAYS flag. If you remove it, it's a triggered (green) condition. See the "Condition flags" topic in the SDK documentation.

    The Simple Control example provided in the SDK has an example of such a condition: CND_CHANGED. Check also how the condition has to be implemented:

    Code:
    long WINAPI DLLExport CndChanged(LPRDATA rdPtr, long param1, long param2)
    {
    	// Always TRUE if first condition
    	if (rdPtr->rHo.hoFlags & HOF_TRUEEVENT)
    		return TRUE;
    
    	// Otherwise true only if same loop number
        LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;
    	if ( rhPtr->rh4.rh4EventCount == rdPtr->dwLastChangedLoopNumber )
    		return TRUE;
    
    	return FALSE;
    }
    long WINAPI DLLExport CndChanged(LPRDATA rdPtr, long param1, long param2)
    {
    	// Always TRUE if first condition
    	if (rdPtr->rHo.hoFlags & HOF_TRUEEVENT)
    		return TRUE;
    
    	// Otherwise true only if same loop number
    	LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;
    	if ( rhPtr->rh4.rh4EventCount == rdPtr->dwLastChangedLoopNumber )
    		return TRUE;
    
    	return FALSE;
    }
    rh4EventCount is the current game loop number, dwLastChangedLoopNumber is the loop number when the event is triggered (stored in Runtime.cpp).
    Excelent!
    Thank you for that info!
    However I've gotten into a situation , because of my lack of experience, where I don't have the runtime data on scope inside a function that needs to trigger the instant event.

    This is the function that needs to trigger the instant event:
    Code:
    static void CCONV onDistanceChange(PhidgetDistanceSensorHandle ch, void* ctx, uint32_t distance) {
    	
    	int port;
    	Phidget_getHubPort((PhidgetHandle)ch, & port);
    	::GPV_last_distance_port = port;
    
    	switch (port) {
    	case 0:
    		::GPV_last_distance_changed = 1;
    		::GPV_last_distance_value = distance;
    		break;
    	case 2:
    		::GPV_last_distance_changed1 = 1;
    		::GPV_last_distance_value1 = distance;
    		break;
    	case 3:
    		::GPV_last_distance_changed2 = 1;
    		::GPV_last_distance_value2 = distance;
    		break;
    	case 4:
    		::GPV_last_distance_changed3 = 1;
    		::GPV_last_distance_value3 = distance;
    		break;
    	default:
    		break;
    	}
    
    	//LPRDATA rdPtr = ::GPV_runtime_pointer; // no :(
    	//GenerateEvent(NULL,3); // no :(
    
    	PhidgetLog_log(PHIDGET_LOG_CRITICAL, "Distance Changed");
    }
    As you can see, I had to make a switch to set duplicated global values and trigger duplicated regular conditions (distance1, distance2 etc.)
    I want to call an instant condition and be able to retrieve the port instantly. but I don't know how to call an instant function from here. Because this function gets called by the device-threaded handler and doesn't pass the rdPtr.

  6. #6
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    13,560
    Mentioned
    208 Post(s)
    Tagged
    3 Thread(s)
    Can you store any user data in the data pointed by "ctx" (I guess it means context)? If so, just store rdPtr in CreateRunObject (like ctx->userData = rdPtr and retrieve it from ctx in onDistanceChange.

    If you can't, if you always use a single Phidgets object in the current frame you could store rdPtr in a global value when CreateRunObject is called and clear it when DestroyRunObject is called:

    Code:
    LPRDATA uniqueRdPtr;
    
    short WINAPI DLLExport CreateRunObject(LPRDATA rdPtr, LPEDATA edPtr, fpcob cobPtr)
    {
    	...
    	uniqueRdPtr = rdPtr;
    	...
    }
    
    short WINAPI DLLExport DestroyRunObject(LPRDATA rdPtr, long fast)
    {
    	...
    	if ( uniqueRdPtr == rdPtr )
    		uniqueRdPtr = NULL;
    	...
    }
    
    static void CCONV onDistanceChange(PhidgetDistanceSensorHandle ch, void* ctx, uint32_t distance) {
    
    	...
    	if ( uniqueRdPtr != NULL )
    		callRunTimeFunction(uniqueRdPtr, RFUNCTION_PUSHEVENT, 3, 0);		// or RFUNCTION_GENERATEEVENT if required
    	...
    
    }
    If the user can insert several Phidgets objects in the same frame (or in the current frame and in a sub-application in the same frame), this won't work. In this case for example you could store a global list of <LPRDATA, ctx> pairs, add the current pair to the global list in CreateRunObbject, remove it from the list in DestroyRunObject and search in the list for the rdPtr that corresponds to the ctx parameter in onDistanceChange. A bit more complicated.

  7. #7
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    AlanRuno's Avatar
    Join Date
    May 2013
    Posts
    344
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hey, thanks for that info Yves!
    I only use one object, I didn't know ctx could help me with that, but yeah that is passed on to the function, I will store rdPtr there.
    I case it doesn't work I can try the other two options
    Thanks!!

Similar Threads

  1. Can I make an app as Instant App?
    By MSA in forum Android Export Module 2.5
    Replies: 0
    Last Post: 3rd July 2018, 12:55 PM
  2. HOw to make IF-else condition in Fusion 2.5
    By ramyhakam in forum Fusion 2.5
    Replies: 1
    Last Post: 19th December 2015, 02:27 AM
  3. Replies: 2
    Last Post: 26th September 2015, 07:23 PM
  4. Replies: 5
    Last Post: 16th November 2014, 03:36 PM
  5. instant hit bullet/laser tutorial for fusion 2.5?
    By jinchoung in forum Fusion 2.5
    Replies: 2
    Last Post: 9th July 2014, 05:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •