Beispiel #1
0
static void event_execute( const SDL_Event& event, command_executor* executor)
{
	if (!executor) return;
	const hotkey_ptr hk = get_hotkey(event);
	if (!hk->active() || hk->is_disabled()) {
		return;
	}

	bool press = event.type == SDL_KEYDOWN || event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN;

	execute_command(hotkey::get_hotkey_command(hk->get_command()), executor, -1, press);
	executor->set_button_state();
}
Beispiel #2
0
void add_hotkey(const hotkey_ptr item)
{

	if (item == hotkey_ptr()) {
		return;
	}

	scope_changer scope_ch;
	set_active_scopes(hotkey::get_hotkey_command(item->get_command()).scope);

	if (!hotkeys_.empty()) {
		hotkeys_.erase(
			std::remove_if(hotkeys_.begin(), hotkeys_.end(), [item](const hotkey::hotkey_ptr& hk) { return hk->bindings_equal(item); }),
			hotkeys_.end());
	}

	hotkeys_.push_back(item);

}
Beispiel #3
0
bool hotkey_base::bindings_equal(hotkey_ptr other)
{

	bool ret;

	if (other == hotkey_ptr()) {
		return false;
	}

	hk_scopes scopematch = hotkey::get_hotkey_command(get_command()).scope
			& hotkey::get_hotkey_command(other->get_command()).scope;

	if (scopematch.none()) {
		return false;
	}

	ret = mod_ == other->mod_ && bindings_equal_helper(other);

	return ret;
}