Skip to content

Commit

Permalink
Make freenect_flags an actual flag enum
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Xiao <brx@cs.cmu.edu>
  • Loading branch information
nneonneo committed Sep 15, 2013
1 parent 6ab505f commit b5c9a1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/libfreenect.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ typedef enum {
FREENECT_AUTO_WHITE_BALANCE = 1 << 1,
FREENECT_RAW_COLOR = 1 << 4,
// registers to be written with 0 or 1
FREENECT_MIRROR_DEPTH = 0x0017,
FREENECT_MIRROR_VIDEO = 0x0047,
FREENECT_MIRROR_DEPTH = 1 << 16,
FREENECT_MIRROR_VIDEO = 1 << 17,
} freenect_flag;

/// Possible values for setting each `freenect_flag`
Expand Down
20 changes: 17 additions & 3 deletions src/flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,26 @@
// freenect_set_flag is the only function exposed in libfreenect.h
// The rest are available internally via #include flags.h

static int register_for_flag(int flag) {
switch(flag) {
case FREENECT_MIRROR_DEPTH:
return 0x17;
case FREENECT_MIRROR_VIDEO:
return 0x47;
default:
return -1;
}
}

int freenect_set_flag(freenect_device *dev, freenect_flag flag, freenect_flag_value value)
{
if (flag == FREENECT_MIRROR_DEPTH || flag == FREENECT_MIRROR_VIDEO)
return write_register(dev, flag, value);

if (flag >= (1<<16)) {
int reg = register_for_flag(flag);
if(reg < 0)
return -1;
return write_register(dev, reg, value);
}

uint16_t reg = read_cmos_register(dev, 0x0106);
if (reg < 0)
return reg;
Expand Down

0 comments on commit b5c9a1c

Please sign in to comment.