| 370 | } |
| 371 | |
| 372 | long |
| 373 | MainWindow::onSendOutputReport(FXObject *sender, FXSelector sel, void *ptr) |
| 374 | { |
| 375 | char buf[256]; |
| 376 | size_t data_len, len; |
| 377 | int textfield_len; |
| 378 | |
| 379 | memset(buf, 0x0, sizeof(buf)); |
| 380 | textfield_len = getLengthFromTextField(output_len); |
| 381 | data_len = getDataFromTextField(output_text, buf, sizeof(buf)); |
| 382 | |
| 383 | if (textfield_len < 0) { |
| 384 | FXMessageBox::error(this, MBOX_OK, "Invalid length", "Length field is invalid. Please enter a number in hex, octal, or decimal."); |
| 385 | return 1; |
| 386 | } |
| 387 | |
| 388 | if (textfield_len > sizeof(buf)) { |
| 389 | FXMessageBox::error(this, MBOX_OK, "Invalid length", "Length field is too long."); |
| 390 | return 1; |
| 391 | } |
| 392 | |
| 393 | len = (textfield_len)? textfield_len: data_len; |
| 394 | |
| 395 | int res = hid_write(connected_device, (const unsigned char*)buf, len); |
| 396 | if (res < 0) { |
| 397 | FXMessageBox::error(this, MBOX_OK, "Error Writing", "Could not write to device. Error reported was: %ls", hid_error(connected_device)); |
| 398 | } |
| 399 | |
| 400 | return 1; |
| 401 | } |
| 402 | |
| 403 | long |
| 404 | MainWindow::onSendFeatureReport(FXObject *sender, FXSelector sel, void *ptr) |