예제 #1
0
void CReactionInterface::updateModifiersInChemEq()
{
  mChemEqI.clearModifiers();
  size_t j, jmax = size();

  for (j = 0; j < jmax; ++j)
    if (getUsage(j) == CFunctionParameter::MODIFIER) //all the modifiers in the table
      if (getMapping(j) != "unknown")
        mChemEqI.addModifier(getMapping(j));
}
예제 #2
0
    void adjustRange(int portId, Addr orig, Addr& low, Addr& high)
    {
        if(DMI_DEBUG) {
            icmPrintf("TLM: %s adjustRange port %d input lo:" FMT_64x " hi:" FMT_64x "\n", name(), portId, low, high);
        }
        icmPortMapping *map = getMapping(portId, orig);
        Addr portLo, portHi;

        map->getRegion(portLo, portHi);

        if(DMI_DEBUG) {
            icmPrintf("TLM: %s adjustRange region addr:" FMT_64x " (lo:" FMT_64x " hi:" FMT_64x ")\n", name(), orig, portLo, portHi);
        }

        // low is always correct
        low  += portLo;

        // if high > decoder, it's the special case of the device not knowing it's size
        // or just being larger than the decoder
        Addr maxDecode = portHi - portLo;
        if(high > maxDecode) {
            high = portLo + maxDecode;
        } else {
            high += portLo;
        }

        if(DMI_DEBUG) {
            icmPrintf("TLM: %s adjustRange changed: lo:" FMT_64x " hi:" FMT_64x "\n\n", name(), low, high);
        }

        assert(high >= low);
        assert(high - low <= maxDecode);

    }
예제 #3
0
	int getPortId(const Addr address, Addr& offset)
	{
		int i;
		for(i = 0; i < NR_OF_TARGETS; i++) {
		  icmPortMapping *decode = getMapping(i, address);
		  if (decode) {
			  offset = decode->offsetInto(address);
			  return i;
		  }
		}
		return -1;
	}
예제 #4
0
void PlainDictionary::populateHeader(Header &header, string rootNode)
{
    header.insert(rootNode, HDTVocabulary::DICTIONARY_TYPE, HDTVocabulary::DICTIONARY_TYPE_PLAIN);
    header.insert(rootNode, HDTVocabulary::DICTIONARY_NUMSUBJECTS, getNsubjects());
    header.insert(rootNode, HDTVocabulary::DICTIONARY_NUMPREDICATES, getNpredicates());
    header.insert(rootNode, HDTVocabulary::DICTIONARY_NUMOBJECTS, getNobjects());
    header.insert(rootNode, HDTVocabulary::DICTIONARY_NUMSHARED, getNshared());
    header.insert(rootNode, HDTVocabulary::DICTIONARY_MAXSUBJECTID, getMaxSubjectID());
    header.insert(rootNode, HDTVocabulary::DICTIONARY_MAXPREDICATEID, getMaxPredicateID());
    header.insert(rootNode, HDTVocabulary::DICTIONARY_MAXOBJECTTID, getMaxObjectID());
    header.insert(rootNode, HDTVocabulary::DICTIONARY_MAPPING, getMapping());
    header.insert(rootNode, HDTVocabulary::DICTIONARY_SIZE_STRINGS, size());
}
예제 #5
0
int
main(int argc, char * argv[]) {

    struct cmdlineInfo cmdline;
    FILE * ifP;
    xelval lmin, lmax;
    gray * lumamap;           /* Luminosity map */
    unsigned int * lumahist;  /* Histogram of luminosity values */
    int rows, cols;           /* Rows, columns of input image */
    xelval maxval;            /* Maxval of input image */
    int format;               /* Format indicator (PBM/PGM/PPM) */
    xel ** xels;              /* Pixel array */
    unsigned int pixelCount;

    pnm_init(&argc, argv);

    parseCommandLine(argc, argv, &cmdline);

    ifP = pm_openr(cmdline.inputFileName);

    xels = pnm_readpnm(ifP, &cols, &rows, &maxval, &format);

    pm_close(ifP);

    computeLuminosityHistogram(xels, rows, cols, maxval, format,
                               cmdline.gray, &lumahist, &lmin, &lmax,
                               &pixelCount);

    getMapping(cmdline.rmap, lumahist, maxval, pixelCount, &lumamap);

    if (cmdline.verbose)
        reportMap(lumahist, maxval, lumamap);

    remap(xels, cols, rows, maxval, format, !!cmdline.gray, lumamap);

    pnm_writepnm(stdout, xels, cols, rows, maxval, format, 0);

    if (cmdline.wmap)
        writeMap(cmdline.wmap, lumamap, maxval);

    pgm_freerow(lumamap);

    return 0;
}
void FengYin::onOkClicked()
{
    Role::onOkClicked();
    SafeList<Card*> selectedCards;
    SafeList<Player*>selectedPlayers;

    selectedCards=handArea->getSelectedCards();
    selectedPlayers=playerArea->getSelectedPlayers();

    network::Action* action;
    try{
    switch(state)
    {
//封印法术
    case FENG_ZHI_FENG_YIN:
        action = newAction(ACTION_MAGIC_SKILL, getMapping(selectedCards[0]->getElement()));
        action->add_card_ids(selectedCards[0]->getID());
        action->add_dst_ids(selectedPlayers[0]->getID());
        emit sendCommand(network::MSG_ACTION, action);
        gui->reset();
        break;
//五系束缚
    case WU_XI_SHU_FU:
        action = newAction(ACTION_MAGIC_SKILL, WU_XI_SHU_FU);
        action->add_dst_ids(selectedPlayers[0]->getID());
        emit sendCommand(network::MSG_ACTION, action);
        gui->reset();
        break;
//封印破碎
    case FENG_YIN_PO_SUI:
        action = newAction(ACTION_MAGIC_SKILL, FENG_YIN_PO_SUI);
        action->add_dst_ids(selectedPlayers[0]->getID());
        action->add_card_ids(tipArea->getSelectedCardID());
        emit sendCommand(network::MSG_ACTION, action);
        gui->reset();
        break;
    }
    }catch(int error){
        logic->onError(error);
    }
}
예제 #7
0
void VertexWelder::addNewVertex(NxU32 oldIndex)
{
	assert(mMappingSize + 1 < mMappingSpace);

#ifdef DEBUG_WELDER
	printf("addNewVertex %d (%d)-> %d\n", oldIndex, getMapping(oldIndex), mMappingSize);
#endif
	NxVec3& vertex = *(NxVec3*)(((char*)mWriteVerticesPtr) + mWriteVerticesStride * mMappingSize);
	NxVec3& normal = *(NxVec3*)(((char*)mWriteNormalsPtr)  + mWriteNormalsStride  * mMappingSize);
	void* userData =  (float*) (((char*)mWriteUserDataPtr) + mWriteUserDataStride * mMappingSize);

	NxVec3& parentVertex = *(NxVec3*)(((char*)mWriteVerticesPtr) + mWriteVerticesStride * oldIndex);
	NxVec3& parentNormal = *(NxVec3*)(((char*)mWriteNormalsPtr)  + mWriteNormalsStride  * oldIndex);
	void* parentUserData =  (float*) (((char*)mWriteUserDataPtr) + mWriteUserDataStride * oldIndex);

	vertex = parentVertex;
	normal = parentNormal;
	memcpy(userData, parentUserData, mWriteUserDataSize);

	mMappingSize++;
}
예제 #8
0
static void draw_controlsMenu(int c)
{
	int leftMargin=3;
	int tabstop1 = 17;
	int tabstop2 = 19;
	int tabstop3 = 21;
	int tabstop4 = 23;
	int tabstop5 = 25;
	int tabstop6 = 27;
	int tabstop7 = 29;
	int tabstop8 = 31;
	int tabstop9 = 33;

	int menuLine = 3;
	static int b=0;
	int bb=(b%6)/3;
	SDL_Rect r;
	extern SDL_Surface *text_screen;
	r.x=80-64; r.y=0; r.w=110+64+64; r.h=240;

	text_draw_background();
	text_draw_window(2,2,40,30,text_str_controls_title);

	// 1
	if (menuControls == 0 && bb)
		write_text_inv(3, menuLine, "Return to main menu");
	else
		write_text(3, menuLine, "Return to main menu");

	menuLine++;
	write_text(leftMargin,menuLine,text_str_controls_separator);
	menuLine++;

	// 2
	write_text(leftMargin,menuLine,"Custom Controls");
	if ((mainMenu_customControls==1)&&((menuControls!=1)||(bb)))
		write_text_inv(tabstop3,menuLine,"On");
	else
		write_text(tabstop3,menuLine,"On");
	if ((mainMenu_customControls==0)&&((menuControls!=1)||(bb)))
		write_text_inv(tabstop6,menuLine,"Off");
	else
		write_text(tabstop6,menuLine,"Off");

	menuLine++;
	write_text(leftMargin,menuLine,text_str_controls_separator);
	menuLine++;

	// 3
	write_text(leftMargin,menuLine," DPAD");
	if ((mainMenu_custom_dpad==0)&&((menuControls!=2)||(bb)))
		write_text_inv(tabstop1-6,menuLine,"Custom");
	else
		write_text(tabstop1-6,menuLine,"Custom");
	if ((mainMenu_custom_dpad==1)&&((menuControls!=2)||(bb)))
		write_text_inv(tabstop2,menuLine,"Joystick");
	else
		write_text(tabstop2,menuLine,"Joystick");
	if ((mainMenu_custom_dpad==2)&&((menuControls!=2)||(bb)))
		write_text_inv(tabstop6+2,menuLine,"Mouse");
	else
		write_text(tabstop6+2,menuLine,"Mouse");

	if (mainMenu_custom_dpad==0)
	{
		// 4
		menuLine+=2;
		write_text(leftMargin,menuLine,"    up");
		getMapping(mainMenu_custom_up);
		if ((menuControls!=3)||(bb))
			write_text_inv(tabstop1-4,menuLine,mapping);
		else
			write_text(tabstop1-4,menuLine,mapping);
		// 5
		menuLine+=2;
		write_text(leftMargin,menuLine,"  down");
		getMapping(mainMenu_custom_down);
		if ((menuControls!=4)||(bb))
			write_text_inv(tabstop1-4,menuLine,mapping);
		else
			write_text(tabstop1-4,menuLine,mapping);
		// 6
		menuLine+=2;
		write_text(leftMargin,menuLine,"  left");
		getMapping(mainMenu_custom_left);
		if ((menuControls!=5)||(bb))
			write_text_inv(tabstop1-4,menuLine,mapping);
		else
			write_text(tabstop1-4,menuLine,mapping);
		// 7
		menuLine+=2;
		write_text(leftMargin,menuLine," right");
		getMapping(mainMenu_custom_right);
		if ((menuControls!=6)||(bb))
			write_text_inv(tabstop1-4,menuLine,mapping);
		else
			write_text(tabstop1-4,menuLine,mapping);
	}

	// 8
	menuLine+=3;
	write_text(leftMargin,menuLine,"   (A)");
	getMapping(mainMenu_custom_A);
	if ((menuControls!=7)||(bb))
		write_text_inv(tabstop1-4,menuLine,mapping);
	else
		write_text(tabstop1-4,menuLine,mapping);
	// 9
	menuLine+=2;
	write_text(leftMargin,menuLine,"   (B)");
	getMapping(mainMenu_custom_B);
	if ((menuControls!=8)||(bb))
		write_text_inv(tabstop1-4,menuLine,mapping);
	else
		write_text(tabstop1-4,menuLine,mapping);
	// 10
	menuLine+=2;
	write_text(leftMargin,menuLine,"   (X)");
	getMapping(mainMenu_custom_X);
	if ((menuControls!=9)||(bb))
		write_text_inv(tabstop1-4,menuLine,mapping);
	else
		write_text(tabstop1-4,menuLine,mapping);
	// 11
	menuLine+=2;
	write_text(leftMargin,menuLine,"   (Y)");
	getMapping(mainMenu_custom_Y);
	if ((menuControls!=10)||(bb))
		write_text_inv(tabstop1-4,menuLine,mapping);
	else
		write_text(tabstop1-4,menuLine,mapping);

	// 12
	menuLine+=3;
	write_text(leftMargin,menuLine,"   (L)");
	getMapping(mainMenu_custom_L);
	if ((menuControls!=11)||(bb))
		write_text_inv(tabstop1-4,menuLine,mapping);
	else
		write_text(tabstop1-4,menuLine,mapping);
	// 13
	menuLine+=2;
	write_text(leftMargin,menuLine,"   (R)");
	getMapping(mainMenu_custom_R);
	if ((menuControls!=12)||(bb))
		write_text_inv(tabstop1-4,menuLine,mapping);
	else
		write_text(tabstop1-4,menuLine,mapping);

	text_flip();
	b++;
}
예제 #9
0
void ConfusabledataBuilder::addKeyEntry(
    UChar32     keyChar,     // The key character
    UHashtable *table,       // The table, one of SATable, MATable, etc.
    int32_t     tableFlag,   // One of USPOOF_SA_TABLE_FLAG, etc.
    UErrorCode &status) {

    SPUString *targetMapping = static_cast<SPUString *>(uhash_iget(table, keyChar));
    if (targetMapping == NULL) {
        // No mapping for this key character.
        //   (This function is called for all four tables for each key char that
        //    is seen anywhere, so this no entry cases are very much expected.)
        return;
    }

    // Check whether there is already an entry with the correct mapping.
    // If so, simply set the flag in the keyTable saying that the existing entry
    // applies to the table that we're doing now.

    UBool keyHasMultipleValues = FALSE;
    int32_t i;
    for (i=fKeyVec->size()-1; i>=0 ; i--) {
        int32_t key = fKeyVec->elementAti(i);
        if ((key & 0x0ffffff) != keyChar) {
            // We have now checked all existing key entries for this key char (if any)
            //  without finding one with the same mapping.
            break;
        }
        UnicodeString mapping = getMapping(i);
        if (mapping == *(targetMapping->fStr)) {
            // The run time entry we are currently testing has the correct mapping.
            // Set the flag in it indicating that it applies to the new table also.
            key |= tableFlag;
            fKeyVec->setElementAt(key, i);
            return;
        }
        keyHasMultipleValues = TRUE;
    }

    // Need to add a new entry to the binary data being built for this mapping.
    // Includes adding entries to both the key table and the parallel values table.

    int32_t newKey = keyChar | tableFlag;
    if (keyHasMultipleValues) {
        newKey |= USPOOF_KEY_MULTIPLE_VALUES;
    }
    int32_t adjustedMappingLength = targetMapping->fStr->length() - 1;
    if (adjustedMappingLength>3) {
        adjustedMappingLength = 3;
    }
    newKey |= adjustedMappingLength << USPOOF_KEY_LENGTH_SHIFT;

    int32_t newData = targetMapping->fStrTableIndex;

    fKeyVec->addElement(newKey, status);
    fValueVec->addElement(newData, status);

    // If the preceding key entry is for the same key character (but with a different mapping)
    //   set the multiple-values flag on it.
    if (keyHasMultipleValues) {
        int32_t previousKeyIndex = fKeyVec->size() - 2;
        int32_t previousKey = fKeyVec->elementAti(previousKeyIndex);
        previousKey |= USPOOF_KEY_MULTIPLE_VALUES;
        fKeyVec->setElementAt(previousKey, previousKeyIndex);
    }
}
예제 #10
0
int doSchedule(int *spsr, volatile unsigned int *sp[], q_elem **next, int timedSchedule)
{
	#if DEBUG_SCHEDULE
	kprintf("do Schedule timed=%d forcere=%d forceup=%d\r\n", timedSchedule, force_reschedule, force_updateRegs);
	#endif
	int returnValue = 0;

	if(!timedSchedule && !force_reschedule)
	{
		(*next) = thread.current;
		return returnValue;
	}

	if(current_wants_to_be_destroyed)
	{
		q_elem *tmp = thread.current;

		thread.thread_count--;
		thread.threads_ready--;
		threadsPerPidCount[tmp->tcb.pid]--;

		// free stack
		unsigned int stackMap = getMapping(tmp->tcb.pid, 0xB+tmp->id)-0xA;
		free_0_63&=(~(1<<stackMap));
		minvalidate(tmp->tcb.pid, 0xB+tmp->id);

		// free data if all threads of a process died
		if(threadsPerPidCount[tmp->tcb.pid]<=0)
		{
			unsigned int dataMap = getMapping(tmp->tcb.pid, 0xA)-0xA;
			free_0_63&=(~(1<<dataMap));
			minvalidate(tmp->tcb.pid, 0xA);
		}

		thread.current = nextThread();

		queueOut(tmp, &thread.head);
		appendElem(tmp, &thread.free_elems);

		force_updateRegs = 1;
		current_wants_to_be_destroyed = 0;
	}
	
	if(!force_updateRegs)
	{
		saveCurrentThread(*sp, *spsr);
		(*next) = nextThread();
	}
	else
	{
		(*next) = thread.current;
	}

	#if DEBUG
	kprintf("waiting: ");
	printListPrev(thread.waiting);
	kprintf("\r\n");
	kprintf("queue: ");
	printListPrev(thread.head);
	kprintf("\r\n");
	kprintf("next %d\r\n", (*next)->id);
	#endif

	if(force_reschedule)
		force_reschedule=0;

	updateTimer(next, timedSchedule);

	#if DEBUG
	kprintf("TIMER NEXT\r\n");
	kprintf("waiting: ");
	printListPrev(thread.waiting);
	kprintf("\r\n");
	kprintf("queue: ");
	printListPrev(thread.head);
	kprintf("\r\n");
	kprintf("next %d\r\n", (*next)->id);
	#endif

	#if DEBUG_THREAD_REGS
	kprintf("next PC %x before THREAD REGS\r\n",(*next)->tcb.regs[15]);
	#endif

	switch(updateThreadRegs((*next),sp))
	{
		// didn't do the context switch, so update LR
		case 1:
			returnValue = 1;
		break;
		case -1:
			kprintf("ERROR no next Thread, something went wrong\r\n");
			while(1);
		break;

	}
	

	return returnValue;
}
예제 #11
0
// -----------------------------------------------------------------------
void VertexWelder::initialize(const NxClothMeshDesc& unweldedMesh)
{
	NxArray<NxU32> mapping;
	NxReal squaredEpsilon = mEpsilon * mEpsilon;
	for (NxU32 i = 0; i < unweldedMesh.numVertices; i++)
	{
		const NxVec3& curVec = *(const NxVec3*)(((const char*)unweldedMesh.points) + (i * unweldedMesh.pointStrideBytes));

		// Find Vertex in newVertices
		NxU32 newIndex = 0;
		for (newIndex = 0; newIndex < mNewVertices.size(); newIndex++)
		{
			NxVec3& newVec = mNewVertices[newIndex];
			if ((mEpsilon == 0 && newVec == curVec) || (newVec.distanceSquared(curVec) < squaredEpsilon))
			//if (newVec == curVec)
			{
				break;
			}
		}

		if (newIndex == mNewVertices.size())
		{
			// Not found in previous list
			mNewVertices.push_back(curVec);
		}

		mapping.push_back(newIndex);
	}

	// Store mapping
	mMappingSize = mapping.size();
	mMappingSpace = unweldedMesh.numTriangles * 3;
	mMappingDomain = mNewVertices.size();
	mMapping = (NxU32*)malloc(sizeof(NxU32) * mMappingSpace);
	memcpy(mMapping, &mapping[0], sizeof(NxU32) * mMappingSize);
	memset(((NxU32*)mMapping) + mMappingSize, 0, sizeof(NxU32) * (mMappingSpace - mMappingSize));
	mapping.clear();

	if (mNewVertices.size() < unweldedMesh.numVertices)
	{
		mUsed = true;
	}
	else
	{
		return;
	}

	if (unweldedMesh.flags & NX_MF_16_BIT_INDICES)
	{
		mNewFaces16 = (NxU16*)malloc(sizeof(NxU16) * unweldedMesh.numTriangles * 3);
	}
	else
	{
		mNewFaces32 = (NxU32*)malloc(sizeof(NxU32) * unweldedMesh.numTriangles * 3);
	}

	for (NxU32 i = 0; i < unweldedMesh.numTriangles; i++)
	{
		NxU32 triangles[3];
		const char* triangleChar = ((const char*)unweldedMesh.triangles) + (unweldedMesh.triangleStrideBytes * i);
		if (mNewFaces16)
		{
			const NxU16* tris = (const NxU16*)triangleChar;
			triangles[0] = tris[0];
			triangles[1] = tris[1];
			triangles[2] = tris[2];
		}
		else
		{
			assert(mNewFaces32 != NULL);
			const NxU32* tris = (const NxU32*)triangleChar;
			triangles[0] = tris[0];
			triangles[1] = tris[1];
			triangles[2] = tris[2];
		}

		for (NxU32 j = 0; j < 3; j++)
		{
			triangles[j] = getMapping(triangles[j]);
		}

		if (mNewFaces16)
		{
			for (NxU32 j = 0; j < 3; j++)
			{
				mNewFaces16[3*i+j] = (NxU16)(triangles[j] & 0xffff);
			}
		}
		else
		{
			for (NxU32 j = 0; j < 3; j++)
			{
				mNewFaces32[3*i+j] = triangles[j];
			}
		}
	}
}
예제 #12
0
void VertexWelder::update(NxMeshData meshData)
{
	assert(mWriteVerticesPtr != NULL);

	bool updateVertices = (*(meshData.dirtyBufferFlagsPtr) & (NX_MDF_VERTICES_POS_DIRTY | NX_MDF_VERTICES_NORMAL_DIRTY)) > 0;
	bool updateIndices = (*(meshData.dirtyBufferFlagsPtr) & (NX_MDF_INDICES_DIRTY | NX_MDF_PARENT_INDICES_DIRTY)) > 0;

	NxU32 numNewVertices = *meshData.numVerticesPtr;
	NxU32 numTriangles = *meshData.numIndicesPtr / 3;
	NxU32 oldMappingDomain = mMappingDomain;
	
	NxArray<NewVertex> newVertices;
	NxArray<DifficultVertex> difficultVertices;

	mMappingDomainAddition = 0;

	if (updateVertices)
	{
		
		if (mMappingDomain < numNewVertices)
		{
#ifdef DEBUG_WELDER
			printf("------------------------------------\n");
#endif
			for (NxU32 i = mMappingDomain; i < numNewVertices; i++)
			{
				NewVertex v;
				v.index = i;
				v.parent = *(NxU32*)(((char*)meshData.parentIndicesBegin) + meshData.parentIndicesByteStride * i);
				while (v.parent >= (NxI32)mMappingDomain) {
					v.parent = *(NxU32*)(((char*)meshData.parentIndicesBegin) + meshData.parentIndicesByteStride * v.parent);
				}
#ifdef DEBUG_WELDER
				printf("New Vertex: %d %d\n", v.index, v.parent);
#endif
				newVertices.push_back(v);
			}
			std::sort(newVertices.begin(), newVertices.end(), sortParent);
		}
		
		for (NxU32 i = 0; i < mMappingSize; i++)
		{
			NxU32 mappedIndex = getMapping(i);

			NewVertex newV;
			newV.parent = mappedIndex;
			// Find all vertices that are a parent for a newly created vertex
			NxArray<NewVertex>::iterator found = std::lower_bound(newVertices.begin(), newVertices.end(), newV, sortParent);
			while (found != NULL && found->parent == mappedIndex)
			{
				found->mappedVertices ++;
				if (found->mappedVertices == 1)
				{
					found->unMapParent = i;
#ifdef DEBUG_WELDER
					printf("New Vertex Update, %d %d %d\n", found->index, found->parent, found->unMapParent);
#endif
				}
				else
				{
					// several unmapped parents
					DifficultVertex v;
					v.mappedIndex = found->index;
					v.unMappedIndex = i;
					difficultVertices.push_back(v);
#ifdef DEBUG_WELDER
					printf("Difficult Vertex %d %d\n", v.unMappedIndex, v.mappedIndex);
#endif

					if (found->mappedVertices == 2)
					{
						v.unMappedIndex = found->unMapParent;
						difficultVertices.push_back(v);
#ifdef DEBUG_WELDER
						printf("Difficult Vertex %d %d\n", v.unMappedIndex, v.mappedIndex);
#endif
					}

					found->unMapParent = -2;
				}
				found++;
			}
			

			NxVec3& vertex = *(NxVec3*)(((char*)mWriteVerticesPtr) + mWriteVerticesStride * i);
			NxVec3& normal = *(NxVec3*)(((char*)mWriteNormalsPtr) + mWriteNormalsStride* i);
			//float* texCoord = (float*)(((char*)texCoords) + texStride * i);

			const NxVec3& oldVertex = *(NxVec3*)(((char*)meshData.verticesPosBegin) + meshData.verticesPosByteStride * mappedIndex);
			const NxVec3& oldNormal = *(NxVec3*)(((char*)meshData.verticesNormalBegin) + meshData.verticesNormalByteStride * mappedIndex);

			vertex = oldVertex;
			normal = oldNormal;
		}
		// Adapt the mapping table
		std::sort(newVertices.begin(), newVertices.end(), sortIndex);
		std::sort(difficultVertices.begin(), difficultVertices.end(), sortDifficultExt);	
	}

	if (updateIndices)
	{
		std::vector<bool> bitVector(mMappingSpace, false);
#ifdef DEBUG_WELDER
		printf("updateIndices: Vertices: %d, Indices %d, gfx Vertices: %d\n", *meshData.numVerticesPtr, *meshData.numIndicesPtr, mMappingSize);
#endif
		if (difficultVertices.size() > 0)
		{
#ifdef DEBUG_WELDER
			printf("    Difficult Vertices:\n");
#endif
			for (NxU32 i = 0; i < difficultVertices.size(); i++)
			{
				DifficultVertex& v = difficultVertices[i];
#ifdef DEBUG_WELDER
				printf("      V %d %d\n", v.unMappedIndex, v.mappedIndex);
#endif
			}
		}
		assert((meshData.flags & NX_MF_16_BIT_INDICES) == 0);
		assert(meshData.indicesByteStride == 4);
		for (NxU32 i = 0; i < numTriangles; i++)
		{
			const NxU32* simTriangle = (NxU32*)(((char*)meshData.indicesBegin) + meshData.indicesByteStride * (i*3));
			NxU32* gfxTriangle = (NxU32*)(((char*)mWriteIndicesPtr) + mWriteIndicesStride* i);
			
			if (simTriangle[0] == simTriangle[1] && simTriangle[1] == simTriangle[2])
			{
				// Face was deleted (outside valid bounds probably)
				gfxTriangle[0] = gfxTriangle[1] = gfxTriangle[2] = 0;
				continue;
			}
			for (NxU32 j = 0; j < 3; j++)
			{

				DifficultVertex v;
				v.mappedIndex = simTriangle[j];
				v.unMappedIndex = gfxTriangle[j];
				if (std::binary_search(difficultVertices.begin(), difficultVertices.end(), v, sortDifficult))
				{
					NxArray<DifficultVertex>::iterator it = std::lower_bound(difficultVertices.begin(), difficultVertices.end(), v, sortDifficultExt);
#ifdef DEBUG_WELDER
					printf("-- Triangle %d (%d) (%d %d %d) (%d %d %d)", i, j, simTriangle[0], simTriangle[1], simTriangle[2], gfxTriangle[0], gfxTriangle[1], gfxTriangle[2]);
					printf(" %d %d\n", v.unMappedIndex, v.mappedIndex);
#endif

					if (it == NULL || it->mappedIndex != simTriangle[j])
					{
						// element hasn't been found

						//insert element
#ifdef DEBUG_WELDER
						printf("Adding Diff %d %d\n", v.unMappedIndex, v.mappedIndex);
#endif
						difficultVertices.push_back(v);

						// sort now, don't know whether this could be done less often, so far the list is extremely small
						std::sort(difficultVertices.begin(), difficultVertices.end(), sortDifficultExt);

						// get the freshly created item
						it = std::lower_bound(difficultVertices.begin(), difficultVertices.end(), v, sortDifficultExt);

						// element has to exist
						assert(it != NULL);
					}

					if (it->newUnMappedIndex >= 0)
					{
						gfxTriangle[j] = it->newUnMappedIndex;
					}
					else if (bitVector[it->unMappedIndex])
					{
#ifdef DEBUG_WELDER
						printf("Bit %d is true\n", it->unMappedIndex);
#endif
						// create a new gfx vertex
						it->newUnMappedIndex = mMappingSize;
						addNewVertex(gfxTriangle[j]);
						setMapping(it->newUnMappedIndex, simTriangle[j]);
						gfxTriangle[j] = it->newUnMappedIndex;
						bitVector[it->newUnMappedIndex] = true;
					}
					else
					{
#ifdef DEBUG_WELDER
						printf("Set Bit %d to true\n", it->unMappedIndex);
#endif
						bitVector[it->unMappedIndex] = true;
						it->newUnMappedIndex = it->unMappedIndex;
						setMapping(it->newUnMappedIndex, simTriangle[j]);
					}
				}
				else if (simTriangle[j] >= oldMappingDomain) // only used when not a difficult vertex
				{
					// unamp index and update
					for (NxU32 k = 0; k < newVertices.size(); k++)
					{
						NewVertex& v = newVertices[k];
						if (v.index == simTriangle[j] && v.mappedVertices == 1)
						{
#ifdef DEBUG_WELDER
							printf("- Triangle %d (%d %d %d) (%d %d %d)", i, simTriangle[0], simTriangle[1], simTriangle[2], gfxTriangle[0], gfxTriangle[1], gfxTriangle[2]);
							printf(" %d %d\n", v.unMapIndex, v.index);
#endif
							if (v.unMapIndex == -1)
							{
#ifdef DEBUG_WELDER
								printf("Add Simple\n");
#endif
								v.unMapIndex = mMappingSize;
								//addNewVertex(vertices, vertexStride, normals, normalStride, texCoords, texStride, v.unMapParent);
								addNewVertex(gfxTriangle[j]);
								gfxTriangle[j] = v.unMapIndex;
								setMapping(v.unMapIndex, v.index);
							}
							else
							{
#ifdef DEBUG_WELDER
								printf("Use Simple\n");
#endif
								gfxTriangle[j] = v.unMapIndex;
							}
							break; // for (k)
						}
					}
				}
			}
		}
	}

	if (updateVertices)
	{
		mMappingDomain = *meshData.numVerticesPtr;

#ifdef DEBUG_WELDER
		static bool sanityCheck = true;
		if (sanityCheck)
		{
			// sanity check
			NxU32 temp = 0;
			for (NxU32 i = 0; i < mMappingSize; i++)
			{
				temp = NxMath::max(getMapping(i), temp);
			}
			if (temp != mMappingDomain - 1)
			{
				printf("Mapping Domain not right, is %d, should be %d\n", temp, mMappingDomain-1);
				assert(0);
			}
			for (NxU32 i = 0; i < numTriangles; i++)
			{
				const NxU32* simTriangle = (NxU32*)(((char*)meshData.indicesBegin) + meshData.indicesByteStride * (i*3));
				NxU32* gfxTriangle = (NxU32*)(((char*)mWriteIndicesPtr) + mWriteIndicesStride * i);
				for (NxU32 j = 0; j < 3; j++)
				{
					if (simTriangle[j] != getMapping(gfxTriangle[j]))
					{
						printf("Triangle %d (%d) not correct (%d %d %d) -> (%d %d %d) != (%d %d %d)\n",
							i, 3*i+j,
							gfxTriangle[0], gfxTriangle[1], gfxTriangle[2],
							getMapping(gfxTriangle[0]), getMapping(gfxTriangle[1]), getMapping(gfxTriangle[2]),
							simTriangle[0], simTriangle[1], simTriangle[2]);
						assert(0);
					}
				}
			}
		}
#endif
	}

	return;
}
예제 #13
0
파일: gui.cpp 프로젝트: kerheol/uae4all
//pnd_nubstate_t t;
void gui_handle_events (void)
{
	printf("gui_handle_events\n");
/*if(blubb<0)
{
	test = pnd_evdev_open(pnd_evdev_nub1);
	printf("nub1 open: %d\n", test);
	test = pnd_evdev_open(pnd_evdev_nub2);
	printf("nub2 open: %d\n", test);
	t.x=1;
	t.y=1;
	printf("nubstate 1: x=%d y=%d\n", t.x, t.y);
}
blubb++;
if(blubb>100 && blubb<0)
{
	pnd_evdev_catchup(1);
	blubb=0;
}
test = pnd_evdev_nub_state(pnd_evdev_nub1, &t);
printf("nubstate 1: x=%d y=%d, returnvalue=%d\n", t.x, t.y, test);
pnd_evdev_nub_state(pnd_evdev_nub2, &t);
printf("nubstate 2: x=%d y=%d\n", t.x, t.y);
*/

#if ! defined (DREAMCAST) && ! defined (GP2X) && ! defined (PSP) && ! defined (GIZMONDO)
	Uint8 *keystate = SDL_GetKeyState(NULL);
	if ( keystate[SDLK_F12] )
		SDL_WM_ToggleFullScreen(prSDLScreen);
	else
	if ( keystate[SDLK_F11] )
#else
#ifdef DREAMCAST
	if (SDL_JoystickGetButton(uae4all_joy0,3) )
#endif
#ifdef GP2X
    if (SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_SELECT))
#endif
#ifdef PSP
	if (SDL_JoystickGetButton(uae4all_joy0, PSP_BUTTON_SELECT))
#endif
#ifdef GIZMONDO
	Uint8 *keystate = SDL_GetKeyState(NULL);
	if ( keystate[SDLK_F1] )
#endif
#endif
#ifdef GP2X
	{
		// hack: always use SDL_SWSURFACE in menus
		//switch_to_sw_sdl();
		goMenu();
		//switch_to_hw_sdl(0);
	}
#else
		goMenu();
#endif

#ifndef PANDORA
#if defined (DREAMCAST) || defined (GP2X) || defined (PSP) || defined (GIZMONDO)
#ifdef DREAMCAST
	if (SDL_JoystickGetAxis (uae4all_joy0, 2))
		if (vkbd_mode)
		{
			vkbd_mode=0;
   			notice_screen_contents_lost();
		}
	if (SDL_JoystickGetAxis (uae4all_joy0, 3))
		vkbd_mode=1;
#else

	if (!gp2xMouseEmuOn && !gp2xButtonRemappingOn)
	{
#ifdef GP2X
		if (SDL_JoystickGetButton (uae4all_joy0, GP2X_BUTTON_L))
#else
#ifdef GIZMONDO
		if (SDL_JoystickGetButton (uae4all_joy0, GIZ_LTRIG))
#else
		if (SDL_JoystickGetButton (uae4all_joy0, PSP_BUTTON_L))
#endif
#endif
		{
			/*if (vkbd_mode)
			{
				vkbd_mode = 0;
				goingVkbd=0;
				notice_screen_contents_lost();
			}
			else*/
				goingSuperThrottle=1;
		}
		else
		{
			if (!nowSuperThrottle)
				goingSuperThrottle=0;
			/*else
				goingVkbd=0;*/
		}

#ifdef GP2X
		if (SDL_JoystickGetButton (uae4all_joy0, GP2X_BUTTON_R))
#else
#ifdef GIZMONDO
		if (SDL_JoystickGetButton (uae4all_joy0, GIZ_RTRIG))
#else
		if (SDL_JoystickGetButton (uae4all_joy0, PSP_BUTTON_R))
#endif
#endif
		{
			if (goingSuperThrottle)
				goSuperThrottle();
			/*else
			{
				if (goingVkbd>4)
					vkbd_mode=1;
				else
					goingVkbd++;
			}*/
		}
		else
		{
			if (nowSuperThrottle)
				leftSuperThrottle();
			/*else
				goingVkbd=0;*/
		}
	}

#endif
#endif

	/*if (vkbd_key)
	{
		if (vkbd_keysave==-1234567)
		{
			SDL_keysym ks;
			ks.sym=vkbd_key;
			vkbd_keysave=keycode2amiga(&ks);
			if (vkbd_keysave >= 0)
			{
				if (!uae4all_keystate[vkbd_keysave])
				{
					uae4all_keystate[vkbd_keysave]=1;
					record_key(vkbd_keysave<<1);
				}
			}
		}
	}
	else
		if (vkbd_keysave!=-1234567)
		{
			if (vkbd_keysave >= 0)
			{
				uae4all_keystate[vkbd_keysave]=0;
				record_key((vkbd_keysave << 1) | 1);
			}
			vkbd_keysave=-1234567;
		}*/
#endif

#ifdef PANDORA
	Uint8 *keystate = SDL_GetKeyState(NULL);
	if(keystate[SDLK_F12])
	{
		if(hwScaled)
			SDL_WM_ToggleFullScreen(prSDLScreen);
		else
			SDL_WM_ToggleFullScreen(prSDLScaleScreen);
	}

if(!vkbd_mode)
{
	//L + R
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
	{
		//up
		if(SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
		{
			moveVertical(1);
			moved_y += 2;
		}
		//down
		else if(SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
		{
			moveVertical(-1);
			moved_y -= 2;
		}
		//left
		else if(SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
		{
			screenWidth -=10;
			if(screenWidth<200)
				screenWidth = 200;
			update_display();
		}
		//right
		else if(SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
		{
			screenWidth +=10;
			if(screenWidth>800)
				screenWidth = 800;
			update_display();
		}
		//1
		else if(keystate[SDLK_1])
		{
			mainMenu_displayedLines = 200;
			screenWidth = 768;
			presetModeId = 0;
			strcpy(presetMode, "320x200 upscaled");
			update_display();
		}
		//2
		else if(keystate[SDLK_2])
		{
			mainMenu_displayedLines = 216;
			screenWidth = 716;
			presetModeId = 1;
			strcpy(presetMode, "320x216 upscaled");
			update_display();
		}
		//3
		else if(keystate[SDLK_3])
		{
			mainMenu_displayedLines = 240;
			screenWidth = 640;
			presetModeId = 2;
			strcpy(presetMode, "320x240 upscaled");
			update_display();
		}
		//4
		else if(keystate[SDLK_4])
		{
			mainMenu_displayedLines = 256;
			screenWidth = 600;
			presetModeId = 3;
			strcpy(presetMode, "320x256 upscaled");
			update_display();
		}
		//5
		else if(keystate[SDLK_5])
		{
			mainMenu_displayedLines = 262;
			screenWidth = 588;
			presetModeId = 4;
			strcpy(presetMode, "320x262 upscaled");
			update_display();
		}
		//6
		else if(keystate[SDLK_6])
		{
			mainMenu_displayedLines = 270;
			screenWidth = 570;
			presetModeId = 5;
			strcpy(presetMode, "320x270 upscaled");
			update_display();
		}
		//7
		else if(keystate[SDLK_7])
		{
			mainMenu_displayedLines = 200;
			screenWidth = 640;
			presetModeId = 6;
			strcpy(presetMode, "320x200 NTSC");
			update_display();
		}
		//8
		else if(keystate[SDLK_8])
		{
			mainMenu_displayedLines = 200;
			screenWidth = 800;
			presetModeId = 7;
			strcpy(presetMode, "320x200 fullscreen");
			update_display();
		}
	}

	//autofire on/off
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
	{
		//(Y) button
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_Y))
		{
			if(!justPressedY)
			{
				//autofire on/off
				switch_autofire = !switch_autofire;
				justPressedY=1;
			}
		}
		else if(justPressedY)
			justPressedY=0;
	}

	if (mainMenu_customControls && !gp2xMouseEmuOn && !gp2xButtonRemappingOn)
	{
		if(mainMenu_custom_dpad == 0)
		{
			//UP
			if(SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
			{
				if(!justMovedUp)
				{
					if(mainMenu_custom_up == -1) buttonstate[0]=1;
					else if(mainMenu_custom_up == -2) buttonstate[2]=1;
					else if(mainMenu_custom_up > 0)
					{
						getMapping(mainMenu_custom_up);
						uae4all_keystate[customKey] = 1;
						record_key(customKey << 1);
					}
					justMovedUp=1;
				}
			}
			else if(justMovedUp)
			{
				if(mainMenu_custom_up == -1) buttonstate[0]=0;
				else if(mainMenu_custom_up == -2) buttonstate[2]=0;
				else if(mainMenu_custom_up > 0)
				{
					getMapping(mainMenu_custom_up);
					uae4all_keystate[customKey] = 0;
					record_key((customKey << 1) | 1);
				}
				justMovedUp=0;
			}

			//DOWN
			if(SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
			{
				if(!justMovedDown)
				{
					if(mainMenu_custom_down == -1) buttonstate[0]=1;
					else if(mainMenu_custom_down == -2) buttonstate[2]=1;
					else if(mainMenu_custom_down > 0)
					{
						getMapping(mainMenu_custom_down);
						uae4all_keystate[customKey] = 1;
						record_key(customKey << 1);
					}
					justMovedDown=1;
				}
			}
			else if(justMovedDown)
			{
				if(mainMenu_custom_down == -1) buttonstate[0]=0;
				else if(mainMenu_custom_down == -2) buttonstate[2]=0;
				else if(mainMenu_custom_down > 0)
				{
					getMapping(mainMenu_custom_down);
					uae4all_keystate[customKey] = 0;
					record_key((customKey << 1) | 1);
				}
				justMovedDown=0;
			}

			//LEFT
			if(SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
			{
				if(!justMovedLeft)
				{
					if(mainMenu_custom_left == -1) buttonstate[0]=1;
					else if(mainMenu_custom_left == -2) buttonstate[2]=1;
					else if(mainMenu_custom_left > 0)
					{
						getMapping(mainMenu_custom_left);
						uae4all_keystate[customKey] = 1;
						record_key(customKey << 1);
					}
					justMovedLeft=1;
				}
			}
			else if(justMovedLeft)
			{
				if(mainMenu_custom_left == -1) buttonstate[0]=0;
				else if(mainMenu_custom_left == -2) buttonstate[2]=0;
				else if(mainMenu_custom_left > 0)
				{
					getMapping(mainMenu_custom_left);
					uae4all_keystate[customKey] = 0;
					record_key((customKey << 1) | 1);
				}
				justMovedLeft=0;
			}

 			//RIGHT
			if(SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
			{
				if(!justMovedRight)
				{
					if(mainMenu_custom_right == -1) buttonstate[0]=1;
					else if(mainMenu_custom_right == -2) buttonstate[2]=1;
					else if(mainMenu_custom_right > 0)
					{
						getMapping(mainMenu_custom_right);
						uae4all_keystate[customKey] = 1;
						record_key(customKey << 1);
					}
					justMovedRight=1;
				}
			}
			else if(justMovedRight)
			{
				if(mainMenu_custom_right == -1) buttonstate[0]=0;
				else if(mainMenu_custom_right == -2) buttonstate[2]=0;
				else if(mainMenu_custom_right > 0)
				{
					getMapping(mainMenu_custom_right);
					uae4all_keystate[customKey] = 0;
					record_key((customKey << 1) | 1);
				}
				justMovedRight=0;
			}
		}

		//(A)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_B))
		{
			if(!justPressedA)
			{
				if(mainMenu_custom_A == -1) buttonstate[0]=1;
				else if(mainMenu_custom_A == -2) buttonstate[2]=1;
				else if(mainMenu_custom_A > 0)
				{
					getMapping(mainMenu_custom_A);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedA=1;
			}
		}
		else if(justPressedA)
		{
			if(mainMenu_custom_A == -1) buttonstate[0]=0;
			else if(mainMenu_custom_A == -2) buttonstate[2]=0;
			else if(mainMenu_custom_A > 0)
			{
				getMapping(mainMenu_custom_A);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedA=0;
		}

		//(B)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_A))
		{
			if(!justPressedB)
			{
				if(mainMenu_custom_B == -1) buttonstate[0]=1;
				else if(mainMenu_custom_B == -2) buttonstate[2]=1;
				else if(mainMenu_custom_B > 0)
				{
					getMapping(mainMenu_custom_B);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedB=1;
			}
		}
		else if(justPressedB)
		{
			if(mainMenu_custom_B == -1) buttonstate[0]=0;
			else if(mainMenu_custom_B == -2) buttonstate[2]=0;
			else if(mainMenu_custom_B > 0)
			{
				getMapping(mainMenu_custom_B);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedB=0;
		}

		//(X)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_X))
		{
			if(!justPressedX)
			{
				if(mainMenu_custom_X == -1) buttonstate[0]=1;
				else if(mainMenu_custom_X == -2) buttonstate[2]=1;
				else if(mainMenu_custom_X > 0)
				{
					getMapping(mainMenu_custom_X);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedX=1;
			}
		}
		else if(justPressedX)
		{
			if(mainMenu_custom_X == -1) buttonstate[0]=0;
			else if(mainMenu_custom_X == -2) buttonstate[2]=0;
			else if(mainMenu_custom_X > 0)
			{
				getMapping(mainMenu_custom_X);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedX=0;
		}

		//(Y)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_Y))
		{
			if(!justPressedY)
			{
				if(mainMenu_custom_Y == -1) buttonstate[0]=1;
				else if(mainMenu_custom_Y == -2) buttonstate[2]=1;
				else if(mainMenu_custom_Y > 0)
				{
					getMapping(mainMenu_custom_Y);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedY=1;
			}
		}
		else if(justPressedY)
		{
			if(mainMenu_custom_Y == -1) buttonstate[0]=0;
			else if(mainMenu_custom_Y == -2) buttonstate[2]=0;
			else if(mainMenu_custom_Y > 0)
			{
				getMapping(mainMenu_custom_Y);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedY=0;
		}

		//(L)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L))
		{
			if(!justPressedL)
			{
				if(mainMenu_custom_L == -1) buttonstate[0]=1;
				else if(mainMenu_custom_L == -2) buttonstate[2]=1;
				else if(mainMenu_custom_L > 0)
				{
					getMapping(mainMenu_custom_L);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedL=1;
			}
		}
		else if(justPressedL)
		{
			if(mainMenu_custom_L == -1) buttonstate[0]=0;
			else if(mainMenu_custom_L == -2) buttonstate[2]=0;
			else if(mainMenu_custom_L > 0)
			{
				getMapping(mainMenu_custom_L);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedL=0;
		}

		//(R)
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
		{
			if(!justPressedR)
			{
				if(mainMenu_custom_R == -1) buttonstate[0]=1;
				else if(mainMenu_custom_R == -2) buttonstate[2]=1;
				else if(mainMenu_custom_R > 0)
				{
					getMapping(mainMenu_custom_R);
					uae4all_keystate[customKey] = 1;
					record_key(customKey << 1);
				}
				justPressedR=1;
			}
		}
		else if(justPressedR)
		{
			if(mainMenu_custom_R == -1) buttonstate[0]=0;
			else if(mainMenu_custom_R == -2) buttonstate[2]=0;
			else if(mainMenu_custom_R > 0)
			{
				getMapping(mainMenu_custom_R);
				uae4all_keystate[customKey] = 0;
				record_key((customKey << 1) | 1);
			}
			justPressedR=0;
		}
	}
	else if(!gp2xMouseEmuOn)
	{
		//DPad = arrow keys in stylus-mode
		if(gp2xButtonRemappingOn)
		{
			//dpad up
			if (SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
			{
				if(!justMovedUp)
				{
					//left and right mouse-buttons down
					buttonstate[0] = 1;
					buttonstate[2] = 1;
					stylusClickOverride = 1;
					justMovedUp=1;
				}
			}
			else if(justMovedUp)
			{
				//left and right mouse-buttons up
				buttonstate[0] = 0;
				buttonstate[2] = 0;
				stylusClickOverride = 0;
				justMovedUp=0;
			}
			//dpad down
			if (SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
			{
				if(!justMovedDown)
				{
					//no clicks with stylus now
					stylusClickOverride=1;
					justMovedDown=1;
				}
			}
			else if(justMovedDown)
			{
				//clicks active again
				stylusClickOverride=0;
				justMovedDown=0;
			}
			//dpad left
			if (SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
			{
				if(!justMovedLeft)
				{
					//left mouse-button down
					buttonstate[0] = 1;
					stylusClickOverride = 1;
					justMovedLeft=1;
				}
			}
			else if(justMovedLeft)
			{
				//left mouse-button up
				buttonstate[0] = 0;
				stylusClickOverride = 0;
				justMovedLeft=0;
			}
			//dpad right
			if (SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
			{
				if(!justMovedRight)
				{
					//right mouse-button down
					buttonstate[2] = 1;
					stylusClickOverride = 1;
					justMovedRight=1;
				}
			}
			else if(justMovedRight)
			{
				//right mouse-button up
				buttonstate[2] = 0;
				stylusClickOverride = 0;
				justMovedRight=0;
			}
			//L + up
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
				stylusAdjustY-=2;
			//L + down
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
				stylusAdjustY+=2;
			//L + left
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
				stylusAdjustX-=2;
			//L + right
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
				stylusAdjustX+=2;
		}
		//R-trigger in joystick mode
		else if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
		{
			//(A) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_A))
			{
				if(!justPressedA)
				{
					//CTRL
					uae4all_keystate[AK_CTRL] = 1;
					record_key(AK_CTRL << 1);
					justPressedA=1;
				}
			}
			else if(justPressedA)
			{
				uae4all_keystate[AK_CTRL] = 0;
				record_key((AK_CTRL << 1) | 1);
				justPressedA=0;
			}
			//(B) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_B))
			{
				if(!justPressedB)
				{
					//left ALT
					uae4all_keystate[AK_LALT] = 1;
					record_key(AK_LALT << 1);
					justPressedB=1;
				}
			}
			else if(justPressedB)
			{
				uae4all_keystate[AK_LALT] = 0;
				record_key((AK_LALT << 1) | 1);
				justPressedB=0;
			}
			//(X) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_X))
			{
				if(!justPressedX)
				{
					//HELP
					uae4all_keystate[AK_HELP] = 1;
					record_key(AK_HELP << 1);
					justPressedX=1;
				}
			}
			else if(justPressedX)
			{
				//HELP
				uae4all_keystate[AK_HELP] = 0;
				record_key((AK_HELP << 1) | 1);
				justPressedX=0;
			}
		}
		else if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L))
		{
			//(A) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_A))
			{
				if(!justPressedA)
				{
					//right mouse-button down
					buttonstate[2] = 1;
					justPressedA=1;
				}
			}
			else if(justPressedA)
			{
				//right mouse-button up
				buttonstate[2] = 0;
				justPressedA=0;
			}
			//(B) button
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_B))
			{
				if(!justPressedB)
				{
					//left mouse-button down
					buttonstate[0] = 1;
					justPressedB=1;
				}
			}
			else if(justPressedB)
			{
				//left mouse-button up
				buttonstate[0] = 0;
				justPressedB=0;
			}
		}
		else
		{
			if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_Y))
			{
				if(!justPressedY)
				{
					//SPACE
					uae4all_keystate[AK_SPC] = 1;
					record_key(AK_SPC << 1);
					justPressedY=1;
				}
			}
			else if(justPressedY)
			{
				//SPACE
				uae4all_keystate[AK_SPC] = 0;
				record_key((AK_SPC << 1) | 1);
				justPressedY=0;
			}
		}
	}
	else
	{
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_A))
		{
			if(!justPressedA)
			{
				//right mouse-button down
				buttonstate[2] = 1;
				justPressedA=1;
			}
		}
		else if(justPressedA)
		{
			//right mouse-button up
			buttonstate[2] = 0;
			justPressedA=0;
		}
		//(B) button
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_B))
		{
			if(!justPressedB)
			{
				//left mouse-button down
				buttonstate[0] = 1;
				justPressedB=1;
			}
		}
		else if(justPressedB)
		{
			//left mouse-button up
			buttonstate[0] = 0;
			justPressedB=0;
		}
		if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_Y))
		{
			if(!justPressedY)
			{
				//SPACE
				uae4all_keystate[AK_SPC] = 1;
				record_key(AK_SPC << 1);
				justPressedY=1;
			}
		}
		else if(justPressedY)
		{
			//SPACE
			uae4all_keystate[AK_SPC] = 0;
			record_key((AK_SPC << 1) | 1);
			justPressedY=0;
		}
		if (SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
		{
			if(!justMovedLeft)
			{
				//left ALT
				uae4all_keystate[0x64] = 1;
				record_key(0x64 << 1);
				justMovedLeft=1;
			}
		}
		else if(justMovedLeft)
		{
			//left ALT
			uae4all_keystate[0x64] = 0;
			record_key((0x64 << 1) | 1);
			justMovedLeft=0;
		}
		if (SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
		{
			if(!justMovedRight)
			{
				//left ALT
				uae4all_keystate[0x64] = 1;
				record_key(0x64 << 1);
				justMovedRight=1;
			}
		}
		else if(justMovedRight)
		{
			//left ALT
			uae4all_keystate[0x64] = 0;
			record_key((0x64 << 1) | 1);
			justMovedRight=0;
		}
	}

	if(!mainMenu_customControls && SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_R))
	{
		//R+dpad = arrow keys in joystick mode
		//dpad up
		if (SDL_JoystickGetAxis(uae4all_joy0, 1) < 0)
		{
			if(!justMovedUp)
			{
				//arrow up
				uae4all_keystate[0x4C] = 1;
				record_key(0x4C << 1);
				justMovedUp=1;
			}
		}
		else if(justMovedUp)
		{
			//arrow up
			uae4all_keystate[0x4C] = 0;
			record_key((0x4C << 1) | 1);
			justMovedUp=0;
		}
		//dpad down
		if (SDL_JoystickGetAxis(uae4all_joy0, 1) > 0)
		{
			if(!justMovedDown)
			{
				//arrow down
				uae4all_keystate[0x4D] = 1;
				record_key(0x4D << 1);
				justMovedDown=1;
			}
		}
		else if(justMovedDown)
		{
			//arrow down
			uae4all_keystate[0x4D] = 0;
			record_key((0x4D << 1) | 1);
			justMovedDown=0;
		}
		//dpad left
		if (SDL_JoystickGetAxis(uae4all_joy0, 0) < 0)
		{
			if(!justMovedLeft)
			{
				//arrow left
				uae4all_keystate[0x4F] = 1;
				record_key(0x4F << 1);
				justMovedLeft=1;
			}
		}
		else if(justMovedLeft)
		{
			//arrow left
			uae4all_keystate[0x4F] = 0;
			record_key((0x4F << 1) | 1);
			justMovedLeft=0;
		}
		//dpad right
		if (SDL_JoystickGetAxis(uae4all_joy0, 0) > 0)
		{
			if(!justMovedRight)
			{
				//arrow right
				uae4all_keystate[0x4E] = 1;
				record_key(0x4E << 1);
				justMovedRight=1;
			}
		}
		else if(justMovedRight)
		{
			//arrow right
			uae4all_keystate[0x4E] = 0;
			record_key((0x4E << 1) | 1);
			justMovedRight=0;
		}
	}

	//L+D: show/hide status ln
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_d])
	{
		keystate[SDLK_d]=0;
		mainMenu_showStatus = !mainMenu_showStatus;
	}
}

	//L+K: virtual keyboard
	if (SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_k])
	{
		if(!justLK)
		{
			vkbd_mode = !vkbd_mode;
			justLK=1;
		}
	}
	else if(justLK)
		justLK=0;

#ifndef CYCLONE
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_s])
	{
		keystate[SDLK_s]=0;
		savestate_state = STATE_DOSAVE;
	}
	if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_l])
	{
		extern char *savestate_filename;
		FILE *f=fopen(savestate_filename, "rb");
		keystate[SDLK_l]=0;
		if(f)
		{
			fclose(f);
			savestate_state = STATE_DORESTORE;
		}
		else
			gui_set_message("Failed: Savestate not found", 100);
	}
#endif
//if(SDL_JoystickGetButton(uae4all_joy0, GP2X_BUTTON_L) && keystate[SDLK_1])
//{
//	resChange = 1;
//	gfxHeight	 = 256;
//	prSDLScreen = SDL_SetVideoMode(320, 256, 16, VIDEO_FLAGS);
//	system("export SDL_OMAP_LAYER_SIZE=800x480");
//}
#endif

	if (vkbd_key)
	{
		if (vkbd_keysave==-1234567)
		{
			SDL_keysym ks;
			ks.sym=vkbd_key;
			vkbd_keysave=keycode2amiga(&ks);
			if (vkbd_keysave >= 0)
			{
				if (!uae4all_keystate[vkbd_keysave])
				{
					uae4all_keystate[vkbd_keysave]=1;
					record_key(vkbd_keysave<<1);
				}
			}
		}
	}
	else
		if (vkbd_keysave!=-1234567)
		{
			if (vkbd_keysave >= 0)
			{
				uae4all_keystate[vkbd_keysave]=0;
				record_key((vkbd_keysave << 1) | 1);
			}
			vkbd_keysave=-1234567;
		}
}
string ConfigurationReader::ReadConfiguration(configutation _property)
{
	return m_map[getMapping(_property)];
}