From 19d1ec14e06ed570ede41d79c0c9caf8d681b694 Mon Sep 17 00:00:00 2001 From: mtorromeo Date: Mon, 10 Nov 2008 23:16:29 +0000 Subject: [PATCH] Added keyboard support git-svn-id: https://gmenu2x.svn.sourceforge.net/svnroot/gmenu2x@149 bad23c4b-591a-0410-b480-ec8053e4ca07 --- pandora/gmenu2x.conf | 3 ++- pandora/input.conf.xbox360 | 9 +++++++++ pandora/skins/Default/skin.conf | 10 +++++----- src/inputmanager.cpp | 26 +++++++++++++++++++++++--- src/inputmanager.h | 2 ++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/pandora/gmenu2x.conf b/pandora/gmenu2x.conf index 30e7414..a50a59c 100644 --- a/pandora/gmenu2x.conf +++ b/pandora/gmenu2x.conf @@ -12,6 +12,7 @@ link=0 globalVolume=0 globalVolume=67 saveSelection=1 -globalVolume=0 +globalVolume=0 gamma=10 +globalVolume=0 videoBpp=24 diff --git a/pandora/input.conf.xbox360 b/pandora/input.conf.xbox360 index 61b33d6..bc3e89f 100644 --- a/pandora/input.conf.xbox360 +++ b/pandora/input.conf.xbox360 @@ -1,14 +1,23 @@ a=joystickbutton,0,2 b=joystickbutton,0,1 +b=keyboard,13 +b=keyboard,271 x=joystickbutton,0,0 +x=keyboard,8 y=joystickbutton,0,3 l=joystickbutton,0,4 +l=keyboard,49 r=joystickbutton,0,5 +r=keyboard,50 select=joystickbutton,0,10 start=joystickbutton,0,6 volup=joystickaxys,0,5,10000 voldown=joystickaxys,0,2,10000 up=joystickaxys,0,1,-10000 +up=keyboard,273 down=joystickaxys,0,1,10000 +down=keyboard,274 left=joystickaxys,0,0,-10000 +left=keyboard,276 right=joystickaxys,0,0,10000 +right=keyboard,275 \ No newline at end of file diff --git a/pandora/skins/Default/skin.conf b/pandora/skins/Default/skin.conf index 5d48407..c98f25d 100644 --- a/pandora/skins/Default/skin.conf +++ b/pandora/skins/Default/skin.conf @@ -1,9 +1,9 @@ messageBoxBorder=#505050ff -topBarBg=#ffffff82 -selectionBg=#ffffff82 -messageBoxBg=#ffffffff -messageBoxSelection=#a0a0a0ff -bottomBarBg=#ffffff82 +topBarBg=#ffffff80 +selectionBg=#ffffff80 +messageBoxBg=#00000080 +messageBoxSelection=#fffffff80 +bottomBarBg=#ffffff80 topBarHeight=50 linkHeight=50 linkWidth=80 \ No newline at end of file diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index 68a06a8..93e2529 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -84,9 +84,9 @@ void InputManager::init(string conffile) { if (action >= 0) { split(values, value, ","); - if (values.size() >= 3) { + if (values.size() >= 2) { - if (values[0] == "joystickbutton") { + if (values[0] == "joystickbutton" && values.size()==3) { InputMap map; map.type = InputManager::MAPPING_TYPE_BUTTON; map.num = atoi(values[1].c_str()); @@ -100,6 +100,11 @@ void InputManager::init(string conffile) { map.value = atoi(values[2].c_str()); map.treshold = atoi(values[3].c_str()); mappings[action].push_back(map); + } else if (values[0] == "keyboard") { + InputMap map; + map.type = InputManager::MAPPING_TYPE_KEYPRESS; + map.value = atoi(values[1].c_str()); + mappings[action].push_back(map); } } @@ -125,6 +130,14 @@ void InputManager::setActionsCount(int count) { void InputManager::update() { SDL_JoystickUpdate(); + + events.clear(); + SDL_Event event; + while (SDL_PollEvent(&event)) { + SDL_Event evcopy = event; + events.push_back(evcopy); + } + Uint32 tick = SDL_GetTicks(); for (uint x=0; x0 && axyspos > map.treshold) return true; } break; + case InputManager::MAPPING_TYPE_KEYPRESS: + for (uint ex=0; ex MappingList; +typedef vector SDLEventList; /** Manages all input peripherals @@ -61,6 +62,7 @@ class InputManager { InputMap getInputMapping(int action); vector actionTick; vector interval; + SDLEventList events; public: static const int MAPPING_TYPE_UNDEFINED = -1;