[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] [pingus] 2 new revisions pushed by address@hidden on 2014-0
From: |
pingus |
Subject: |
[Pingus-CVS] [pingus] 2 new revisions pushed by address@hidden on 2014-07-27 19:32 GMT |
Date: |
Sun, 27 Jul 2014 19:32:57 +0000 |
feature/sdl2 moved from 805afaf0678e to fe793ae0b646
2 new revisions:
Revision: 294b7f98ce47
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:22:52 2014 UTC
Log: Fixed another scancode/keycode mixup
http://code.google.com/p/pingus/source/detail?r=294b7f98ce47
Revision: fe793ae0b646
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:32:36 2014 UTC
Log: Fixed keyboard->button mapping
http://code.google.com/p/pingus/source/detail?r=fe793ae0b646
==============================================================================
Revision: 294b7f98ce47
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:22:52 2014 UTC
Log: Fixed another scancode/keycode mixup
http://code.google.com/p/pingus/source/detail?r=294b7f98ce47
Modified:
/src/engine/input/sdl_driver.cpp
=======================================
--- /src/engine/input/sdl_driver.cpp Sun Jul 27 19:17:47 2014 UTC
+++ /src/engine/input/sdl_driver.cpp Sun Jul 27 19:22:52 2014 UTC
@@ -33,9 +33,9 @@
string2key(),
joystick_handles()
{
- for (int i = 0; i < SDL_NUM_SCANCODES; ++i)
+ for (int i = 0; i < SDL_NUM_SCANCODES; ++i)
{
- const char* key_name = SDL_GetKeyName(static_cast<SDL_Keycode>(i));
+ const char* key_name =
SDL_GetScancodeName(static_cast<SDL_Scancode>(i));
string2key[key_name] = static_cast<SDL_Keycode>(i);
// FIXME: Make the keynames somewhere user visible so that users can
use them
==============================================================================
Revision: fe793ae0b646
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:32:36 2014 UTC
Log: Fixed keyboard->button mapping
http://code.google.com/p/pingus/source/detail?r=fe793ae0b646
Modified:
/data/controller/default.scm
/src/engine/input/sdl_driver.cpp
/src/engine/input/sdl_driver.hpp
/src/pingus/screens/game_session.cpp
=======================================
--- /data/controller/default.scm Sat Oct 22 23:50:29 2011 UTC
+++ /data/controller/default.scm Sun Jul 27 19:32:36 2014 UTC
@@ -7,10 +7,10 @@
(standard-scroller
(core:button-scroller
- (up (sdl:keyboard-button (key "up")))
- (down (sdl:keyboard-button (key "down")))
- (left (sdl:keyboard-button (key "left")))
- (right (sdl:keyboard-button (key "right")))))
+ (up (sdl:keyboard-button (key "Up")))
+ (down (sdl:keyboard-button (key "Down")))
+ (left (sdl:keyboard-button (key "Left")))
+ (right (sdl:keyboard-button (key "Right")))))
(primary-button
(sdl:mouse-button (button 1)))
@@ -20,26 +20,26 @@
(sdl:mouse-button (button 3)))
(pause-button
- (sdl:keyboard-button (key "p")))
+ (sdl:keyboard-button (key "P")))
(fast-forward-button
- (sdl:keyboard-button (key "f"))
- (sdl:keyboard-button (key "space")))
+ (sdl:keyboard-button (key "F"))
+ (sdl:keyboard-button (key "Space")))
(single-step-button
- (sdl:keyboard-button (key "s")))
+ (sdl:keyboard-button (key "S")))
(armageddon-button
- (sdl:keyboard-button (key "a")))
+ (sdl:keyboard-button (key "A")))
(escape-button
- (sdl:keyboard-button (key "escape")))
+ (sdl:keyboard-button (key "Escape")))
(action-up-button
(sdl:mouse-button (button 4)))
-
+
(action-down-button
- (sdl:keyboard-button (key "tab"))
+ (sdl:keyboard-button (key "Tab"))
(sdl:mouse-button (button 5)))
(action-1-button (sdl:keyboard-button (key "1")))
=======================================
--- /src/engine/input/sdl_driver.cpp Sun Jul 27 19:22:52 2014 UTC
+++ /src/engine/input/sdl_driver.cpp Sun Jul 27 19:32:36 2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
@@ -30,14 +30,11 @@
joystick_button_bindings(),
joystick_axis_bindings(),
keyboard_binding(0),
- string2key(),
joystick_handles()
{
for (int i = 0; i < SDL_NUM_SCANCODES; ++i)
{
const char* key_name =
SDL_GetScancodeName(static_cast<SDL_Scancode>(i));
- string2key[key_name] = static_cast<SDL_Keycode>(i);
-
// FIXME: Make the keynames somewhere user visible so that users can
use them
log_debug("Key: '%1%'", key_name);
}
@@ -45,7 +42,7 @@
SDLDriver::~SDLDriver()
{
-
+
}
Keyboard*
@@ -64,12 +61,12 @@
reader.read_int("device", binding.device);
reader.read_int("button", binding.button);
-
+
if (open_joystick(binding.device))
{
binding.binding = new Button(parent);
joystick_button_bindings.push_back(binding);
-
+
return binding.binding;
}
else
@@ -89,23 +86,23 @@
}
else if (reader.get_name() == "sdl:keyboard-button")
{
- std::string key;
- if (reader.read_string("key", key))
+ std::string key_str;
+ if (reader.read_string("key", key_str))
{
- String2Key::iterator i = string2key.find(key);
- if (i != string2key.end())
+ SDL_Keycode key = SDL_GetKeyFromName(key_str.c_str());
+ if (key != SDLK_UNKNOWN)
{
KeyboardButtonBinding binding;
-
- binding.key = i->second;
+
+ binding.key = key;
binding.binding = new Button(parent);
keyboard_button_bindings.push_back(binding);
return binding.binding;
}
- else
+ else
{
- log_error("couldn't find keysym for key '%1%'", key);
+ log_error("couldn't find keycode for key '%1%'", key_str);
return 0;
}
}
@@ -130,12 +127,12 @@
reader.read_int("device", binding.device);
reader.read_int("axis", binding.axis);
-
+
if (open_joystick(binding.device))
{
binding.binding = new Axis(parent);
joystick_axis_bindings.push_back(binding);
-
+
return binding.binding;
}
else
@@ -185,7 +182,7 @@
}
}
-bool
+bool
SDLDriver::open_joystick(int device)
{
JoystickHandles::iterator i = joystick_handles.find(device);
@@ -228,7 +225,7 @@
for(std::vector<PointerBinding>::iterator i =
pointer_bindings.begin();
i != pointer_bindings.end(); ++i)
{
- i->binding->set_pos(Vector2f(static_cast<float>(event.motion.x),
+ i->binding->set_pos(Vector2f(static_cast<float>(event.motion.x),
static_cast<float>(event.motion.y)));
}
@@ -277,13 +274,13 @@
case SDL_WINDOWEVENT_RESIZED:
Display::resize(Size(event.window.data1, event.window.data2));
break;
-
+
default:
break;
}
break;
- case SDL_KEYDOWN:
+ case SDL_KEYDOWN:
case SDL_KEYUP:
// keyboard events
if (keyboard_binding)
@@ -293,7 +290,7 @@
if (event.key.state == SDL_PRESSED)
global_event.on_button_press(event.key);
else
- global_event.on_button_release(event.key);
+ global_event.on_button_release(event.key);
// game button events
for(std::vector<KeyboardButtonBinding>::iterator i =
keyboard_button_bindings.begin();
@@ -311,14 +308,14 @@
case SDL_JOYAXISMOTION:
for(std::vector<JoystickAxisBinding>::iterator i =
joystick_axis_bindings.begin();
- i != joystick_axis_bindings.end(); ++i)
+ i != joystick_axis_bindings.end(); ++i)
{
if (event.jaxis.which == i->device &&
event.jaxis.axis == i->axis)
i->binding->set_state(static_cast<float>(event.jaxis.value) /
32767.0f);
}
break;
-
+
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
for(std::vector<JoystickButtonBinding>::iterator i =
joystick_button_bindings.begin();
@@ -331,7 +328,7 @@
}
}
break;
-
+
default:
// FIXME: Do something with other events
break;
=======================================
--- /src/engine/input/sdl_driver.hpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/input/sdl_driver.hpp Sun Jul 27 19:32:36 2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
@@ -74,12 +74,9 @@
std::vector<JoystickAxisBinding> joystick_axis_bindings;
Keyboard* keyboard_binding;
- typedef std::map<std::string, SDL_Keycode> String2Key;
- String2Key string2key;
-
typedef std::map<int, SDL_Joystick*> JoystickHandles;
JoystickHandles joystick_handles;
-
+
public:
SDLDriver();
~SDLDriver();
=======================================
--- /src/pingus/screens/game_session.cpp Sun Jul 27 03:58:39 2014 UTC
+++ /src/pingus/screens/game_session.cpp Sun Jul 27 19:32:36 2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
@@ -60,7 +60,7 @@
log_debug("GameSession");
// -- Client stuff
-
+
// These object will get deleted by the gui_manager
button_panel = new ButtonPanel(get_server(), Vector2i(0, (size.height -
150)/2));
@@ -69,7 +69,7 @@
playfield = new Playfield(get_server(), this,
Rect(Vector2i(Math::max((Display::get_width() - world_width)/2, 0),
-
Math::max((Display::get_height() - world_height)/2, 0)),
+
Math::max((Display::get_height() - world_height)/2, 0)),
Size(Math::min(Display::get_width(),
world_width),
Math::min(Display::get_height(),
world_height))));
@@ -172,7 +172,7 @@
GameSession::draw_background (DrawingContext& gc)
{
Rect rect = playfield->get_rect();
-
+
if (rect != Rect(Vector2i(0,0), Size(Display::get_width(),
Display::get_height())))
{ // Draw a black border around the playfield when the playfield is
smaller then the screen
Color border_color(0, 0, 0);
@@ -245,9 +245,12 @@
case Input::KEYBOARD_EVENT_TYPE:
break;
+ case Input::TEXT_INPUT_EVENT_TYPE:
+ break;
+
default:
// unhandled event
- log_info("GameSession::process_events (): unhandled event: %1%",
event.type);
+ log_info("unhandled event: %1%", event.type);
break;
}
}
@@ -345,7 +348,7 @@
if (globals::developer_mode)
log_info("Starting Music: %1%", server->get_plf().get_music());
- if (server->get_plf().get_music() == "none" ||
+ if (server->get_plf().get_music() == "none" ||
server->get_plf().get_music().empty())
{
Sound::PingusSound::stop_music();
@@ -401,9 +404,9 @@
int world_width = server->get_world()->get_width();
int world_height = server->get_world()->get_height();
-
+
playfield->set_rect(Rect(Vector2i(Math::max((size.width -
world_width)/2, 0),
- Math::max((size.height -
world_height)/2, 0)),
+ Math::max((size.height -
world_height)/2, 0)),
Size(Math::min(size.width, world_width),
Math::min(size.height, world_height))));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] [pingus] 2 new revisions pushed by address@hidden on 2014-07-27 19:32 GMT,
pingus <=