Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated FFI interface to match new interface. All tests run, some tests

fail.

Signed-off-by: Alex Weiss <algrs@cacography.net>
  • Loading branch information...
commit 1f24415207b6fbd73e1ef65e54133c8658c97e2c 1 parent 26396fa
@algrs authored
Showing with 48 additions and 6 deletions.
  1. +48 −6 wrappers/ruby/ffi-libfreenect/lib/ffi/freenect.rb
View
54 wrappers/ruby/ffi-libfreenect/lib/ffi/freenect.rb
@@ -74,6 +74,13 @@ module FFI::Freenect
:yuv_raw, YUV_RAW_SIZE,
:ir_10bit_packed, IR_10BIT_PACKED_SIZE )
+ RESOLUTION_LOW = 0
+ RESOLUTION_MEDIUM = 1
+ RESOLUTION_HIGH = 2
+
+ RESOLUTIONS = enum( :low, RESOLUTION_LOW,
+ :medium, RESOLUTION_MEDIUM,
+ :high, RESOLUTION_HIGH )
DEPTH_11BIT = 0
DEPTH_10BIT = 1
@@ -98,6 +105,13 @@ module FFI::Freenect
:limit, TILT_STATUS_LIMIT,
:moving, TILT_STATUS_MOVING)
+ DEVICE_MOTOR = 0x01
+ DEVICE_CAMERA = 0x02
+ DEVICE_AUDIO = 0x04
+
+ DEVICES = enum( :motor, DEVICE_MOTOR,
+ :camera, DEVICE_CAMERA,
+ :audio, DEVICE_AUDIO)
LOG_FATAL = 0
LOG_ERROR = 1
@@ -121,12 +135,29 @@ module FFI::Freenect
typedef :pointer, :freenect_device
typedef :pointer, :freenect_usb_context # actually a libusb_context
+ class FrameModeFormat < FFI::Union
+ layout :dummy, :int32,
+ :video_format, VIDEO_FORMATS,
+ :depth_format, DEPTH_FORMATS
+ end
+ class FrameMode < FFI::Struct
+ layout :reserved, :uint32,
+ :resolution, RESOLUTIONS,
+ :union, FrameModeFormat,
+ :bytes, :int32,
+ :width, :int16,
+ :height, :int16,
+ :data_bits_per_pixel, :int8,
+ :padding_bits_per_pixel, :int8,
+ :framerate, :int8,
+ :is_valid, :int8,
+ end
class RawTiltState < FFI::Struct
- layout :accelerometer_x, :int16_t,
- :accelerometer_y, :int16_t,
- :accelerometer_z, :int16_t,
- :tilt_angle, :int8_t,
+ layout :accelerometer_x, :int16,
+ :accelerometer_y, :int16,
+ :accelerometer_z, :int16,
+ :tilt_angle, :int8,
:tilt_status, TILT_STATUS_CODES
end
@@ -138,6 +169,7 @@ class RawTiltState < FFI::Struct
attach_function :freenect_set_log_callback, [:freenect_context, :freenect_log_cb], :void
attach_function :freenect_process_events, [:freenect_context], :int
attach_function :freenect_num_devices, [:freenect_context], :int
+ attach_function :freenect_select_subdevices, [:freenect_context, DEVICES], :void
attach_function :freenect_open_device, [:freenect_context, :freenect_device, :int], :int
attach_function :freenect_close_device, [:freenect_device], :int
attach_function :freenect_init, [:freenect_context, :freenect_usb_context], :int
@@ -146,8 +178,6 @@ class RawTiltState < FFI::Struct
attach_function :freenect_get_user, [:freenect_device], :pointer
attach_function :freenect_set_depth_callback, [:freenect_device, :freenect_depth_cb], :void
attach_function :freenect_set_video_callback, [:freenect_device, :freenect_video_cb], :void
- attach_function :freenect_set_depth_format, [:freenect_device, DEPTH_FORMATS], :int
- attach_function :freenect_set_video_format, [:freenect_device, VIDEO_FORMATS], :int
attach_function :freenect_set_depth_buffer, [:freenect_device, :void], :int
attach_function :freenect_set_video_buffer, [:freenect_device, :void], :int
attach_function :freenect_start_depth, [:freenect_device], :int
@@ -161,6 +191,18 @@ class RawTiltState < FFI::Struct
attach_function :freenect_set_led, [:freenect_device, LED_OPTIONS], :int
attach_function :freenect_get_mks_accel, [RawTiltState, :pointer, :pointer, :pointer], :void
+ attach_function :freenect_get_video_mode_count, [], :int
+ attach_function :freenect_get_video_mode, [:int], FrameMode
+ attach_function :freenect_get_current_video_mode, [:freenect_device], FrameMode
+ attach_function :freenect_find_video_mode, [RESOLUTIONS, VIDEO_FORMATS], FrameMode
+ attach_function :freenect_set_video_mode, [:freenect_device, FrameMode], :int
+
+ attach_function :freenect_get_depth_mode_count, [], :int
+ attach_function :freenect_get_depth_mode, [:int], FrameMode
+ attach_function :freenect_get_current_depth_mode, [:freenect_device], FrameMode
+ attach_function :freenect_find_depth_mode, [RESOLUTIONS, DEPTH_FORMATS], FrameMode
+ attach_function :freenect_set_depth_mode, [:freenect_device, FrameMode], :int
+
attach_function :freenect_sync_get_video, [:pointer, :pointer, :int, VIDEO_FORMATS], :int
attach_function :freenect_sync_get_depth, [:pointer, :pointer, :int, DEPTH_FORMATS], :int
attach_function :freenect_sync_stop, [], :void
Please sign in to comment.
Something went wrong with that request. Please try again.