示例#1
0
void EventHandler::Update( )
{
	SDL_Event event;
	while ( SDL_PollEvent( &event ) )
	{
		switch ( event.type )
		{
			case SDL_QUIT :
				AddQuitEvent();
				break;
			case SDL_KEYDOWN : 
			case SDL_KEYUP :
				HandleKeyBoard( event );
				break;
			case SDL_MOUSEBUTTONDOWN :
			case SDL_MOUSEBUTTONUP :
				HandleMouseButton( event );
				break;
			case SDL_MOUSEMOTION :
				HandleMouseMove( event );
				break;
			default :
				break;
		}
	}
}
示例#2
0
static void
HandleMouseEvent(MirPointerEvent const* pointer, SDL_Window* sdl_window)
{
    SDL_SetMouseFocus(sdl_window);

    switch (MIR_mir_pointer_event_action(pointer)) {
        case mir_pointer_action_button_down:
            HandleMouseButton(sdl_window, SDL_PRESSED, pointer);
            break;
        case mir_pointer_action_button_up:
            HandleMouseButton(sdl_window, SDL_RELEASED, pointer);
            break;
        case mir_pointer_action_motion: {
            int x, y;
            int hscroll, vscroll;
            SDL_Mouse* mouse = SDL_GetMouse();
            x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x);
            y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_y);

            if (mouse) {
                if (mouse->relative_mode) {
                    int relative_x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_relative_x);
                    int relative_y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_relative_y);
                    HandleMouseMotion(sdl_window, relative_x, relative_y);
                }
                else if (mouse->x != x || mouse->y != y) {
                    HandleMouseMotion(sdl_window, x, y);
                }
            }

            hscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_hscroll);
            vscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_vscroll);
            if (vscroll != 0 || hscroll != 0)
                HandleMouseScroll(sdl_window, hscroll, vscroll);
        }
            break;
        case mir_pointer_action_leave:
            SDL_SetMouseFocus(NULL);
            break;
        case mir_pointer_action_enter:
        default:
            break;
    }
}
示例#3
0
static void
HandleMouseEvent(MirMotionEvent const motion, int cord_index, SDL_Window* sdl_window)
{
    SDL_SetMouseFocus(sdl_window);

    switch (motion.action) {
    case mir_motion_action_down:
    case mir_motion_action_pointer_down:
        HandleMouseButton(sdl_window, SDL_PRESSED, motion.button_state);
        break;
    case mir_motion_action_up:
    case mir_motion_action_pointer_up:
        HandleMouseButton(sdl_window, SDL_RELEASED, motion.button_state);
        break;
    case mir_motion_action_hover_move:
    case mir_motion_action_move:
        HandleMouseMotion(sdl_window,
                          motion.pointer_coordinates[cord_index].x,
                          motion.pointer_coordinates[cord_index].y);
        break;
    case mir_motion_action_outside:
        SDL_SetMouseFocus(NULL);
        break;
    case mir_motion_action_scroll:
        HandleMouseScroll(sdl_window,
                          motion.pointer_coordinates[cord_index].hscroll,
                          motion.pointer_coordinates[cord_index].vscroll);
        break;
    case mir_motion_action_cancel:
    case mir_motion_action_hover_enter:
    case mir_motion_action_hover_exit:
        break;
    default:
        break;
    }
}
示例#4
0
void HaikuDirectWindow::DispatchMessage(BMessage *message, BHandler *handler) {
	switch (message->what) {
		case B_MOUSE_DOWN:
		case B_MOUSE_UP:
			HandleMouseButton(message);
			break;

		case B_MOUSE_MOVED:
			HandleMouseMoved(message);
			break;

		case B_MOUSE_WHEEL_CHANGED:
			HandleMouseWheelChanged(message);
			break;

		case B_KEY_DOWN:
		case B_KEY_UP:
			HandleKeyboardEvent(message);
			break;

		case B_MODIFIERS_CHANGED:
			HandleKeyboardModifierEvent(message);
			break;

		case B_WINDOW_RESIZED:
			HandleWindowResized(message);
			break;

		case LOCKGL_MSG:
			view->LockGL();
			break;

		case UNLOCKGL_MSG:
			view->UnlockGL();
			break;

		default:
			BDirectWindow::DispatchMessage(message, handler);
	}
}
示例#5
0
文件: MGLInput.cpp 项目: MrMCG/MGL
void MGLInput::MouseButtonCallBack(GLFWwindow* window, GLuint button, GLuint action, GLuint mods) {
	static auto game = static_cast<MGLInput*>(glfwGetWindowUserPointer(window));
	game->HandleMouseButton(button, MGL::BitShiftLeftEnableZero(action), mods); // GLFW actions -> MGLInputType ButtonActions
}