コード例 #1
0
PsychError SCREENGetOpenGLDrawMode(void)
{
    static char useString[] = "[targetwindow, IsOpenGLRendering] = Screen('GetOpenGLDrawMode');";
    static char synopsisString[] = "Return information about current OpenGL rendering state.\n"
        "'targetwindow' is the window handle of the window that is currently enabled for "
		"drawing. That is, the last window a Screen drawing command was drawing to, or "
		"the window which is the current target for OpenGL rendering commands.\n"
		"'IsOpenGLRendering' if equal to zero, then normal 2D Screen drawing is active. "
		"If greater than zero, then Matlab OpenGL drawing is active, ie. a Screen('BeginOpenGL'); "
		"command was executed and OpenGL code can draw into 'targetwindow'. ";
		
    static char seeAlsoString[] = "BeginOpenGL EndOpenGL SetOpenGLTexture GetOpenGLTexture moglcore";	

	PsychWindowRecordType	*windowRecord;
    
	//all sub functions should have these two lines
    PsychPushHelp(useString, synopsisString,seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
    
    //check for superfluous arguments
    PsychErrorExit(PsychCapNumInputArgs(0));        // The maximum number of inputs
    PsychErrorExit(PsychRequireNumInputArgs(0));    // Number of required inputs.
    PsychErrorExit(PsychCapNumOutputArgs(2));       // The maximum number of outputs

	windowRecord = PsychGetDrawingTarget();

	// Return window handle of currently active drawing target window:
	PsychCopyOutDoubleArg(1, FALSE, (double) ((windowRecord) ? windowRecord->windowIndex : 0));
	
	// Return draw mode: OpenGL userspace rendering or Screen() internal rendering?
	PsychCopyOutDoubleArg(2, FALSE, (double) PsychIsUserspaceRendering());

	// Ready:
    return(PsychError_none);
}
コード例 #2
0
PsychError SCREENWindowSize(void)
{

    PsychWindowRecordType *windowRecord;
    int screenNumber;
    PsychRectType rect;
    double	rectWidth, rectHeight;

    //all sub functions should have these two lines
    PsychPushHelp(useString, synopsisString,seeAlsoString);
    if(PsychIsGiveHelp()) {
        PsychGiveHelp();
        return(PsychError_none);
    };

    //check for superfluous arguments
    PsychErrorExit(PsychCapNumInputArgs(1));		//The maximum number of inputs
    PsychErrorExit(PsychRequireNumInputArgs(1));	//Insist that the argument be present.
    PsychErrorExit(PsychCapNumOutputArgs(2));		//The maximum number of outputs

    if(PsychIsScreenNumberArg(1)) {
        PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
        PsychGetScreenRect(screenNumber, rect);
        rectWidth=PsychGetWidthFromRect(rect);
        rectHeight=PsychGetHeightFromRect(rect);
        PsychCopyOutDoubleArg(1, kPsychArgOptional, rectWidth);
        PsychCopyOutDoubleArg(2, kPsychArgOptional, rectHeight);
    } else if(PsychIsWindowIndexArg(1)) {
        PsychAllocInWindowRecordArg(1, TRUE, &windowRecord);
        PsychOSProcessEvents(windowRecord, 0);

        rectWidth=PsychGetWidthFromRect(windowRecord->rect);
        rectHeight=PsychGetHeightFromRect(windowRecord->rect);

        if (windowRecord->specialflags & kPsychHalfWidthWindow) {
            // Special case for stereo: Only half the real window width:
            rectWidth = rectWidth / 2;
        }

        if (windowRecord->specialflags & kPsychHalfHeightWindow) {
            // Special case for stereo: Only half the real window width:
            rectHeight = rectHeight / 2;
        }

        PsychCopyOutDoubleArg(1, kPsychArgOptional, rectWidth);
        PsychCopyOutDoubleArg(2, kPsychArgOptional, rectHeight);
    } else
        PsychErrorExitMsg(PsychError_user, "Argument was recognized as neither a window index nor a screen pointer");

    return(PsychError_none);
}
コード例 #3
0
PsychError SCREENStopVideoCapture(void) 
{
    int capturehandle = -1;
    int dropped;
    
    // All sub functions should have these two lines
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none);};
    PsychErrorExit(PsychCapNumInputArgs(1));            // Max. 1 input args.
    PsychErrorExit(PsychRequireNumInputArgs(1));        // Min. 1 input args required.
    PsychErrorExit(PsychCapNumOutputArgs(1));           // One output arg.
    
    // Get the handle:
    PsychCopyInIntegerArg(1, TRUE, &capturehandle);
    if (capturehandle==-1) {
        PsychErrorExitMsg(PsychError_user, "StopVideoCapture called without valid handle to a capture object.");
    }
    
    // Try to stop capture:
    dropped = PsychVideoCaptureRate(capturehandle, 0, 0, NULL);

    PsychCopyOutDoubleArg(1, FALSE, dropped);
    
    // Ready!    
    return(PsychError_none);
}
コード例 #4
0
PsychError EyelinkCurrentMode(void)
{
	int		iMode	= 0;
	
	// Add help strings
	PsychPushHelp(useString, synopsisString, seeAlsoString);
	
	// Output help if asked
	if(PsychIsGiveHelp()) {
		PsychGiveHelp();
		return(PsychError_none);
	}
	
	// Check arguments
	PsychErrorExit(PsychCapNumInputArgs(0));
	PsychErrorExit(PsychRequireNumInputArgs(0));
	PsychErrorExit(PsychCapNumOutputArgs(1));    

	// Verify eyelink is up and running
	EyelinkSystemIsConnected();
	EyelinkSystemIsInitialized();
	
	iMode = eyelink_current_mode();
	
	// Assign output arg
	PsychCopyOutDoubleArg(1, TRUE, iMode);
	
	return(PsychError_none);
}
コード例 #5
0
PsychError SCREENTextStyle(void) 
{

    boolean						doSetStyle;
    PsychWindowRecordType		*windowRecord;
    int							oldTextStyle, newTextStyle;
    
    //all subfunctions should have these two lines.  
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
    
    //check for valid number of arguments
    PsychErrorExit(PsychRequireNumInputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(2));   	
    PsychErrorExit(PsychCapNumOutputArgs(1)); 
    
    //Get the window record
    PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
    
    //Save the old text size value and return it.
    oldTextStyle=windowRecord->textAttributes.textStyle;
    PsychCopyOutDoubleArg(1, FALSE, (double)oldTextStyle);
    
    //Fetch and set the new size if it is specified. 
    doSetStyle= PsychCopyInIntegerArg(2, FALSE, &newTextStyle);
    if(doSetStyle)
        windowRecord->textAttributes.textStyle=newTextStyle;
        
    return(PsychError_none);

}
コード例 #6
0
PsychError EyelinkGetTrackerVersion(void)
{
	int iVersion=0;
	char strVersion[40]="unknown tracker type";
	
	//all sub functions should have these two lines
	PsychPushHelp(useString, synopsisString, seeAlsoString);
	if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
	
	//check to see if the user supplied superfluous arguments
	PsychErrorExit(PsychCapNumInputArgs(0));
	PsychErrorExit(PsychRequireNumInputArgs(0));
	PsychErrorExit(PsychCapNumOutputArgs(2));
	
//	// Verify eyelink is up and running
//	EyelinkSystemIsConnected();
//	EyelinkSystemIsInitialized();
	
	iVersion = eyelink_get_tracker_version(strVersion);
	
	//   mexPrintf("Tracker Version: '%s'\n", strVersion );
	PsychCopyOutDoubleArg(1, TRUE, iVersion);
	PsychCopyOutCharArg(2, FALSE, strVersion);
	
	return(PsychError_none);	
}
コード例 #7
0
ファイル: Gestalt.c プロジェクト: BackupTheBerlios/osxptb-svn
PsychError GESTALTGestalt(void) 
{
	char					*selectorCString;
	OSType					selectorConstant;
	CFStringRef				selectorCFString;
	OSErr					callError;
	long					responseLong, i;
	PsychNativeBooleanType	*responseArray;
	psych_bool					returnResponse;

    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(1));
	
    PsychAllocInCharArg(1, kPsychArgRequired, &selectorCString);
	if( strlen(selectorCString) != 4)
		PsychErrorExitMsg(PsychError_user, "The selector code must be a four-character string");
	selectorCFString=CFStringCreateWithCString (NULL, selectorCString, kCFStringEncodingUTF8);
	selectorConstant= UTGetOSTypeFromString(selectorCFString); 
	callError= Gestalt(selectorConstant, &responseLong);
	CFRelease(selectorCFString);
	if(callError)
		PsychCopyOutDoubleArg(1, kPsychArgOptional, (double)callError);
	else{
		returnResponse=PsychAllocOutBooleanMatArg(1, kPsychArgOptional, 1, 32, 1, &responseArray);
		if(returnResponse){
			for(i=0;i<32;i++){
				if(1<<i & responseLong) 
					responseArray[31-i]=TRUE;
				else
					responseArray[31-i]=FALSE;
			}
		}
	}
    return(PsychError_none);	
}
コード例 #8
0
PsychError SCREENPixelSize(void) 
{
    int 			screenNumber;
    double 			depth;
    PsychWindowRecordType	*windowRecord; 
    
    //all sub functions should have these two lines
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    //check to see if the user supplied superfluous arguments
    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(1));
    
    //get specified screen number.
    if(PsychIsScreenNumberArg(1)){    
        PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
        depth=(double)PsychGetScreenDepthValue(screenNumber);
    }else if(PsychIsWindowIndexArg(1)){
        PsychAllocInWindowRecordArg(1,TRUE,&windowRecord);
        depth=(double)windowRecord->depth;
    }else
        PsychErrorExit(PsychError_invalidNumdex);
        
    //Allocate a return matrix and load it with the depth values.  
    PsychCopyOutDoubleArg(1, FALSE, depth);
    
    return(PsychError_none);	
}
コード例 #9
0
ファイル: IOPort.c プロジェクト: BackupTheBerlios/osxptb-svn
PsychError IOPORTVerbosity(void)
{
 	static char useString[] = "oldlevel = IOPort('Verbosity' [,level]);";
	static char synopsisString[] = 
		"Set level of verbosity for error/warning/status messages. 'level' optional, new level "
		"of verbosity. 'oldlevel' is the old level of verbosity. The following levels are "
		"supported: 0 = Shut up. 1 = Print errors, 2 = Print also warnings, 3 = Print also some info, "
		"4 = Print more useful info (default), >5 = Be very verbose (mostly for debugging the driver itself). ";		
	static char seeAlsoString[] = "";	 
	
	int level= -1;

	// Setup online help: 
	PsychPushHelp(useString, synopsisString, seeAlsoString);
	if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none); };
	
	PsychErrorExit(PsychCapNumInputArgs(1));     // The maximum number of inputs
	PsychErrorExit(PsychRequireNumInputArgs(0)); // The required number of inputs	
	PsychErrorExit(PsychCapNumOutputArgs(1));	 // The maximum number of outputs

	PsychCopyInIntegerArg(1, kPsychArgOptional, &level);
	if (level < -1) PsychErrorExitMsg(PsychError_user, "Invalid level of verbosity provided. Valid are levels of zero and greater.");
	
	// Return current/old level:
	PsychCopyOutDoubleArg(1, kPsychArgOptional, (double) verbosity);

	// Set new level, if one was provided:
	if (level > -1) verbosity = level;

	return(PsychError_none);
}
コード例 #10
0
ファイル: WaitSecs.c プロジェクト: AlanFreeman/Psychtoolbox-3
PsychError WAITSECSYieldSecs(void)
{
    static char useString[] = "[realWakeupTimeSecs] = WaitSecs('YieldSecs', waitPeriodSecs);";
    //                                                                      1 
    static char synopsisString[] = 
    "Wait for at least \"waitPeriodSecs\", don't care if it takes a few milliseconds longer. "
    "Optionally, return the real wakeup time \"realWakeupTimeSecs\".\n"
	"This call is useful if you want your code to release the cpu for a few milliseconds, "
	"e.g., to avoid overloading the cpu in a spinning loop, and you don't care if the "
	"wait takes a few msecs longer than specified. If you do care, use one of the other "
	"WaitSecs() variants! The other variants emphasize accuracy of timed waits, even if "
	"this causes a high load on the processor.\n";
	
    static char seeAlsoString[] = "";	

    double	waitPeriodSecs;
    double	now;

    //all sub functions should have these two lines
    PsychPushHelp(useString, synopsisString,seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    //check to see if the user supplied superfluous arguments
    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(1));
    
    PsychCopyInDoubleArg(1,TRUE,&waitPeriodSecs);
    PsychYieldIntervalSeconds(waitPeriodSecs);

    // Return current system time at end of sleep:
    PsychGetAdjustedPrecisionTimerSeconds(&now);
    PsychCopyOutDoubleArg(1, FALSE, now);

    return(PsychError_none);	
}
コード例 #11
0
PsychError SCREENWindowSize(void)  
{
	PsychWindowRecordType *windowRecord;
	int screenNumber;
	double	rectWidth, rectHeight;
    long fbWidth, fbHeight;
    int realFBSize = 0;
    
	//all sub functions should have these two lines
	PsychPushHelp(useString, synopsisString,seeAlsoString);
	if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
	
	//check for superfluous arguments
	PsychErrorExit(PsychCapNumInputArgs(2));		//The maximum number of inputs
	PsychErrorExit(PsychRequireNumInputArgs(1));	//Insist that the argument be present.   
	PsychErrorExit(PsychCapNumOutputArgs(2));		//The maximum number of outputs

    // Get optional 'realFBSize' flag: Defaults to zero.
    PsychCopyInIntegerArg(2, FALSE, &realFBSize);

	if(PsychIsScreenNumberArg(1)){
		PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
        if (realFBSize) {
            // Physical size in pixels:
            PsychGetScreenPixelSize(screenNumber, &fbWidth, &fbHeight);
        }
        else {
            // Logical size in points:
            PsychGetScreenSize(screenNumber, &fbWidth, &fbHeight);
        }
		PsychCopyOutDoubleArg(1, kPsychArgOptional, fbWidth);
		PsychCopyOutDoubleArg(2, kPsychArgOptional, fbHeight);
	}else if(PsychIsWindowIndexArg(1)){
		PsychAllocInWindowRecordArg(1, TRUE, &windowRecord);
		PsychOSProcessEvents(windowRecord, 0);

		rectWidth=PsychGetWidthFromRect((realFBSize) ? windowRecord->rect : windowRecord->clientrect);
		rectHeight=PsychGetHeightFromRect((realFBSize) ? windowRecord->rect : windowRecord->clientrect);

		PsychCopyOutDoubleArg(1, kPsychArgOptional, rectWidth);
		PsychCopyOutDoubleArg(2, kPsychArgOptional, rectHeight);
	}else
		PsychErrorExitMsg(PsychError_user, "Argument was recognized as neither a window index nor a screen pointer");

	return(PsychError_none);
}
コード例 #12
0
PsychError SCREENStartVideoCapture(void) 
{
    int capturehandle = -1;
    double captureFPS = 25;
    int dropframes = 0;
    double starttime = 0;

    // All sub functions should have these two lines
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none);};
    PsychErrorExit(PsychCapNumInputArgs(4));            // Max. 4 input args.
    PsychErrorExit(PsychRequireNumInputArgs(1));        // Min. 1 input args required.
    PsychErrorExit(PsychCapNumOutputArgs(2));           // Max. 2 output args.
    
    // Get the handle:
    PsychCopyInIntegerArg(1, TRUE, &capturehandle);
    if (capturehandle==-1) {
        PsychErrorExitMsg(PsychError_user, "StartVideoCapture called without valid handle to a capture object.");
    }
    
    PsychCopyInDoubleArg(2, FALSE, &captureFPS);
    if (captureFPS<=0) {
        PsychErrorExitMsg(PsychError_user, "StartVideoCapture called with a negative capture rate.");
    }

    PsychCopyInIntegerArg(3, FALSE, &dropframes);
    if (dropframes<0) {
        PsychErrorExitMsg(PsychError_user, "StartVideoCapture called with invalid (negative) dropframes - argument.");
    }

    PsychCopyInDoubleArg(4, FALSE, &starttime);
    if (starttime<0) {
        PsychErrorExitMsg(PsychError_user, "StartVideoCapture called with invalid (negative) startAt - argument.");
    }

    // Try to start capture:
    captureFPS = (double) PsychVideoCaptureRate(capturehandle, captureFPS, dropframes, &starttime);

    PsychCopyOutDoubleArg(1, FALSE, captureFPS);
    PsychCopyOutDoubleArg(2, FALSE, starttime);

    // Ready!    
    return(PsychError_none);
}
コード例 #13
0
PsychError PSYCHHIDOpenUSBDevice(void) 
{
	PsychUSBSetupSpec deviceSpec;
	int deviceID, vendorID, configurationId;
	int errcode;
	int usbHandle = -1;
	PsychUSBDeviceRecord *usbDev = NULL;
	
	// Setup the help features.
	PsychPushHelp(useString, synopsisString, seeAlsoString);
    if (PsychIsGiveHelp()) {
		PsychGiveHelp();
		return PsychError_none;
	}
	
	// Make sure the correct number of input arguments is supplied.
    PsychErrorExit(PsychCapNumInputArgs(3));
	PsychErrorExit(PsychRequireNumInputArgs(2));
    PsychErrorExit(PsychCapNumOutputArgs(1));
	
	// Grab the mandatory vendor and device IDs.
	PsychCopyInIntegerArg(1, TRUE, &vendorID);
	PsychCopyInIntegerArg(2, TRUE, &deviceID);

	// Try to get free slot in internal device bank: This will error-exit if no capacity left.
	usbDev = PsychHIDGetFreeUSBDeviceSlot(&usbHandle);

	// Setup specification of wanted device:
	// So far we only match against vendorID and deviceID, but may want to extend this
	// to more options in the future. That's why its passed via a PsychUSBSetupSpec struct.
	// -> Can rather easily extend that struct (and corresponding open routines) with new
	// fields without major code rewrites in other places.
	deviceSpec.vendorID = vendorID;
	deviceSpec.deviceID = deviceID;

	// This is the index of the device configuration to choose: Defaults to zero.
	configurationId = 0;
	PsychCopyInIntegerArg(3, FALSE, &configurationId);	
	deviceSpec.configurationID = (int) configurationId;

	// Try to open the device. This will init the device structure properly and
	// also set the valid flag to "active/open" if open succeeds:
	if (!PsychHIDOSOpenUSBDevice(usbDev, &errcode, &deviceSpec)) {
		// MK TODO: We don't set or use 'errcode' yet.
		PsychErrorExitMsg(PsychError_user, "Failed to open the specified type of generic USB device. Make sure it is plugged in or not already open.");
	}

	// Return device handle:
	PsychCopyOutDoubleArg(1, FALSE, (double) usbHandle);

	return PsychError_none;
}
コード例 #14
0
PsychError SCREENDisplaySize(void)
{
    static char useString[] = "[width, height]=Screen('DisplaySize', ScreenNumber);";
    static char synopsisString[] =
        "Return the physical width and height of the output display device associated with 'ScreenNumber'. "
        "The size is returned in units of millimeters as reported by the display device itself to the OS. "
        "On MacOS-X, if Extended Display Identification Data (EDID) for the display device is not "
        "available, the size is estimated by OS-X based on the device width and height in pixels, with an "
        "assumed resolution of 2.835 pixels/mm or 72 DPI, a reasonable guess for displays predating "
        "EDID support. On M$-Windows and GNU/Linux, the behaviour in case of missing EDID data is "
        "unknown. This function returns a width and height of zero if physical display size can't be "
        "queried from the operating system. Please handle the returned information with great caution. "
        "It is unclear how accurate the EDID data for typical monitors or video beamers really is. This "
        "information could be pretty unreliable and therefore misleading!";
    static char seeAlsoString[] = "";
    int screenNumber, Width, Height;

    //all sub functions should have these two lines
    PsychPushHelp(useString, synopsisString,seeAlsoString);
    if(PsychIsGiveHelp()) {
        PsychGiveHelp();
        return(PsychError_none);
    };

    //check for superfluous arguments
    PsychErrorExit(PsychCapNumInputArgs(1));		//The maximum number of inputs
    PsychErrorExit(PsychRequireNumInputArgs(1));	//Insist that the argument be present.
    PsychErrorExit(PsychCapNumOutputArgs(2));		//The maximum number of outputs

    // Retrieve screen number:
    PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
    // Query physical size of this screen in millimeters:
    PsychGetDisplaySize(screenNumber, &Width, &Height);
    // Return it:
    PsychCopyOutDoubleArg(1, kPsychArgOptional, (double) Width);
    PsychCopyOutDoubleArg(2, kPsychArgOptional, (double) Height);

    return(PsychError_none);
}
コード例 #15
0
PsychError SCREENTextStyle(void) 
{
    psych_bool						doSetStyle, foundFont;
    PsychWindowRecordType		*windowRecord;
    int							oldTextStyle, newTextStyle;

#if PSYCH_SYSTEM == PSYCH_OSX
    PsychFontStructType			*fontRecord;
#endif

    //all subfunctions should have these two lines.  
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
    
    //check for valid number of arguments
    PsychErrorExit(PsychRequireNumInputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(2));   	
    PsychErrorExit(PsychCapNumOutputArgs(1)); 
    
    //Get the window record
    PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
    
    //Save the old text size value and return it.
    oldTextStyle=windowRecord->textAttributes.textStyle;
    PsychCopyOutDoubleArg(1, FALSE, (double)oldTextStyle);
    
    //Fetch and set the new size if it is specified. 
    doSetStyle= PsychCopyInIntegerArg(2, FALSE, &newTextStyle);
    if (doSetStyle) {
      windowRecord->textAttributes.needsRebuild|=(windowRecord->textAttributes.textStyle != newTextStyle) ? TRUE : FALSE;
      windowRecord->textAttributes.textStyle=newTextStyle;
	  
	  #if PSYCH_SYSTEM == PSYCH_OSX
	  // Need to update font name and number from changed style on OS/X:
	  foundFont = PsychGetFontRecordFromFontFamilyNameAndFontStyle((char*) windowRecord->textAttributes.textFontName, windowRecord->textAttributes.textStyle, &fontRecord);
	  if (foundFont) {
		strncpy((char*) windowRecord->textAttributes.textFontName, (const char*) fontRecord->fontFMFamilyName, 255);
		windowRecord->textAttributes.textFontNumber= fontRecord->fontNumber;
	  }
	  else {
		// Failed! Revert to old setting:
		windowRecord->textAttributes.textStyle = oldTextStyle;
	  }
	  
	  #endif
    }
	
    return(PsychError_none);
}
コード例 #16
0
PsychError PSYCHHIDGetNumDevices(void) 
{
    psych_uint32 numDevices;
    
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
    	 
    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(0));
    
    PsychHIDVerifyInit();
    numDevices=HIDCountDevices();
    PsychCopyOutDoubleArg(1, FALSE, (double)numDevices);
    
    return(PsychError_none);	
}
コード例 #17
0
PsychError SCREENGetMovieTimeIndex(void) 

{

    int                                     moviehandle = -1;

    

    // All sub functions should have these two lines

    PsychPushHelp(useString, synopsisString, seeAlsoString);

    if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none);};

    

    PsychErrorExit(PsychCapNumInputArgs(1));            // Max. 1 input args.

    PsychErrorExit(PsychRequireNumInputArgs(1));        // Min. 1 input args required.

    PsychErrorExit(PsychCapNumOutputArgs(1));           // One output arg.

    

    // Get the movie handle:

    PsychCopyInIntegerArg(1, TRUE, &moviehandle);

    if (moviehandle==-1) {

        PsychErrorExitMsg(PsychError_user, "GetMovieTimeIndex called without valid handle to a movie object.");

    }

    

    // Retrieve and return current movie time index:

    PsychCopyOutDoubleArg(1, TRUE, PsychGetMovieTimeIndex(moviehandle));

    

    // Ready!    

    return(PsychError_none);

}
コード例 #18
0
PsychError SCREENTextFont(void) 
{

    boolean			doSetByName, doSetByNumber, foundFont;
    PsychWindowRecordType	*windowRecord;
    PsychFontStructType		*fontRecord;
    int				oldTextFontNumber, inputTextFontNumber;
    char			*oldTextFontName, *inputTextFontName;
    
    //all subfunctions should have these two lines.  
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
    
    //check for valid number of arguments
    PsychErrorExit(PsychRequireNumInputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(2));   	
    PsychErrorExit(PsychCapNumOutputArgs(2)); 
    
    //Get the window record
    PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
    
    //Save the old text size value and return it.
    oldTextFontNumber=windowRecord->textAttributes.textFontNumber;
    PsychCopyOutDoubleArg(2, FALSE, (double)oldTextFontNumber);
    oldTextFontName=windowRecord->textAttributes.textFontName;
    PsychCopyOutCharArg(1, FALSE, oldTextFontName); 
    
	
    //Fetch and set the new font if specified by name or number
    PsychCheckInputArgType(2, kPsychArgOptional, PsychArgType_double | PsychArgType_char);  //if the argument is there check that it is the right type.
    doSetByNumber= PsychCopyInIntegerArg(2, kPsychArgAnything, &inputTextFontNumber);
    doSetByName= PsychAllocInCharArg(2, kPsychArgAnything, &inputTextFontName);
    foundFont=0;
    if(doSetByNumber)
        foundFont=PsychGetFontRecordFromFontNumber(inputTextFontNumber, &fontRecord);
    if(doSetByName)
        foundFont=PsychGetFontRecordFromFontFamilyNameAndFontStyle(inputTextFontName, windowRecord->textAttributes.textStyle, &fontRecord);
    if(foundFont){
        strncpy(windowRecord->textAttributes.textFontName, fontRecord->fontFMFamilyName, 255);
        windowRecord->textAttributes.textFontNumber= fontRecord->fontNumber;
    }
    
    return(PsychError_none);

}
コード例 #19
0
PsychError SCREENPlayMovie(void) 

{
    int                                 moviehandle = -1;
    double                              rate = 0;
    int                                 loop = 0;
    double                              sndvolume = 1;
    double                              dropped = 0;
    
    // All sub functions should have these two lines
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none);};

    PsychErrorExit(PsychCapNumInputArgs(4));            // Max. 4 input args.
    PsychErrorExit(PsychRequireNumInputArgs(2));        // Min. 2 input args required.
    PsychErrorExit(PsychCapNumOutputArgs(1));           // Max. 1 output args.

    // Get the movie handle:
    PsychCopyInIntegerArg(1, TRUE, &moviehandle);
    if (moviehandle==-1) {
        PsychErrorExitMsg(PsychError_user, "PlayMovie called without valid handle to a movie object.");
    }

    // Get the requested playback rate.
    PsychCopyInDoubleArg(2, TRUE, &rate);

    // Get the 'loop' flag: If zero, we don't loop, otherwise we loop.
    PsychCopyInIntegerArg(3, FALSE, &loop);

    // Get the requested sound volume. Defaults to 1 == Full blast!
    PsychCopyInDoubleArg(4, FALSE, &sndvolume);
    if (sndvolume<0) sndvolume = 0;
    if (sndvolume>1) sndvolume = 1;

    // Start playback via low-level routines:
    dropped = (double) PsychPlaybackRate(moviehandle, rate, loop, sndvolume);

    // Return optional count of dropped frames:
    PsychCopyOutDoubleArg(1, FALSE, dropped);

    // Ready!
    return(PsychError_none);
}
コード例 #20
0
ファイル: WaitSecs.c プロジェクト: AlanFreeman/Psychtoolbox-3
PsychError WAITSECSWaitUntilSecs(void)
{
    static char useString[] = "[realWakeupTimeSecs] = WaitSecs('UntilTime', whenSecs);";
    //                                                                      1 
    static char synopsisString[] = 
    "Wait until at least system time \"whenSecs\" has been reached. "
    "Optionally, return the real wakeup time \"realWakeupTimeSecs\".\n"
    "This allows conveniently waiting until an absolute point in time "
    "has been reached, or to allow drift-free waiting for a well defined "
    "interval, more accurate than the standard WaitSecs() call.\n"
    "Example:\n"
    "Wait until 0.6 secs after last stimulus onset, if vbl=Screen('Flip', window); "
    "was the onset timestamp vbl from a previous flip:\n"
    "realwakeup = WaitSecs('UntilTime', vbl + 0.6);\n\n"
    "In a perfect world, realwakeup == vbl + 0.6, in reality it will be\n"
    "realwakeup == vbl + 0.6 + randomjitter; with randomjitter being the "
    "hopefully small scheduling delay of your operating system. If the "
    "delay is high or varies a lot between trials then your system has "
    "noisy timing or real timing problems.\n";
	
    static char seeAlsoString[] = "";	

    double	waitUntilSecs;
    double	now;

    //all sub functions should have these two lines
    PsychPushHelp(useString, synopsisString,seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    //check to see if the user supplied superfluous arguments
    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(1));
    
    PsychCopyInDoubleArg(1,TRUE,&waitUntilSecs);
    PsychWaitUntilSeconds(waitUntilSecs);

    // Return current system time at end of sleep:
    PsychGetAdjustedPrecisionTimerSeconds(&now);
    PsychCopyOutDoubleArg(1, FALSE, now);

    return(PsychError_none);	
}
コード例 #21
0
PsychError PSYCHHIDGetRawState(void) 
{
    int			deviceIndex, elementIndex;
    double              value;

    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(2));

    PsychCopyInIntegerArg(1, TRUE, &deviceIndex);
    PsychCopyInIntegerArg(2, TRUE, &elementIndex);

    PsychHIDOSGamePadAxisQuery(deviceIndex, elementIndex, NULL, NULL, &value, NULL);

    if (PSYCH_SYSTEM != PSYCH_LINUX) PsychCopyOutDoubleArg(1, FALSE, value);

    return(PsychError_none);
}
コード例 #22
0
PsychError SCREENSetVideoCaptureParameter(void) 
{
    int capturehandle = -1;
    double value = DBL_MAX;
    double oldvalue;
    char* pname = NULL;

    // All sub functions should have these two lines
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none);};

    PsychErrorExit(PsychCapNumInputArgs(3));            // Max. 3 input args.
    PsychErrorExit(PsychRequireNumInputArgs(2));        // Min. 2 input args required.
    PsychErrorExit(PsychCapNumOutputArgs(1));           // One output arg.
    
    // Get the device handle:
    PsychCopyInIntegerArg(1, TRUE, &capturehandle);
    if (capturehandle==-1) {
        PsychErrorExitMsg(PsychError_user, "SetVideoCaptureParameter called without valid handle to a capture object.");
    }
    
    // Copy in parameter name string:
    PsychAllocInCharArg(2, TRUE, &pname);
    if (pname == NULL) {
        PsychErrorExitMsg(PsychError_user, "SetVideoCaptureParameter called without a parameter name string.");
    }

    // Copy in (optional) value for parameter:
    PsychCopyInDoubleArg(3, FALSE, &value);

    // Try to set parameter:
    oldvalue = PsychVideoCaptureSetParameter(capturehandle, pname, value);

    // Return old value of capture parameter:
    if (strstr(pname, "Get")==NULL) {
      PsychCopyOutDoubleArg(1, FALSE, oldvalue);
    }

    // Ready!    
    return(PsychError_none);
}
コード例 #23
0
PsychError EyelinkImageModeDisplay(void)
{
	int		iResult		= 0;
	
	// Add help strings
	PsychPushHelp(useString, synopsisString, seeAlsoString);
	
	// Output help if asked
	if(PsychIsGiveHelp()) {
		PsychGiveHelp();
		return(PsychError_none);
	}
		
	// Check arguments
	PsychErrorExit(PsychCapNumInputArgs(0));
	PsychErrorExit(PsychRequireNumInputArgs(0));
	PsychErrorExit(PsychCapNumOutputArgs(1));
	
	// Verify eyelink is up and running
	EyelinkSystemIsConnected();
	EyelinkSystemIsInitialized();
	
	if(0)
	{
		// NOTE:  Enno's OSX version added this eyelink call. Not sure if we want it or not.
		eyelink_start_setup();	
		iResult = image_mode_display();
	}
	else
	{
		//mexPrintf("EyelinkImageModeDisplay is not yet implemented.\n");
		iResult=0;
	}
	
	// Assign output arg if available
	PsychCopyOutDoubleArg(1, FALSE, iResult);
	
	return(PsychError_none);
}
コード例 #24
0
PsychError EyelinkTimeOffset(void)
{
   double offset;

   //all sub functions should have these two lines
   PsychPushHelp(useString, synopsisString, seeAlsoString);
   if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

   //check to see if the user supplied superfluous arguments
   PsychErrorExit(PsychCapNumInputArgs(0));
   PsychErrorExit(PsychRequireNumInputArgs(0));
   PsychErrorExit(PsychCapNumOutputArgs(1));

	// Verify eyelink is up and running
	EyelinkSystemIsConnected();
	EyelinkSystemIsInitialized();

   offset = eyelink_double_usec_offset()/1000;
   
   PsychCopyOutDoubleArg(1, FALSE, offset);
   
   return(PsychError_none);	
}
コード例 #25
0
PsychError EyelinkGetNextDataType(void)
{
   int type = 0;

   //all sub functions should have these two lines
   PsychPushHelp(useString, synopsisString, seeAlsoString);
   if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

   //check to see if the user supplied superfluous arguments
   PsychErrorExit(PsychCapNumInputArgs(0));
   PsychErrorExit(PsychRequireNumInputArgs(0));
   PsychErrorExit(PsychCapNumOutputArgs(1));

	// Verify eyelink is up and running
	EyelinkSystemIsConnected();
	EyelinkSystemIsInitialized();

   type = eyelink_get_next_data(NULL);

   PsychCopyOutDoubleArg(1, TRUE,  type);
   
   return(PsychError_none);
}
コード例 #26
0
PsychError PSYCHHIDKbQueueFlush(void) 
{
    int deviceIndex, flushType;
    
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(2));

    deviceIndex = -1;
    PsychCopyInIntegerArg(1, kPsychArgOptional, &deviceIndex);

	flushType = 1;
    PsychCopyInIntegerArg(2, kPsychArgOptional, &flushType);
	
	// Return current count of contained events pre-flush:
	PsychCopyOutDoubleArg(1, FALSE, (double) PsychHIDAvailEventBuffer((PSYCH_SYSTEM != PSYCH_OSX) ? deviceIndex : 0, (flushType & 4) ? 1 : 0));

    if (flushType & 1) PsychHIDOSKbQueueFlush(deviceIndex);
    if (flushType & 2) PsychHIDFlushEventBuffer((PSYCH_SYSTEM != PSYCH_OSX) ? deviceIndex : 0);

    return(PsychError_none);	
}
コード例 #27
0
ファイル: WaitSecs.c プロジェクト: AlanFreeman/Psychtoolbox-3
PsychError WAITSECSWaitSecs(void) 
{
    double	waitPeriodSecs;
    double	now;

    //check to see if the user supplied superfluous arguments
    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(1));
    
    if (!PsychCopyInDoubleArg(1, FALSE, &waitPeriodSecs)) {
	// Called without arguments. Output synopsis:
	WAITSECSSynopsis();
	return(PsychError_none);
    }

    // Wait for requested interval:
    PsychWaitIntervalSeconds(waitPeriodSecs);

    // Return current system time at end of sleep:
    PsychGetAdjustedPrecisionTimerSeconds(&now);
    PsychCopyOutDoubleArg(1, FALSE, now);

    return(PsychError_none);	
}
コード例 #28
0
PsychError EyelinkAcceptTrigger(void)
{
   int result;
   
   //all sub functions should have these two lines
   PsychPushHelp(useString, synopsisString, seeAlsoString);
   if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

   //check to see if the user supplied superfluous arguments
   PsychErrorExit(PsychCapNumInputArgs(0));
   PsychErrorExit(PsychRequireNumInputArgs(0));
   PsychErrorExit(PsychCapNumOutputArgs(1));
 
	// Verify eyelink is up and running
	EyelinkSystemIsConnected();
	EyelinkSystemIsInitialized();

   result = eyelink_accept_trigger();

   /* if there is an output variable available, assign result to it.   */
   PsychCopyOutDoubleArg(1, FALSE, result);
   
   return(PsychError_none);
}
コード例 #29
0
ファイル: IOPort.c プロジェクト: BackupTheBerlios/osxptb-svn
PsychError IOPORTBytesAvailable(void)
{
 	static char useString[] = "navailable = IOPort('BytesAvailable', handle);";
	static char synopsisString[] = "Return number 'navailable' of data bytes available for readout from device specified by 'handle'.";
	static char seeAlsoString[] = "'Read'";
	
	int				handle;
		
	// Setup online help: 
	PsychPushHelp(useString, synopsisString, seeAlsoString);
	if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none); };
	
	PsychErrorExit(PsychCapNumInputArgs(1));     // The maximum number of inputs
	PsychErrorExit(PsychRequireNumInputArgs(1)); // The required number of inputs	
	PsychErrorExit(PsychCapNumOutputArgs(1));	 // The maximum number of outputs

	// Get required port handle:
	PsychCopyInIntegerArg(1, kPsychArgRequired, &handle);
	
	// Copy out number of bytes available for read on port:
	PsychCopyOutDoubleArg(1, kPsychArgOptional, (double) PsychBytesAvailableIOPort(handle));

    return(PsychError_none);
}
コード例 #30
0
PsychError SCREENCreateMovie(void)
{
    static char useString[] = "moviePtr = Screen('CreateMovie', windowPtr, movieFile [, width][, height][, frameRate=30][, movieOptions][, numChannels=4][, bitdepth=8]);";
    static char synopsisString[] =
        "Create a new movie file with filename 'movieFile' and according to given 'movieOptions'.\n"
        "The function returns a handle 'moviePtr' to the file.\n"
        "Currently only single-track video encoding is supported.\n"
        "See 'Screen AddAudioBufferToMovie?' on how to add audio tracks to movies.\n"
        "\n"
        "Movie creation is a 3 step procedure:\n"
        "1. Create a movie and define encoding options via 'CreateMovie'.\n"
        "2. Add video and audio data to the movie via calls to 'AddFrameToMovie' et al.\n"
        "3. Finalize and close the movie via a call to 'FinalizeMovie'.\n\n"
        "All following parameters are optional and have reasonable defaults:\n\n"
        "'width' Width of movie video frames in pixels. Defaults to width of window 'windowPtr'.\n"
        "'height' Height of movie video frames in pixels. Defaults to height of window 'windowPtr'.\n"
        "'frameRate' Playback framerate of movie. Defaults to 30 fps. Technically this is not the "
        "playback framerate but the granularity in 1/frameRate seconds with which the duration of "
        "a single movie frame can be specified. When you call 'AddFrameToMovie', there's an optional "
        "parameter 'frameDuration' which defaults to one. The parameter defines the display duration "
        "of that frame as the fraction 'frameDuration' / 'frameRate' seconds, so 'frameRate' defines "
        "the denominator of that term. However, for a default 'frameDuration' of one, this is equivalent "
        "to the 'frameRate' of the movie, at least if you leave everything at defaults.\n\n"
        "'movieoptions' a textstring which allows to define additional parameters via keyword=parm pairs. "
        "For GStreamer movie writing, you can provide the same options as for GStreamer video recording. "
        "See 'help VideoRecording' for supported options and tips.\n"
        "Keywords unknown to a certain implementation or codec will be silently ignored:\n"
        "EncodingQuality=x Set encoding quality to value x, in the range 0.0 for lowest movie quality to "
        "1.0 for highest quality. Default is 0.5 = normal quality. 1.0 often provides near-lossless encoding.\n"
        "'numChannels' Optional number of image channels to encode: Can be 1, 3 or 4 on OpenGL graphics hardware, "
        "and 3 or 4 on OpenGL-ES hardware. 1 = Red/Grayscale channel only, 3 = RGB, 4 = RGBA. Please note that not "
        "all video codecs can encode pure 1 channel data or RGBA data, ie. an alpha channel. If an unsuitable codec "
        "is selected, movie writing may fail, or unsupported channels (e.g., the alpha channel) may get silently "
        "discarded. It could also happen that a codec which doesn't support 1 channel storage will replicate "
        "the Red/Grayscale data into all three RGB channels, leading to no data loss but increased movie file size. "
        "Default is to request RGBA 4 channel data from the system, encoding to RGBA or RGB, depending on codec.\n"
        "'bitdepth' Optional color/intensity resolution of each channel: Default is 8 bpc, for 8 bit per component "
        "storage. OpenGL graphics hardware, but not OpenGL-ES, also supports 16 bpc image readback. However, not all "
        "codecs can encode with > 8 bpc color/luminance precision, so encoding with 16 bpc may fail or silently reduce "
        "precision to less bits, possibly 8 bpc or less. If you specify the special keyword UsePTB16BPC in 'movieoptions', "
        "then PTB will use its own proprietary 16 bpc format for 1 or 3 channel mode. This format can only be read by "
        "PTB's own movie playback functions, not by other software.\n"
        "In general, embedded OpenGL-ES graphics hardware is more restricted in the type of image data it can return. "
        "Most video codecs are lossy codecs. They will intentionally throw away color or spatial precision of encoded "
        "video to reduce video file size or network bandwidth, often in a way that is not easily perceptible to the "
        "naked eye. If you require high fidelity, make sure to double-check your results for a given codec + parameter "
        "setup, e.g., via encoding + decoding the movie and checking the original data against decoded data.\n"
        "\n";

    static char seeAlsoString[] = "FinalizeMovie AddFrameToMovie CloseMovie PlayMovie GetMovieImage GetMovieTimeIndex SetMovieTimeIndex";

    PsychWindowRecordType                   *windowRecord;
    char                                    *moviefile;
    char                                    *movieOptions;
    int                                     moviehandle = -1;
    double                                  framerate = 30.0;
    int                                     width;
    int                                     height;
    int                                     numChannels, bitdepth;
    char                                    defaultOptions[2] = "";

    // All sub functions should have these two lines
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()) {PsychGiveHelp(); return(PsychError_none);};

    PsychErrorExit(PsychCapNumInputArgs(8));            // Max. 8 input args.
    PsychErrorExit(PsychRequireNumInputArgs(2));        // Min. 2 input args required.
    PsychErrorExit(PsychCapNumOutputArgs(1));           // Max. 1 output args.

    // Get the window record from the window record argument and get info from the window record
    PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
    // Only onscreen windows allowed:
    if(!PsychIsOnscreenWindow(windowRecord)) {
        PsychErrorExitMsg(PsychError_user, "CreateMovie called on something else than an onscreen window.");
    }

    // Get the movie name string:
    moviefile = NULL;
    PsychAllocInCharArg(2, kPsychArgRequired, &moviefile);

    // Get the optional size:
    // Default Width and Height of movie frames is derived from size of window:
    width  = (int) PsychGetWidthFromRect(windowRecord->clientrect);
    height = (int) PsychGetHeightFromRect(windowRecord->clientrect);
    PsychCopyInIntegerArg(3, kPsychArgOptional, &width);
    PsychCopyInIntegerArg(4, kPsychArgOptional, &height);

    // Get the optional framerate:
    PsychCopyInDoubleArg(5, kPsychArgOptional, &framerate);

    // Get the optional options string:
    movieOptions = defaultOptions;
    PsychAllocInCharArg(6, kPsychArgOptional, &movieOptions);

    // Get optional number of channels of movie:
    numChannels = 4;
    PsychCopyInIntegerArg(7, kPsychArgOptional, &numChannels);
    if (numChannels != 1 && numChannels != 3 && numChannels != 4) PsychErrorExitMsg(PsychError_user, "Invalid number of channels 'numChannels' provided. Only 1, 3 or 4 channels allowed!");

    // Get optional bitdepth of movie:
    bitdepth = 8;
    PsychCopyInIntegerArg(8, kPsychArgOptional, &bitdepth);
    if (bitdepth != 8 && bitdepth != 16) PsychErrorExitMsg(PsychError_user, "Invalid 'bitdepth' provided. Only 8 bpc or 16 bpc allowed!");

    // Create movie of given size and framerate with given options:
    moviehandle = PsychCreateNewMovieFile(moviefile, width, height, framerate, numChannels, bitdepth, movieOptions, NULL);
    if (0 > moviehandle) {
        PsychErrorExitMsg(PsychError_user, "CreateMovie failed for reason mentioned above.");
    }

    // Return handle to it:
    PsychCopyOutDoubleArg(1, FALSE, (double) moviehandle);

    return(PsychError_none);
}