📄 sdlinputhandler.cc
字号:
//// Copyright (c) 2004 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//------------------------------------------------------------------------------#include "SDLInputHandler.h"#include "InputListener.h"#include <cassert>//------------------------------------------------------------------------------using input::SDLInputHandler;//------------------------------------------------------------------------------SDLInputHandler* SDLInputHandler::instance = 0;//------------------------------------------------------------------------------SDLInputHandler& SDLInputHandler::get(){ assert(instance!=0); return *instance;}//------------------------------------------------------------------------------SDLInputHandler::SDLInputHandler(InputListener& inputListener) : inputListener(inputListener){ assert(instance==0); instance = this;}//------------------------------------------------------------------------------SDLInputHandler::~SDLInputHandler(){ instance = 0;}//------------------------------------------------------------------------------void SDLInputHandler::processEvents(){ SDL_Event event; while(SDL_PollEvent(&event)) { processEvent(event); }}//------------------------------------------------------------------------------void SDLInputHandler::processEvent(SDL_Event& event){ static struct { SDLKey sym; int mod; InputListener::operation_t operation; } operations[] = { {SDLK_UP, KMOD_NONE, InputListener::UP}, {SDLK_8, KMOD_NONE, InputListener::UP}, {SDLK_KP8, KMOD_NONE, InputListener::UP}, {SDLK_DOWN, KMOD_NONE, InputListener::DOWN}, {SDLK_2, KMOD_NONE, InputListener::DOWN}, {SDLK_KP2, KMOD_NONE, InputListener::DOWN}, {SDLK_LEFT, KMOD_NONE, InputListener::LEFT}, {SDLK_4, KMOD_NONE, InputListener::LEFT}, {SDLK_KP4, KMOD_NONE, InputListener::LEFT}, {SDLK_RIGHT, KMOD_NONE, InputListener::RIGHT}, {SDLK_6, KMOD_NONE, InputListener::RIGHT}, {SDLK_KP6, KMOD_NONE, InputListener::RIGHT}, {SDLK_RETURN, KMOD_NONE, InputListener::ACTIVATE}, {SDLK_5, KMOD_NONE, InputListener::ACTIVATE}, {SDLK_KP5, KMOD_NONE, InputListener::ACTIVATE}, {SDLK_KP_ENTER, KMOD_NONE, InputListener::ACTIVATE}, {SDLK_t, KMOD_NONE, InputListener::MENU_TITLE}, {SDLK_r, KMOD_NONE, InputListener::MENU_ROOT}, {SDLK_r, KMOD_LSHIFT, InputListener::MENU_ROOT_FORCED}, {SDLK_s, KMOD_NONE, InputListener::MENU_SUBPICTURE}, {SDLK_a, KMOD_NONE, InputListener::MENU_AUDIO}, {SDLK_n, KMOD_NONE, InputListener::MENU_ANGLE}, {SDLK_p, KMOD_NONE, InputListener::MENU_PART}, {SDLK_p, KMOD_LSHIFT, InputListener::PREVIOUS_CHAPTER}, {SDLK_PAGEUP, KMOD_NONE, InputListener::PREVIOUS_CHAPTER}, {SDLK_n, KMOD_LSHIFT, InputListener::NEXT_CHAPTER}, {SDLK_PAGEDOWN, KMOD_NONE, InputListener::NEXT_CHAPTER}, {SDLK_1, KMOD_NONE, InputListener::PLAY}, {SDLK_SPACE, KMOD_NONE, InputListener::PAUSE}, {SDLK_PERIOD, KMOD_LSHIFT, InputListener::PLAY_FAST_FORWARD}, {SDLK_COMMA, KMOD_LSHIFT, InputListener::PLAY_FAST_BACKWARD}, {SDLK_e, KMOD_NONE, InputListener::EJECT}, {SDLK_END, KMOD_NONE, InputListener::EJECT}, {SDLK_o, KMOD_NONE, InputListener::TOGGLE_OUTPUT}, {SDLK_y, KMOD_NONE, InputListener::RESYNCHRONIZE}, {SDLK_HOME, KMOD_NONE, InputListener::RESYNCHRONIZE}, {SDLK_y, KMOD_LSHIFT, InputListener::RESYNCHRONIZE_ALL}, {SDLK_v, KMOD_NONE, InputListener::VOLUME_RESET}, {SDLK_EQUALS, KMOD_NONE, InputListener::VOLUME_UP}, {SDLK_MINUS, KMOD_NONE, InputListener::VOLUME_DOWN}, {SDLK_m, KMOD_NONE, InputListener::TOGGLE_AUDIO}, {SDLK_RIGHTBRACKET, KMOD_NONE, InputListener::INCREASE_BRIGHTNESS}, {SDLK_LEFTBRACKET, KMOD_NONE, InputListener::DECREASE_BRIGHTNESS}, {SDLK_a, KMOD_LSHIFT, InputListener::CHANGE_ANGLE}, {SDLK_l, KMOD_LSHIFT, InputListener::NEXT_AUDIO_STREAM}, {SDLK_l, KMOD_LALT, InputListener::PREVIOUS_AUDIO_STREAM}, {SDLK_s, KMOD_LSHIFT, InputListener::NEXT_SPU_STREAM}, {SDLK_s, KMOD_LALT, InputListener::PREVIOUS_SPU_STREAM}, {SDLK_i, KMOD_NONE, InputListener::PRINT_STATUS}, {SDLK_z, KMOD_NONE, InputListener::SAVE_DVD_STATE}, {SDLK_z, KMOD_LSHIFT, InputListener::RESUME_DVD_STATE}, {SDLK_q, KMOD_LSHIFT, InputListener::QUIT}, {SDLK_UNKNOWN, 0, InputListener::NONE} }; if (event.type==SDL_KEYDOWN) { for(size_t i = 0; operations[i].operation!=InputListener::NONE; ++i) { if (event.key.keysym.sym==operations[i].sym && event.key.keysym.mod==operations[i].mod) { inputListener.handleOperation(operations[i].operation); } } }} //------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -