diff --git a/doomsday/engine/portable/include/b_main.h b/doomsday/engine/portable/include/b_main.h index 912a88dc92..cd55521cb5 100644 --- a/doomsday/engine/portable/include/b_main.h +++ b/doomsday/engine/portable/include/b_main.h @@ -32,6 +32,7 @@ #define DEFAULT_BINDING_CONTEXT_NAME "game" #define CONSOLE_BINDING_CONTEXT_NAME "console" #define UI_BINDING_CONTEXT_NAME "deui" +#define GLOBAL_BINDING_CONTEXT_NAME "global" void B_Register(void); void B_Init(void); @@ -40,6 +41,11 @@ boolean B_Delete(int bid); boolean B_Responder(ddevent_t* ev); void B_WriteToFile(FILE* file); +/** + * Enable the contexts for the initial state. + */ +void B_InitialContextActivations(void); + void B_BindDefaults(void); void B_BindGameDefaults(void); diff --git a/doomsday/engine/portable/src/b_main.c b/doomsday/engine/portable/src/b_main.c index 910d71d75c..95b34b2eb5 100644 --- a/doomsday/engine/portable/src/b_main.c +++ b/doomsday/engine/portable/src/b_main.c @@ -215,6 +215,13 @@ void B_Init(void) // UI doesn't let anything past it. B_AcquireAll(B_NewContext(UI_BINDING_CONTEXT_NAME), true); + + // Top-level context that is always active and overrides every other context. + // To be used only for system-level functionality. + bc = B_NewContext(GLOBAL_BINDING_CONTEXT_NAME); + bc->flags |= BCF_PROTECTED; + B_ActivateContext(bc, true); + /* B_BindCommand("joy-hat-angle3", "print {angle 3}"); B_BindCommand("joy-hat-center", "print center"); @@ -244,13 +251,34 @@ void B_Init(void) // Bind all the defaults for the engine only. B_BindDefaults(); - // Enable the contexts for the initial state. + B_InitialContextActivations(); +} + +void B_InitialContextActivations(void) +{ + int i; + + // Disable all contexts. + for(i = 0; i < B_ContextCount(); ++i) + { + B_ActivateContext(B_ContextByPos(i), false); + } + + // These are the contexts active by default. + B_ActivateContext(B_ContextByName(GLOBAL_BINDING_CONTEXT_NAME), true); B_ActivateContext(B_ContextByName(DEFAULT_BINDING_CONTEXT_NAME), true); + + if(Con_IsActive()) + { + B_ActivateContext(B_ContextByName(CONSOLE_BINDING_CONTEXT_NAME), true); + } } void B_BindDefaults(void) { // Engine's highest priority context: opening control panel, opening the console. + B_BindCommand("global:key-f11-down + key-alt-down", "releasemouse"); + B_BindCommand("global:key-f11-down", "togglefullscreen"); // Console bindings (when open). diff --git a/doomsday/engine/portable/src/dd_input.c b/doomsday/engine/portable/src/dd_input.c index fd21b29682..a22cdf4916 100644 --- a/doomsday/engine/portable/src/dd_input.c +++ b/doomsday/engine/portable/src/dd_input.c @@ -1054,10 +1054,10 @@ static void dispatchEvents(eventqueue_t* q, timespan_t ticLength) continue; } - if(UI_Responder(ddev)) continue; - if(Con_Responder(ddev)) continue; + if(UI_Responder(ddev)) continue; /// @todo: use the bindings system (deui context fallback) + if(Con_Responder(ddev)) continue; /// @todo refactor: use the bindings system - if(callGameResponders) + if(callGameResponders) /// @todo refactor: use the bindings system (chat context fallback) { // The game's normal responder only returns true if the bindings can't // be used (like when chatting). diff --git a/doomsday/engine/portable/src/dd_main.c b/doomsday/engine/portable/src/dd_main.c index 7207ad433e..f77414abdb 100644 --- a/doomsday/engine/portable/src/dd_main.c +++ b/doomsday/engine/portable/src/dd_main.c @@ -1109,6 +1109,8 @@ boolean DD_ChangeGame2(Game* game, boolean allowReload) P_ControlShutdown(); Con_Execute(CMDS_DDAY, "clearbindings", true, false); + B_BindDefaults(); + B_InitialContextActivations(); for(i = 0; i < DDMAXPLAYERS; ++i) { diff --git a/doomsday/plugins/common/src/g_controls.c b/doomsday/plugins/common/src/g_controls.c index 66e676a55e..40b091efe2 100644 --- a/doomsday/plugins/common/src/g_controls.c +++ b/doomsday/plugins/common/src/g_controls.c @@ -397,8 +397,6 @@ D_CMD(DefaultGameBinds) "bindevent shortcut:key-f9 quickload", "bindevent shortcut:key-f10 quit", //"bindevent shortcut:key-f11 togglegamma", - "bindevent shortcut:key-f11+key-alt-down releasemouse", - "bindevent shortcut:key-f11 togglefullscreen", "bindevent shortcut:key-print screenshot", "bindevent shortcut:key-f12 screenshot",