summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.cpp70
-rw-r--r--src/client.h2
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/game.cpp5
-rw-r--r--src/game.h1
-rw-r--r--src/gui/setup_other.cpp3
6 files changed, 81 insertions, 1 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 0f02375a1..85a224b41 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2768,3 +2768,73 @@ void Client::logVars()
logger->log("DATADIR2: %s", getenv("DATADIR2"));
#endif
}
+
+void Client::logEvent(const SDL_Event &event)
+{
+ switch (event.type)
+ {
+ case SDL_MOUSEMOTION:
+ logger->log("event: SDL_MOUSEMOTION: %d,%d,%d",
+ event.motion.state, event.motion.x, event.motion.y);
+ break;
+ case SDL_KEYDOWN:
+ logger->log("event: SDL_KEYDOWN: %d,%d,%d", event.key.state,
+ event.key.keysym.scancode, event.key.keysym.unicode);
+ break;
+ case SDL_KEYUP:
+ logger->log("event: SDL_KEYUP: %d,%d,%d", event.key.state,
+ event.key.keysym.scancode, event.key.keysym.unicode);
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ logger->log("event: SDL_MOUSEBUTTONDOWN: %d,%d,%d,%d",
+ event.button.button, event.button.state,
+ event.button.x, event.button.y);
+ break;
+ case SDL_MOUSEBUTTONUP:
+ logger->log("event: SDL_MOUSEBUTTONUP: %d,%d,%d,%d",
+ event.button.button, event.button.state,
+ event.button.x, event.button.y);
+ break;
+ case SDL_JOYAXISMOTION:
+ logger->log("event: SDL_JOYAXISMOTION: %d,%d,%d",
+ event.jaxis.which, event.jaxis.axis, event.jaxis.value);
+ break;
+ case SDL_JOYBALLMOTION:
+ logger->log("event: SDL_JOYBALLMOTION: %d,%d,%d,%d",
+ event.jball.which, event.jball.ball,
+ event.jball.xrel, event.jball.yrel);
+ break;
+ case SDL_JOYHATMOTION:
+ logger->log("event: SDL_JOYHATMOTION: %d,%d,%d", event.jhat.which,
+ event.jhat.hat, event.jhat.value);
+ break;
+ case SDL_JOYBUTTONDOWN:
+ logger->log("event: SDL_JOYBUTTONDOWN: %d,%d,%d",
+ event.jbutton.which, event.jbutton.button,
+ event.jbutton.state);
+ break;
+ case SDL_JOYBUTTONUP:
+ logger->log("event: SDL_JOYBUTTONUP: %d,%d,%d",
+ event.jbutton.which, event.jbutton.button,
+ event.jbutton.state);
+ break;
+ case SDL_QUIT:
+ logger->log("event: SDL_QUIT");
+ break;
+ case SDL_SYSWMEVENT:
+ logger->log("event: SDL_SYSWMEVENT");
+ break;
+ case SDL_VIDEORESIZE:
+ logger->log("event: SDL_VIDEORESIZE");
+ break;
+ case SDL_VIDEOEXPOSE:
+ logger->log("event: SDL_VIDEOEXPOSE");
+ break;
+ case SDL_USEREVENT:
+ logger->log("event: SDL_USEREVENT");
+ break;
+ default:
+ logger->log("event: other: %d", event.type);
+ break;
+ };
+}
diff --git a/src/client.h b/src/client.h
index a437ebb44..d684904af 100644
--- a/src/client.h
+++ b/src/client.h
@@ -314,6 +314,8 @@ public:
static bool checkPackets(const int type) A_WARN_UNUSED;
+ static void logEvent(const SDL_Event &event);
+
PacketLimit mPacketLimits[PACKET_SIZE + 1];
private:
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 57b87dafe..3744b3657 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -289,6 +289,7 @@ DefaultsData* getConfigDefaults()
#else
AddDEF("enableGamma", true);
#endif
+ AddDEF("logInput", false);
return configData;
}
diff --git a/src/game.cpp b/src/game.cpp
index 57b855a18..32201a85b 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -376,7 +376,8 @@ Game::Game():
mAdjustLevel(0),
mAdjustPerfomance(config.getBoolValue("adjustPerfomance")),
mLowerCounter(0),
- mPing(0)
+ mPing(0),
+ mLogInput(config.getBoolValue("logInput"))
{
touchManager.setInGame(true);
spellManager = new SpellManager;
@@ -932,6 +933,8 @@ void Game::handleInput()
while (SDL_PollEvent(&event))
{
BLOCK_START("Game::handleInput 2")
+ if (mLogInput)
+ Client::logEvent(event);
updateHistory(event);
checkKeys();
diff --git a/src/game.h b/src/game.h
index 353729091..27e3c72b3 100644
--- a/src/game.h
+++ b/src/game.h
@@ -139,6 +139,7 @@ class Game final
bool mAdjustPerfomance;
int mLowerCounter;
int mPing;
+ bool mLogInput;
static Game *mInstance;
};
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 0d6dc92ff..24b1837f9 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -229,6 +229,9 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
new SetupItemCheckBox(_("Enable OpenGL log"), "",
"debugOpenGL", this, "debugOpenGLEvent");
+ new SetupItemCheckBox(_("Enable input log"), "",
+ "logInput", this, "logInputEvent");
+
new SetupItemCheckBox(_("Low traffic mode"), "", "lowTraffic",
this, "lowTrafficEvent");