Exemplo n.º 1
0
inline lirc_t sync_rec_buffer(struct ir_remote * remote)
{
	int count;
	lirc_t deltas, deltap;

	count = 0;
	deltas = get_next_space(1000000);
	if (deltas == 0)
		return (0);

	if (last_remote != NULL && !is_rcmm(remote)) {
		while (!expect_at_least(last_remote, deltas, last_remote->min_remaining_gap)) {
			deltap = get_next_pulse(1000000);
			if (deltap == 0)
				return (0);
			deltas = get_next_space(1000000);
			if (deltas == 0)
				return (0);
			count++;
			if (count > REC_SYNC) {	/* no sync found,
						   let's try a diffrent remote */
				return (0);
			}
		}
		if (has_toggle_mask(remote)) {
			if (!expect_at_most(last_remote, deltas, last_remote->max_remaining_gap)) {
				remote->toggle_mask_state = 0;
				remote->toggle_code = NULL;
			}

		}
	}
	rec_buffer.sum = 0;
	return (deltas);
}
Exemplo n.º 2
0
//-------------------------------------------------------------------------
// This function is called by the LIRC daemon during the transform of a
// received code into an lirc event.
//
// It gets the global variable code (remote keypress code).
//
// It returns:
//	prep		Code prefix (zero for this LIRC driver)
//      codep		Code of keypress
//	postp		Trailing code (zero for this LIRC dirver)
//      repeat_flagp	True if the keypress is a repeated keypress
//      remaining_gapp	Extimated time gap remaining before next code?
//-------------------------------------------------------------------------
int accent_decode (struct ir_remote *remote,
                   ir_code *prep,
                   ir_code *codep,
                   ir_code *postp,
                   int *repeat_flagp,
                   lirc_t *remaining_gapp)
{
    LOGPRINTF(LOG_DEBUG, "Entering accent_decode(), code = %016llx\n",
              code);

    LOGPRINTF(LOG_DEBUG, "accent_decode() is calling map_code()");
    if (!map_code(remote, prep, codep, postp,
                  0, 0, ACCENT_CODE_LENGTH, code, 0, 0))
    {
        return(0);
    }

    // Check the time gap between the last keypress and this one.
    if (start.tv_sec - last.tv_sec >= 2) {
        // Gap of 2 or more seconds: this is not a repeated keypress.
        *repeat_flagp = 0;
        gap = 0;
    } else {
        // Calculate the time gap in microseconds.
        gap = (start.tv_sec - last.tv_sec) * 1000000 +
              (start.tv_usec - last.tv_usec);
        if(expect_at_most(remote, gap, remote->remaining_gap))
        {
            // The gap is shorter than a standard gap
            // (with relative or aboslute tolerance): this
            // is a repeated keypress.
            *repeat_flagp = 1;
        }
        else
        {
            // Standard gap: this is a new keypress.
            *repeat_flagp = 0;
        }
    }

    // Calculate extimated time gap remaining for the next code.
    if (is_const(remote)) {
        // The sum (signal_length + gap) is always constant
        // so the gap is shorter when the code is longer.
        if (remote->gap > signal_length) {
            *remaining_gapp = remote->gap - signal_length;
        } else {
            *remaining_gapp = 0;
        }
    } else {
        // The gap after the signal is always constant.
        // This is the case of Kanam Accent serial remote.
        *remaining_gapp = remote->gap;
    }

    LOGPRINTF(LOG_DEBUG, "Exiting accent_decode()");
    LOGPRINTF(LOG_DEBUG, "prep:                   %016llx\n", *prep);
    LOGPRINTF(LOG_DEBUG, "codep:                  %016llx\n", *codep);
    LOGPRINTF(LOG_DEBUG, "postp:                  %016llx\n", *postp);
    LOGPRINTF(LOG_DEBUG, "repeat_flagp:           %d\n",
              *repeat_flagp);
    LOGPRINTF(LOG_DEBUG, "code:                   %016llx\n", code);
    LOGPRINTF(LOG_DEBUG, "is_const(remote):       %d\n",
              is_const(remote));
    LOGPRINTF(LOG_DEBUG, "remote->gap:            %lu\n",
              (unsigned long) remote->gap);
    LOGPRINTF(LOG_DEBUG, "remote->remaining_gap:  %lu\n",
              (unsigned long) remote->remaining_gap);
    LOGPRINTF(LOG_DEBUG, "signal length:          %lu\n",
              (unsigned long) signal_length);
    LOGPRINTF(LOG_DEBUG, "gap:                    %lu\n",
              (unsigned long) gap);
    LOGPRINTF(LOG_DEBUG, "extim. remaining_gap:   %lu\n",
              (unsigned long) *remaining_gapp);

    return(1);
}