Example #1
0
void MouseMove()
{
/*
	// Toggle Caps Lock key:
    INPUT input[2];
    ::ZeroMemory(input, sizeof(input));        
    input[0].type = input[1].type = INPUT_KEYBOARD;
    input[0].ki.wVk  = input[1].ki.wVk = VK_CAPITAL;        
    input[1].ki.dwFlags = KEYEVENTF_KEYUP;  // THIS IS IMPORTANT
    ::SendInput(2, input, sizeof(INPUT));
*/
	// Get Screen Resolution
	DEVMODE mode;
	::EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS, &mode);
	
	INPUT in;
	ZeroMemory(&in, sizeof(in));
	in.type = INPUT_MOUSE;
	in.mi.dx = 40 * (65535 / mode.dmPelsWidth);
	in.mi.dy = 20 * (65535 / mode.dmPelsHeight);
 
	//MOUSEEVENTF_MOVE	마우스 이동
	//MOUSEEVENTF_LEFTDOWN	마우스 왼쪽 버턴 DOWN
	//MOUSEEVENTF_LEFTUP	마우스 왼쪽 버턴 UP
	//MOUSEEVENTF_RIGHTDOWN	마우스 오른쪽 버턴 DOWN
	//MOUSEEVENTF_RIGHTUP	마우스 왼쪽 버턴 UP
	//MOUSEEVENTF_MIDDLEDOWN	마우스 가운데 버턴 DOWN
	//MOUSEEVENTF_MIDDLEDOUP	마우스 가운데 버턴 UP
	//MOUSEEVENTF_WHEEL	마우스 휠 움직임

	//in.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;
	//::SendInput(1, &in, sizeof(in));

	// 마우스 커서의 좌표를 pt로 얻어 온다.
	tagPOINT pt;
	GetCursorPos(&pt);
	
	// Move the Mouse position without EVENT : FASTER
	//SetCursorPos(pt.x + 20, pt.y +20);
	SetCursorPos(40, 20);

	//in.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP;
	//::SendInput(1, &in, sizeof(in));
	//::SendInput(1, &in, sizeof(in));
	in.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN| MOUSEEVENTF_RIGHTUP;
	::SendInput(1, &in, sizeof(in));

	SetCursorPos(340, 20);
	//in.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_RIGHTDOWN;
	//::SendInput(1, &in, sizeof(in));

	// wheel test
	SetCursorPos(1000, 800);
	::SendInput(1, &in, sizeof(in));
	mouse_wheel(-3);

}
Example #2
0
  void WindowProfiler::mousewheel(int y)
  {
    WindowProfiler::Window &window = m_window;
    m_profiler.reset();

    if (mouse_wheel(y)) return;

    window.m_wheel += y;
  }
Example #3
0
window::window( const std::shared_ptr<platform::window> &win )
	: _window( win )
{
	precondition( bool(_window), "null window" );
	_window->exposed = [this] ( void ) { paint(); };
	_window->resized = [this] ( double w, double h ) { resized( w, h ); };
	_window->mouse_pressed = [this]( const std::shared_ptr<platform::mouse> &, const base::point &p, int b ) { mouse_press( p, b ); };
	_window->mouse_released = [this]( const std::shared_ptr<platform::mouse> &, const base::point &p, int b ) { mouse_release( p, b ); };
	_window->mouse_moved = [this]( const std::shared_ptr<platform::mouse> &, const base::point &p ) { mouse_moved( p ); };
	_window->mouse_wheel = [this]( const std::shared_ptr<platform::mouse> &, int i ) { mouse_wheel( i ); };
	_window->key_pressed = [this]( const std::shared_ptr<platform::keyboard> &, const platform::scancode &c ) { key_pressed( c ); };
	_window->key_released = [this]( const std::shared_ptr<platform::keyboard> &, const platform::scancode &c ) { key_released( c ); };
	_window->text_entered = [this]( const std::shared_ptr<platform::keyboard> &, const char32_t &c ) { text_entered( c ); };
	_canvas = std::make_shared<draw::canvas>();
}
Example #4
0
void slider::handle_event(const SDL_Event& event)
{
	gui::widget::handle_event(event);

	if (!enabled() || hidden())
		return;

	STATE start_state = state_;

	switch(event.type) {
	case SDL_MOUSEBUTTONUP:
		if (!mouse_locked()) {
			bool on = sdl::point_in_rect(event.button.x, event.button.y, slider_area());
			state_ = on ? ACTIVE : NORMAL;
		}
		break;
	case SDL_MOUSEBUTTONDOWN:
		if (!mouse_locked())
			mouse_down(event.button);
		break;
	case SDL_MOUSEMOTION:
		if (!mouse_locked())
			mouse_motion(event.motion);
		break;
	case SDL_KEYDOWN:
		if(focus(&event) && allow_key_events()) { //allow_key_events is used by zoom_sliders to disable left-right key press, which is buggy for them
			const SDL_Keysym& key = reinterpret_cast<const SDL_KeyboardEvent&>(event).keysym;
			const int c = key.sym;
			if(c == SDLK_LEFT) {
				sound::play_UI_sound(game_config::sounds::slider_adjust);
				set_value(value_ - increment_);
			} else if(c == SDLK_RIGHT) {
				sound::play_UI_sound(game_config::sounds::slider_adjust);
				set_value(value_ + increment_);
			}
		}
		break;
	case SDL_MOUSEWHEEL:
		if (!mouse_locked())
			mouse_wheel(event.wheel);
		break;
	default:
		return;
	}
	if (start_state != state_)
		set_dirty(true);
}
Example #5
0
void OVR_SDL2_app::dispatch(SDL_Event& e)
{
    switch (e.type)
    {
        case SDL_KEYDOWN:
            keyboard(e.key.keysym.scancode, true,  (e.key.repeat != 0));
            break;
        case SDL_KEYUP:
            keyboard(e.key.keysym.scancode, false, (e.key.repeat != 0));
            break;
        case SDL_MOUSEBUTTONDOWN:
            mouse_button(e.button.button, true);
            break;
        case SDL_MOUSEBUTTONUP:
            mouse_button(e.button.button, false);
            break;
        case SDL_MOUSEMOTION:
            mouse_motion(e.motion.xrel, e.motion.yrel);
            break;
        case SDL_MOUSEWHEEL:
            mouse_wheel(e.wheel.x, e.wheel.y);
            break;
        case SDL_CONTROLLERAXISMOTION:
            game_axis(e.caxis.which, e.caxis.axis, e.caxis.value / 32768.f);
            break;
        case SDL_CONTROLLERBUTTONDOWN:
            game_button(e.caxis.which, e.cbutton.button, true);
            break;
        case SDL_CONTROLLERBUTTONUP:
            game_button(e.caxis.which, e.cbutton.button, false);
            break;
        case SDL_CONTROLLERDEVICEADDED:
            game_connect(e.cdevice.which, true);
            break;
        case SDL_CONTROLLERDEVICEREMOVED:
            game_connect(e.cdevice.which, false);
            break;
        case SDL_QUIT:
            running = false;
            break;
    }
}