Beispiel #1
0
void TouchManager::mouseTouchBegin(const ci::app::MouseEvent &event, int id){
	ci::Vec2f globalPos = translateMousePoint(event.getPos());

	if(shouldDiscardTouch(globalPos)){
		return;
	}
	inputBegin(id, globalPos);
}
Beispiel #2
0
void TouchManager::touchesBegin(const ds::ui::TouchEvent &event) {
	for (auto touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt) {

		ci::Vec2f touchPos = touchIt->getPos();
		if(mOverrideTranslation && !event.getInWorldSpace()){
			overrideTouchTranslation(touchPos);
		}

		int fingerId = touchIt->getId() + MOUSE_RESERVED_IDS;

		if(shouldDiscardTouch(touchPos)){
			mDiscardTouchMap[fingerId] = true;
			continue;
		}

		inputBegin(fingerId, touchPos);
	}
}
static void makeSubstitutions(void *inputPvt,void *macPvt,char *templateName)
{
    char *input;
    static char buffer[MAX_BUFFER_SIZE];
    int  n;
    static int unexpWarned = 0;

    inputBegin(inputPvt,templateName);
    while((input = inputNextLine(inputPvt))) {
	int	expand=1;
	char	*p;
	char	*command = 0;

	p = input; 
	/*skip whitespace at beginning of line*/
	while(*p && (isspace(*p))) ++p;
	/*Look for i or s */
	if(*p && (*p=='i' || *p=='s')) command = p;
	if(command) {
	    char *pstart;
	    char *pend;
	    char *copy;
	    int  cmdind=-1;
	    int  i;
	    
	    for(i=0; i< NELEMENTS(cmdNames); i++) {
		if(strstr(command,cmdNames[i])) {
		    cmdind = i;
		}
	    }
	    if(cmdind<0) goto endif;
	    p = command + strlen(cmdNames[cmdind]);
	    /*skip whitespace after command*/
	    while(*p && (isspace(*p))) ++p;
	    /*Next character must be quote*/
	    if((*p==0) || (*p!='"')) goto endif;
	    pstart = ++p;
	    /*Look for end quote*/
	    while(*p && (*p!='"')) {
		/*allow escape for imbeded quote*/
		if((*p=='\\') && *(p+1)=='"') {
		    p += 2; continue;
		} else {
		    if(*p=='"') break;
		}
		++p;
	    }
	    pend = p;
	    if(*p==0) goto endif;
            /*skip quote and any trailing blanks*/
            while(*++p==' ') ;
            if(*p != '\n' && *p !=0) goto endif;
	    copy = calloc(pend-pstart+1,sizeof(char));
	    strncpy(copy,pstart,pend-pstart);
	    switch(cmdind) {
	    case cmdInclude:
	        inputNewIncludeFile(inputPvt,copy);
		break;
	    case cmdSubstitute:
		addMacroReplacements(macPvt,copy);
		break;
	    default:
		fprintf(stderr,"Logic Error: makeSubstitutions\n");
	        inputErrPrint(inputPvt);
		exit(1);
	    }
	    free(copy);
	    expand = 0;
	}
endif:
	if (expand) {
	    n = macExpandString(macPvt,input,buffer,MAX_BUFFER_SIZE-1);
	    fputs(buffer,stdout);
	    if (!unexpWarned && n<0) {
		fprintf(stderr,"Warning: unexpanded macros in ouput\n");
		unexpWarned++;
	    }
	}
    }
}