bool RPiCamera::applySetting(unsigned int id, int value) { debug << "RPiCamera: Trying: " << controlName(id) << " -> " << value << std::endl; struct v4l2_queryctrl queryctrl; queryctrl.id = id; if(ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl) < 0) return false; if(queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) return false; // not available if(queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN && queryctrl.type != V4L2_CTRL_TYPE_INTEGER && queryctrl.type != V4L2_CTRL_TYPE_MENU) return false; // not supported // clip value if(value < queryctrl.minimum) value = queryctrl.minimum; if(value > queryctrl.maximum) value = queryctrl.maximum; struct v4l2_control control_s; control_s.id = id; control_s.value = value; if(ioctl(fd, VIDIOC_S_CTRL, &control_s) < 0) return false; debug << "RPiCamera: Apply: " << controlName(id) << " -> " << value << " (" << queryctrl.minimum << "," << queryctrl.maximum << "," << queryctrl.default_value << ")" << std::endl; return true; }
void Container::addControls(Theme* theme, Properties* properties) { GP_ASSERT(theme); GP_ASSERT(properties); // Add all the controls to this container. Properties* controlSpace = properties->getNextNamespace(); while (controlSpace != NULL) { Control* control = NULL; const char* controlStyleName = controlSpace->getString("style"); Theme::Style* controlStyle = NULL; if (controlStyleName) { controlStyle = theme->getStyle(controlStyleName); } else { Theme::Style::Overlay* overlay = Theme::Style::Overlay::create(); controlStyle = new Theme::Style(theme, "", 1.0f / theme->_texture->getWidth(), 1.0f / theme->_texture->getHeight(), Theme::Margin::empty(), Theme::Border::empty(), overlay, overlay, overlay, overlay); } std::string controlName(controlSpace->getNamespace()); std::transform(controlName.begin(), controlName.end(), controlName.begin(), (int(*)(int))toupper); if (controlName == "LABEL") { control = Label::create(controlStyle, controlSpace); } else if (controlName == "BUTTON") { control = Button::create(controlStyle, controlSpace); } else if (controlName == "CHECKBOX") { control = CheckBox::create(controlStyle, controlSpace); } else if (controlName == "RADIOBUTTON") { control = RadioButton::create(controlStyle, controlSpace); } else if (controlName == "CONTAINER") { control = Container::create(controlStyle, controlSpace, theme); } else if (controlName == "SLIDER") { control = Slider::create(controlStyle, controlSpace); } else if (controlName == "TEXTBOX") { control = TextBox::create(controlStyle, controlSpace); } else if (controlName == "JOYSTICK") { control = Joystick::create(controlStyle, controlSpace); } else { GP_ERROR("Failed to create control; unrecognized control name '%s'.", controlName.c_str()); } // Add the new control to the form. if (control) { addControl(control); if (control->getZIndex() == -1) { control->setZIndex(_zIndexDefault++); } } // Get the next control. controlSpace = properties->getNextNamespace(); } // Sort controls by Z-Order. std::sort(_controls.begin(), _controls.end(), &sortControlsByZOrder); }