| 219 | } |
| 220 | |
| 221 | long |
| 222 | MainWindow::onConnect(FXObject *sender, FXSelector sel, void *ptr) |
| 223 | { |
| 224 | if (connected_device != NULL) |
| 225 | return 1; |
| 226 | |
| 227 | FXint cur_item = device_list->getCurrentItem(); |
| 228 | if (cur_item < 0) |
| 229 | return -1; |
| 230 | FXListItem *item = device_list->getItem(cur_item); |
| 231 | if (!item) |
| 232 | return -1; |
| 233 | struct hid_device_info *device_info = (struct hid_device_info*) item->getData(); |
| 234 | if (!device_info) |
| 235 | return -1; |
| 236 | |
| 237 | connected_device = hid_open_path(device_info->path); |
| 238 | |
| 239 | if (!connected_device) { |
| 240 | FXMessageBox::error(this, MBOX_OK, "Device Error", "Unable To Connect to Device"); |
| 241 | return -1; |
| 242 | } |
| 243 | |
| 244 | hid_set_nonblocking(connected_device, 1); |
| 245 | |
| 246 | getApp()->addTimeout(this, ID_TIMER, |
| 247 | 5 * timeout_scalar /*5ms*/); |
| 248 | |
| 249 | FXString s; |
| 250 | s.format("Connected to: %04hx:%04hx -", device_info->vendor_id, device_info->product_id); |
| 251 | s += FXString(" ") + device_info->manufacturer_string; |
| 252 | s += FXString(" ") + device_info->product_string; |
| 253 | connected_label->setText(s); |
| 254 | output_button->enable(); |
| 255 | feature_button->enable(); |
| 256 | get_feature_button->enable(); |
| 257 | connect_button->disable(); |
| 258 | disconnect_button->enable(); |
| 259 | input_text->setText(""); |
| 260 | |
| 261 | |
| 262 | return 1; |
| 263 | } |
| 264 | |
| 265 | long |
| 266 | MainWindow::onDisconnect(FXObject *sender, FXSelector sel, void *ptr) |
nothing calls this directly
no test coverage detected