示例#1
0
void basic_handler::handle_event(const SDL_Event& event)
{

	switch (event.type) {
	case SDL_KEYDOWN:
	case SDL_KEYUP:
		// If we're in a dialog we only want to handle items that are explicitly
		// handled by the executor.
		// If we're not in a dialog we can call the regular key event handler.
		if (!gui::in_dialog()) {
			key_event(event,exec_);
		} else if (exec_ != nullptr) {
			event_execute(event,exec_);
		}
		break;
	case SDL_JOYBUTTONDOWN:
	case SDL_JOYBUTTONUP:
		if (!gui::in_dialog()) {
			jbutton_event(event,exec_);
		} else if (exec_ != nullptr) {
			event_execute(event,exec_);
		}
		break;
	case SDL_MOUSEBUTTONDOWN:
	case SDL_MOUSEBUTTONUP:
		if (!gui::in_dialog()) {
			mbutton_event(event,exec_);
		} else if (exec_ != nullptr) {
			event_execute(event,exec_);
		}
		break;
	}
}
示例#2
0
bool mac_node_receive(node_t *node, node_t *incoming_node, mac_pdu_t *pdu)
{
    rs_assert(pdu!= NULL);
    rs_assert(node != NULL);

    bool all_ok = event_execute(mac_event_pdu_receive, node, incoming_node, pdu);

    mac_pdu_destroy(pdu);

    return all_ok;
}
示例#3
0
bool mac_node_send(node_t *node, node_t *outgoing_node, uint16 type, void *sdu)
{
    rs_assert(node != NULL);

    mac_pdu_t *mac_pdu = mac_pdu_create(node->mac_info->address, outgoing_node != NULL ? outgoing_node->mac_info->address : "");
    mac_pdu_set_sdu(mac_pdu, type, sdu);

    if (!event_execute(mac_event_pdu_send, node, outgoing_node, mac_pdu)) {
        mac_pdu->sdu = NULL;
        mac_pdu_destroy(mac_pdu);

        return FALSE;
    }

    return TRUE;
}
示例#4
0
void key_event(const SDL_Event& event, command_executor* executor)
{
	if (!executor) return;
	event_execute(event,executor);
}
示例#5
0
void jhat_event(const SDL_Event& event, command_executor* executor)
{
	event_execute(event, executor);
}