//---------------------------------------------------------------------------
void __fastcall THttpTestForm::HeadButtonClick(TObject *Sender)
{
    int I;

    DisplayMemo->Clear();
    DocumentMemo->Clear();
    SetButtonState(FALSE);

    PrepareConnection();
    SslHttpCli1->RcvdStream = NULL;

    try {
        SslHttpCli1->Head();
    } __except (TRUE) {
        SetButtonState(TRUE);
        Display("HEAD Failed !");
        Display("StatusCode   = " + IntToStr(SslHttpCli1->StatusCode));
        Display("ReasonPhrase = " + SslHttpCli1->ReasonPhrase);
        return;
    }

    Display("StatusCode = " + IntToStr(SslHttpCli1->StatusCode));

    for (I = 0; I < SslHttpCli1->RcvdHeader->Count; I++)
        Display("hdr>" + SslHttpCli1->RcvdHeader->Strings[I]);

    SetButtonState(TRUE);
}
//---------------------------------------------------------------------------
void __fastcall THttpTestForm::HeadButtonClick(TObject *Sender)
{
    int I;

    DisplayMemo->Clear();
    DocumentMemo->Clear();
    SetButtonState(FALSE);

    HttpCli1->URL        = URLEdit->Text;
    HttpCli1->Proxy      = ProxyHostEdit->Text;
    HttpCli1->ProxyPort  = ProxyPortEdit->Text;
    HttpCli1->RcvdStream = NULL;
    if (DateTimeEdit->Text != "")
        HttpCli1->ModifiedSince = StrToDateTime(DateTimeEdit->Text);
    else
        HttpCli1->ModifiedSince = 0;

    try {
        HttpCli1->Head();
    } __except (TRUE) {
        SetButtonState(TRUE);
        DisplayMemo->Lines->Add("HEAD Failed !");
        DisplayMemo->Lines->Add("StatusCode   = " + IntToStr(HttpCli1->StatusCode));
        DisplayMemo->Lines->Add("ReasonPhrase = " + HttpCli1->ReasonPhrase);
        return;
    }

    DisplayMemo->Lines->Add("StatusCode = " + IntToStr(HttpCli1->StatusCode));

    for (I = 0; I < HttpCli1->RcvdHeader->Count; I++)
        DisplayMemo->Lines->Add("hdr>" + HttpCli1->RcvdHeader->Strings[I]);

    SetButtonState(TRUE);
}
Example #3
0
void VdkCheckBox::DoHandleNotify(const VdkNotify &notice) {
    switch (notice.GetNotifyCode()) {
    case VCN_DISABLED:
    case VCN_ENABLED: {
        bool enable = IsEnabled();
        if (m_bToggled) {
            if (!enable) {
                SetButtonState(CHECKED_DISABLED);
            } else {
                SetButtonState(CHECKED);
            }
        } else {
            if (!enable) {
                SetButtonState(NORMAL_DISABLED);
            } else {
                SetButtonState(NORMAL);
            }
        }

        EnableRelatedCtrls(enable, notice.GetVObjDC());

        break;
    }

    default:

        break;
    }
}
Example #4
0
void IButton::EnableButton(bool enable /*= true*/)
{
	if (enable)
	{
		RETURN_IF(!IsDisabled());
		SetButtonState(mButtonState == ButtonState::Disabled ? ButtonState::Normal : ButtonState::Selected);
	}
	else
	{
		RETURN_IF(IsDisabled());
		SetButtonState(mButtonState == ButtonState::Normal ? ButtonState::Disabled : ButtonState::DisabledSelected);
	}
}
Example #5
0
void IButton::SetIsSelected(bool selected /*= true*/)
{
	if (selected)
	{
		RETURN_IF(IsSelected());
		SetButtonState(mButtonState == ButtonState::Normal ? ButtonState::Selected : ButtonState::DisabledSelected);
	}
	else
	{
		RETURN_IF(!IsSelected());
		SetButtonState(mButtonState == ButtonState::Selected ? ButtonState::Normal : ButtonState::Disabled);
	}
}
Example #6
0
bool CButton::HandleMessage(CMessage* pMessage)
{
	bool bHandled = false;

	if (pMessage)
	{
		switch(pMessage->MessageType())
		{
		case CMessage::MOUSE_BUTTONUP:
		{
			CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
			if (pMouseMessage && m_eButtonState == DOWN)
			{
				SetButtonState(UP);
				bHandled = true;
			}
			break;
		}
		default :
			bHandled = CWindow::HandleMessage(pMessage);
			break;
		}
	}

	return bHandled;
}
Example #7
0
bool CButton::OnMouseButtonUp(CPoint Point, unsigned int Button)
{
	bool bResult = CWindow::OnMouseButtonUp(Point, Button);

	if (!bResult && m_bVisible && (m_eButtonState == DOWN) &&
		(m_MouseButton == Button) && (m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
	{
		SetButtonState(UP);
		CMessage::EMessageType MessageType =  CMessage::UNKNOWN;
		switch (m_MouseButton)
		{
		case CMouseMessage::LEFT:
			MessageType = CMessage::CTRL_SINGLELCLICK;
			break;
		case CMouseMessage::RIGHT:
			MessageType = CMessage::CTRL_SINGLERCLICK;
			break;
		case CMouseMessage::MIDDLE:
			MessageType = CMessage::CTRL_SINGLEMCLICK;
			break;
		}
		CMessageServer::Instance().QueueMessage(new TIntMessage(MessageType, m_pParentWindow, this, 0));
		bResult = true;
	}

	return bResult;
}
Example #8
0
/*****************************************************************************
** Procedure:  CDSPhone::UnsolicitedEvent
**
** Arguments: 'lpBuff'    - Data buffer (structure) specific to code
**
** Returns:    void
**
** Description:  This function processes any responses from the device which
**               are not matched to a pending line request.
**
*****************************************************************************/
bool CDSPhone::UnsolicitedEvent(LPCVOID lpBuff)
{             
	USES_CONVERSION;
	EVENTBUFF* pevBuff = (EVENTBUFF*) lpBuff;

    switch (pevBuff->dwResponse)
    {
        // A lamp has changed states.
        case EMRESULT_LAMPCHANGED:        
        {
            LPEMLAMPCHANGE lpChange = (LPEMLAMPCHANGE) pevBuff->lpBuff;
            SetLampState ((int)lpChange->wButtonLampID, g_LampStates[lpChange->wLampState]);
        }                                        
        break;
        
        // A hookswitch device has changed states.
        case EMRESULT_HSCHANGED:
        {
            LPEMHOOKSWITCHCHANGE lpChange = (LPEMHOOKSWITCHCHANGE) pevBuff->lpBuff;
            _TSP_ASSERTE (lpChange->wHookswitchID == HSDEVICE_HANDSET);
            SetHookSwitch (PHONEHOOKSWITCHDEV_HANDSET, g_hsStates[lpChange->wHookswitchState]);
        }
        break;

        // A button has changed
        case EMRESULT_BUTTONCHANGED:
        {
            LPEMBUTTONCHANGE lpChange = (LPEMBUTTONCHANGE) pevBuff->lpBuff;
            SetButtonState (lpChange->wButtonLampID, g_ButtonStates[lpChange->wButtonState]);
        }                    
        break;
        
        // Ringer mode changed
        case EMRESULT_RINGCHANGE:
            SetRingMode (*((LPDWORD)pevBuff->lpBuff));
            break;
        
        // Volume/Gain of the handset changed
        case EMRESULT_LEVELCHANGED:
        {
            LPEMLEVELCHANGE lpChange = (LPEMLEVELCHANGE) pevBuff->lpBuff;
            if (lpChange->wLevelType == LEVELTYPE_MIC)
                SetGain (PHONEHOOKSWITCHDEV_HANDSET, lpChange->wLevel);
            else if (lpChange->wLevelType == LEVELTYPE_SPEAKER)
                SetVolume (PHONEHOOKSWITCHDEV_HANDSET, lpChange->wLevel);
        }
        break;                        
        
        // The display has changed.
        case EMRESULT_DISPLAYCHANGED:
        {
            LPEMDISPLAY lpChange = (LPEMDISPLAY) pevBuff->lpBuff;
            SetDisplay (A2T(lpChange->szDisplay));
        }        
        break;
    }

	return true;

}// CDSPhone::UnsolicitedEvent
Example #9
0
bool JoystickInfo::PollButtons(u32 &pkey)
{
    // MAKE sure to look for changes in the state!!
    for (int i = 0; i < GetNumButtons(); ++i)
    {
        int but = SDL_JoystickGetButton(GetJoy(), i);
        if (but != GetButtonState(i))
        {
            // Pressure sensitive button are detected as both button (digital) and axes (analog). So better
            // drop the button to emulate the pressure sensiblity of the ds2 :)
            // Trick: detect the release of the button. It avoid all races condition between axes and buttons :)
            // If the button support pressure it will be detected as an axis when it is pressed.
            if (but) {
                SetButtonState(i, but);
                return false;
            }


            pkey = button_to_key(i);
            return true;
        }
    }

    return false;
}
Example #10
0
 PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) :
     m_event()
 {
     SetType(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON);
     SetPeripheralIndex(peripheralIndex);
     SetDriverIndex(buttonIndex);
     SetButtonState(state);
 }
Example #11
0
void IButton::OnTapStateChanged(InputState oldState,InputState newState)
{
	switch (newState)
	{
		case InputState::Begin:
			SetButtonState(IsDisabled() ? ButtonState::DisabledSelected : ButtonState::Selected);
			break;
		case InputState::End:
			SetButtonState(IsDisabled() ? ButtonState::Disabled : ButtonState::Normal);
			break;
		case InputState::None:
			SetButtonState(IsDisabled() ? ButtonState::Disabled : ButtonState::Normal);
			break;
		default:
			break;
	}
}
Example #12
0
void JoystickInfo::SaveState()
{
    for (int i = 0; i < numbuttons; ++i)
        SetButtonState(i, SDL_JoystickGetButton(joy, i));
    for (int i = 0; i < numaxes; ++i)
        SetAxisState(i, SDL_JoystickGetAxis(joy, i));
    for (int i = 0; i < numhats; ++i)
        SetHatState(i, SDL_JoystickGetHat(joy, i));
}
Example #13
0
void VdkCheckBox::DoDraw(wxDC &dc) {
    if (m_bToggled) {
        if (GetLastState() == VdkButton::NORMAL) {
            SetButtonState(CHECKED);
        }
    }

    VdkButton::DoDraw(dc);
}
//---------------------------------------------------------------------------
void __fastcall THttpTestForm::PostButtonClick(TObject *Sender)
{
    TMemoryStream *DataOut;
    TFileStream   *DataIn;
    AnsiString    Buf;
    int           I;

    DisplayMemo->Clear();
    DocumentMemo->Clear();
    SetButtonState(FALSE);

    DataOut = new TMemoryStream;
    Buf     = DataEdit->Text;
    DataOut->Write(&Buf[1], Buf.Length());
    DataOut->Seek(0, soFromBeginning);

    HttpCli1->SendStream = DataOut;
    HttpCli1->Proxy      = ProxyHostEdit->Text;
    HttpCli1->ProxyPort  = ProxyPortEdit->Text;
    HttpCli1->RcvdStream = NULL;
    HttpCli1->URL        = URLEdit->Text;
    try {
        HttpCli1->Post();
    } __except (TRUE) {
        SetButtonState(TRUE);
        delete DataOut;
        DisplayMemo->Lines->Add("POST Failed !");
        DisplayMemo->Lines->Add("StatusCode   = " + IntToStr(HttpCli1->StatusCode));
        DisplayMemo->Lines->Add("ReasonPhrase = " + HttpCli1->ReasonPhrase);
        return;
    }
    delete DataOut;

    DisplayMemo->Lines->Add("StatusCode = " + IntToStr(HttpCli1->StatusCode));

    for (I = 0; I < HttpCli1->RcvdHeader->Count; I++)
        DisplayMemo->Lines->Add("hdr>" + HttpCli1->RcvdHeader->Strings[I]);

    DataIn = new TFileStream(HttpCli1->DocName, fmOpenRead);
    DocumentMemo->Lines->LoadFromStream(DataIn);
    delete DataIn;

    SetButtonState(TRUE);
}
Example #15
0
void CPage6::OnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult)
{

	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
	HTREEITEM hItem = pNMTreeView->itemNew.hItem;
	CString strPathName = GetPathFromItem (hItem);

	if (!IsMediaValid (strPathName)) 
	{
		HTREEITEM hRoot = GetDriveNode (hItem);
		m_FileTree.Expand (hRoot, TVE_COLLAPSE);
		DeleteChildren (hRoot);
		AddDummyNode (hRoot);
		*pResult = TRUE;
		return;
	}


	if (!IsPathValid (strPathName)) 
	{
		if(strPathName != MYCOMPUTER && strPathName != "")
		{
			m_FileTree.DeleteItem (hItem);
			*pResult = TRUE;
			return;
		}
	}

	CWaitCursor wait;
	
	if (pNMTreeView->action == TVE_EXPAND) 
	{
		if(strPathName != MYCOMPUTER)
		{
			DeleteChildren (hItem);
			if (!AddDirectoryNodes (hItem, strPathName))
				*pResult = TRUE;
		}
	}
	else {
		if(strPathName != MYCOMPUTER)
		{
			DeleteChildren (hItem);
			if (IsDriveNode (hItem))
				AddDummyNode (hItem);
			else
				SetButtonState (hItem, strPathName);
		}
	}

	m_LocalPath = strPathName;


	*pResult = 0;
}
Example #16
0
BOOL CRRECToolBar::CheckButton(int nID, BOOL bChecked)
{
    UINT nState = GetToolBarCtrl().GetState(nID);

    if (!bChecked)
        nState &= ~TBSTATE_CHECKED;
    else
        nState |= TBSTATE_CHECKED;

    return SetButtonState(nID, nState);
}
Example #17
0
BOOL CDriveView::AddDriveItem(LPCTSTR pszDrive)
{
    CString string;
    HTREEITEM hItem;

    UINT nType = ::GetDriveType (pszDrive);

    switch (nType) {

    case DRIVE_REMOVABLE:
        hItem = GetTreeCtrl ().InsertItem (pszDrive, ILI_FLOPPY,
            ILI_FLOPPY);
        GetTreeCtrl ().InsertItem (_T (""), ILI_CLOSED_FOLDER,
            ILI_CLOSED_FOLDER, hItem);
        break;

    case DRIVE_FIXED:
    case DRIVE_RAMDISK:
        hItem = GetTreeCtrl ().InsertItem (pszDrive, ILI_HARD_DISK,
            ILI_HARD_DISK);
        SetButtonState (hItem, pszDrive);
        break;

    case DRIVE_REMOTE:
        hItem = GetTreeCtrl ().InsertItem (pszDrive, ILI_NET_DRIVE,
            ILI_NET_DRIVE);
        SetButtonState (hItem, pszDrive);
        break;

    case DRIVE_CDROM:
        hItem = GetTreeCtrl ().InsertItem (pszDrive, ILI_CD_ROM,
            ILI_CD_ROM);
        GetTreeCtrl ().InsertItem (_T (""), ILI_CLOSED_FOLDER,
            ILI_CLOSED_FOLDER, hItem);
        break;

    default:
        return FALSE;
    }
    return TRUE;
}
//---------------------------------------------------------------------------
void __fastcall THttpTestForm::GetButtonClick(TObject *Sender)
{
    int     I;
    TStream *DataIn;

    DisplayMemo->Clear();
    DocumentMemo->Clear();
    SetButtonState(FALSE);

    HttpCli1->URL        = URLEdit->Text;
    HttpCli1->Proxy      = ProxyHostEdit->Text;
    HttpCli1->ProxyPort  = ProxyPortEdit->Text;
    HttpCli1->RcvdStream = NULL;
    if (DateTimeEdit->Text != "")
        HttpCli1->ModifiedSince = StrToDateTime(DateTimeEdit->Text);
    else
        HttpCli1->ModifiedSince = 0;

    try {
        HttpCli1->Get();
    } __except (TRUE) {
        SetButtonState(TRUE);
        DisplayMemo->Lines->Add("GET Failed !");
        DisplayMemo->Lines->Add("StatusCode   = " + IntToStr(HttpCli1->StatusCode));
        DisplayMemo->Lines->Add("ReasonPhrase = " + HttpCli1->ReasonPhrase);
        HttpCli1DocEnd(NULL);
        return;
    }

    DisplayMemo->Lines->Add("StatusCode = " + IntToStr(HttpCli1->StatusCode));

    for (I = 0; I < HttpCli1->RcvdHeader->Count; I++)
        DisplayMemo->Lines->Add("hdr>" + HttpCli1->RcvdHeader->Strings[I]);

    DataIn = new TFileStream(HttpCli1->DocName, fmOpenRead);
    DocumentMemo->Lines->LoadFromStream(DataIn);
    delete DataIn;

    SetButtonState(TRUE);
}
Example #19
0
bool CButton::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
	bool bResult = CWindow::OnMouseButtonDown(Point, Button);

 	if (!bResult && m_bVisible && (m_eButtonState == UP) && (m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
	{
		SetButtonState(DOWN);
		m_MouseButton = Button;
		bResult = true;
	}

	return bResult;
}
int CResourceFolderView::AddDirectories(HTREEITEM hItem, LPCTSTR pszPath)
{
    HANDLE hFind;
    WIN32_FIND_DATA fd;
    HTREEITEM hNewItem;

    int nCount = 0;

	// convert relative paths to full paths
	CString strPath = convertRelativeToFullPath( pszPath );

	// set the file handler 
    if ((hFind = ::FindFirstFile (strPath, &fd)) == INVALID_HANDLE_VALUE) {
        if (GetTreeCtrl ().GetParentItem (hItem) == NULL)
            GetTreeCtrl ().InsertItem (_T (""), ILI_CLOSED_FOLDER,
                ILI_CLOSED_FOLDER, hItem);
        return 0;
    }

    do {
		// check if it is a folder or not
        if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
            CString strComp = (LPCTSTR) &fd.cFileName;  
            
			// skipp '.' and '..'
			if ((strComp != _T (".")) && (strComp != _T ("..")))
			{
				// add the folder elements
                hNewItem =
                    GetTreeCtrl ().InsertItem ((LPCTSTR) &fd.cFileName,
                    ILI_CLOSED_FOLDER, ILI_OPEN_FOLDER, hItem);

                CString strNewPath = pszPath;
                if (strNewPath.Right (1) != _T ("\\"))
                    strNewPath += _T ("\\");

                strNewPath += (LPCTSTR) &fd.cFileName;

				// set them expandable if necessary
                SetButtonState (hNewItem, strNewPath);
                nCount++;
            }
        }
    } while (::FindNextFile (hFind, &fd));

    ::FindClose (hFind);
    return nCount;
}
Example #21
0
void Button::Draw(const sf::Event& ev) {
	SetButtonState(ev);
	if (!mEnabled){
		DisableCount();
	}
	if (mWindow != nullptr){
		if (mUnselectedSprite != nullptr){
			if (mCurrentState == Unselected){
				mWindow->draw(*mUnselectedSprite);
			}
			else{
				mWindow->draw(*mSelectedSprite);
			}
		}
		if (mText != nullptr){
			mWindow->draw(*mText);
		}
	}
};
Example #22
0
int CDriveView::AddDirectories(HTREEITEM hItem, LPCTSTR pszPath)
{
    HANDLE hFind;
    WIN32_FIND_DATA fd;
    HTREEITEM hNewItem;

    int nCount = 0;

    CString strPath = pszPath;
    if (strPath.Right (1) != _T ("\\"))
        strPath += _T ("\\");
    strPath += _T ("*.*");

    if ((hFind = ::FindFirstFile (strPath, &fd)) == INVALID_HANDLE_VALUE) {
        if (GetTreeCtrl ().GetParentItem (hItem) == NULL)
            GetTreeCtrl ().InsertItem (_T (""), ILI_CLOSED_FOLDER,
                ILI_CLOSED_FOLDER, hItem);
        return 0;
    }

    do {
        if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
            CString strComp = (LPCTSTR) &fd.cFileName;
            if ((strComp != _T (".")) && (strComp != _T (".."))) {
                hNewItem =
                    GetTreeCtrl ().InsertItem ((LPCTSTR) &fd.cFileName,
                    ILI_CLOSED_FOLDER, ILI_OPEN_FOLDER, hItem);

                CString strNewPath = pszPath;
                if (strNewPath.Right (1) != _T ("\\"))
                    strNewPath += _T ("\\");

                strNewPath += (LPCTSTR) &fd.cFileName;
                SetButtonState (hNewItem, strNewPath);
                nCount++;
            }
        }
    } while (::FindNextFile (hFind, &fd));

    ::FindClose (hFind);
    return nCount;
}
Example #23
0
void CDriveView::OnItemExpanding(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
    HTREEITEM hItem = pNMTreeView->itemNew.hItem;
    CString string = GetPathFromItem (hItem);

    *pResult = FALSE;

    if (pNMTreeView->action == TVE_EXPAND) {
        DeleteFirstChild (hItem);
        if (AddDirectories (hItem, string) == 0)
            *pResult = TRUE;
    }
    else { // pNMTreeView->action == TVE_COLLAPSE
        DeleteAllChildren (hItem);
        if (GetTreeCtrl ().GetParentItem (hItem) == NULL)
            GetTreeCtrl ().InsertItem (_T (""), ILI_CLOSED_FOLDER,
                ILI_CLOSED_FOLDER, hItem);
        else
            SetButtonState (hItem, string);
    }
}
Example #24
0
///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
void InputSystem::ProcessXboxControllerInput( XboxControllerState& controllerState )
{
	static const unsigned short	BIT_A_BUTTON				= 0x1000;
	static const unsigned short	BIT_B_BUTTON				= 0x2000;
	static const unsigned short	BIT_X_BUTTON				= 0x4000;
	static const unsigned short	BIT_Y_BUTTON				= 0x8000;
	static const unsigned short	BIT_RIGHT_BUMPER_BUTTON		= 0x0200;
	static const unsigned short	BIT_LEFT_BUMPER_BUTTON		= 0x0100;
	static const unsigned short	BIT_RIGHT_STICK_BUTTON		= 0x0080;
	static const unsigned short	BIT_LEFT_STICK_BUTTON		= 0x0040;
	static const unsigned short	BIT_START_BUTTON			= 0x0010;
	static const unsigned short	BIT_BACK_BUTTON				= 0x0020;
	static const unsigned short	BIT_DPAD_NORTH_BUTTON		= 0x0001;
	static const unsigned short	BIT_DPAD_SOUTH_BUTTON		= 0x0002;
	static const unsigned short	BIT_DPAD_WEST_BUTTON		= 0x0004;
	static const unsigned short	BIT_DPAD_EAST_BUTTON		= 0x0008;
	static const unsigned short	BIT_DPAD_NORTHEAST_BUTTON	= 0x0009;
	static const unsigned short	BIT_DPAD_NORTHWEST_BUTTON	= 0x0005;
	static const unsigned short	BIT_DPAD_SOUTHEAST_BUTTON	= 0x000a;
	static const unsigned short	BIT_DPAD_SOUTHWEST_BUTTON	= 0x0006;

	XINPUT_STATE xboxInputState;
	memset( &xboxInputState, 0, sizeof( xboxInputState ) );

	DWORD errorStatus = XInputGetState( controllerState.m_controllerID, &xboxInputState );
	if( errorStatus == ERROR_SUCCESS )
	{
		controllerState.m_isPluggedIn = true;
		SetButtonState( XBOX_BUTTON_A, ( BIT_A_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_B, ( BIT_B_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_X, ( BIT_X_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_Y, ( BIT_Y_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_BUMPER_LEFT, ( BIT_LEFT_BUMPER_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_BUMPER_RIGHT, ( BIT_RIGHT_BUMPER_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_STICK_LEFT, ( BIT_LEFT_STICK_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_STICK_RIGHT, ( BIT_RIGHT_STICK_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_BACK, ( BIT_BACK_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_START, ( BIT_START_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_DPAD_NORTH, ( BIT_DPAD_NORTH_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_DPAD_SOUTH, ( BIT_DPAD_SOUTH_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_DPAD_EAST, ( BIT_DPAD_EAST_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_DPAD_WEST, ( BIT_DPAD_WEST_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_DPAD_NORTHEAST, ( BIT_DPAD_NORTHEAST_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_DPAD_NORTHWEST, ( BIT_DPAD_NORTHWEST_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_DPAD_SOUTHEAST, ( BIT_DPAD_SOUTHEAST_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_DPAD_SOUTHWEST, ( BIT_DPAD_SOUTHWEST_BUTTON & xboxInputState.Gamepad.wButtons ) ? true : false, controllerState.m_controllerID );

		SetButtonState( XBOX_BUTTON_TRIGGER_LEFT, xboxInputState.Gamepad.bLeftTrigger > 127 ? true : false, controllerState.m_controllerID );
		SetButtonState( XBOX_BUTTON_TRIGGER_RIGHT, xboxInputState.Gamepad.bRightTrigger > 127 ? true : false, controllerState.m_controllerID );

		float leftStickX = NormalizeXboxControllerStickValue( xboxInputState.Gamepad.sThumbLX );
		float leftStickY = NormalizeXboxControllerStickValue( xboxInputState.Gamepad.sThumbLY );
		float rightStickX = NormalizeXboxControllerStickValue( xboxInputState.Gamepad.sThumbRX );
		float rightStickY = NormalizeXboxControllerStickValue( xboxInputState.Gamepad.sThumbRY );

		controllerState.m_normalizedStickStates[ XBOX_STICK_LEFT ] = Vector2( leftStickX, leftStickY );
		controllerState.m_normalizedStickStates[ XBOX_STICK_RIGHT ] = Vector2( rightStickX, rightStickY );

		float normalizedLeftTrigger = NormalizeXboxControllerTriggerValue( xboxInputState.Gamepad.bLeftTrigger );
		float normalizedRightTrigger = NormalizeXboxControllerTriggerValue( xboxInputState.Gamepad.bRightTrigger );

		controllerState.m_normalizedTriggerStates[ XBOX_TRIGGER_LEFT ] = normalizedLeftTrigger;
		controllerState.m_normalizedTriggerStates[ XBOX_TRIGGER_RIGHT ] = normalizedRightTrigger;
	}
	else if( errorStatus == ERROR_DEVICE_NOT_CONNECTED )
		controllerState.m_isPluggedIn = false;
}
Example #25
0
bool Button::IsPressed(const sf::Event& ev){
	SetButtonState(ev);
	return mCurrentState == Released;
};
Example #26
0
UINT CPage6::AddDirectoryNodes(HTREEITEM hItem, CString &strPathName)
{
	WCHAR wBuf[60];
	DWORD    bytesReturned=0;
	ULONG   num=0;
	PDIRECTORY_INFO   temp={0};
	DIRECTORY_INFO_EX  DIRECTORY_INFO_b;
	CString str,str1,strFileSpec = strPathName;
	if (strFileSpec.Right (1) != "\\")
		strFileSpec += "\\";
	char  a[MAX_PATH];
	
	str1=strFileSpec;
	CMySystem::WCHARToChar(a,strFileSpec.GetBuffer(strFileSpec.GetLength()));

	strFileSpec += "*.*";
	DeviceIoControl(hDevice,(DWORD)IOCTL_MT_GETDIRNUMINF,a,sizeof(a),&num,sizeof(ULONG),&bytesReturned,NULL);
	if(num==0)
	{
		AfxMessageBox(L"驱动未加载,列举出错!");
		return 0;
	}
	temp=(PDIRECTORY_INFO)calloc(num,sizeof(DIRECTORY_INFO));
	if(temp==NULL)
	{

		return 0;
	}
	DeviceIoControl(hDevice,(DWORD)IOCTL_MT_GETDIRINF,a,sizeof(a),temp,num*sizeof(DIRECTORY_INFO),&bytesReturned,NULL);	
	CWaitCursor wait;
	WCHAR wTemp[MAX_PATH]={'\0'};
	m_FileList.DeleteAllItems();
   	index=0;
	SetPath(str1,hDevice);
	for(ULONG i=0;i<num;i++)
	{
		TRACE("AddDirectoryNode:%d\n",i);
		CMySystem::CharToWCHAR(wTemp,temp[i].FileName);
		str.Format(L"%s",wTemp);
		str=str1+str;
		CString strFileName = (LPCTSTR) &temp[i].FileName;
		if(PathIsDirectory(str))
		{
			if(strcmp(temp[i].FileName,"."))
			{
				if(strcmp(temp[i].FileName,".."))
				{
					CMySystem::CharToWCHAR(wTemp,temp[i].FileName);
					HTREEITEM hChild =
						m_FileTree.InsertItem ((LPCTSTR) wTemp,//&fd.cFileName,
						ILI_CLSDFLD , ILI_OPENFLD , hItem , TVI_SORT);

					CString strNewPathName = strPathName;
					if (strNewPathName.Right (1) != "\\")
					{strNewPathName += "\\";}
					CMySystem::CharToWCHAR(wBuf,temp[i].FileName);

					strNewPathName += wBuf;//fd.cFileName;
					SetButtonState (hChild, strNewPathName);	
					
				}

			}
		}
		else
		{
			DIRECTORY_INFO_b.DirectoryInfo=temp[i];
			DIRECTORY_INFO_b.path=str1;
		
			AddToListView(&DIRECTORY_INFO_b);	
		}
	} 
	delete temp;
	return num;
}
Example #27
0
// Handling of user interface and other events
void MainWindow::MessageReceived(BMessage *message)
{
	switch(message->what){
		case SELECTION_CHANGED:
			BRow *row;
			row = teamView->RowAt(message->FindInt32("index"));

			if(row != NULL && message->FindInt32("buttons") == B_SECONDARY_MOUSE_BUTTON){
				BPoint point;
				uint32 state;
				teamView->GetMouse(&point,&state);

				BPoint p2 = teamView->ConvertToScreen(point);
				p2.x -= 5.0;
				p2.y -= 5.0;
				//if(fItemMenu->FindMarked())
				//	fItemMenu->FindMarked()->SetMarked(false);

				teamView->SelectionMessage()->ReplaceInt32("buttons",0);
				teamView->ActionMenu()->Go(p2, true, true, true);
				//fItemMenu->Go(p2, true, true, true);
			}
			SetButtonState();
			break;
		case IE_MAINWINDOW_MAINMENU_ACTION_KILL:
		case IE_MAINWINDOW_MAINKILL:
			DoKill();
		 	UpdateTeams();
		 	SetButtonState();
			break;
		case IE_MAINWINDOW_MAINMENU_ACTION_SUSPEND:
		case IE_MAINWINDOW_MAINSUSPEND:
			DoSuspend();
			UpdateTeams();
			SetButtonState();
			break;
		case IE_MAINWINDOW_MAINMENU_ACTION_RESUME:
		case IE_MAINWINDOW_MAINRESUME:
			DoResume();
			UpdateTeams();
			SetButtonState();
			break;
		case SET_PRIORITY: {
			int32 priority = message->FindInt32("priority");
			DoPriority(priority);
			UpdateTeams();
			SetButtonState();
			break;
		}
		case IE_MAINWINDOW_MAINPRIORITYVALUE:
			// takes priority from text field
			DoPriority();
			UpdateTeams();
			SetButtonState();
			break;
		case IE_MAINWINDOW_MAINUPDATE:
			UpdateTeams();
			SetButtonState();
			break;
		case B_ABOUT_REQUESTED:    // "About…" is selected from menu…
		{
			BAboutWindow* fAboutWin = new BAboutWindow(B_TRANSLATE_SYSTEM_NAME("Slayer"), slayer_signature);
			fAboutWin->AddDescription(B_TRANSLATE("A thread manager for Haiku"));
			fAboutWin->SetVersion(SLAYER_VERSION);
			fAboutWin->AddCopyright(1999, "Arto Jalkanen");
			const char* authors[] = {
				"Arto Jalkanen ([email protected])",
				NULL
			};
			fAboutWin->AddAuthors(authors);
			fAboutWin->Show();
		}
			break;
		case IE_MAINWINDOW_MAINMENU_FILE_DOCS__:
		{
			BMessage message(B_REFS_RECEIVED);
			message.AddString("url", ProjectWebsite);
			be_roster->Launch("text/html", &message);
		}
			break;
		case IE_MAINWINDOW_MAINMENU_FILE_QUIT:    // "Quit" is selected from menu…
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;
		case IE_MAINWINDOW_MAINMENU_WINDOWS_SETTINGS:
		{
			const char* windowSettingsTitle = B_TRANSLATE("Settings");
			BWindow *settings = slayer->FindWindow(windowSettingsTitle);
			if (!settings)
				new SettingsWindow(windowSettingsTitle);
			else if (settings->Lock()) {
				settings->Activate(true);
				settings->Unlock();
			}
		}
			break;
		default:
			BWindow::MessageReceived(message);
			break;
	}

}
Example #28
0
MainWindow::MainWindow(void)
	: BWindow(BRect(200,200,800,750), B_TRANSLATE_SYSTEM_NAME("Slayer"), B_TITLED_WINDOW, 0)
{
	slayer->mainWindow = this;
	refreshThread = NULL;
	if (Lock()) {
		teamView = new TeamListView("MainTeamList");
		// Menü
		BMenuBar* menuBar = new BMenuBar("MenuBar");
		BMenu* menu;
		menu = new BMenu(B_TRANSLATE_SYSTEM_NAME("Slayer"));
		menuBar->AddItem(menu);
		menu->AddItem(new BMenuItem(B_TRANSLATE("About Slayer..."), new BMessage(B_ABOUT_REQUESTED)));
		menu->AddSeparatorItem();
		menu->AddItem(new BMenuItem(B_TRANSLATE("Settings..."), new BMessage(IE_MAINWINDOW_MAINMENU_WINDOWS_SETTINGS)));
		menu->AddSeparatorItem();
		menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q'));

		menu = new BMenu(B_TRANSLATE("Action"));
		menu->AddItem(new BMenuItem(B_TRANSLATE("Kill"), new BMessage(IE_MAINWINDOW_MAINKILL), 'K'));
		menu->AddItem(new BMenuItem(B_TRANSLATE("Suspend"), new BMessage(IE_MAINWINDOW_MAINSUSPEND), 'S'));
		menu->AddItem(new BMenuItem(B_TRANSLATE("Resume"), new BMessage(IE_MAINWINDOW_MAINRESUME), 'R'));
		menu->AddSeparatorItem();
		priorityMenu = new PriorityMenu(teamView);
		menu->AddItem(priorityMenu);
		priorityMenu->BuildMenu();

		menuBar->AddItem(menu);

		fToolBar = new BToolBar(B_HORIZONTAL);

		BGroupLayout *topBox = BLayoutBuilder::Group<>(this,B_VERTICAL, 0)
			.Add(menuBar)
			.Add(fToolBar)
			.AddGroup(B_VERTICAL)
			.SetInsets(B_USE_WINDOW_INSETS, 0, B_USE_WINDOW_INSETS, B_USE_WINDOW_INSETS)
			.Add(teamView);

		teamView->LoadState(&(slayer->options.columnsState));

		team_items_list = 0;
		team_amount = 0;
		iteration = 0;

		refreshThread = new RefreshThread();
		UpdateTeams();

		if (slayer->options.wind_rect.IsValid()) {
			MoveTo(slayer->options.wind_rect.left,
			       slayer->options.wind_rect.top);
			ResizeTo(slayer->options.wind_rect.Width(),
			         slayer->options.wind_rect.Height());
		}
		minimized = false;
		if (slayer->options.workspace_activation == Options::all_workspaces)
			SetWorkspaces(B_ALL_WORKSPACES);
		else if (slayer->options.workspace_activation == Options::saved_workspace)
		    SetWorkspaces(0x1UL << (slayer->options.workspaces -1 ));

		if (slayer->options.wind_minimized)
			Minimize(true);

		// Quitting has to be disabled if docked
		if (slayer->docked) {
			BMenu *menu = (BMenu *)FindView("MainMenu");
			BMenuItem *item = menu->FindItem(IE_MAINWINDOW_MAINMENU_FILE_QUIT);
			item->SetEnabled(false);
		}

		fToolBar->AddAction(new BMessage(IE_MAINWINDOW_MAINKILL),this,
			ResourceVectorToBitmap("KILL"),B_TRANSLATE("Kill"),"",false);
		fToolBar->AddAction(new BMessage(IE_MAINWINDOW_MAINSUSPEND),this,
			ResourceVectorToBitmap("SUSPEND"),B_TRANSLATE("Suspend"),"",false);
		fToolBar->AddAction(new BMessage(IE_MAINWINDOW_MAINRESUME),this,
			ResourceVectorToBitmap("RESUME"),B_TRANSLATE("Resume"),"",false);
		fToolBar->AddAction(new BMessage(IE_MAINWINDOW_MAINUPDATE),this,
			ResourceVectorToBitmap("FORCED_RELOAD"),B_TRANSLATE("Forced reload"),"",false);
		fToolBar->GetLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
		if (teamView != NULL)
			teamView->MakeFocus();

		SetButtonState();

		refreshThread->Go();
		Unlock();
	}
	Show();
}
//---------------------------------------------------------------------------
void __fastcall THttpTestForm::HttpCli1RequestDone(TObject *Sender,
    THttpRequest RqType, WORD Error)
{
    SetButtonState(TRUE);
    DisplayMemo->Lines->Add("RequestDone Error = " + IntToStr(Error));
}