Exemple #1
0
input_manager::t_input_event_list &input_manager::get_or_create_event_list(
    const std::string &action_descriptor, const std::string &context )
{
    // A new context is created in the event that the user creates a local
    // keymapping in a context that doesn't yet exist e.g. a context without
    // any pre-existing keybindings.
    t_actions &actions = action_contexts[context];

    // A new action is created in the event that the user creates a local
    // keymapping that masks a global one.
    if( actions.find( action_descriptor ) == actions.end() ) {
        action_attributes &attributes = actions[action_descriptor];
        attributes.name = get_default_action_name( action_descriptor );
        attributes.is_user_created = true;
    }

    return actions[action_descriptor].input_events;
}
Exemple #2
0
input_manager::t_input_event_list &input_manager::get_event_list(
    const std::string &action_descriptor, const std::string &context)
{
    const t_action_contexts::iterator action_context = action_contexts.find(context);
    if (action_context != action_contexts.end()) {
        // A new action is created in the event that the user creates a local
        // keymapping that masks a global one.
        t_actions &actions = action_context->second;
        if (actions.find(action_descriptor) == actions.end()) {
            action_attributes &attributes = actions[action_descriptor];
            attributes.name = get_default_action_name(action_descriptor);
            attributes.is_user_created = true;
        }

        return actions[action_descriptor].input_events;
    }
    static t_input_event_list empty;
    return empty;
}
Exemple #3
0
const action_attributes &input_manager::get_action_attributes(
    const std::string &action_id,
    const std::string context,
    bool *overwrites_default)
{

    if (context != default_context_id) {
        // Check if the action exists in the provided context
        t_action_contexts::const_iterator action_context = action_contexts.find(context);
        if (action_context != action_contexts.end()) {
            t_actions::const_iterator action = action_context->second.find(action_id);
            if (action != action_context->second.end()) {
                if(overwrites_default) {
                    *overwrites_default = true;
                }

                return action->second;
            }
        }
    }

    // If not, we use the default binding.
    if(overwrites_default) {
        *overwrites_default = false;
    }

    t_actions &default_action_context = action_contexts[default_context_id];
    const t_actions::const_iterator default_action = default_action_context.find(action_id);
    if (default_action == default_action_context.end()) {
        // A new action is created in the event that the requested action is
        // not in the keybindings configuration e.g. the entry is missing.
        default_action_context[action_id].name = get_default_action_name(action_id);
    }

    return default_action_context[action_id];
}