diff --git a/doc/js-events.md b/doc/js-events.md index 2c37a3937d5..d415b668955 100644 --- a/doc/js-events.md +++ b/doc/js-events.md @@ -247,8 +247,3 @@ An event that is called whenever an alliance is broken. An event that is called from a script and synchronized with all other scripts and hosts to prevent desync from happening. Sync requests must be carefully validated to prevent cheating! - -## eventKeyPressed(meta, key) - -An event that is called whenever user presses a key in the game, not counting chat -or other pop-up user interfaces. The key values are currently undocumented. diff --git a/src/input/manager.cpp b/src/input/manager.cpp index b2424a1bfff..6f655391829 100644 --- a/src/input/manager.cpp +++ b/src/input/manager.cpp @@ -32,8 +32,8 @@ #include "../keybind.h" #include "../keyedit.h" #include "../display3d.h" // For playerPos -#include "../qtscript.h" // For triggerEventKeyPressed #include "../main.h" // For KeyMapPath +#include "lib/netplay/nettypes.h" // For NETisReplay() KeyMappings& InputManager::mappings() @@ -299,66 +299,4 @@ void InputManager::processMappings(const bool bAllowMouseWheelEvents) consumedInputs.insert(keyToProcess.keys.input); } } - - /* Script callback - find out what meta key was pressed */ - int pressedMetaKey = KEY_IGNORE; - - /* getLastMetaKey() can't be used here, have to do manually */ - if (keyDown(KEY_LCTRL)) - { - pressedMetaKey = KEY_LCTRL; - } - else if (keyDown(KEY_RCTRL)) - { - pressedMetaKey = KEY_RCTRL; - } - else if (keyDown(KEY_LALT)) - { - pressedMetaKey = KEY_LALT; - } - else if (keyDown(KEY_RALT)) - { - pressedMetaKey = KEY_RALT; - } - else if (keyDown(KEY_LSHIFT)) - { - pressedMetaKey = KEY_LSHIFT; - } - else if (keyDown(KEY_RSHIFT)) - { - pressedMetaKey = KEY_RSHIFT; - } - else if (keyDown(KEY_LMETA)) - { - pressedMetaKey = KEY_LMETA; - } - else if (keyDown(KEY_RMETA)) - { - pressedMetaKey = KEY_RMETA; - } - - /* Find out what keys were pressed */ - for (int i = 0; i < KEY_MAXSCAN; i++) - { - /* Skip meta keys */ - switch (i) - { - case KEY_LCTRL: - case KEY_RCTRL: - case KEY_LALT: - case KEY_RALT: - case KEY_LSHIFT: - case KEY_RSHIFT: - case KEY_LMETA: - case KEY_RMETA: - continue; - break; - } - - /* Let scripts process this key if it's pressed */ - if (keyPressed((KEY_CODE)i)) - { - triggerEventKeyPressed(pressedMetaKey, i); - } - } } diff --git a/src/qtscript.cpp b/src/qtscript.cpp index e8923b8235a..6b9bd77a23b 100644 --- a/src/qtscript.cpp +++ b/src/qtscript.cpp @@ -1695,20 +1695,6 @@ bool triggerEventSyncRequest(int from, int req_id, int x, int y, BASE_OBJECT *ps return true; } -//__ ## eventKeyPressed(meta, key) -//__ -//__ An event that is called whenever user presses a key in the game, not counting chat -//__ or other pop-up user interfaces. The key values are currently undocumented. -bool triggerEventKeyPressed(int meta, int key) -{ - ASSERT(scriptsReady, "Scripts not initialized yet"); - for (auto *instance : scripts) - { - instance->handle_eventKeyPressed(meta, key); - } - return true; -} - // ---- #define ALL_PLAYERS -1 diff --git a/src/qtscript.h b/src/qtscript.h index 87c30bcc0ff..1ccc3e736e9 100644 --- a/src/qtscript.h +++ b/src/qtscript.h @@ -155,7 +155,6 @@ bool triggerEventSelected(); bool triggerEventPlayerLeft(int player); bool triggerEventDesignCreated(DROID_TEMPLATE *psTemplate); bool triggerEventSyncRequest(int from, int req_id, int x, int y, BASE_OBJECT *psObj, BASE_OBJECT *psObj2); -bool triggerEventKeyPressed(int meta, int key); bool triggerEventAllianceOffer(uint8_t from, uint8_t to); bool triggerEventAllianceAccepted(uint8_t from, uint8_t to); bool triggerEventAllianceBroken(uint8_t from, uint8_t to); diff --git a/src/quickjs_backend.cpp b/src/quickjs_backend.cpp index 72b4d6ce899..8e57f6dd29e 100644 --- a/src/quickjs_backend.cpp +++ b/src/quickjs_backend.cpp @@ -655,12 +655,6 @@ class quickjs_scripting_instance : public wzapi::scripting_instance //__ cheating! //__ virtual bool handle_eventSyncRequest(int from, int req_id, int x, int y, const BASE_OBJECT *psObj, const BASE_OBJECT *psObj2) override; - - //__ ## eventKeyPressed(meta, key) - //__ - //__ An event that is called whenever user presses a key in the game, not counting chat - //__ or other pop-up user interfaces. The key values are currently undocumented. - virtual bool handle_eventKeyPressed(int meta, int key) override; }; // private QuickJS bureaucracy @@ -3036,7 +3030,6 @@ IMPL_EVENT_HANDLER(eventAllianceBroken, uint8_t, uint8_t) // MARK: Special input events IMPL_EVENT_HANDLER(eventSyncRequest, int, int, int, int, const BASE_OBJECT *, const BASE_OBJECT *) -IMPL_EVENT_HANDLER(eventKeyPressed, int, int) // ---------------------------------------------------------------------------------------- // Script functions diff --git a/src/wzapi.h b/src/wzapi.h index 58b2836e18a..3f7e1dc7b3e 100644 --- a/src/wzapi.h +++ b/src/wzapi.h @@ -546,12 +546,6 @@ namespace wzapi //__ cheating! //__ virtual bool handle_eventSyncRequest(int from, int req_id, int x, int y, const BASE_OBJECT *psObj, const BASE_OBJECT *psObj2) = 0; - - //__ ## eventKeyPressed(meta, key) - //__ - //__ An event that is called whenever user presses a key in the game, not counting chat - //__ or other pop-up user interfaces. The key values are currently undocumented. - virtual bool handle_eventKeyPressed(int meta, int key) SCRIPTING_EVENT_NON_REQUIRED }; enum class GlobalVariableFlags