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
|
/*
PsychToolbox3/Source/Common/PsychHID/PsychHIDGetRawState.c
PROJECTS: PsychHID only.
PLATFORMS: All.
AUTHORS:
Allen.Ingling@nyu.edu awi
mario.kleiner@tuebingen.mpg.de mk
HISTORY:
5/12/03 awi Created.
7/29/11 mk Refactored for multi-platform.
TO DO:
*/
#include "PsychHID.h"
static char useString[]= "elementState=PsychHID('RawState', deviceNumber, elementNumber)";
static char synopsisString[] =
"Return the immediate state of the specified element on the specified device.";
static char seeAlsoString[] = "";
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);
}
#if PSYCH_SYSTEM == PSYCH_OSX
PsychError PsychHIDOSGamePadAxisQuery(int deviceIndex, int axisId, double* min, double* max, double* val, char* axisLabel)
{
double elementValue;
pRecDevice deviceRecord;
pRecElement elementRecord;
int elementIndex = axisId;
PsychHIDVerifyInit();
deviceRecord= PsychHIDGetDeviceRecordPtrFromIndex(deviceIndex);
elementRecord= PsychHIDGetElementRecordFromDeviceRecordAndElementIndex(deviceRecord, elementIndex);
elementValue = IOHIDElement_GetValue(elementRecord, kIOHIDValueScaleTypePhysical);
if (val) *val = elementValue;
return(PsychError_none);
}
#endif
|