Beispiel #1
0
void UIInputText::DeleteText()
{
	textList.clear();
	UpdateTextTexture();
	cursorPosition = 0;
	UpdateCursorPosition();
}
void CustomColorsSystem::ProcessUIEvent(DAVA::UIEvent *event)
{
	if (!IsLandscapeEditingEnabled())
	{
		return;
	}
	
	UpdateCursorPosition();
	
	if (event->tid == UIEvent::BUTTON_1)
	{
		Vector3 point;
		
		switch(event->phase)
		{
			case UIEvent::PHASE_BEGAN:
				if (isIntersectsLandscape)
				{
					UpdateToolImage();
					StoreOriginalState();
					editingIsEnabled = true;
				}
				break;
				
			case UIEvent::PHASE_DRAG:
				break;
				
			case UIEvent::PHASE_ENDED:
				FinishEditing();
				break;
		}
	}
}
Beispiel #3
0
void CTextInputWidget::MoveCursorRight()
{
	if( myCursorPosition < (int)(myText.size()) )
	{
		myCursorPosition++;
		UpdateCursorPosition();
	}
}
Beispiel #4
0
void CTextInputWidget::MoveCursorToBegining()
{
	if( myCursorPosition != 0 )
	{
		myCursorPosition = 0;
		UpdateCursorPosition();
	}
}
Beispiel #5
0
void CTextInputWidget::MoveCursorLeft()
{
	if( myCursorPosition > 0 )
	{
		myCursorPosition--;
		UpdateCursorPosition();
	}
}
Beispiel #6
0
void CTextInputWidget::MoveCursorToEnd()
{
	if( myCursorPosition != myText.size() )
	{
		myCursorPosition = myText.size();
		UpdateCursorPosition();
	}
}
void LandscapeEditorDrawSystem::SetCursorSize(uint32 cursorSize)
{
	this->cursorSize = cursorSize;
	if (landscapeProxy)
	{
		landscapeProxy->SetCursorScale((float32)cursorSize);
		UpdateCursorPosition();
	}
}
Beispiel #8
0
void CTextInputWidget::ShowCursor()
{
	if( myFocus == false )
	{
		myFocus = true;
		myCursorSprite = mySpriteHandler->LoadSprite( myCursorImageFile );
		ZChanged();
		UpdateCursorPosition();
	}

}
Beispiel #9
0
void UIInputText::RenderCursor()
{
	int timeSinceStart = (int)(App->GetTimeSinceStart() * cursorBlinkSpeed);
	int rest = timeSinceStart % 2;
	if (rest == 0)
	{
		if (cursorNeedUpdate)
			UpdateCursorPosition();
		int x1 = cursorStart.x - App->render->camera.x + GetWorldRect().x;
		int x2 = x1;
		int y1 = cursorStart.y - App->render->camera.y + GetWorldRect().y;
		int y2 = y1 + defaultText->GetWorldRect().h;
		App->render->DrawLine(x1, y1, x2, y2, 255, 255, 255);
	}
}
Beispiel #10
0
void CTextInputWidget::SetText( const std::string& text )
{
	if( myText != text )
	{
		SetTextWithoutCursorUpdate( text );

		if( true )
		{
			int t = myCursorPosition;

			if( myCursorPosition < 0 )
				myCursorPosition = 0;
			if( myCursorPosition > (int)myText.size() )
				myCursorPosition = myText.size();

			if( myCursorPosition != t )
				UpdateCursorPosition();
		}
	}
}
Beispiel #11
0
void CTextInputWidget::RemoveALetterDeleteStyle()
{
	// delete erase )
	if( myText.empty() == false )
	{
		// just limiting cursor position so that's it's not all over town
		if( myCursorPosition < 0 )
			myCursorPosition = 0;

		// delete doesn't erase a letter if at the very end of string
		if( myCursorPosition < (int)myText.size() )
		{
			std::string edit( myText );
			edit.erase( myCursorPosition, 1 );

			SetTextWithoutCursorUpdate( edit );
			
			// myCursorPosition--;
			UpdateCursorPosition();
		}
	}
}
Beispiel #12
0
void CTextInputWidget::RemoveALetter()
{
	// backspace erase )
	if( myText.empty() == false )
	{
		// just limiting cursor position so that's it's not all over town
		if( myCursorPosition > (int)myText.size() )
			myCursorPosition = myText.size();

		// backspace doesn't erase a letter if the cursor position is zero 
		// (the cursor is at the very begining of the text)
		if( myCursorPosition > 0 )
		{
			std::string edit( myText );
			edit.erase( myCursorPosition - 1, 1 );

			SetTextWithoutCursorUpdate( edit );
			
			myCursorPosition--;
			UpdateCursorPosition();
		}
	}
}
Beispiel #13
0
void CTextInputWidget::MoveCursorToMousePosition( const types::point& mouse_point )
{
	if( myCursorSprite )
	{
		/*int search_this = mouse_point.x - GetRect().x;

		if( search_this > 0 && myText.empty() == false )
		{
			std::string text = HandleText( myText );
			for( unsigned int i = 0; i < text.size(); i++ )
			{
				if( mySpriteHandler->GetTextLength( GetSprite(), text.substr( 0, i ) ) > search_this )
					break;

				myCursorPosition = i;
			}
			UpdateCursorPosition();
		}*/

		myCursorPosition = mySpriteHandler->GetCursorTextPosition( GetSprite(), mouse_point );
		UpdateCursorPosition();
	}
}
Beispiel #14
0
void CTextInputWidget::AddCharacter( const types::charset& c )
{
	if( myCursorPosition < 0 ) 
		myCursorPosition = 0;
	
	if( myCursorPosition > (int)myText.size() )
		myCursorPosition = myText.size();

	std::string edit( myText );
	std::stringstream ss;
	ss << c;

	std::string append_piece = ss.str();
	edit.insert( myCursorPosition, append_piece );
	// logger_debug << edit << std::endl;

	SetTextWithoutCursorUpdate( edit );

	myCursorPosition += (int)append_piece.size();
	UpdateCursorPosition();

	// SetText( myText + event->GetAsCharacter() );
}
void LandscapeEditorDrawSystem::SetCursorPosition(const Vector2& cursorPos)
{
	cursorPosition = cursorPos;// - Vector2(cursorSize / 2.f, cursorSize / 2.f);
	UpdateCursorPosition();
}
Beispiel #16
0
//-----------------------------------------------------------------------------
// Name: OnLeftButtonDown()
// Desc: If we are drawing a curve, then read buffered data and draw
//      lines from point to point.  By reading buffered data, we can
//      track the motion of the mouse accurately without coalescing.
//
//      This function illustrates how a non-message-based program can
//      process buffered data directly from a device, processing
//      messages only occasionally (as required by Windows).
//
//      This function also illustrates how an application can piece
//      together buffered data elements based on the sequence number.
//      A single mouse action (e.g., moving diagonally) is reported
//      as a series of events, all with the same sequence number.
//      Zero is never a valid DirectInput sequence number, so it is
//      safe to use it as a sentinel value.
//-----------------------------------------------------------------------------
VOID OnLeftButtonDown( HWND hWnd )
{
    HRESULT             hr;
    LEFTBUTTONINFO      lbInfo;
    BOOL                bDone;
    DIDEVICEOBJECTDATA  od;
    DWORD               dwElements;
    MSG                 msg;

    // For performance, draw directly onto the window's DC instead of
    // invalidating and waiting for the WM_PAINT message.  Of course,
    // we always draw onto our bitmap, too, since that's what really
    // counts.

    // hide cursor and initialize button info with cursor position
    StartPenDraw( hWnd, &lbInfo );
    InvalidateCursorRect( hWnd );
    UpdateWindow( hWnd );

    // Keep reading data elements until we see a "mouse button up" event.
    bDone = FALSE;
    while( !bDone ) 
    {
        dwElements = 1;
        hr = g_pMouse->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), 
                                      &od, &dwElements, 0 );
        if( FAILED(hr) )       
            break;

        // If theres no data available, finish the element 
        // we have been collecting, and then process our message 
        // queue so the system doesn't think the app has hung.
        if( dwElements == 0 ) 
        {
            // if there is a partial motion, flush it out 
            OnLeftButtonDown_FlushMotion( &lbInfo );

            while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) 
            {
                // If it's a quit message, we're outta here 
                if( msg.message == WM_QUIT ) 
                {
                    // Re-post the quit message so the
                    // outer loop will see it and exit.
                    PostQuitMessage( (int)msg.wParam );
                    bDone = TRUE;                    
                    break;
                } 
                else 
                {
                    TranslateMessage( &msg );
                    DispatchMessage( &msg );
                }
            }
            continue;
        }

        // If this is the start of a new event, flush out the old one 
        if( od.dwSequence != lbInfo.dwSeqLastSeen ) 
        {
            OnLeftButtonDown_FlushMotion( &lbInfo );
            lbInfo.dwSeqLastSeen = od.dwSequence;
        }

        // Look at the element to see what happened 
        switch( od.dwOfs ) 
        {
            case DIMOFS_X:      // Mouse horizontal motion 
                UpdateCursorPosition( od.dwData, 0 );
                lbInfo.bMoved = TRUE;
                break;

            case DIMOFS_Y:      // Mouse vertical motion 
                UpdateCursorPosition( 0, od.dwData );
                lbInfo.bMoved = TRUE;
                break;

            case DIMOFS_BUTTON0: // Button 0 pressed or released 
            case DIMOFS_BUTTON1: // Button 1 pressed or released 
                if( ( g_bSwapMouseButtons  && DIMOFS_BUTTON1 == od.dwOfs ) ||
                    ( !g_bSwapMouseButtons && DIMOFS_BUTTON0 == od.dwOfs ) )
                {
                    if( !(od.dwData & 0x80) ) 
                    { 
                        // Button released, so flush out dregs 
                        bDone = TRUE;
                        OnLeftButtonDown_FlushMotion( &lbInfo ); 
                    }
                }
                break;
        }
    }

    ReleaseDC( hWnd, lbInfo.hdcWindow );

    // Re-show the cursor now that scrawling is finished 
    FinishPenDraw( hWnd );
    InvalidateCursorRect( hWnd );
}
Beispiel #17
0
//-----------------------------------------------------------------------------
// Name: OnMouseInput()
// Desc: Handles responding to any mouse input that is generated from
//       the mouse event being triggered.
//-----------------------------------------------------------------------------
VOID OnMouseInput( HWND hWnd )
{
    BOOL                bDone;
    DIDEVICEOBJECTDATA  od;
    DWORD               dwElements;
    HRESULT             hr;

    // Invalidate the old cursor so it will be erased 
    InvalidateCursorRect( hWnd );

    // Attempt to read one data element.  Continue as long as
    // device data is available.
    bDone = FALSE;
    while( !bDone ) 
    {
        dwElements = 1;
        hr = g_pMouse->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), 
                                      &od, &dwElements, 0 );

        if( hr == DIERR_INPUTLOST ) 
        {
            SetAcquire();
            break;
        }

        // Unable to read data or no data available
        if( FAILED(hr) || dwElements == 0 ) 
        {
            break;
        }

        // Look at the element to see what happened
        switch( od.dwOfs ) 
        {     
            case DIMOFS_X:       // Mouse horizontal motion 
                UpdateCursorPosition( od.dwData, 0 ); 
                break;

            case DIMOFS_Y:       // Mouse vertical motion 
                UpdateCursorPosition( 0, od.dwData ); 
                break;

            case DIMOFS_BUTTON0: // Right button pressed or released 
            case DIMOFS_BUTTON1: // Left button pressed or released 
                // Is the right or a swapped left button down?
                if( ( g_bSwapMouseButtons  && DIMOFS_BUTTON1 == od.dwOfs ) ||
                    ( !g_bSwapMouseButtons && DIMOFS_BUTTON0 == od.dwOfs ) )
                {
                    if( od.dwData & 0x80 ) 
                    { 
                        // left button pressed, so go into button-down mode 
                        bDone = TRUE;
                        OnLeftButtonDown( hWnd ); 
                    }
                }

                // is the left or a swapped right button down?
                if( ( g_bSwapMouseButtons  && DIMOFS_BUTTON0 == od.dwOfs ) ||
                    ( !g_bSwapMouseButtons && DIMOFS_BUTTON1 == od.dwOfs ) )
                {
                    if( !(od.dwData & 0x80) ) 
                    {  
                        // button released, so check context menu 
                        bDone = TRUE;
                        OnRightButtonUp( hWnd ); 
                    }
                }
                break;
        }
    }

    // Invalidate the new cursor so it will be drawn 
    InvalidateCursorRect( hWnd );
}
Beispiel #18
0
void FlowTab::EmitUpdateCursorPosition()
{
    emit UpdateCursorPosition(GetCursorLine(), GetCursorColumn());
}
Beispiel #19
0
void CTextInputWidget::RectChanged()
{
	CWidget::RectChanged();
	UpdateCursorPosition();
}
Beispiel #20
0
void decodepad (int pad)
{
  int i, offset;
  float t;

  signed char pad_x = PAD_StickX (pad);
  signed char pad_y = PAD_StickY (pad);
  u32 jp = PAD_ButtonsHeld (pad);

#ifdef HW_RVL
  signed char wm_ax = 0;
  signed char wm_ay = 0;
  u32 wp = 0;
  wm_ax = WPAD_StickX ((u8)pad, 0);
  wm_ay = WPAD_StickY ((u8)pad, 0);
  wp = WPAD_ButtonsHeld (pad);

  u32 exp_type;
  if ( WPAD_Probe(pad, &exp_type) != 0 ) exp_type = WPAD_EXP_NONE;
#endif

	/***
	Gamecube Joystick input
	***/
	// Is XY inside the "zone"?
	if (pad_x * pad_x + pad_y * pad_y > PADCAL * PADCAL)
	{
		/*** we don't want division by zero ***/
	    if (pad_x > 0 && pad_y == 0)
			jp |= PAD_BUTTON_RIGHT;
	    if (pad_x < 0 && pad_y == 0)
			jp |= PAD_BUTTON_LEFT;
	    if (pad_x == 0 && pad_y > 0)
			jp |= PAD_BUTTON_UP;
	    if (pad_x == 0 && pad_y < 0)
			jp |= PAD_BUTTON_DOWN;

	    if (pad_x != 0 && pad_y != 0)
		{

			/*** Recalc left / right ***/
			t = (float) pad_y / pad_x;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (pad_x >= 0)
					jp |= PAD_BUTTON_RIGHT;
				else
					jp |= PAD_BUTTON_LEFT;
			}

			/*** Recalc up / down ***/
			t = (float) pad_x / pad_y;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (pad_y >= 0)
					jp |= PAD_BUTTON_UP;
				else
					jp |= PAD_BUTTON_DOWN;
			}
		}
	}
#ifdef HW_RVL
	/***
	Wii Joystick (classic, nunchuk) input
	***/
	// Is XY inside the "zone"?
	if (wm_ax * wm_ax + wm_ay * wm_ay > PADCAL * PADCAL)
	{
		/*** we don't want division by zero ***/
	    if (wm_ax > 0 && wm_ay == 0)
			wp |= WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT;
	    if (wm_ax < 0 && wm_ay == 0)
			wp |= WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT;
	    if (wm_ax == 0 && wm_ay > 0)
			wp |= WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP;
	    if (wm_ax == 0 && wm_ay < 0)
			wp |= WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN;

	    if (wm_ax != 0 && wm_ay != 0)
		{

			/*** Recalc left / right ***/
			t = (float) wm_ay / wm_ax;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ax >= 0)
					wp |= WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT;
				else
					wp |= WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT;
			}

			/*** Recalc up / down ***/
			t = (float) wm_ax / wm_ay;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ay >= 0)
					wp |= WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP;
				else
					wp |= WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN;
			}
		}
	}
#endif

	/*** Fix offset to pad ***/
	offset = ((pad + 1) << 4);

	/*** Report pressed buttons (gamepads) ***/
	for (i = 0; i < MAXJP; i++)
    {
		if ( (jp & gcpadmap[i])											// gamecube controller
#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & wmpadmap[i]) )	// wiimote
		|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & ccpadmap[i]) )	// classic controller
		|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & ncpadmap[i]) )	// nunchuk + wiimote
#endif
		)
			S9xReportButton (offset + i, true);
		else
			S9xReportButton (offset + i, false);
    }

	/*** Superscope ***/
	if (Settings.SuperScopeMaster && pad == GCSettings.Superscope-1)	// report only once
	{
		// buttons
		offset = 0x50;
		for (i = 0; i < 6; i++)
		{
		  if ( jp & gcscopemap[i]
#ifdef HW_RVL
				|| wp & wmscopemap[i]
#endif
		  )
			S9xReportButton (offset + i, true);
		  else
			S9xReportButton (offset + i, false);
		}
		// pointer
		offset = 0x80;
		UpdateCursorPosition (pad, cursor_x[0], cursor_y[0]);
		S9xReportPointer(offset, (u16)cursor_x[0], (u16)cursor_y[0]);
	}
	/*** Mouse ***/
	else if (Settings.MouseMaster && pad < GCSettings.Mouse)
	{
		// buttons
		offset = 0x60+(2*pad);
		for (i = 0; i < 2; i++)
		{
		  if ( jp & gcmousemap[i]
#ifdef HW_RVL
				|| wp & wmmousemap[i]
#endif
		  )
			S9xReportButton (offset + i, true);
		  else
			S9xReportButton (offset + i, false);
		}
		// pointer
		offset = 0x81;
		UpdateCursorPosition (pad, cursor_x[1+pad], cursor_y[1+pad]);
		S9xReportPointer(offset+pad, (u16)cursor_x[1+pad], (u16)cursor_y[1+pad]);
	}
	/*** Justifier ***/
	else if (Settings.JustifierMaster && pad < GCSettings.Justifier)
	{
		// buttons
		offset = 0x70+(3*pad);
		for (i = 0; i < 3; i++)
		{
		  if ( jp & gcjustmap[i]
#ifdef HW_RVL
				|| wp & wmjustmap[i]
#endif
		  )
			S9xReportButton (offset + i, true);
		  else
			S9xReportButton (offset + i, false);
		}
		// pointer
		offset = 0x83;
		UpdateCursorPosition (pad, cursor_x[3+pad], cursor_y[3+pad]);
		S9xReportPointer(offset+pad, (u16)cursor_x[3+pad], (u16)cursor_y[3+pad]);
	}
}
Beispiel #21
0
static unsigned char DecodeJoy(unsigned short chan)
{
	s8 pad_x = userInput[chan].pad.stickX;
	s8 pad_y = userInput[chan].pad.stickY;
	u32 jp = userInput[chan].pad.btns_h;
	unsigned char J = 0;

	#ifdef HW_RVL
	s8 wm_ax = userInput[chan].WPAD_StickX(0);
	s8 wm_ay = userInput[chan].WPAD_StickY(0);
	u32 wp = userInput[chan].wpad->btns_h;

	u32 exp_type;
	if ( WPAD_Probe(chan, &exp_type) != 0 ) exp_type = WPAD_EXP_NONE;
	#endif

	/***
	Gamecube Joystick input
	***/
	// Is XY inside the "zone"?
	if (pad_x * pad_x + pad_y * pad_y > PADCAL * PADCAL)
	{
		if (pad_x > 0 && pad_y == 0) J |= JOY_RIGHT;
		if (pad_x < 0 && pad_y == 0) J |= JOY_LEFT;
		if (pad_x == 0 && pad_y > 0) J |= JOY_UP;
		if (pad_x == 0 && pad_y < 0) J |= JOY_DOWN;

		if (pad_x != 0 && pad_y != 0)
		{
			if ((float)pad_y / pad_x >= -2.41421356237 && (float)pad_y / pad_x < 2.41421356237)
			{
				if (pad_x >= 0)
					J |= JOY_RIGHT;
				else
					J |= JOY_LEFT;
			}

			if ((float)pad_x / pad_y >= -2.41421356237 && (float)pad_x / pad_y < 2.41421356237)
			{
				if (pad_y >= 0)
					J |= JOY_UP;
				else
					J |= JOY_DOWN;
			}
		}
	}
#ifdef HW_RVL
	/***
	Wii Joystick (classic, nunchuk) input
	***/
	// Is XY inside the "zone"?
	if (wm_ax * wm_ax + wm_ay * wm_ay > PADCAL * PADCAL)
	{
		/*** we don't want division by zero ***/
		if (wm_ax > 0 && wm_ay == 0)
			J |= JOY_RIGHT;
		if (wm_ax < 0 && wm_ay == 0)
			J |= JOY_LEFT;
		if (wm_ax == 0 && wm_ay > 0)
			J |= JOY_UP;
		if (wm_ax == 0 && wm_ay < 0)
			J |= JOY_DOWN;

		if (wm_ax != 0 && wm_ay != 0)
		{

			/*** Recalc left / right ***/
			float t;

			t = (float) wm_ay / wm_ax;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ax >= 0)
					J |= JOY_RIGHT;
				else
					J |= JOY_LEFT;
			}

			/*** Recalc up / down ***/
			t = (float) wm_ax / wm_ay;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ay >= 0)
					J |= JOY_UP;
				else
					J |= JOY_DOWN;
			}
		}
	}
#endif

	// Report pressed buttons (gamepads)
	int i;
	for (i = 0; i < MAXJP; i++)
	{
		if ( (jp & btnmap[CTRL_PAD][CTRLR_GCPAD][i])											// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_PAD][CTRLR_WIIMOTE][i]) )	// wiimote
		|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) )	// classic controller
		|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) )	// nunchuk + wiimote
		#endif
		)
		{
			// if zapper is on, ignore all buttons except START and SELECT
			if(GCSettings.Controller != CTRL_ZAPPER || nespadmap[i] == JOY_START || nespadmap[i] == JOY_SELECT)
			{
				if(rapidAlternator && nespadmap[i] == RAPID_A)
				{
					// activate rapid fire for A button
					J |= JOY_A;
				}
				else if(rapidAlternator && nespadmap[i] == RAPID_B)
				{
					// activate rapid fire for B button
					J |= JOY_B;
				}
				else if(nespadmap[i] > 0)
				{
					J |= nespadmap[i];
				}
				else
				{
					if(GameInfo->type == GIT_FDS) // FDS
					{
						/* the commands shouldn't be issued in parallel so
						 * we'll delay them so the virtual FDS has a chance
						 * to process them
						 */
						if(FDSSwitchRequested == 0)
							FDSSwitchRequested = 1;
					}
					else
						FCEUI_VSUniCoin(); // insert coin for VS Games
				}
			}
		}
	}

	// zapper enabled
	if(GCSettings.Controller == CTRL_ZAPPER)
	{
		int z; // NES port # (0 or 1)

		if(GameInfo->type == GIT_VSUNI)
			z = 0;
		else
			z = 1;

		myzappers[z][2] = 0; // reset trigger to not pressed

		// is trigger pressed?
		if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0])	// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) )	// wiimote
		#endif
		)
		{
			// report trigger press
			myzappers[z][2] |= 2;
		}

		// VS zapper games
		if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1])	// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) )	// wiimote
		#endif
		)
		{
			FCEUI_VSUniCoin(); // insert coin for VS zapper games
		}

		// cursor position
		UpdateCursorPosition(0); // update cursor for wiimote 1
		myzappers[z][0] = pos_x;
		myzappers[z][1] = pos_y;

		// Report changes to FCE Ultra
		zapperdata[z]->Update(z,myzappers[z],0);
	}

	return J;
}
void HeightmapEditorSystem::ProcessUIEvent(DAVA::UIEvent *event)
{
	if (!IsLandscapeEditingEnabled())
	{
		return;
	}
	
	UpdateCursorPosition();
	
	if (event->tid == UIEvent::BUTTON_1)
	{
		Vector3 point;
		
		switch(event->phase)
		{
			case UIEvent::PHASE_BEGAN:
				if (drawingType == HEIGHTMAP_DRAW_ABSOLUTE_DROPPER ||
					drawingType == HEIGHTMAP_DROPPER)
				{
					curHeight = drawSystem->GetHeightAtPoint(cursorPosition);
					
					SceneSignals::Instance()->EmitDropperHeightChanged(dynamic_cast<SceneEditor2*>(GetScene()), curHeight);
				}
				
				if (isIntersectsLandscape)
				{
					if (drawingType == HEIGHTMAP_COPY_PASTE)
					{
						int32 curKeyModifiers = QApplication::keyboardModifiers();
						if (curKeyModifiers & Qt::AltModifier)
						{
							copyPasteFrom = cursorPosition;
							copyPasteTo = Vector2(-1.f, -1.f);
							return;
						}
						else
						{
							if (copyPasteFrom == Vector2(-1.f, -1.f))
							{
								return;
							}
							copyPasteTo = cursorPosition;
							StoreOriginalHeightmap();
						}
					}
					else
					{
						if (drawingType != HEIGHTMAP_DROPPER)
						{
							StoreOriginalHeightmap();
						}
					}

					UpdateToolImage();
					editingIsEnabled = true;
				}

				activeDrawingType = drawingType;
				break;
				
			case UIEvent::PHASE_DRAG:
				break;
				
			case UIEvent::PHASE_ENDED:
				FinishEditing();
				break;
		}
	}
}
Beispiel #23
0
static unsigned char DecodeJoy(unsigned short chan)
{
	s8 pad_x = userInput[chan].pad.stickX;
	s8 pad_y = userInput[chan].pad.stickY;
	u32 jp = userInput[chan].pad.btns_h;
	unsigned char J = 0;

	#ifdef HW_RVL
	s8 wm_ax = userInput[chan].WPAD_StickX(0);
	s8 wm_ay = userInput[chan].WPAD_StickY(0);
	u32 wp = userInput[chan].wpad->btns_h;
	bool isWUPC = userInput[chan].wpad->exp.classic.type == 2;

	u32 exp_type;
	if ( WPAD_Probe(chan, &exp_type) != 0 )
		exp_type = WPAD_EXP_NONE;

	s16 wiidrc_ax = userInput[chan].wiidrcdata.stickX;
	s16 wiidrc_ay = userInput[chan].wiidrcdata.stickY;
	u32 wiidrcp = userInput[chan].wiidrcdata.btns_h;
	#endif

	/***
	Gamecube Joystick input
	***/
	if (pad_y > ANALOG_SENSITIVITY)
		J |= JOY_UP;
	else if (pad_y < -ANALOG_SENSITIVITY)
		J |= JOY_DOWN;
	if (pad_x < -ANALOG_SENSITIVITY)
		J |= JOY_LEFT;
	else if (pad_x > ANALOG_SENSITIVITY)
		J |= JOY_RIGHT;
#ifdef HW_RVL
	/***
	Wii Joystick (classic, nunchuk) input
	***/
	if (wm_ay > ANALOG_SENSITIVITY)
		J |= JOY_UP;
	else if (wm_ay < -ANALOG_SENSITIVITY)
		J |= JOY_DOWN;
	if (wm_ax < -ANALOG_SENSITIVITY)
		J |= JOY_LEFT;
	else if (wm_ax > ANALOG_SENSITIVITY)
		J |= JOY_RIGHT;

	/* WiiU Gamepad */
	if (wiidrc_ay > ANALOG_SENSITIVITY)
		J |= JOY_UP;
	else if (wiidrc_ay < -ANALOG_SENSITIVITY)
		J |= JOY_DOWN;
	if (wiidrc_ax < -ANALOG_SENSITIVITY)
		J |= JOY_LEFT;
	else if (wiidrc_ax > ANALOG_SENSITIVITY)
		J |= JOY_RIGHT;
#endif

	bool zapper_triggered = false;
	// zapper enabled
	if(GCSettings.Controller == CTRL_ZAPPER)
	{
		int z; // NES port # (0 or 1)

		if(GameInfo->type == GIT_VSUNI)
			z = 0;
		else
			z = 1;

		myzappers[z][2] = 0; // reset trigger to not pressed

		// is trigger pressed?
		if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0])	// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) )	// wiimote
		|| (wiidrcp & btnmap[CTRL_ZAPPER][CTRLR_WIIDRC][0]) // Wii U Gamepad
		#endif
		)
		{
			// report trigger press
			myzappers[z][2] |= 2;
			zapper_triggered = true;
		}

		// VS zapper games
		if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1])	// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) )	// wiimote
		|| (wiidrcp & btnmap[CTRL_ZAPPER][CTRLR_WIIDRC][1]) // Wii U Gamepad
		#endif
		)
		{
			FCEUI_VSUniCoin(); // insert coin for VS zapper games
			zapper_triggered = true;
		}

		// cursor position
		int channel = 0;	// by default, use wiimote 1
		#ifdef HW_RVL
		if (userInput[1].wpad->ir.valid)
		{
			channel = 1;	// if wiimote 2 is connected, use wiimote 2 as zapper
		}
		#endif
		UpdateCursorPosition(channel); // update cursor for wiimote
		myzappers[z][0] = pos_x;
		myzappers[z][1] = pos_y;

		// Report changes to FCE Ultra
		zapperdata[z]->Update(z,myzappers[z],0);
	}

	// Report pressed buttons (gamepads)
	int i;
	for (i = 0; i < MAXJP; i++)
	{
		if ( (jp & btnmap[CTRL_PAD][CTRLR_GCPAD][i])										// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_PAD][CTRLR_WIIMOTE][i]) )		// wiimote
		|| ( (exp_type == WPAD_EXP_CLASSIC && !isWUPC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) )	// classic controller
		|| ( (exp_type == WPAD_EXP_CLASSIC && isWUPC) && (wp & btnmap[CTRL_PAD][CTRLR_WUPC][i]) )		// wii u pro controller
		|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) )	// nunchuk + wiimote
		|| ( (wiidrcp & btnmap[CTRL_PAD][CTRLR_WIIDRC][i]) ) // Wii U Gamepad
		#endif
		)
		{
			// if zapper is on, ignore all buttons except START and SELECT
			if (!zapper_triggered)
			{
				if(rapidAlternator && nespadmap[i] == RAPID_A)
				{
					// activate rapid fire for A button
					J |= JOY_A;
				}
				else if(rapidAlternator && nespadmap[i] == RAPID_B)
				{
					// activate rapid fire for B button
					J |= JOY_B;
				}
				else if(nespadmap[i] > 0)
				{
					J |= nespadmap[i];
				}
				else
				{
					if(GameInfo->type == GIT_FDS) // FDS
					{
						/* the commands shouldn't be issued in parallel so
						 * we'll delay them so the virtual FDS has a chance
						 * to process them
						 */
						if(FDSSwitchRequested == 0)
							FDSSwitchRequested = 1;
					}
					else
						FCEUI_VSUniCoin(); // insert coin for VS Games
				}
			}
		}
	}

	return J;
}