diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index 95e9f834..e68dd203 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -30,6 +30,7 @@ #define LAN_EN 31 //#define DARK_STYLE "dark" +#define APP_NAME "DSView" //--------------------api--- diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 87a0da61..c8bc5c70 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -881,7 +881,7 @@ void MainWindow::on_search(bool visible) void MainWindow::on_screenShot() { AppConfig &app = AppConfig::Instance(); - QString default_name = app._userHistory.screenShotPath + "/DSView" + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss"); + QString default_name = app._userHistory.screenShotPath + "/" + APP_NAME + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss"); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QScreen *scr = QGuiApplication::primaryScreen(); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index adf1a5f4..094c446b 100755 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -1212,10 +1212,10 @@ void SigSession::hotplug_callback(void *ctx, void *dev, int event, void *user_da (void)dev; (void)user_data; - if (1 == event) { + if (USB_EV_HOTPLUG_ATTACH == event) { _session->_hot_attach = true; qDebug("receive event:DreamSourceLab Hardware attached!"); - }else if (2 == event) { + }else if (USB_EV_HOTPLUG_DETTACH == event) { _session->_hot_detach = true; qDebug("receive event:DreamSourceLab Hardware detached!"); }else{ diff --git a/libsigrok4DSL/backend.c b/libsigrok4DSL/backend.c index 156922f5..164c5b37 100755 --- a/libsigrok4DSL/backend.c +++ b/libsigrok4DSL/backend.c @@ -416,9 +416,15 @@ LIBUSB_CALL int sr_hotplug_callback(struct libusb_context *ctx, struct libusb_de return 0; } + int ev = USB_EV_HOTPLUG_UNKNOW; + if (event == (int)LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED) + ev = USB_EV_HOTPLUG_ATTACH; + else if (event == (int)LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT) + ev = USB_EV_HOTPLUG_DETTACH; + struct sr_context *user_ctx = (struct sr_context*)user_data; if (user_ctx->hotplug_callback != NULL){ - user_ctx->hotplug_callback(ctx, dev, (int)event, user_ctx->hotplug_user_data); + user_ctx->hotplug_callback(ctx, dev, ev, user_ctx->hotplug_user_data); } return 0; diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 47a3f97f..18807c7d 100755 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -174,6 +174,11 @@ enum { #define SR_PRIV #endif + +#define USB_EV_HOTPLUG_UNKNOW 0 +#define USB_EV_HOTPLUG_ATTACH 1 +#define USB_EV_HOTPLUG_DETTACH 2 + /** Data types used by sr_config_info(). */ enum {