Made dll reloading fallback work on linux and added default keybindings

dev
shariq 8 years ago
parent 73107e244c
commit 62639d9689
  1. 14
      README.md
  2. 9
      build/genie.lua
  3. 8
      src/game/main.c
  4. 67
      src/libsymmetry/input.c

@ -10,7 +10,7 @@
- ### Entity - ### Entity
```.conf ```
# Comment, Sample entity definition in file, paremeters left out are set to defaults # Comment, Sample entity definition in file, paremeters left out are set to defaults
# Empty line at the end specifies end of entity definition # Empty line at the end specifies end of entity definition
entity: "Something" entity: "Something"
@ -27,7 +27,7 @@
- Add to_string functions for major structs like transform, model etc to ease in conversion? - Add to_string functions for major structs like transform, model etc to ease in conversion?
- ### Configuration Variables a.k.a cfg-vars - ### Configuration Variables a.k.a cfg-vars
```.conf ```
# Comment # Comment
render_width: 1024 render_width: 1024
render_height: 1024 render_height: 1024
@ -43,7 +43,7 @@
- ### Keybindings - ### Keybindings
```.conf ```
# All keys are parsed by comparing the output of SDL_GetKeyname # All keys are parsed by comparing the output of SDL_GetKeyname
# Each line represents a keybinding # Each line represents a keybinding
Move_Forward: W Move_Forward: W
@ -149,8 +149,6 @@
- ## TODO - ## TODO
- Add file copy and delete to platform api
- Make dll reloading workaround compatilble on linux
- Find a solution for the asset import/export situation by either updating the blender exporter or adding assimp as dependancy - Find a solution for the asset import/export situation by either updating the blender exporter or adding assimp as dependancy
- Fix bugs with sound sources not updating - Fix bugs with sound sources not updating
- Add creating distributable build and uploading to itch.io account support to GENie under windows and linux. - Add creating distributable build and uploading to itch.io account support to GENie under windows and linux.
@ -294,8 +292,7 @@
* Fix frustum culling sometimes not working * Fix frustum culling sometimes not working
* Compile and test on windows * Compile and test on windows
* Fix mouse bugs * Fix mouse bugs
* Fix * Fix issues with opengl context showing 2.1 only
* issues with opengl context showing 2.1 only
* Improve this readme * Improve this readme
* Replace orgfile with simple text readme and reduce duplication * Replace orgfile with simple text readme and reduce duplication
* Fix camera acting all weird when right click is held * Fix camera acting all weird when right click is held
@ -308,3 +305,6 @@
* Implemented file copy and file delete on windows and linux. * Implemented file copy and file delete on windows and linux.
* Implemented a work-around for dll locking on windows by creating a copy of the game lib at launch and when reloading, * Implemented a work-around for dll locking on windows by creating a copy of the game lib at launch and when reloading,
unloading the current dll, deleting it and creating new copy of the updated dll and loading that unloading the current dll, deleting it and creating new copy of the updated dll and loading that
* Added file copy and delete to platform api
* Made dll reloading workaround compatilble on linux
* Default keybindings as fallback

@ -8,7 +8,7 @@ solution "Symmetry"
configuration {"linux"} configuration {"linux"}
postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets debug/assets"} postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets debug/assets"}
postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets release/assets"} postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets release/assets"}
buildoptions {"-Wall", "-std=c99"} buildoptions {"-Wall", "-std=c99", "`pkg-config --cflags-only-I sdl2`"}
configuration {"windows", "gmake"} configuration {"windows", "gmake"}
postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets debug/assets"} postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets debug/assets"}
@ -118,13 +118,16 @@ solution "Symmetry"
------------------------- -------------------------
project "Library" project "Library"
kind "SharedLib" kind "SharedLib"
targetname "libSymmetry"
language "C" language "C"
targetname "Symmetry"
defines {"GAME_LIB"} defines {"GAME_LIB"}
files { "../src/common/**.c", "../src/common/**.h", "../src/libsymmetry/**.h", "../src/libsymmetry/**.c" } files { "../src/common/**.c", "../src/common/**.h", "../src/libsymmetry/**.h", "../src/libsymmetry/**.c" }
configuration {"windows", "gmake"} configuration {"windows or linux", "gmake"}
buildoptions {"`pkg-config --cflags-only-I sdl2`"} buildoptions {"`pkg-config --cflags-only-I sdl2`"}
configuration "windows"
targetname "libSymmetry"
configuration "Debug" configuration "Debug"
defines {"GL_DEBUG_CONTEXT", "AL_DEBUG"} defines {"GL_DEBUG_CONTEXT", "AL_DEBUG"}

@ -12,8 +12,10 @@
static struct Platform_Api platform_api; static struct Platform_Api platform_api;
static struct Window* window = NULL; static struct Window* window = NULL;
static bool reload_game = false; static bool reload_game = false;
#if defined(__MSC_VER)
static const char* lib_name = "libSymmetry.dll"; static const char* lib_name = "libSymmetry.dll";
static const char* lib_copy_name = "libSymmetry.copy.dll"; static const char* lib_copy_name = "libSymmetry.copy.dll";
#endif
void* game_lib_handle = NULL; void* game_lib_handle = NULL;
struct Game_Api game; struct Game_Api game;
@ -128,11 +130,13 @@ int main(int argc, char** args)
game_lib_handle = NULL; game_lib_handle = NULL;
game.cleanup = NULL; game.cleanup = NULL;
game.init = NULL; game.init = NULL;
#if defined(_MSC_VER)
if(!io_file_delete(DIRT_EXECUTABLE, lib_copy_name)) if(!io_file_delete(DIRT_EXECUTABLE, lib_copy_name))
{ {
done = true; done = true;
continue; continue;
} }
#endif
} }
if(!game_lib_load()) if(!game_lib_load())
@ -225,6 +229,7 @@ void game_lib_reload(void)
bool game_lib_load(void) bool game_lib_load(void)
{ {
#if defined(__MSC_VER)
if(!io_file_copy(DIRT_EXECUTABLE, lib_name, lib_copy_name)) if(!io_file_copy(DIRT_EXECUTABLE, lib_name, lib_copy_name))
{ {
log_error("main:game_lib_load", "Failed to copy dll"); log_error("main:game_lib_load", "Failed to copy dll");
@ -232,6 +237,9 @@ bool game_lib_load(void)
} }
game_lib_handle = platform_load_library("libSymmetry.copy"); game_lib_handle = platform_load_library("libSymmetry.copy");
#else
game_lib_handle = platform_load_library("Symmetry");
#endif
if(!game_lib_handle) if(!game_lib_handle)
{ {
log_error("main:game_lib_load", "Failed to load game library"); log_error("main:game_lib_load", "Failed to load game library");

@ -45,36 +45,37 @@ void input_init(void)
} }
} }
/* struct Key_Combination forward_keys[2] = {{KEY_W, KMD_NONE}, {KEY_UP, KMD_ALT | KMD_SHIFT}}; */ /* Default keys for fallback */
/* struct Key_Combination backward_keys[2] = {{KEY_S, KMD_NONE}, {KEY_DOWN, KMD_NONE}}; */ struct Key_Combination forward_keys[2] = {{KEY_W, KMD_NONE}, {KEY_UP, KMD_ALT | KMD_SHIFT}};
/* struct Key_Combination up_keys[2] = {KEY_Q}; */ struct Key_Combination backward_keys[2] = {{KEY_S, KMD_NONE}, {KEY_DOWN, KMD_NONE}};
/* struct Key_Combination down_keys[2] = {KEY_E}; */ struct Key_Combination up_keys[2] = {{KEY_Q}};
/* struct Key_Combination left_keys[2] = {KEY_A, KEY_LEFT}; */ struct Key_Combination down_keys[2] = {{KEY_E}};
/* struct Key_Combination right_keys[2] = {KEY_D, KEY_RIGHT}; */ struct Key_Combination left_keys[2] = {{KEY_A}, {KEY_LEFT}};
/* struct Key_Combination turn_right_keys[1] = {KEY_L}; */ struct Key_Combination right_keys[2] = {{KEY_D}, {KEY_RIGHT}};
/* struct Key_Combination turn_left_keys[1] = {KEY_J}; */ struct Key_Combination turn_right_keys[1] = {{KEY_L}};
/* struct Key_Combination turn_up_keys[1] = {KEY_I}; */ struct Key_Combination turn_left_keys[1] = {{KEY_J}};
/* struct Key_Combination turn_down_keys[1] = {KEY_K}; */ struct Key_Combination turn_up_keys[1] = {{KEY_I}};
/* struct Key_Combination sprint_keys[2] = {KEY_LSHIFT, KEY_RSHIFT}; */ struct Key_Combination turn_down_keys[1] = {{KEY_K}};
/* struct Key_Combination recompute_keys[2] = {KEY_F5, KEY_H}; */ struct Key_Combination sprint_keys[2] = {{KEY_LSHIFT}, {KEY_RSHIFT}};
/* struct Key_Combination ed_toggle_keys[1] = {KEY_F1}; */ struct Key_Combination ed_toggle_keys[1] = {{KEY_F1}};
/* struct Key_Combination win_fullscr_keys[1] = {KEY_F11}; */ struct Key_Combination win_fullscr_keys[1] = {{KEY_F11}};
/* struct Key_Combination win_max_keys[1] = {KEY_F12}; */ struct Key_Combination win_max_keys[1] = {{KEY_F12}};
/* input_map_create("Move_Forward", forward_keys, 2); */ struct Key_Combination reload_game_keys[1] = {{KEY_F5}};
/* input_map_create("Move_Backward", backward_keys, 2); */ input_map_create("Move_Forward", forward_keys, 2);
/* input_map_create("Move_Up", up_keys, 1); */ input_map_create("Move_Backward", backward_keys, 2);
/* input_map_create("Move_Down", down_keys, 1); */ input_map_create("Move_Up", up_keys, 1);
/* input_map_create("Move_Left", left_keys, 2); */ input_map_create("Move_Down", down_keys, 1);
/* input_map_create("Move_Right", right_keys, 2); */ input_map_create("Move_Left", left_keys, 2);
/* input_map_create("Turn_Right", turn_right_keys, 1); */ input_map_create("Move_Right", right_keys, 2);
/* input_map_create("Turn_Left", turn_left_keys, 1); */ input_map_create("Turn_Right", turn_right_keys, 1);
/* input_map_create("Turn_Up", turn_up_keys, 1); */ input_map_create("Turn_Left", turn_left_keys, 1);
/* input_map_create("Turn_Down", turn_down_keys, 1); */ input_map_create("Turn_Up", turn_up_keys, 1);
/* input_map_create("Sprint", sprint_keys, 2); */ input_map_create("Turn_Down", turn_down_keys, 1);
/* input_map_create("Recompute", recompute_keys, 2); */ input_map_create("Sprint", sprint_keys, 2);
/* input_map_create("Editor_Toggle", ed_toggle_keys, 1); */ input_map_create("Editor_Toggle", ed_toggle_keys, 1);
/* input_map_create("Window_Fullscreen", win_fullscr_keys, 1); */ input_map_create("Window_Fullscreen", win_fullscr_keys, 1);
/* input_map_create("Window_Maximize", win_max_keys, 1); */ input_map_create("Window_Maximize", win_max_keys, 1);
input_map_create("Reload_Game_Lib", reload_game_keys, 1);
} }
void input_cleanup(void) void input_cleanup(void)
@ -344,6 +345,7 @@ void input_map_create(const char* name, struct Key_Combination* keys, int num_ke
for(int i = 0; i < num_keys; i++) for(int i = 0; i < num_keys; i++)
{ {
struct Key_Combination* new_comb = array_grow(map->keys, struct Key_Combination); struct Key_Combination* new_comb = array_grow(map->keys, struct Key_Combination);
new_comb->mods = KMD_NONE;
*new_comb = keys[i]; *new_comb = keys[i];
log_message("Added new Key combination to input map : %s", name); log_message("Added new Key combination to input map : %s", name);
} }
@ -355,7 +357,10 @@ void input_map_create(const char* name, struct Key_Combination* keys, int num_ke
new_map->keys = array_new_cap(struct Key_Combination, num_keys); new_map->keys = array_new_cap(struct Key_Combination, num_keys);
new_map->state = KS_INACTIVE; new_map->state = KS_INACTIVE;
for(int i = 0; i < num_keys; i++) for(int i = 0; i < num_keys; i++)
new_map->keys[i] = keys[i]; {
new_map->keys[i].mods = KMD_NONE;
new_map->keys[i] = keys[i];
}
log_message("Created Input Map : %s", name); log_message("Created Input Map : %s", name);
} }
} }

Loading…
Cancel
Save