Пример #1
0
void Input_Engine::Touched(Touch &_touch)
{
    if (input_controller == NULL) return;
    TransformTouch(_touch);

    Touch &touch = GetTouch(_touch.ID);
    if(touch.Active == _touch.Active)
        return;
    bool pressed;
    _touch.Active ? pressed = true : pressed = false;
    touch = _touch;
    if(pressed)
    {
        for (int i = 0; i < input_controller->input_objects.size(); i++)
        {
            input_controller->input_objects[i]->TouchesBegan(touch);
        }
    }
    else
    {
        for (int i = 0; i < input_controller->input_objects.size(); i++)
        {
            input_controller->input_objects[i]->TouchesEnded(touch);
        }
    }

    input_controller->InputChanged();
}
Пример #2
0
void WaitForTouch(void)
{
	while(1)
	{
		SVC_WaitVBlankIntr();
		if(GetTouch(NULL, NULL))
			break;
	}
}
Пример #3
0
void MultiTouchMotionCB(s3ePointerTouchMotionEvent* event)
{
    CTouch* pTouch = GetTouch(event->m_TouchID);
    if( pTouch )
    {
        pTouch->x = event->m_x;
        pTouch->y = event->m_y;
    }
}
Пример #4
0
// callback called whenever a touch is initiated or ended.
void MultiTouchButtonCB(s3ePointerTouchEvent* event) {
	CTouch* touch = GetTouch(event->m_TouchID);
	if (touch) {
        touch->active = event->m_Pressed != 0;
		touch->x = event->m_x;
		touch->y = event->m_y;

        // if it's the beginning of a touch, then determine what kind of gesture it is and set initial info.
        if (touch->active) {
            if (touch->x > (int32) IwGxGetScreenWidth() - 60) {
                touch->gesture_type = CREATE_UNIT;
                int y = touch->y - 94; // Palate offset
                
                if(y < 0) return;
                
                switch (y / 55) {
                    case 0:
                        unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2_MINUS_THROWER", IW_GX_RESTYPE_TEXTURE));
                        touch->unit = new Thrower(localPlayer, game, 0, 0);
                        break;
                    case 1:
                        unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2_MINUS_WRECKER", IW_GX_RESTYPE_TEXTURE));
                        touch->unit = new Wrecker(localPlayer, game, 0, 0);
                        break;
                    case 2: 
                        unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2_MINUS_MUNCHER", IW_GX_RESTYPE_TEXTURE));
                        touch->unit = new Muncher(localPlayer, game, 0, 0);
                        break;
                    case 3:
                        unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2_MINUS_SHOOTER", IW_GX_RESTYPE_TEXTURE));
                        touch->unit = new Shooter(localPlayer, game, 0, 0);
                        break;
                    case 4: 
                        unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2_MINUS_SPREADER", IW_GX_RESTYPE_TEXTURE));
                        touch->unit = new Spreader(localPlayer, game, 0, 0);
                        break;
                    default: break;
                }
                   
            } else {
                touch->gesture_type = DRAG_WORLD;
                worldScrollSpeed = 0;
            }
        // if it's the end of a touch, check what kind of gesture it and render.
        } else {
			switch(touch->gesture_type) {
				case CREATE_UNIT:
                    unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2", IW_GX_RESTYPE_TEXTURE));
                    renderUnitCreation(touch);
                    break;
				case DRAG_WORLD: /* shouldn't need to do anything */ break;
				default: break;
            }
        }
	}
}
Пример #5
0
df::TouchEvent MapWidget::GetTouchEvent(QMouseEvent * e, df::TouchEvent::ETouchType type) const
{
  df::TouchEvent event;
  event.SetTouchType(type);
  event.SetFirstTouch(GetTouch(e));
  if (IsCommandModifier(e))
    event.SetSecondTouch(GetSymmetrical(event.GetFirstTouch()));

  return event;
}
Пример #6
0
void MultiTouchMotionCB(s3ePointerTouchMotionEvent* event)
{
    CTouch* touch = GetTouch(event->m_TouchID);
    if (touch)
    {
        touch->x = event->m_x;
        touch->y = event->m_y;
    }
    Control::getInstance().pointerMotion(event->m_x, event->m_y, event->m_TouchID);
}
Пример #7
0
/*****************************************************************
 * 函数名称:execGame
 * 描述说明:运行连连看游戏
 * 输入参数:p_gameUi:游戏体指针,blockNum:当前关数
 * 输出参数:1:重新开始当前关2:返回3:闯关成功4:超时5:死局
*****************************************************************/
int execGame(gameUi_t *p_gameUi, int blockNum)
{
	int ret = 0;
	struct LcdDot touchXY;

	gameExeFlag = 1;
	restTime = 75;
	noConnectTime = 0;
	initGame(p_gameUi, blockNum);
	showGame(p_gameUi);
	
	while(1){
		while(GetTouch(&touchXY) == 0);

		if(restTime <= 0){
			gameExeFlag = 0;
			return 4;
		}

		if(noConnectTime > 3){
			if(haveConnect(&p_gameUi->m_mat) == 0){
				gameExeFlag = 0;
				return 5;
			}else{
				noConnectTime = 0;
			}
		}

		ret = doGame(&p_gameUi->m_gameMng, &p_gameUi->m_mat, &touchXY);
		if(ret != 0){//按在矩阵内
			if(ret == 2){//点击第二次
				if(seccess(&p_gameUi->m_gameMng)){
					gameExeFlag = 0;
					return 3;
				}else{
					//gameDelay(1000);
					//showGame(p_gameUi);	
				}
			}
		}else{//按在矩阵外
			//showGame(p_gameUi);
			ret = getMenu(&p_gameUi->m_ui, &touchXY);

			if(ret > 0){
				gameExeFlag = 0;
				return ret;
			}
		}
	}

	return 0;
}
Пример #8
0
void MultiTouchButtonCB(s3ePointerTouchEvent* event)
{
    CTouch* touch = GetTouch(event->m_TouchID);
    if (touch)
    {
        touch->active = event->m_Pressed != 0;
        touch->x = event->m_x;
        touch->y = event->m_y;
    }
    if (event->m_Pressed)
        Control::getInstance().pointerPressed(event->m_x,event->m_y,S3E_POINTER_BUTTON_SELECT,event->m_TouchID);
    else
        Control::getInstance().pointerReleased(event->m_x,event->m_y,S3E_POINTER_BUTTON_SELECT,event->m_TouchID);
    sprintf(g_TouchEventMsg, "`x666666Touch %u %s",event->m_TouchID, event->m_Pressed ? "PRESSED" : "RELEASED");
}
Пример #9
0
// called whenever a touch is moved.
void MultiTouchMotionCB(s3ePointerTouchMotionEvent* event) {
    if(event->m_x < 0) return;
    
	CTouch* touch = GetTouch(event->m_TouchID);

    if (touch->gesture_type == DRAG_WORLD && touch->active) {
		touch->last_x = touch->x;
        touch->last_y = touch->y;
		touch->x = event->m_x;
        touch->y = event->m_y;
			
		worldScrollSpeed = getAngleDiff(touch);
    } else {
		touch->x = event->m_x;
		touch->y = event->m_y;
	}
}
Пример #10
0
void Input_Engine::TouchMoved(Touch &_touch)
{
    if (input_controller == NULL) return;
    TransformTouch(_touch);

    Touch touch = GetTouch(_touch.ID);
    if(touch.Active)
    {
        touch = _touch;

        for (int i = 0; i < input_controller->input_objects.size(); i++)
        {
            input_controller->input_objects[i]->TouchesMoved(touch);
        }

        input_controller->InputChanged();
    }
}
Пример #11
0
void MultiTouchButtonCB(s3ePointerTouchEvent* event)
{
    CTouch* pTouch = GetTouch(event->m_TouchID);
    if (pTouch)
    {
        pTouch->active = event->m_Pressed != 0; 
        pTouch->x = event->m_x;
        pTouch->y = event->m_y;
        pTouch->startX = event->m_x;
        pTouch->startY = event->m_y;
    }
	
	MapBackground::g_iActiveTouches = 0;

	for (int i = 0; i < MAX_TOUCHES; ++i)
	{
		if (MapBackground::g_Touches[i].active)
		{
			MapBackground::g_iActiveTouches++;
		}
	}
}
Пример #12
0
CTouch* Control::getPointer(int id){
    return GetTouch(id);
}
Пример #13
0
static void ShowMenuScreen(void)
{
	MenuScreenConfiguration * configuration = Screen.configuration;
	MenuScreenChoice * choices = configuration->choices;
	int options = configuration->options;
	
	const ScreenColor normalColor = SCGray;
	const ScreenColor highlightColor = SCWhite;
	const ScreenColor disabledColor = SCDarkGray;
	const int topTextLine = 10;
	const int animationLine = (topTextLine + 2);
	const int extraTextLine = (animationLine + 2);
	const int keyboardTextLine = 1;
	const int startKeyboardRowsLine = 3;
	const int numKeyboardRows = 3;
	const int numListRows = 5;
	const int startListLine = 1;
	const int startChoicesLine = (SCREEN_HEIGHT - (Screen.numChoices * 2));
	const char keyboardRows[numKeyboardRows][32] =
	{
		"1 2 3 4 5 6 7 8 9 0 - + = _ . < ",
		" A B C D E F G H I J K L M N O  ",
		"  P Q R S T U V W X Y Z  space  "
	};
	const char listBorder[32] = "--------------------";
	const int spacePos = (strchr(keyboardRows[2], 's') - keyboardRows[2]);
	const char animationChars[] = "-*";
	const gsi_time animationTickTime = 500;
	
	BOOL done = FALSE;
	int choiceIndex;
	BOOL keyboard;
	BOOL touching;
	BOOL list;
	BOOL animated;
	int x, y;
	int touchingLine;
	int touchingPos;
	int choiceLine;
	int keyboardLine;
	BOOL wasTouching = FALSE;
	int wasTouchingChoice = -1;
	ScreenColor color;
	int i;
	int range;
	char touchingChar;
	char wasTouchingChar = 0;
	int keyboardPos;
	int numListItems;
	int listScroll = 0;
	BOOL wasTouchingUp = FALSE;
	BOOL wasTouchingDown = FALSE;
	int listItem;
	const char * choiceSelection;
	int animationCount = 0;
	gsi_time lastAnimationTime = current_time();
	gsi_time now;
	char animationText[] = "-";

	// is it animated?
	animated = (options & SCREEN_OPTION_ANIMATED)?TRUE:FALSE;
	
	// is there a keyboard?
	keyboard = (options & SCREEN_OPTION_KEYBOARD)?TRUE:FALSE;

	// is there a list?
	list = (options & SCREEN_OPTION_LIST)?TRUE:FALSE;

	// we can't have a list and a keyboard
	if(keyboard && list)
		OS_Panic("Can't have a keyboard and a list on a menu screen\n");

	// call the init func
	if(configuration->initFunc)
	{
		configuration->initFunc();
		if(NextMenuScreenConfiguration)
			return;
	}

	// if there is a keyboard, get the initial position
	if(keyboard)
		keyboardPos = (int)strlen(Screen.keyboardText);

	// loop until we're done
	while(!done)
	{
		// wait for a screen update to complete
		SVC_WaitVBlankIntr();

		// call the think func
		if(configuration->thinkFunc)
		{
			configuration->thinkFunc();
			if(NextMenuScreenConfiguration)
				return;
		}

		// count the number of list items
		if(list)
		{
			for(numListItems = 0 ; numListItems < MAX_LIST_STRINGS ; numListItems++)
			{
				if(Screen.list[numListItems][0] == '\0')
					break;
			}
		}

		// check for a touch
		touching = GetTouch(&x, &y);
		if(touching)
		{
			// figure out which line we're touching
			touchingLine = (y / (TOUCH_Y_RANGE / SCREEN_HEIGHT));
			
			// figure out which position we're touching
			touchingPos = (x / (TOUCH_X_RANGE / SCREEN_WIDTH));
		}
		else if (wasTouching)
		{
			// check for touching a choice
			if(wasTouchingChoice != -1)
			{
				choiceSelection = choices[wasTouchingChoice].text;
				wasTouchingChoice = -1;

				// call the chose func
				if(configuration->choseFunc)
				{
					configuration->choseFunc(choiceSelection);
					if(NextMenuScreenConfiguration)
						return;
				}
			}
			// check for touching up on the list
			else if(wasTouchingUp)
			{
				if(listScroll > 0)
					listScroll--;
			}
			// check for touching down on the list
			else if(wasTouchingDown)
			{
				if(listScroll < (numListItems - numListRows))
					listScroll++;
			}
			// check for touching a keyboard char
			else if(wasTouchingChar != 0)
			{
				// check for backspace
				if(wasTouchingChar == '<')
				{
					if(keyboardPos > 0)
					{
						keyboardPos--;
						Screen.keyboardText[keyboardPos] = '\0';
					}
				}
				else
				{
					if(keyboardPos < MAX_KEYBOARD_TEXT_LEN)
					{
						Screen.keyboardText[keyboardPos] = wasTouchingChar;
						keyboardPos++;
						Screen.keyboardText[keyboardPos] = '\0';
					}
				}
			}
		}
		wasTouching = touching;
		
		// clear both screens
		ClearScreens();
		
		// show the title on the top screen
		SetTopScreenLineCentered(topTextLine, SCYellow, configuration->topScreenText);

		// show animation
		if(animated)
		{
			now = current_time();
			if((now - lastAnimationTime) >= animationTickTime)
			{
				animationCount++;
				animationCount %= strlen(animationChars);
				lastAnimationTime += animationTickTime;
			}

			animationText[0] = animationChars[animationCount];

			SetTopScreenLineCentered(animationLine, SCYellow, animationText);
		}

		// show extra text
		for(i = 0 ; i < MAX_EXTRA_TEXT_STRINGS ; i++)
		{
			if(options & SCREEN_OPTION_EXTRAS_CENTERED)
				SetTopScreenLineCentered(extraTextLine + i, SCWhite, Screen.extraText[i]);
			else
				SetTopScreenLine(extraTextLine + i, SCWhite, Screen.extraText[i]);
		}
		
		// show the list
		if(list)
		{
			// clear touching vars
			wasTouchingUp = FALSE;
			wasTouchingDown = FALSE;
			
			// show "up" if needed
			if(listScroll > 0)
			{
				if(touching && (touchingLine == startListLine))
				{
					wasTouchingUp = TRUE;
					color = highlightColor;
				}
				else
				{
					color = normalColor;
				}
				SetBottomScreenLineCentered(startListLine, color, "up");
			}
			
			// show the top line
			SetBottomScreenLineCentered(startListLine + 1, normalColor, listBorder);
			
			// show the list items
			for(i = 0 ; i < numListRows ; i++)
			{
				listItem = (listScroll + i);
				
				if(listItem >= numListItems)
					break;
				
				// is this item being touched?
				if(touching && (touchingLine == (startListLine + 2 + i)))
					Screen.listSelection = listItem;
				
				// set the color
				if(Screen.listSelection == listItem)
					color = highlightColor;
				else
					color = normalColor;
				
				// show the item
				SetBottomScreenLineCentered(startListLine + 2 + i, color, Screen.list[listScroll + i]);
			}
			
			// show the bottom line
			SetBottomScreenLineCentered(startListLine + numListRows + 2, normalColor, listBorder);
			
			// show "down" if needed
			if(listScroll < (numListItems - numListRows))
			{
				if(touching && (touchingLine == (startListLine + numListRows + 3)))
				{
					wasTouchingDown = TRUE;
					color = highlightColor;
				}
				else
				{
					color = normalColor;
				}
				SetBottomScreenLineCentered(startListLine + numListRows + 3, color, "down");
			}
		}
		
		// show a keyboard
		if(keyboard)
		{
			// show the text
			SetBottomScreenLine(keyboardTextLine, SCGreen, Screen.keyboardText);
			
			// clear touching var
			wasTouchingChar = 0;
			
			// loop through the keyboard rows
			for(i = 0 ; i < numKeyboardRows ; i++)
			{
				// get the line to show this row on
				keyboardLine = (startKeyboardRowsLine + i);
				
				// check if we're touching this row
				if(touching && (touchingLine == keyboardLine))
				{
					// get the char we're touching
					touchingChar = keyboardRows[i][touchingPos];
					
					// handle touching 'space' specially
					if(islower(touchingChar))
					{
						wasTouchingChar = ' ';
						
						touchingPos = spacePos;
						range = 5;
					}
					else
					{
						if(touchingChar != ' ')
							wasTouchingChar = touchingChar;
						
						range = 1;
					}
					
					// show the keyboard row with the selection highlighted
					SetBottomScreenLineHighlight(
						keyboardLine, normalColor, keyboardRows[i],
						touchingPos, range, highlightColor);
				}
				else
				{
					// show the keyboard row
					SetBottomScreenLine(keyboardLine, normalColor, keyboardRows[i]);
				}
			}
		}
		
		// show the choices
		wasTouchingChoice = -1;
		for(choiceIndex = 0 ; choiceIndex < Screen.numChoices ; choiceIndex++)
		{
			// this is the line to show this choice on
			choiceLine = (startChoicesLine + (choiceIndex * 2));
			
			// check if we're touching this choice
			if((choices[choiceIndex].options & CHOICE_OPTION_DISABLED) || 
				((choices[choiceIndex].options & CHOICE_OPTION_NEEDS_LIST_SELECTION) && (Screen.listSelection == -1)))
			{
				color = disabledColor;
			}
			else if(touching && (touchingLine == choiceLine))
			{
				color = highlightColor;
				wasTouchingChoice = choiceIndex;
			}
			else
			{
				color = normalColor;
			}
			
			// show the line
			SetBottomScreenLineCentered(choiceLine, color, choices[choiceIndex].text);
		}
	}
}