This file is indexed.

/usr/share/psychtoolbox-3/PsychContributed/WinJoystickMex.c is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
/*------------------------------------------------------------------------------
WinJoystickMex.c -- A simple Matlab/Octave MEX file for query of joysticks on Microsoft Windows.

On Matlab, compile with:

mex -v -g WinJoystickMex.c winmm.lib

On Octave, compile with:

mex -v -g WinJoystickMex.c -lwinmm

------------------------------------------------------------------------------

    WinJoystickMex.c is Copyright (C) 2009-2012 Mario Kleiner

    This program is licensed under the MIT license.

	A copy of the license can be found in the License.txt file inside the
	Psychtoolbox-3 top level folder.
------------------------------------------------------------------------------*/

/* Windows includes: */
#include <windows.h>

/* Matlab includes: */
#include "mex.h"

/* This is the main entry point from Matlab: */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
{
	JOYINFO joy;	// Struct into which joystick state is returned.
	MMRESULT rc;	// Return code of function.
	unsigned int cmd;
	double* out;
	
	// Get our name for output:
	const char* me = mexFunctionName();

	if(nrhs < 1) {
		mexPrintf("WinJoystickMex: A simple Matlab/Octave MEX file for query of simple joysticks on Microsoft Windows\n\n");
		mexPrintf("(C) 2009-2012 by Mario Kleiner -- Licensed to you under the MIT license.\n");
		mexPrintf("This file is part of Psychtoolbox-3 but should also work independently.\n");
		mexPrintf("\n");
		mexPrintf("Usage:\n\n");
		mexPrintf("[x, y, z, buttons] = %s(joystickId);\n", me);
		mexPrintf("- Query joystick device 'joystickId'. This can be any number between 0 and 15.\n");
		mexPrintf("0 is the first connected joystick, 1 the 2nd, etc...\n");
		mexPrintf("x, y and z are the current x, y and z coordinate of the joystick.\n");
		mexPrintf("buttons is a 4-element vector, each element being zero if the corresponding button is released,\n");
		mexPrintf("one if the corresponding button is pressed.\n\n\n");
        return;
	}
	
	/* First argument must be the joystick id: */
	cmd = (unsigned int) mxGetScalar(prhs[0]);
	
	/* Call joystick function: */
	if ((rc = joyGetPos((UINT) cmd, &joy)) != JOYERR_NOERROR) {
		// Failed!
		mexPrintf("For failed joystick call with 'joystickId' = %i.\n", cmd);
		switch((int) rc) {
			case MMSYSERR_NODRIVER:
				mexErrMsgTxt("The joystick driver is not present or active on this system! [MMSYSERR_NODRIVER]");
			break;
			
			case JOYERR_NOCANDO:
				mexErrMsgTxt("Some system service for joystick support is not present or active on this system! [JOYERR_NOCANDO]");
			break;
			
			case MMSYSERR_INVALPARAM:
			case JOYERR_PARMS:
				mexErrMsgTxt("Invalid 'joystickId' passed! [MMSYSERR_INVALPARAM or JOYERR_PARMS]");
			break;

			case JOYERR_UNPLUGGED:
				mexErrMsgTxt("The specified joystick is not connected to the system! [JOYERR_UNPLUGGED]");
			break;

			default:
				mexPrintf("Return code of failed joystick call is %i.\n", rc);
				mexErrMsgTxt("Unknown error! See return code above.");
		}
	}

	// Return X pos:
	plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
	*(mxGetPr(plhs[0])) = (double) joy.wXpos;

	// Return Y pos:
	plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
	*(mxGetPr(plhs[1])) = (double) joy.wYpos;

	// Return Z pos:
	plhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
	*(mxGetPr(plhs[2])) = (double) joy.wZpos;
	
	// Return 4-element button state vector:
	plhs[3] = mxCreateDoubleMatrix(1, 4, mxREAL);
	out = mxGetPr(plhs[3]);
	out[0] = (joy.wButtons & JOY_BUTTON1) ? 1 : 0;
	out[1] = (joy.wButtons & JOY_BUTTON2) ? 1 : 0;
	out[2] = (joy.wButtons & JOY_BUTTON3) ? 1 : 0;
	out[3] = (joy.wButtons & JOY_BUTTON4) ? 1 : 0;

	// Done.
	return;
}