---
src/interface/keyboard.cpp | 193 +++++++++++++++++++++----------
src/interface/keyboard.h | 6 +
src/interface/man_machine_interface.cpp | 179 +++++++++++++++++++----------
src/interface/man_machine_interface.h | 55 +++++++--
4 files changed, 299 insertions(+), 134 deletions(-)
diff --git a/src/interface/keyboard.cpp b/src/interface/keyboard.cpp
index 7debe61..b5dc813 100644
--- a/src/interface/keyboard.cpp
+++ b/src/interface/keyboard.cpp
@@ -24,6 +24,15 @@
#include "network/chat.h"
#include <SDL_events.h>
+#define MODIFIER_OFFSET (SDLK_LAST + 1)
+#define SHIFT_BIT 0x1
+#define ALT_BIT 0x2
+#define CONTROL_BIT 0x4
+#define SHIFT_OFFSET (MODIFIER_OFFSET * SHIFT_BIT)
+#define CONTROL_OFFSET (MODIFIER_OFFSET * CONTROL_BIT)
+#define ALT_OFFSET (MODIFIER_OFFSET * ALT_BIT)
+
+
Keyboard::Keyboard() : ManMachineInterface()
{
//Disable repeated events when a key is kept down
@@ -37,43 +46,106 @@ Keyboard::Keyboard() : ManMachineInterface()
void Keyboard::SetDefaultConfig()
{
- SetKeyAction(SDLK_LEFT, ManMachineInterface::KEY_MOVE_LEFT);
- SetKeyAction(SDLK_RIGHT, ManMachineInterface::KEY_MOVE_RIGHT);
- SetKeyAction(SDLK_UP, ManMachineInterface::KEY_UP);
- SetKeyAction(SDLK_DOWN, ManMachineInterface::KEY_DOWN);
- SetKeyAction(SDLK_RETURN, ManMachineInterface::KEY_JUMP);
- SetKeyAction(SDLK_BACKSPACE, ManMachineInterface::KEY_HIGH_JUMP);
- SetKeyAction(SDLK_b, ManMachineInterface::KEY_BACK_JUMP);
- SetKeyAction(SDLK_SPACE, ManMachineInterface::KEY_SHOOT);
- SetKeyAction(SDLK_TAB, ManMachineInterface::KEY_NEXT_CHARACTER);
- SetKeyAction(SDLK_ESCAPE, ManMachineInterface::KEY_QUIT);
- SetKeyAction(SDLK_PAUSE, ManMachineInterface::KEY_PAUSE);
- SetKeyAction(SDLK_F10, ManMachineInterface::KEY_FULLSCREEN);
- SetKeyAction(SDLK_F9, ManMachineInterface::KEY_TOGGLE_INTERFACE);
- SetKeyAction(SDLK_F1, ManMachineInterface::KEY_WEAPONS1);
- SetKeyAction(SDLK_F2, ManMachineInterface::KEY_WEAPONS2);
- SetKeyAction(SDLK_F3, ManMachineInterface::KEY_WEAPONS3);
- SetKeyAction(SDLK_F4, ManMachineInterface::KEY_WEAPONS4);
- SetKeyAction(SDLK_F5, ManMachineInterface::KEY_WEAPONS5);
- SetKeyAction(SDLK_F6, ManMachineInterface::KEY_WEAPONS6);
- SetKeyAction(SDLK_F7, ManMachineInterface::KEY_WEAPONS7);
- SetKeyAction(SDLK_F8, ManMachineInterface::KEY_WEAPONS8);
- SetKeyAction(SDLK_c, ManMachineInterface::KEY_CENTER);
- SetKeyAction(SDLK_1, ManMachineInterface::KEY_WEAPON_1);
- SetKeyAction(SDLK_2, ManMachineInterface::KEY_WEAPON_2);
- SetKeyAction(SDLK_3, ManMachineInterface::KEY_WEAPON_3);
- SetKeyAction(SDLK_4, ManMachineInterface::KEY_WEAPON_4);
- SetKeyAction(SDLK_5, ManMachineInterface::KEY_WEAPON_5);
- SetKeyAction(SDLK_6, ManMachineInterface::KEY_WEAPON_6);
- SetKeyAction(SDLK_7, ManMachineInterface::KEY_WEAPON_7);
- SetKeyAction(SDLK_8, ManMachineInterface::KEY_WEAPON_8);
- SetKeyAction(SDLK_9, ManMachineInterface::KEY_WEAPON_9);
- SetKeyAction(SDLK_PAGEUP, ManMachineInterface::KEY_WEAPON_MORE);
- SetKeyAction(SDLK_PAGEDOWN, ManMachineInterface::KEY_WEAPON_LESS);
- SetKeyAction(SDLK_s, ManMachineInterface::KEY_CHAT);
- SetKeyAction(SDLK_t, ManMachineInterface::KEY_CHAT);
- SetKeyAction(SDLK_F11,
ManMachineInterface::KEY_MENU_OPTIONS_FROM_GAME);
- SetKeyAction(SDLK_m, ManMachineInterface::KEY_MINIMAP_FROM_GAME);
+ SetKeyAction(SDLK_LEFT,
ManMachineInterface::KEY_MOVE_LEFT);
+ SetKeyAction(SHIFT_OFFSET + SDLK_LEFT,
ManMachineInterface::KEY_MOVE_LEFT_SLOWLY);
+ SetKeyAction(SDLK_RIGHT,
ManMachineInterface::KEY_MOVE_RIGHT);
+ SetKeyAction(SHIFT_OFFSET + SDLK_RIGHT,
ManMachineInterface::KEY_MOVE_RIGHT_SLOWLY);
+ SetKeyAction(SDLK_UP, ManMachineInterface::KEY_UP);
+ SetKeyAction(SHIFT_OFFSET + SDLK_UP,
ManMachineInterface::KEY_UP_SLOWLY);
+ SetKeyAction(SDLK_DOWN, ManMachineInterface::KEY_DOWN);
+ SetKeyAction(SHIFT_OFFSET + SDLK_DOWN,
ManMachineInterface::KEY_DOWN_SLOWLY);
+ SetKeyAction(CONTROL_OFFSET + SDLK_LEFT,
ManMachineInterface::KEY_MOVE_CAMERA_LEFT);
+ SetKeyAction(CONTROL_OFFSET + SDLK_RIGHT,
ManMachineInterface::KEY_MOVE_CAMERA_RIGHT);
+ SetKeyAction(CONTROL_OFFSET + SDLK_UP,
ManMachineInterface::KEY_MOVE_CAMERA_UP);
+ SetKeyAction(CONTROL_OFFSET + SDLK_DOWN,
ManMachineInterface::KEY_MOVE_CAMERA_DOWN);
+ SetKeyAction(SDLK_RETURN, ManMachineInterface::KEY_JUMP);
+ SetKeyAction(SDLK_BACKSPACE,
ManMachineInterface::KEY_HIGH_JUMP);
+ SetKeyAction(SDLK_b,
ManMachineInterface::KEY_BACK_JUMP);
+ SetKeyAction(SDLK_SPACE, ManMachineInterface::KEY_SHOOT);
+ SetKeyAction(SDLK_TAB,
ManMachineInterface::KEY_NEXT_CHARACTER);
+ SetKeyAction(SDLK_ESCAPE, ManMachineInterface::KEY_QUIT);
+ SetKeyAction(SDLK_PAUSE, ManMachineInterface::KEY_PAUSE);
+ SetKeyAction(SDLK_F10,
ManMachineInterface::KEY_FULLSCREEN);
+ SetKeyAction(SDLK_F9,
ManMachineInterface::KEY_TOGGLE_INTERFACE);
+ SetKeyAction(SDLK_F1,
ManMachineInterface::KEY_WEAPONS1);
+ SetKeyAction(SDLK_F2,
ManMachineInterface::KEY_WEAPONS2);
+ SetKeyAction(SDLK_F3,
ManMachineInterface::KEY_WEAPONS3);
+ SetKeyAction(SDLK_F4,
ManMachineInterface::KEY_WEAPONS4);
+ SetKeyAction(SDLK_F5,
ManMachineInterface::KEY_WEAPONS5);
+ SetKeyAction(SDLK_F6,
ManMachineInterface::KEY_WEAPONS6);
+ SetKeyAction(SDLK_F7,
ManMachineInterface::KEY_WEAPONS7);
+ SetKeyAction(SDLK_F8,
ManMachineInterface::KEY_WEAPONS8);
+ SetKeyAction(SDLK_c, ManMachineInterface::KEY_CENTER);
+ SetKeyAction(SDLK_1,
ManMachineInterface::KEY_WEAPON_1);
+ SetKeyAction(SDLK_2,
ManMachineInterface::KEY_WEAPON_2);
+ SetKeyAction(SDLK_3,
ManMachineInterface::KEY_WEAPON_3);
+ SetKeyAction(SDLK_4,
ManMachineInterface::KEY_WEAPON_4);
+ SetKeyAction(SDLK_5,
ManMachineInterface::KEY_WEAPON_5);
+ SetKeyAction(SDLK_6,
ManMachineInterface::KEY_WEAPON_6);
+ SetKeyAction(SDLK_7,
ManMachineInterface::KEY_WEAPON_7);
+ SetKeyAction(SDLK_8,
ManMachineInterface::KEY_WEAPON_8);
+ SetKeyAction(SDLK_9,
ManMachineInterface::KEY_WEAPON_9);
+ SetKeyAction(SDLK_PAGEUP,
ManMachineInterface::KEY_WEAPON_MORE);
+ SetKeyAction(SDLK_PAGEDOWN,
ManMachineInterface::KEY_WEAPON_LESS);
+ SetKeyAction(SDLK_s, ManMachineInterface::KEY_CHAT);
+ SetKeyAction(SDLK_t, ManMachineInterface::KEY_CHAT);
+ SetKeyAction(ALT_OFFSET + SDLK_RETURN, ManMachineInterface::KEY_CHAT);
+ SetKeyAction(SDLK_F11,
ManMachineInterface::KEY_MENU_OPTIONS_FROM_GAME);
+ SetKeyAction(SDLK_m,
ManMachineInterface::KEY_MINIMAP_FROM_GAME);
+}
+
+
+void Keyboard::HandleKeyComboEvent(int key_code, Key_Event_t event_type)
+{
+ MSG_DEBUG("keyboard", "%s %s%s%s%d",
+ event_type == KEY_PRESSED ?"pressed":"released",
+ ((key_code / MODIFIER_OFFSET) & CONTROL_BIT)?"[control] + ": "",
+ ((key_code / MODIFIER_OFFSET) & ALT_BIT)?"[alt] + ": "",
+ ((key_code / MODIFIER_OFFSET) & SHIFT_BIT)?"[shift] + ": "",
+ key_code % MODIFIER_OFFSET);
+ std::map<int, Key_t>::iterator it = layout.find(key_code);
+
+ if(it == layout.end())
+ return;
+
+
+ Key_t key = it->second;
+
+ //While player writes, it cannot control the game but QUIT or PAUSE.
+ if (Game::GetInstance()->chatsession.CheckInput()) {
+ switch (key) {
+ case KEY_QUIT:
+ case KEY_PAUSE:
+ break;
+ default:
+ return;
+ }
+ }
+
+ if(event_type == KEY_PRESSED) {
+ HandleKeyPressed(key);
+ return;
+ }
+
+ if(event_type == KEY_RELEASED) {
+ HandleKeyReleased(key);
+ return;
+ }
+}
+
+static int GetModifierBitsFromSDL() {
+ SDLMod sdl_modifier_bits = SDL_GetModState();
+ int result = 0;
+ if (sdl_modifier_bits & KMOD_SHIFT)
+ result |= SHIFT_BIT;
+
+ if (sdl_modifier_bits & KMOD_ALT)
+ result |= ALT_BIT;
+
+ if (sdl_modifier_bits & KMOD_CTRL)
+ result |= CONTROL_BIT;
+
+ return result;
}
void Keyboard::HandleKeyEvent(const SDL_Event& event)
@@ -101,31 +173,32 @@ void Keyboard::HandleKeyEvent(const SDL_Event& event)
return;
}
- std::map<int, Key_t>::iterator it = layout.find(event.key.keysym.sym);
-
- if(it == layout.end())
+ int previos_modifier_bits = modifier_bits;
+ modifier_bits = GetModifierBitsFromSDL();
+ SDLKey basic_key_code = event.key.keysym.sym;
+ if (basic_key_code >= MODIFIER_OFFSET)
return;
-
- Key_t key = it->second;
-
- //While player writes, it cannot control the game but QUIT or PAUSE.
- if (Game::GetInstance()->chatsession.CheckInput()) {
- switch (key) {
- case KEY_QUIT:
- case KEY_PAUSE:
- break;
- default:
- return;
+ int key_code;
+ if (modifier_bits != previos_modifier_bits) {
+ std::set<SDLKey>::iterator it;
+ for (it = pressed_keys.begin(); it != pressed_keys.end(); it++) {
+ int basic_key_code_it = *it;
+ if (basic_key_code != basic_key_code_it) {
+ key_code = basic_key_code_it + MODIFIER_OFFSET * previos_modifier_bits;
+ HandleKeyComboEvent(key_code, KEY_RELEASED);
+ key_code = basic_key_code_it + MODIFIER_OFFSET * modifier_bits;
+ HandleKeyComboEvent(key_code, KEY_PRESSED);
+ }
}
}
-
- if(event_type == KEY_PRESSED) {
- HandleKeyPressed(key);
- return;
- }
-
- if(event_type == KEY_RELEASED) {
- HandleKeyReleased(key);
- return;
+ if (event_type == KEY_PRESSED) {
+ key_code = basic_key_code + (MODIFIER_OFFSET * modifier_bits);
+ HandleKeyComboEvent(key_code, KEY_PRESSED);
+ pressed_keys.insert(basic_key_code);
+ } else {
+ ASSERT(event_type == KEY_RELEASED);
+ key_code = basic_key_code + (MODIFIER_OFFSET * previos_modifier_bits);
+ HandleKeyComboEvent(key_code, KEY_RELEASED);
+ pressed_keys.erase(basic_key_code);
}
}
diff --git a/src/interface/keyboard.h b/src/interface/keyboard.h
index 44c4856..5c65efd 100644
--- a/src/interface/keyboard.h
+++ b/src/interface/keyboard.h
@@ -24,10 +24,16 @@
//-----------------------------------------------------------------------------
#include "interface/man_machine_interface.h"
#include <WORMUX_singleton.h>
+#include <set>
+#include "SDL_keyboard.h"
//-----------------------------------------------------------------------------
class Keyboard : public ManMachineInterface, public Singleton<Keyboard>
{
+private:
+ int modifier_bits;
+ std::set<SDLKey> pressed_keys;
+ void HandleKeyComboEvent(int key_code, Key_Event_t event_type);
protected:
friend class Singleton<Keyboard>;
Keyboard();
diff --git a/src/interface/man_machine_interface.cpp
b/src/interface/man_machine_interface.cpp
index 6a40e19..034f351 100644
--- a/src/interface/man_machine_interface.cpp
+++ b/src/interface/man_machine_interface.cpp
@@ -75,16 +75,16 @@ bool ManMachineInterface::MoveCamera(const Key_t &key) const
bool r = true;
switch(key) {
- case KEY_MOVE_RIGHT:
+ case KEY_MOVE_CAMERA_RIGHT:
Camera::GetInstance()->SetXY(Point2i(SCROLL_KEYBOARD, 0));
break;
- case KEY_MOVE_LEFT:
+ case KEY_MOVE_CAMERA_LEFT:
Camera::GetInstance()->SetXY(Point2i(-SCROLL_KEYBOARD, 0));
break;
- case KEY_UP:
+ case KEY_MOVE_CAMERA_UP:
Camera::GetInstance()->SetXY(Point2i(0, -SCROLL_KEYBOARD));
break;
- case KEY_DOWN:
+ case KEY_MOVE_CAMERA_DOWN:
Camera::GetInstance()->SetXY(Point2i(0, SCROLL_KEYBOARD));
break;
default:
@@ -101,12 +101,9 @@ bool ManMachineInterface::MoveCamera(const Key_t &key)
const
// Handle a pressed key
void ManMachineInterface::HandleKeyPressed(const Key_t &key)
{
- SDLMod mod = SDL_GetModState();
- if (mod & KMOD_CTRL) {
- if (MoveCamera(key)) {
- PressedKeys[key] = true;
- return;
- }
+ if (MoveCamera(key)) {
+ PressedKeys[key] = true;
+ return;
}
// Key repeat is useful in the menu, but we are handling it manually
@@ -122,30 +119,41 @@ void ManMachineInterface::HandleKeyPressed(const Key_t
&key)
if (Game::GetInstance()->ReadState() == Game::END_TURN) return;
if (ActiveCharacter().IsDead()) return;
- bool shift = !!(SDL_GetModState() & KMOD_SHIFT);
if (Game::GetInstance()->ReadState() == Game::HAS_PLAYED) {
switch (key) {
case KEY_MOVE_RIGHT:
- ActiveCharacter().HandleKeyPressed_MoveRight(shift);
+ ActiveCharacter().HandleKeyPressed_MoveRight(false);
+ break;
+ case KEY_MOVE_RIGHT_SLOWLY:
+ ActiveCharacter().HandleKeyPressed_MoveRight(true);
break;
case KEY_MOVE_LEFT:
- ActiveCharacter().HandleKeyPressed_MoveLeft(shift);
+ ActiveCharacter().HandleKeyPressed_MoveLeft(false);
+ break;
+ case KEY_MOVE_LEFT_SLOWLY:
+ ActiveCharacter().HandleKeyPressed_MoveLeft(true);
break;
case KEY_UP:
- ActiveCharacter().HandleKeyPressed_Up(shift);
+ ActiveCharacter().HandleKeyPressed_Up(false);
+ break;
+ case KEY_UP_SLOWLY:
+ ActiveCharacter().HandleKeyPressed_Up(true);
break;
case KEY_DOWN:
- ActiveCharacter().HandleKeyPressed_Down(shift);
+ ActiveCharacter().HandleKeyPressed_Down(false);
+ break;
+ case KEY_DOWN_SLOWLY:
+ ActiveCharacter().HandleKeyPressed_Down(true);
break;
case KEY_JUMP:
- ActiveCharacter().HandleKeyPressed_Jump(shift);
+ ActiveCharacter().HandleKeyPressed_Jump(false);
break;
case KEY_HIGH_JUMP:
- ActiveCharacter().HandleKeyPressed_HighJump(shift);
+ ActiveCharacter().HandleKeyPressed_HighJump(false);
break;
case KEY_BACK_JUMP:
- ActiveCharacter().HandleKeyPressed_BackJump(shift);
+ ActiveCharacter().HandleKeyPressed_BackJump(false);
break;
case KEY_SHOOT:
// Shoot key is not accepted in HAS_PLAYED state
@@ -160,29 +168,41 @@ void ManMachineInterface::HandleKeyPressed(const Key_t
&key)
switch (key) {
case KEY_MOVE_RIGHT:
- ActiveTeam().AccessWeapon().HandleKeyPressed_MoveRight(shift);
+ ActiveTeam().AccessWeapon().HandleKeyPressed_MoveRight(false);
+ break;
+ case KEY_MOVE_RIGHT_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyPressed_MoveRight(true);
break;
case KEY_MOVE_LEFT:
- ActiveTeam().AccessWeapon().HandleKeyPressed_MoveLeft(shift);
+ ActiveTeam().AccessWeapon().HandleKeyPressed_MoveLeft(false);
+ break;
+ case KEY_MOVE_LEFT_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyPressed_MoveLeft(true);
break;
case KEY_UP:
- ActiveTeam().AccessWeapon().HandleKeyPressed_Up(shift);
+ ActiveTeam().AccessWeapon().HandleKeyPressed_Up(false);
+ break;
+ case KEY_UP_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyPressed_Up(true);
break;
case KEY_DOWN:
- ActiveTeam().AccessWeapon().HandleKeyPressed_Down(shift);
+ ActiveTeam().AccessWeapon().HandleKeyPressed_Down(false);
+ break;
+ case KEY_DOWN_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyPressed_Down(true);
break;
case KEY_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyPressed_Jump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyPressed_Jump(false);
break;
case KEY_HIGH_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyPressed_HighJump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyPressed_HighJump(false);
break;
case KEY_BACK_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyPressed_BackJump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyPressed_BackJump(false);
break;
case KEY_SHOOT:
if (Game::GetInstance()->ReadState() == Game::PLAYING) {
- ActiveTeam().AccessWeapon().HandleKeyPressed_Shoot(shift);
+ ActiveTeam().AccessWeapon().HandleKeyPressed_Shoot(false);
break;
}
default:
@@ -271,25 +291,37 @@ void ManMachineInterface::HandleKeyReleased(const Key_t
&key)
if (Game::GetInstance()->ReadState() == Game::HAS_PLAYED) {
switch (key) {
case KEY_MOVE_RIGHT:
- ActiveCharacter().HandleKeyReleased_MoveRight(shift);
+ ActiveCharacter().HandleKeyReleased_MoveRight(false);
+ return;
+ case KEY_MOVE_RIGHT_SLOWLY:
+ ActiveCharacter().HandleKeyReleased_MoveRight(true);
return;
case KEY_MOVE_LEFT:
- ActiveCharacter().HandleKeyReleased_MoveLeft(shift);
+ ActiveCharacter().HandleKeyReleased_MoveLeft(false);
+ return;
+ case KEY_MOVE_LEFT_SLOWLY:
+ ActiveCharacter().HandleKeyReleased_MoveLeft(true);
return;
case KEY_UP:
- ActiveCharacter().HandleKeyReleased_Up(shift);
+ ActiveCharacter().HandleKeyReleased_Up(false);
+ return;
+ case KEY_UP_SLOWLY:
+ ActiveCharacter().HandleKeyReleased_Up(true);
return;
case KEY_DOWN:
- ActiveCharacter().HandleKeyReleased_Down(shift);
+ ActiveCharacter().HandleKeyReleased_Down(false);
+ return;
+ case KEY_DOWN_SLOWLY:
+ ActiveCharacter().HandleKeyReleased_Down(true);
return;
case KEY_JUMP:
- ActiveCharacter().HandleKeyReleased_Jump(shift);
+ ActiveCharacter().HandleKeyReleased_Jump(false);
return;
case KEY_HIGH_JUMP:
- ActiveCharacter().HandleKeyReleased_HighJump(shift);
+ ActiveCharacter().HandleKeyReleased_HighJump(false);
return;
case KEY_BACK_JUMP:
- ActiveCharacter().HandleKeyReleased_BackJump(shift);
+ ActiveCharacter().HandleKeyReleased_BackJump(false);
return;
case KEY_SHOOT:
// Shoot key is not accepted in HAS_PLAYED state
@@ -304,65 +336,77 @@ void ManMachineInterface::HandleKeyReleased(const Key_t
&key)
switch (key) {
case KEY_MOVE_RIGHT:
- ActiveTeam().AccessWeapon().HandleKeyReleased_MoveRight(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_MoveRight(false);
+ return;
+ case KEY_MOVE_RIGHT_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyReleased_MoveRight(true);
return;
case KEY_MOVE_LEFT:
- ActiveTeam().AccessWeapon().HandleKeyReleased_MoveLeft(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_MoveLeft(false);
+ return;
+ case KEY_MOVE_LEFT_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyReleased_MoveLeft(true);
return;
case KEY_UP:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Up(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Up(false);
+ return;
+ case KEY_UP_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Up(true);
return;
case KEY_DOWN:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Down(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Down(false);
+ return;
+ case KEY_DOWN_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Down(true);
return;
case KEY_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Jump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Jump(false);
return;
case KEY_HIGH_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyReleased_HighJump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_HighJump(false);
return;
case KEY_BACK_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyReleased_BackJump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_BackJump(false);
return;
// Shoot key
case KEY_SHOOT:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Shoot(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Shoot(false);
return;
// Other keys usefull for weapons
case KEY_WEAPON_1:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num1(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num1(false);
return;
case KEY_WEAPON_2:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num2(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num2(false);
return;
case KEY_WEAPON_3:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num3(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num3(false);
return;
case KEY_WEAPON_4:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num4(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num4(false);
return;
case KEY_WEAPON_5:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num5(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num5(false);
return;
case KEY_WEAPON_6:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num6(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num6(false);
return;
case KEY_WEAPON_7:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num7(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num7(false);
return;
case KEY_WEAPON_8:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num8(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num8(false);
return;
case KEY_WEAPON_9:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Num9(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Num9(false);
return;
case KEY_WEAPON_LESS:
- ActiveTeam().AccessWeapon().HandleKeyReleased_Less(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_Less(false);
return;
case KEY_WEAPON_MORE:
- ActiveTeam().AccessWeapon().HandleKeyReleased_More(shift);
+ ActiveTeam().AccessWeapon().HandleKeyReleased_More(false);
return;
default:
break;
@@ -443,7 +487,7 @@ void ManMachineInterface::Refresh() const
if (PressedKeys[i]) {
Key_t key = static_cast<Key_t>(i);
- if (SDL_GetModState()&KMOD_CTRL && MoveCamera(key))
+ if (MoveCamera(key))
continue;
// Managing keys related to character moves
@@ -453,33 +497,44 @@ void ManMachineInterface::Refresh() const
if (Game::GetInstance()->ReadState() == Game::END_TURN) return;
// Movements are managed by weapons because sometimes it overrides the
keys
- bool shift = !!(SDL_GetModState() & KMOD_SHIFT);
switch (key) {
case KEY_MOVE_RIGHT:
- ActiveTeam().AccessWeapon().HandleKeyRefreshed_MoveRight(shift);
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_MoveRight(false);
+ break;
+ case KEY_MOVE_RIGHT_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_MoveRight(true);
break;
case KEY_MOVE_LEFT:
- ActiveTeam().AccessWeapon().HandleKeyRefreshed_MoveLeft(shift);
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_MoveLeft(false);
+ break;
+ case KEY_MOVE_LEFT_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_MoveLeft(true);
break;
case KEY_UP:
- ActiveTeam().AccessWeapon().HandleKeyRefreshed_Up(shift);
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_Up(false);
+ break;
+ case KEY_UP_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_Up(true);
break;
case KEY_DOWN:
- ActiveTeam().AccessWeapon().HandleKeyRefreshed_Down(shift);
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_Down(false);
+ break;
+ case KEY_DOWN_SLOWLY:
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_Down(true);
break;
case KEY_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyRefreshed_Jump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_Jump(false);
break;
case KEY_HIGH_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyRefreshed_HighJump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_HighJump(false);
break;
case KEY_BACK_JUMP:
- ActiveTeam().AccessWeapon().HandleKeyRefreshed_BackJump(shift);
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_BackJump(false);
break;
case KEY_SHOOT:
if (Game::GetInstance()->ReadState() == Game::PLAYING) {
- ActiveTeam().AccessWeapon().HandleKeyRefreshed_Shoot(shift);
+ ActiveTeam().AccessWeapon().HandleKeyRefreshed_Shoot(false);
}
break;
default:
diff --git a/src/interface/man_machine_interface.h
b/src/interface/man_machine_interface.h
index 4fbc198..ff0c3bc 100644
--- a/src/interface/man_machine_interface.h
+++ b/src/interface/man_machine_interface.h
@@ -37,18 +37,49 @@ class ManMachineInterface
public:
typedef enum
{
- KEY_QUIT, KEY_WEAPONS1, KEY_WEAPONS2,
- KEY_WEAPONS3, KEY_WEAPONS4, KEY_WEAPONS5,
- KEY_WEAPONS6, KEY_WEAPONS7, KEY_WEAPONS8,
- KEY_PAUSE, KEY_FULLSCREEN, KEY_TOGGLE_INTERFACE,
- KEY_CENTER, KEY_TOGGLE_WEAPONS_MENUS, KEY_CHAT,
- KEY_MOVE_LEFT, KEY_MOVE_RIGHT, KEY_UP, KEY_DOWN,
- KEY_JUMP, KEY_HIGH_JUMP, KEY_BACK_JUMP,
- KEY_SHOOT, KEY_CHANGE_WEAPON,
- KEY_WEAPON_1, KEY_WEAPON_2, KEY_WEAPON_3,
- KEY_WEAPON_4, KEY_WEAPON_5, KEY_WEAPON_6,
- KEY_WEAPON_7, KEY_WEAPON_8, KEY_WEAPON_9,
- KEY_WEAPON_LESS, KEY_WEAPON_MORE,
+ KEY_QUIT,
+ KEY_WEAPONS1,
+ KEY_WEAPONS2,
+ KEY_WEAPONS3,
+ KEY_WEAPONS4,
+ KEY_WEAPONS5,
+ KEY_WEAPONS6,
+ KEY_WEAPONS7,
+ KEY_WEAPONS8,
+ KEY_PAUSE,
+ KEY_FULLSCREEN,
+ KEY_TOGGLE_INTERFACE,
+ KEY_CENTER,
+ KEY_TOGGLE_WEAPONS_MENUS,
+ KEY_CHAT,
+ KEY_MOVE_LEFT,
+ KEY_MOVE_LEFT_SLOWLY,
+ KEY_MOVE_RIGHT,
+ KEY_MOVE_RIGHT_SLOWLY,
+ KEY_UP,
+ KEY_UP_SLOWLY,
+ KEY_DOWN,
+ KEY_DOWN_SLOWLY,
+ KEY_MOVE_CAMERA_LEFT,
+ KEY_MOVE_CAMERA_RIGHT,
+ KEY_MOVE_CAMERA_UP,
+ KEY_MOVE_CAMERA_DOWN,
+ KEY_JUMP,
+ KEY_HIGH_JUMP,
+ KEY_BACK_JUMP,
+ KEY_SHOOT,
+ KEY_CHANGE_WEAPON,
+ KEY_WEAPON_1,
+ KEY_WEAPON_2,
+ KEY_WEAPON_3,
+ KEY_WEAPON_4,
+ KEY_WEAPON_5,
+ KEY_WEAPON_6,
+ KEY_WEAPON_7,
+ KEY_WEAPON_8,
+ KEY_WEAPON_9,
+ KEY_WEAPON_LESS,
+ KEY_WEAPON_MORE,
KEY_NEXT_CHARACTER,
KEY_MENU_OPTIONS_FROM_GAME,
KEY_MINIMAP_FROM_GAME,
--
1.6.0.4
_______________________________________________
Wormux-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wormux-dev