static char* rec(struct ir_remote* remotes) { unsigned char rc_code; ssize_t size; struct timeval current; size = snd_hwdep_read(hwdep, &rc_code, 1); if (size < 1) return NULL; gettimeofday(¤t, NULL); last_code = code; code = (ir_code)rc_code; /* delay for repeating buttons is up to 320 ms */ repeat_flag = code == last_code && current.tv_sec - last_time.tv_sec <= 2 && time_elapsed(&last_time, ¤t) <= 350000; last_time = current; LOGPRINTF(1, "code: %llx", (__u64)code); LOGPRINTF(1, "repeat_flag: %d", repeat_flag); return decode_all(remotes); }
static int headset_volume_fromcard(struct s_headset *headset) { int len; char line[100]; len = snd_hwdep_read(headset->handle, headset->volumes, sizeof(headset->volumes)); if (len != sizeof(headset->volumes)) return 0; fprintf(stderr, "volume speaker: %d mic: %d\n", headset->volumes[0], headset->volumes[1]); if (headset->volumes[0] != headset->last_volumes[0]) { sprintf(line, "\r\n+VGS=%d\r\n", headset->volumes[0]); write(headset->rfcomm_fd, line, strlen(line)); headset->last_volumes[0] = headset->last_volumes[0]; } if (headset->volumes[1] != headset->last_volumes[1]) { sprintf(line, "\r\n+VGM=%d\r\n", headset->volumes[1]); write(headset->rfcomm_fd, line, strlen(line)); headset->last_volumes[1] = headset->last_volumes[1]; } return 1; }