Ejemplo n.º 1
0
int prLID_GetAbsInfo(VMGlobals *g, int numArgsPushed)
{
	PyrSlot* args = g->sp - 2;
	int evtCode;
	int err;

	PyrObject* obj = SC_LID::getObject(args+0);
	if (!obj) return errWrongType;

	err = slotIntVal(args+1, &evtCode);
	if (err) return err;

	if (!isKindOfSlot(args+2, s_absInfoClass->u.classobj))
		return errWrongType;
	PyrObject* infoObj = slotRawObject(&args[2]);

	SC_LID* dev = SC_LID::getDevice(obj);
	if (!dev) return errFailed;

	struct input_absinfo info;
	err = dev->getAbsInfo(evtCode, &info);
	if (err) return err;

	SetInt(infoObj->slots+0, info.value);
	SetInt(infoObj->slots+1, info.minimum);
	SetInt(infoObj->slots+2, info.maximum);
	SetInt(infoObj->slots+3, info.fuzz);
	SetInt(infoObj->slots+4, info.flat);

	slotCopy(&args[0], &args[2]);

	return errNone;
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: zugcic/v03
	bool OnInitDialog()
	{
		SetInt(IDC_EDIT1,p.x);
		SetInt(IDC_EDIT2,p.y);
		
		return true;
	}
Ejemplo n.º 3
0
void Shader::UpdateUniforms(RenderingEngine& _renderingEngine) {
	for (unsigned int i = 0; i < shaderData->uniformNames.size(); i++) {
		string uniformName = shaderData->uniformNames[i];
		string uniformType = shaderData->uniformTypes[i];

		if (uniformName.substr(0, 2) == "R_") {
			string unprefixedName = uniformName.substr(2, uniformName.length());

			if (unprefixedName == "lightMatrix") {
				SetMatrix4(uniformName, 1, _renderingEngine.GetLightMatrix());
			} else if (uniformType == "sampler2D") {
				int samplerSlot = _renderingEngine.GetSamplerSlot(unprefixedName);
				_renderingEngine.GetTexture(unprefixedName)->Bind(samplerSlot);
				SetInt(uniformName, samplerSlot);
			} else if (uniformType == "vec3") {
				SetVector3(uniformName, *_renderingEngine.GetVector3(unprefixedName));
			} else if (uniformType == "float") {
				SetFloat(uniformName, *_renderingEngine.GetFloat(unprefixedName));
			} else if (uniformType == "int") {
				if (uniformName == "R_DIR_LIGHT_COUNT") {
					SetInt(uniformName, _renderingEngine.GetActiveDirLights().size());
				} if (uniformName == "R_POINT_LIGHT_COUNT") {
					SetInt(uniformName, _renderingEngine.GetActivePointLights().size());
				}
			} else if (uniformType == "DirLight") {
				SetDirectionalLights(uniformName, _renderingEngine.GetActiveDirLights());
			} else if (uniformType == "PointLight") {
				SetPointLights(uniformName, _renderingEngine.GetActivePointLights());
			} else {
				throw "Invalid R_ Uniform:" + uniformName;
			}
		}
	}
}
Ejemplo n.º 4
0
void PushQueueEvents_CalibratedValue (){

	IOHIDEventStruct event;
	pRecDevice  pCurrentHIDDevice = HIDGetFirstDevice ();

	int numdevs = gNumberOfHIDDevices;
	unsigned char result;
	for(int i=0; i< numdevs; i++){

		result = HIDGetEvent(pCurrentHIDDevice, (void*) &event);
		if(result && compiledOK) {
			SInt32 value = event.value;
			int vendorID = pCurrentHIDDevice->vendorID;
			int productID = pCurrentHIDDevice->productID;
			int locID = pCurrentHIDDevice->locID;
			IOHIDElementCookie cookie = (IOHIDElementCookie) event.elementCookie;
			pRecElement pCurrentHIDElement =  HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeAll);
	// use gElementCookie to find current element
			while (pCurrentHIDElement && ( (pCurrentHIDElement->cookie) != cookie))
			pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeAll);

			if (pCurrentHIDElement)
			{
			value = HIDCalibrateValue(value, pCurrentHIDElement);
			//find element to calibrate
			VMGlobals *g = gMainVMGlobals;
			pthread_mutex_lock (&gLangMutex);
			g->canCallOS = false; // cannot call the OS
			++g->sp; SetObject(g->sp, s_hid->u.classobj); // Set the class HIDService
			//set arguments:
			++g->sp;SetInt(g->sp, vendorID);
			++g->sp;SetInt(g->sp, productID);
			++g->sp;SetInt(g->sp, locID);
			++g->sp;SetInt(g->sp, (int) cookie);
			++g->sp;SetInt(g->sp, value);
			runInterpreter(g, s_hidAction, 6);
			g->canCallOS = false; // cannot call the OS
			pthread_mutex_unlock (&gLangMutex);
			}
		}
	/* FIXME: this does not seem to be working!
		if ( !HIDIsValidDevice(pCurrentHIDDevice) )
		{ // readError
		 post("HID: read Error\n");
			int locID = pCurrentHIDDevice->locID;
			VMGlobals *g = gMainVMGlobals;
			pthread_mutex_lock (&gLangMutex);
			g->canCallOS = false; // cannot call the OS
			++g->sp; SetObject(g->sp, s_hid->u.classobj); // Set the class HIDService
			++g->sp;SetInt(g->sp, locID);
			runInterpreter(g, s_readError, 2);
			g->canCallOS = false; // cannot call the OS
			pthread_mutex_unlock (&gLangMutex);
		}*/
	pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
	}
}
Ejemplo n.º 5
0
KeyValues::KeyValues(const char *setName, const char *firstKey, int firstValue, const char *secondKey, int secondValue)
{
	TRACK_KV_ADD(this, setName);

	Init();
	SetName(setName);
	SetInt(firstKey, firstValue);
	SetInt(secondKey, secondValue);
}
Ejemplo n.º 6
0
PyrObject* ConvertReplyAddress(ReplyAddress *inReply)
{
    VMGlobals *g = gMainVMGlobals;
    PyrObject *obj = instantiateObject(g->gc, s_netaddr->u.classobj, 2, true, false);
    PyrSlot *slots = obj->slots;
    SetInt(slots+0, ntohl(inReply->mSockAddr.sin_addr.s_addr));
    SetInt(slots+1, ntohs(inReply->mSockAddr.sin_port));
    return obj;
}
Ejemplo n.º 7
0
void inv_hack_on()
{
	cInv = TRUE;

	ZeroMemory(pak, 20);
	SetShort(0, 0);
	SetShort(0, 2);
	SetShort(0xAD9, 4);
	SetShort(GetClientID(), 6);
	SetInt(0, 8);
	SetInt(2, 12);
	SetInt(1, 16);

	SendPacket(pak, 20);
}
Ejemplo n.º 8
0
/////////////////////////////////////////////////////////
// Resets a value with a string, preserving current type
void VariableData::ResetWith(wxString value) {
	switch (type) {
		case VARDATA_INT: {
			long temp = 0;
			value.ToLong(&temp);
			SetInt(temp);
			break;
		}
		case VARDATA_FLOAT: {
			double temp = 0;
			value.ToDouble(&temp);
			SetFloat(temp);
			break;
		}
		case VARDATA_BOOL:
			if (value == _T("1")) SetBool(true);
			else SetBool(false);
			break;
		case VARDATA_COLOUR: {
			long r=0,g=0,b=0;
			value.Mid(1,2).ToLong(&r,16);
			value.Mid(3,2).ToLong(&g,16);
			value.Mid(5,2).ToLong(&b,16);
			SetColour(wxColour(r,g,b));
			break;
		}
		default:
			SetText(value);
			break;
	}
}
Ejemplo n.º 9
0
int prGetLangPort(VMGlobals *g, int numArgsPushed)
{
	PyrSlot *a = g->sp;
	if (!gUDPport) return errFailed;
	SetInt(a, gUDPport->RealPortNum());
	return errNone;
}
Ejemplo n.º 10
0
void flext_base::cb_int(flext_hdr *c,long v)
{
    t_atom atom; SetInt(atom,v);
    Locker lock(c);
    int const ci = proxy_getinlet((t_object *)&c->obj);
    thisObject(c)->CbMethodHandler(ci,sym_int,1,&atom);
}
Ejemplo n.º 11
0
TBValue::TBValue(TYPE type)
	: m_packed_init(0)
{
	switch (type)
	{
	case TYPE_NULL:
		SetNull();
		break;
	case TYPE_STRING:
		SetString("", SET_AS_STATIC);
		break;
	case TYPE_FLOAT:
		SetFloat(0);
		break;
	case TYPE_INT:
		SetInt(0);
		break;
	case TYPE_OBJECT:
		SetObject(nullptr);
		break;
	case TYPE_ARRAY:
		if (TBValueArray *arr = new TBValueArray())
			SetArray(arr, SET_TAKE_OWNERSHIP);
		break;
	default:
		assert(!"Not implemented!");
	};
}
Ejemplo n.º 12
0
int prPipeOpen(struct VMGlobals *g, int numArgsPushed)
{
	PyrSlot *a, *b, *c;
	char mode[12];
	PyrFile *pfile;
	FILE *file;

	a = g->sp - 2;
	b = g->sp - 1;
	c = g->sp;

	if (NotObj(c) || !isKindOf(slotRawObject(c), class_string)
		|| NotObj(b) || !isKindOf(slotRawObject(b), class_string))
		return errWrongType;
	if (slotRawObject(c)->size > 11) return errFailed;
	pfile = (PyrFile*)slotRawObject(a);

        char *commandLine = (char*)malloc(slotRawObject(b)->size + 1);
	memcpy(commandLine, slotRawString(b)->s, slotRawObject(b)->size);
	commandLine[slotRawString(b)->size] = 0;

	memcpy(mode, slotRawString(c)->s, slotRawObject(c)->size);
	mode[slotRawString(c)->size] = 0;

	pid_t pid;
	file = sc_popen(commandLine, &pid, mode);
	free(commandLine);
	if (file) {
		SetPtr(&pfile->fileptr, file);
		SetInt(a, pid);
	} else {
		SetNil(a);
	}
	return errNone;
}
Ejemplo n.º 13
0
void PerformOSCBundle(int inSize, char* inData, PyrObject *replyObj, int inPortNum)
{
	// convert all data to arrays

	int64 oscTime = OSCtime(inData + 8);
	double seconds = OSCToElapsedTime(oscTime);

	VMGlobals *g = gMainVMGlobals;
	char *data = inData + 16;
	char* dataEnd = inData + inSize;
	while (data < dataEnd) {
		int32 msgSize = OSCint(data);
		data += sizeof(int32);
		if (IsBundle(data))
		{
			PerformOSCBundle(msgSize, data, replyObj, inPortNum);
		}
		else // is a message
		{
			++g->sp; SetObject(g->sp, g->process);
			++g->sp; SetFloat(g->sp, seconds);
			++g->sp; SetObject(g->sp, replyObj);
			++g->sp; SetInt(g->sp, inPortNum);

			PyrObject *arrayObj = ConvertOSCMessage(msgSize, data);
			++g->sp; SetObject(g->sp, arrayObj);
			runInterpreter(g, s_recvoscmsg, 5);
		}
		data += msgSize;
	}
}
Ejemplo n.º 14
0
void PriorityQueueAdd(struct VMGlobals *g, PyrObject* queueobj, PyrSlot* item, double time)
{
	PyrObject *schedq, *newschedq;
	int size, maxsize;

	PyrSlot *schedqSlot = queueobj->slots;
	if (!IsObj(schedqSlot)) {
		size = 32;
		schedq = newPyrArray(g->gc, size, 0, true);
		schedq->size = 1;
		SetInt(schedq->slots + 0, 0); // stability count
		SetObject(schedqSlot, schedq);
		g->gc->GCWriteNew(queueobj, schedq); // we know schedq is white so we can use GCWriteNew
	} else {
		schedq = slotRawObject(schedqSlot);
		maxsize = ARRAYMAXINDEXSIZE(schedq);
		size = schedq->size;
		if (size+3 > maxsize) {

			newschedq = newPyrArray(g->gc, maxsize*2, 0, true);
			newschedq->size = size;

			slotCopy(newschedq->slots, schedq->slots, size);
			assert(IsInt(newschedq->slots));

			SetObject(schedqSlot, newschedq);
			g->gc->GCWriteNew(queueobj, newschedq); // we know newschedq is white so we can use GCWriteNew

			schedq = newschedq;
		}
	}

	addheap(g, schedq, time, item);
}
Ejemplo n.º 15
0
/*************************************
 * operator =
 *************************************/
SHVDataVariant& SHVDataVariantImpl::operator=(const SHVDataVariant& val)
{
	switch (val.GetDataType())
	{
		case SHVDataVariant::TypeInt:
			SetInt(val.AsInt());
			break;
		case SHVDataVariant::TypeInt64:
			SetInt64(val.AsInt64());
			break;
		case SHVDataVariant::TypeBool:
			SetBool(val.AsBool());
			break;
		case SHVDataVariant::TypeDouble:
			SetDouble(val.AsDouble());
			break;
		case SHVDataVariant::TypeString:
			SetString(val.AsString());
			break;
		case SHVDataVariant::TypeTime:
			SetTime(val.AsTime());
			break;
	}
	return *this;
}
Ejemplo n.º 16
0
void
PkyProperty::SetInt( const char* pszSect, const char* pszKey, int val )
{
	auto const strSect= StringConvert::toWstring( pszSect );
	auto const strKey = StringConvert::toWstring( pszKey );
	return SetInt(strSect.c_str(), strKey.c_str(), val );
}
Ejemplo n.º 17
0
int prHIDGetValue(VMGlobals *g, int numArgsPushed)
{
	PyrSlot *a = g->sp - 2; //class
	PyrSlot *b = g->sp - 1; //locID device
	PyrSlot *c = g->sp; //element cookie
	int locID, cookieNum;
	int err = slotIntVal(b, &locID);
	if (err) return err;
	err = slotIntVal(c, &cookieNum);
	if (err) return err;
	IOHIDElementCookie cookie = (IOHIDElementCookie) cookieNum;
	//look for the right device:
    pRecDevice  pCurrentHIDDevice = HIDGetFirstDevice ();
	while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID))
        pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice);
	if(!pCurrentHIDDevice) return errFailed;
	//look for the right element:
	pRecElement pCurrentHIDElement =  HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeAll);
	// use gElementCookie to find current element
    while (pCurrentHIDElement && (pCurrentHIDElement->cookie != cookie))
        pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeAll);

	if (pCurrentHIDElement)
    {
		SInt32 value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement);
		 // if it's not a button and it's not a hatswitch then calibrate
		if(( pCurrentHIDElement->type != kIOHIDElementTypeInput_Button ) &&
			( pCurrentHIDElement->usagePage == 0x01 && pCurrentHIDElement->usage != kHIDUsage_GD_Hatswitch))
			value = HIDCalibrateValue ( value, pCurrentHIDElement );
		SetInt(a, value);
	}
	else SetNil(a);
	return errNone;

}
Ejemplo n.º 18
0
void MyTweener::AddInt(int* var, int startvalue, int endvalue, double tweentime, MyTweenType tweentype, double delay, bool updatewhiledelayed, unsigned int id)
{
    TweenInt* pVar = MyNew TweenInt;
    m_ListOfVars.Add( (TweenVar*)pVar );

    SetInt( m_ListOfVars.Count()-1, var, startvalue, endvalue, tweentime, tweentype, delay, updatewhiledelayed, id );
}
Ejemplo n.º 19
0
PListValue& PListValue::operator =(const PListValue& rhs)
{
    switch (rhs.type_)
    {
    case PLVT_NONE:
        Reset();
        break;
    case PLVT_INT:
        SetInt(rhs.int_);
        break;
    case PLVT_BOOL:
        SetBool(rhs.bool_);
        break;
    case PLVT_FLOAT:
        SetFloat(rhs.float_);
        break;
    case PLVT_STRING:
        SetString(*rhs.string_);
        break;
    case PLVT_VALUEMAP:
        SetValueMap(*rhs.valueMap_);
        break;
    case PLVT_VALUEVECTOR:
        SetValueVector(*rhs.valueVector_);
        break;
    }

    return *this;
}
Ejemplo n.º 20
0
void SC_LID::handleEvent(struct input_event& evt)
{
	if (evt.type != EV_SYN) {
		pthread_mutex_lock(&gLangMutex);
		if (compiledOK) {
			VMGlobals* g = gMainVMGlobals;
			g->canCallOS = false;
			++g->sp; SetObject(g->sp, m_obj);
			++g->sp; SetInt(g->sp, evt.type);
			++g->sp; SetInt(g->sp, evt.code);
			++g->sp; SetInt(g->sp, evt.value);
			runInterpreter(g, s_handleEvent, 4);
			g->canCallOS = false;
		}
		pthread_mutex_unlock(&gLangMutex);
	}
}
Ejemplo n.º 21
0
int prSymbol_SpecialIndex(struct VMGlobals *g, int numArgsPushed)
{
	PyrSlot *a = g->sp;

	SetInt(a, slotRawSymbol(a)->specialIndex);

	return errNone;
}
Ejemplo n.º 22
0
void g2Spinner::IncrementDown()
{
    // Decrease and bounds check float & int respectively
    if(Type == g2SpinnerType_Float)
        SetFloat(fmax(fmin(GetFloat() - FloatInc, FloatMax), FloatMin));
    else if(Type == g2SpinnerType_Int)
        SetInt((int)fmax(fmin(GetInt() - IntInc, IntMax), IntMin));
}
Ejemplo n.º 23
0
int prUnix_Errno(struct VMGlobals *g, int numArgsPushed)
{
	PyrSlot *a = g->sp;

	SetInt(a, errno);

	return errNone;
}
Ejemplo n.º 24
0
int prSFOpenRead(struct VMGlobals *g, int numArgsPushed)
{
	PyrSlot *a, *b;
	char filename[PATH_MAX];
	SNDFILE *file;
	SF_INFO info;
	const char *headerstr;
	const char *sampleformatstr;

	a = g->sp - 1;
	b = g->sp;

	PyrObject *obj1 = slotRawObject(a);

	if (!isKindOfSlot(b, class_string)) return errWrongType;
	if (slotRawObject(b)->size > PATH_MAX - 1) return errFailed;

	memcpy(filename, slotRawString(b)->s, slotRawObject(b)->size);
	filename[slotRawString(b)->size] = 0;

	info.format = 0;
	file = sf_open(filename, SFM_READ, &info);


	if (file) {
		SetPtr(obj1->slots + 0, file);
		sndfileFormatInfoToStrings(&info, &headerstr, &sampleformatstr);
		//headerFormatToString(&info, &headerstr);
		PyrString *hpstr = newPyrString(g->gc, headerstr, 0, true);
		SetObject(obj1->slots+1, hpstr);
		g->gc->GCWriteNew(obj1, (PyrObjectHdr*)hpstr); // we know hpstr is white so we can use GCWriteNew
		PyrString *smpstr = newPyrString(g->gc, sampleformatstr, 0, true);
		SetObject(obj1->slots+2, smpstr);
		g->gc->GCWriteNew(obj1, (PyrObjectHdr*)smpstr); // we know smpstr is white so we can use GCWriteNew
		SetInt(obj1->slots + 3, info.frames);
		SetInt(obj1->slots + 4, info.channels);
		SetInt(obj1->slots + 5, info.samplerate);

		SetTrue(a);
	} else {
		SetNil(a);
		SetFalse(a);
	}
	return errNone;
}
Ejemplo n.º 25
0
int prAs32Bits(VMGlobals *g, int numArgsPushed)
{
	PyrSlot *a = g->sp;
	// return an integer that is a bit pattern for the 32 bit float representation
	union { float f; int32 i; } u;
	u.f = slotRawFloat(a);
	SetInt(a, u.i);
	return errNone;
}
Ejemplo n.º 26
0
    void Color::SetFloats(float r, float g, float b, float a)
    {
        int R = static_cast<int>(r * 255.0f);
        int G = static_cast<int>(g * 255.0f);
        int B = static_cast<int>(b * 255.0f);
        int A = static_cast<int>(a * 255.0f);

        SetInt(R, G, B, A);
    }
Ejemplo n.º 27
0
int prSymbol_AsInteger(struct VMGlobals *g, int numArgsPushed)
{
	PyrSlot *a = g->sp;

	char *str = slotRawSymbol(a)->name;
	SetInt(a, atoi(str));

	return errNone;
}
Ejemplo n.º 28
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
int Settings::GetInt(char *name)
{
    int retValue = mapIntChild[IntKey(name)];
    if(!GetIntFromChild(name, &retValue))
    {
        SetInt(name, retValue);
    }
    return retValue;
}
Ejemplo n.º 29
0
PyrObject* ConvertOSCMessage(int inSize, char *inData)
{
	char *cmdName = inData;
	int cmdNameLen = OSCstrlen(cmdName);
	sc_msg_iter msg(inSize - cmdNameLen, inData + cmdNameLen);

	int numElems;
        if (inSize == cmdNameLen) {
            numElems = 0;
        } else {
			if (!msg.tags) {
				numElems = 0;
				error("OSC messages must have type tags.  %s\n", cmdName);
			} else {
				numElems = strlen(msg.tags);
			}
        }
        //post("tags %s %d\n", msg.tags, numElems);

        VMGlobals *g = gMainVMGlobals;
        PyrObject *obj = newPyrArray(g->gc, numElems + 1, 0, false);
        PyrSlot *slots = obj->slots;

        SetSymbol(slots+0, getsym(cmdName));

        for (int i=0; i<numElems; ++i) {
            char tag = msg.nextTag();
            //post("%d %c\n", i, tag);
            switch (tag) {
                case 'i' :
                    SetInt(slots+i+1, msg.geti());
                    break;
                case 'f' :
                    SetFloat(slots+i+1, msg.getf());
                    break;
                case 'd' :
                    SetFloat(slots+i+1, msg.getd());
                    break;
                case 's' :
                    SetSymbol(slots+i+1, getsym(msg.gets()));
                    //post("sym '%s'\n", slots[i+1].us->name);
                    break;
                case 'b' :
					SetObject(slots+i+1, (PyrObject*)MsgToInt8Array(msg));
                    break;
				case 'c':
					SetChar(slots+i+1, (char)msg.geti());
					break;
				// else add the type tag as a char (jrhb 2009)
				default:
					SetChar(slots+i+1, tag);
					msg.gets();
            }
        }
        obj->size = numElems + 1;
        return obj;
}
Ejemplo n.º 30
-1
static int prSerialPort_RXErrors(struct VMGlobals *g, int numArgsPushed)
{
	PyrSlot* self = g->sp;
	SerialPort* port = (SerialPort*)getSerialPort(self);
	if (port == 0) return errFailed;
	SetInt(self, port->rxErrors());
	return errNone;
}