예제 #1
0
파일: app.cpp 프로젝트: lasty/ld_warmup30
void App::ProcessEvents()
{
	SDL_Event event;

	while (SDL_PollEvent(&event))
	{
		if (event.type == SDL_QUIT)
		{
			Quit();
		}
		else if (event.type == SDL_KEYDOWN)
		{
			OnKey(event.key, true);
		}
		else if (event.type == SDL_KEYUP)
		{
			OnKey(event.key, false);
		}
		else if (event.type == SDL_MOUSEBUTTONDOWN)
		{
			OnMouseButton(event.button.x, event.button.y, event.button.button, true);
		}
		else if (event.type == SDL_MOUSEBUTTONUP)
		{
			OnMouseButton(event.button.x, event.button.y, event.button.button, false);
		}
		else if (event.type == SDL_MOUSEMOTION)
		{
			OnMouseMove(event.button.x, event.button.y);
		}

		//TODO add more event filters as appropriate
	}
}
예제 #2
0
/*------------------------------------------------
  "Add"
--------------------------------------------------*/
void OnAdd(HWND hDlg)
{
	PMOUSESTRUCT pitem;
	int count, index;
	
	count = CBGetCount(hDlg, IDC_NAMECLICK);
	if(count < 0) return;
	
	OnNameDropDown(hDlg);
	
	GetMouseCommandFromDlg(hDlg, get_listitem(m_pMouseCommand, m_nCurrent));
	
	pitem = malloc(sizeof(MOUSESTRUCT));
	memset(pitem, 0, sizeof(MOUSESTRUCT));
	wsprintf(pitem->name, "Mouse%d", count+1);
	pitem->nClick = 1;
	pitem->nCommand = 0;
	// common/list.c
	m_pMouseCommand = add_listitem(m_pMouseCommand, pitem);
	
	index = CBAddString(hDlg, IDC_NAMECLICK, (LPARAM)pitem->name);
	CBSetCurSel(hDlg, IDC_NAMECLICK, index);
	m_nCurrent = index;
	
	if(count == 0)
		EnableMousePageItems(hDlg);
	
	SetMouseCommandToDlg(hDlg, pitem);
	OnFunction(hDlg, FALSE);
#if TC_ENABLE_WHEEL
	OnMouseButton(hDlg);
#endif
	
	PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE);
}
예제 #3
0
/*------------------------------------------------
   "Name" is selected
--------------------------------------------------*/
void OnName(HWND hDlg)
{
	int index;
	
	index = CBGetCurSel(hDlg, IDC_NAMECLICK);
	if(index < 0) return ;
	
	GetMouseCommandFromDlg(hDlg, get_listitem(m_pMouseCommand, m_nCurrent));
	
	SetMouseCommandToDlg(hDlg, get_listitem(m_pMouseCommand, index));
	
	OnFunction(hDlg, TRUE);
#if TC_ENABLE_WHEEL
	OnMouseButton(hDlg);
#endif
	m_nCurrent = index;
}
예제 #4
0
/*------------------------------------------------
  "Delete"
--------------------------------------------------*/
void OnDelete(HWND hDlg)
{
	int count, index;
	PMOUSESTRUCT pitem;
	
	count = CBGetCount(hDlg, IDC_NAMECLICK);
	if(count < 1) return;
	
	index = CBGetCurSel(hDlg, IDC_NAMECLICK);
	if(index < 0) return;
	
	pitem = get_listitem(m_pMouseCommand, index);
	if(pitem == NULL) return;
	// common/list.c
	m_pMouseCommand = del_listitem(m_pMouseCommand, pitem);
	
	CBDeleteString(hDlg, IDC_NAMECLICK, index);
	
	if(count > 0)
	{
		if(index == count - 1) index--;
		CBSetCurSel(hDlg, IDC_NAMECLICK, index);
		
		SetMouseCommandToDlg(hDlg, get_listitem(m_pMouseCommand, index));
		OnFunction(hDlg, TRUE);
	}
	else
	{
		index = -1;
		
		EnableMousePageItems(hDlg);
		SetMouseCommandToDlg(hDlg, NULL);
		OnFunction(hDlg, FALSE);
#if TC_ENABLE_WHEEL
		OnMouseButton(hDlg);
#endif
	}
	m_nCurrent = index;
	
	PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE);
}
예제 #5
0
void EmuWindow_SDL2::PollEvents() {
    SDL_Event event;

    // SDL_PollEvent returns 0 when there are no more events in the event queue
    while (SDL_PollEvent(&event)) {
        switch (event.type) {
        case SDL_WINDOWEVENT:
            switch (event.window.event) {
            case SDL_WINDOWEVENT_SIZE_CHANGED:
            case SDL_WINDOWEVENT_RESIZED:
            case SDL_WINDOWEVENT_MAXIMIZED:
            case SDL_WINDOWEVENT_RESTORED:
            case SDL_WINDOWEVENT_MINIMIZED:
                OnResize();
                break;
            case SDL_WINDOWEVENT_CLOSE:
                is_open = false;
                break;
            }
            break;
        case SDL_KEYDOWN:
        case SDL_KEYUP:
            OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state);
            break;
        case SDL_MOUSEMOTION:
            OnMouseMotion(event.motion.x, event.motion.y);
            break;
        case SDL_MOUSEBUTTONDOWN:
        case SDL_MOUSEBUTTONUP:
            OnMouseButton(event.button.button, event.button.state, event.button.x, event.button.y);
            break;
        case SDL_QUIT:
            is_open = false;
            break;
        }
    }
}
예제 #6
0
bool Control::NotificationMouseButton(const SDL_MouseButtonEvent& buttonEvent)
{
    // raise the mouse button event before the click event
    auto result = OnMouseButton(buttonEvent);

    if (buttonEvent.state == SDL_PRESSED)
    {
        m_flags |= State::MouseDown;
    }
    else if (m_flags & State::MouseDown && buttonEvent.state == SDL_RELEASED)
    {
        auto clickLoc = SDLPoint(buttonEvent.x, buttonEvent.y);
        if (buttonEvent.button == SDL_BUTTON_LEFT)
            OnLeftClick(clickLoc);
        else if (buttonEvent.button == SDL_BUTTON_RIGHT)
            OnRightClick(clickLoc);
        else if (buttonEvent.button == SDL_BUTTON_MIDDLE)
            OnMiddleClick(clickLoc);

        m_flags ^= State::MouseDown;
    }

    return result;
}
예제 #7
0
//-----------------------------------------------------------------------------
// Purpose: Opens the context menu when right-clicked upon.
// Input  : Per MFC OnRightButtonDown.
//-----------------------------------------------------------------------------
void CTitleWnd::OnRButtonDown(UINT nFlags, CPoint point)
{
	OnMouseButton();
}
예제 #8
0
/*------------------------------------------------
  Dialog procedure
--------------------------------------------------*/
INT_PTR CALLBACK PageMouseProc(HWND hDlg, UINT message,
	WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
		case WM_INITDIALOG:
			OnInit(hDlg);
			return TRUE;
		case WM_DESTROY:
			OnDestroy(hDlg);
			break;
		case WM_COMMAND:
		{
			WORD id, code;
			id = LOWORD(wParam); code = HIWORD(wParam);
			switch(id)
			{
				case IDC_NAMECLICK:
					if(code == CBN_SELCHANGE)
					{
						m_bInit = FALSE;
						OnName(hDlg);
						m_bInit = TRUE;
					}
					else if(code == CBN_DROPDOWN)
						OnNameDropDown(hDlg);
					else if(code == CBN_EDITCHANGE)
						SendPSChanged(hDlg);
					break;
				case IDC_ADDCLICK:
					OnAdd(hDlg);
					break;
				case IDC_DELCLICK:
					OnDelete(hDlg);
					break;
				case IDC_MOUSEBUTTON:
					if(code == CBN_SELCHANGE)
					{
#if TC_ENABLE_WHEEL
						OnMouseButton(hDlg);
#endif
						SendPSChanged(hDlg);
					}
					break;
				case IDC_RADSINGLE:
				case IDC_RADDOUBLE:
				case IDC_RADTRIPLE:
				case IDC_RADQUADRUPLE:
				case IDC_MOUSECTRL:
				case IDC_MOUSESHIFT:
				case IDC_MOUSEALT:
				case IDC_RCLICKMENU:
					SendPSChanged(hDlg);
					break;
				case IDC_LMOUSEPASSTHRU:
					g_bApplyClock = TRUE;
					SendPSChanged(hDlg);
					break;
				case IDC_MOUSEFUNC:
					OnFunction(hDlg, TRUE);
					break;
				case IDC_MOUSEOPT:
					if(code == EN_CHANGE)
						SendPSChanged(hDlg);
					break;
				case IDC_MOUSEOPTSANSHO:
					OnBrowse(hDlg);
					break;
			}
			return TRUE;
		}
		case WM_NOTIFY:
			switch(((NMHDR *)lParam)->code)
			{
				case PSN_APPLY: OnApply(hDlg); break;
				case PSN_HELP: MyHelp(GetParent(hDlg), "Mouse"); break;
			}
			return TRUE;
	}
	return FALSE;
}