blob: 472e40c1a995e1e38216d2e900246ed0c83c2de0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
#include "xpad.h"
static int xpad_fd = 0;
/* The F-PAD has to be:
uint16_t fpad = 0x2; // CI flag
if (xpad_len()) {
fpad |= 1<<13; // variable length X-PAD
}
which is included by mot-encoder in the file/fifo
it generates
*/
int xpad_len() {
if (xpad_fd == 0) {
xpad_fd = open("/home/bram/dab/mot-slideshow.file", O_RDONLY);
if (xpad_fd < 0) {
perror("Failed to open xpad file");
exit(1);
}
}
return 1;
}
uint8_t xpad_byte(void) {
uint8_t dat;
assert(xpad_fd != 0);
ssize_t num_read = read(xpad_fd, &dat, 1);
if (num_read == 0) {
fprintf(stderr, "xpad rewind\n");
lseek(xpad_fd, 0, SEEK_SET);
num_read = read(xpad_fd, &dat, 1);
assert(num_read == 1);
}
return dat;
}
|