completed ffi-based input handling for device