aboutsummaryrefslogtreecommitdiff
path: root/src/client/inputhandler.h
Commit message (Collapse)AuthorAge
* Game refactor [4/X]: keycache is now owned by InputHandlerLoic Blot2018-01-20
| | | | | | * Make InputHandler own the key cache * Add a helper function InputHandler::cancelPressed to avoid multiple similar calls in game.cpp * Move RandomInputHandler::step definition into cpp file
* Game refactor [3/X]: Move keycache to inputhandlerLoic Blot2018-01-20
|
* Game/Input refactor [1/X]: make RealInputHandler handle joystick inputs with ↵Loic Blot2018-01-20
| | | | | | | standard input Joystick input is a RealInputHandler only usage, make it intelligent and handle the joystick with keyboard direct. This permits to remove many getters in game which should be owned by RealInputHandler
* Move files to subdirectories (#6599)Vitaliy2017-11-08
| | | | * Move files around
* C++ modernize: Pragma once (#6264)Loïc Blot2017-08-17
| | | | * Migrate cpp headers to pragma once
* Cleanup various headers to reduce compilation times (#6255)Loïc Blot2017-08-16
| | | | * Cleanup various headers to reduce compilation times
* Modernize client code (#6250)Loïc Blot2017-08-15
| | | | | | | | * Various code style fixes * Use range based for loops * Use empty instead of empty objects * Use C++11 default keyword for trivial constructors and destructors * Drop some useless casts * Use emplace_back instead of push_back to improve performance of some vectors push
* Isolate irrlicht references and use a singleton (#6041)Loïc Blot2017-06-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add Device3D class which will contain IrrlichtDevice interface move getSupportedVideoDrivers to Device3D Add Device3D singleton & use it in various places Rename Device3D to Rendering engine & add helper functions to various device pointers More singleton work RenderingEngine owns draw_load_screen move draw functions to RenderingEngine Reduce IrrlichtDevice exposure and guienvironment RenderingEngine: Expose get_timer_time() to remove device from guiEngine Make irrlichtdevice & scene manager less exposed * Code style fixes * Move porting::getVideoDriverName, getVideoDriverFriendlyName, getDisplayDensity, getDisplaySize to RenderingEngine Fix XORG_USED macro -> RenderingEngine + create_engine_device from RenderingEngine constructor directly * enum paralax => enum parallax
* C++11 cleanup on constructors dir client (#6012)Vincent Glize2017-06-21
| | | | * C++11 cleanup on constructors dir client
* Move KeyList & InputHandler from game.h to client/inputhandler.h (#5752)Loïc Blot2017-05-13
| | | | | | | | | | * Move KeyList & InputHandler from game.h to client/inputhandler.h We have a header for inputs, move inputhandler class & related keylist object to it Also introduce a cpp file for MyEventReceiver::OnEvent function in inputhandler.h because a so huge function doesn't needs to be inlined * Pass clang-format on inputhandler.{cpp,h} (compatible)
* Initial Gamepad supportest312016-06-03
| | | | | | | Adds initial ingame gamepad support to minetest. Full Formspec support is not implemented yet and can be added by a later change.
* Tell irrlicht if we handle a key or not.est312016-05-26
| | | | | | | | | We can remove the function in MtNativeActivity now as it serves precisely that purpose: to tell irrlicht that we handled the esc key. TODO for later: * Perhaps try to find a more performant container than KeyList
* Refactor loggingShadowNinja2015-10-14
| | | | | | | | | - Add warning log level - Change debug_log_level setting to enumeration string - Map Irrlicht log events to MT log events - Encapsulate log_* functions and global variables into a class, Logger - Unify dstream with standard logging mechanism - Unify core.debug() with standard core.log() script API
* Misc. minor fixeskwolekr2015-07-10
|
* Use minetest logging facilities for irrlicht log outputShadowNinja2015-07-05
|
* main.cpp rework * Move ClientLauncher class to a dedicated file * ↵Loic Blot2015-02-12
ClientLauncher now owns print_video_modes and speed_tests functions (they are only called by him) * Move GameParams to shared/gameparams.h because it's shared between server and client and launcher need to know it * Move InputHandlers class to client/inputhandler.h * Cleanup includes
="hl opt">; } } luaL_typerror(L, ud, "MetaDataRef"); return NULL; } MetaDataRef* MetaDataRef::checkobject(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TUSERDATA); void *ud = luaL_checkudata_is_metadataref(L, narg); if (!ud) luaL_typerror(L, narg, "MetaDataRef"); return *(MetaDataRef**)ud; // unbox pointer } // Exported functions // contains(self, name) int MetaDataRef::l_contains(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); Metadata *meta = ref->getmeta(false); if (meta == NULL) return 0; lua_pushboolean(L, meta->contains(name)); return 1; } // get(self, name) int MetaDataRef::l_get(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); Metadata *meta = ref->getmeta(false); if (meta == NULL) return 0; std::string str; if (meta->getStringToRef(name, str)) { lua_pushlstring(L, str.c_str(), str.size()); return 1; } return 0; } // get_string(self, name) int MetaDataRef::l_get_string(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); Metadata *meta = ref->getmeta(false); if (meta == NULL) { lua_pushlstring(L, "", 0); return 1; } const std::string &str = meta->getString(name); lua_pushlstring(L, str.c_str(), str.size()); return 1; } // set_string(self, name, var) int MetaDataRef::l_set_string(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); size_t len = 0; const char *s = lua_tolstring(L, 3, &len); std::string str(s, len); Metadata *meta = ref->getmeta(!str.empty()); if (meta == NULL || str == meta->getString(name)) return 0; meta->setString(name, str); ref->reportMetadataChange(&name); return 0; } // get_int(self, name) int MetaDataRef::l_get_int(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); Metadata *meta = ref->getmeta(false); if (meta == NULL) { lua_pushnumber(L, 0); return 1; } const std::string &str = meta->getString(name); lua_pushnumber(L, stoi(str)); return 1; } // set_int(self, name, var) int MetaDataRef::l_set_int(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); int a = luaL_checkint(L, 3); std::string str = itos(a); Metadata *meta = ref->getmeta(true); if (meta == NULL || str == meta->getString(name)) return 0; meta->setString(name, str); ref->reportMetadataChange(&name); return 0; } // get_float(self, name) int MetaDataRef::l_get_float(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); Metadata *meta = ref->getmeta(false); if (meta == NULL) { lua_pushnumber(L, 0); return 1; } const std::string &str = meta->getString(name); lua_pushnumber(L, stof(str)); return 1; } // set_float(self, name, var) int MetaDataRef::l_set_float(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); float a = readParam<float>(L, 3); std::string str = ftos(a); Metadata *meta = ref->getmeta(true); if (meta == NULL || str == meta->getString(name)) return 0; meta->setString(name, str); ref->reportMetadataChange(&name); return 0; } // to_table(self) int MetaDataRef::l_to_table(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); Metadata *meta = ref->getmeta(true); if (meta == NULL) { lua_pushnil(L); return 1; } lua_newtable(L); ref->handleToTable(L, meta); return 1; } // from_table(self, table) int MetaDataRef::l_from_table(lua_State *L) { MAP_LOCK_REQUIRED; MetaDataRef *ref = checkobject(L, 1); int base = 2; ref->clearMeta(); if (!lua_istable(L, base)) { // No metadata lua_pushboolean(L, true); return 1; } // Create new metadata Metadata *meta = ref->getmeta(true); if (meta == NULL) { lua_pushboolean(L, false); return 1; } bool was_successful = ref->handleFromTable(L, base, meta); ref->reportMetadataChange(); lua_pushboolean(L, was_successful); return 1; } void MetaDataRef::handleToTable(lua_State *L, Metadata *meta) { lua_newtable(L); { const StringMap &fields = meta->getStrings(); for (const auto &field : fields) { const std::string &name = field.first; const std::string &value = field.second; lua_pushlstring(L, name.c_str(), name.size()); lua_pushlstring(L, value.c_str(), value.size()); lua_settable(L, -3); } } lua_setfield(L, -2, "fields"); } bool MetaDataRef::handleFromTable(lua_State *L, int table, Metadata *meta) { // Set fields lua_getfield(L, table, "fields"); if (lua_istable(L, -1)) { int fieldstable = lua_gettop(L); lua_pushnil(L); while (lua_next(L, fieldstable) != 0) { // key at index -2 and value at index -1 std::string name = readParam<std::string>(L, -2); size_t cl; const char *cs = lua_tolstring(L, -1, &cl); meta->setString(name, std::string(cs, cl)); lua_pop(L, 1); // Remove value, keep key for next iteration } lua_pop(L, 1); } return true; } // equals(self, other) int MetaDataRef::l_equals(lua_State *L) { MetaDataRef *ref1 = checkobject(L, 1); Metadata *data1 = ref1->getmeta(false); MetaDataRef *ref2 = checkobject(L, 2); Metadata *data2 = ref2->getmeta(false); if (data1 == NULL || data2 == NULL) lua_pushboolean(L, data1 == data2); else lua_pushboolean(L, *data1 == *data2); return 1; }