mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-24 11:09:48 +02:00
feat(tui/wx): support pongo/dfu modes
This commit is contained in:
9 files changed
+84
-27
No files matched your search
@@ -73,6 +73,7 @@ struct ManagedDevice {
|
||||
bool normalPresent = false;
|
||||
bool recoveryPresent = false;
|
||||
bool dfuPresent = false;
|
||||
bool pongoPresent = false;
|
||||
hotplug_handle_t handle{};
|
||||
uint32_t device_id = 0;
|
||||
|
||||
@@ -279,6 +280,7 @@ static void handle_other_add(hotplug_handle_t handle, DeviceMode mode) {
|
||||
|
||||
m.recoveryPresent = (mode == DeviceMode::Recovery);
|
||||
m.dfuPresent = (mode == DeviceMode::DFU);
|
||||
m.pongoPresent = (mode == DeviceMode::Pongo);
|
||||
}
|
||||
publish_state();
|
||||
}
|
||||
@@ -304,6 +306,7 @@ static void remove_device(platform_service_t service, DeviceMode mode, uint32_t
|
||||
switch (mode) {
|
||||
case DeviceMode::Recovery: return pair.second.recoveryPresent;
|
||||
case DeviceMode::DFU: return pair.second.dfuPresent;
|
||||
case DeviceMode::Pongo: return pair.second.pongoPresent;
|
||||
default: return false;
|
||||
}
|
||||
});
|
||||
@@ -319,9 +322,11 @@ static void remove_device(platform_service_t service, DeviceMode mode, uint32_t
|
||||
m.recoveryPresent = false;
|
||||
} else if (mode == DeviceMode::DFU) {
|
||||
m.dfuPresent = false;
|
||||
} else if (mode == DeviceMode::Pongo) {
|
||||
m.pongoPresent = false;
|
||||
}
|
||||
|
||||
if (!m.normalPresent && !m.recoveryPresent && !m.dfuPresent) {
|
||||
if (!m.normalPresent && !m.recoveryPresent && !m.dfuPresent && !m.pongoPresent) {
|
||||
release_handle(m.handle);
|
||||
g_devices.erase(it);
|
||||
}
|
||||
@@ -419,6 +424,9 @@ static void hotplug_callback(hotplug_event_t event, hotplug_handle_t handle) {
|
||||
case HOTPLUG_EVENT_DFU_REMOVE: remove_device(srv, DeviceMode::DFU); break;
|
||||
case HOTPLUG_EVENT_RECOVERY_ADD: handle_other_add(handle, DeviceMode::Recovery); break;
|
||||
case HOTPLUG_EVENT_RECOVERY_REMOVE: remove_device(srv, DeviceMode::Recovery); break;
|
||||
case HOTPLUG_EVENT_PONGO_ADD: handle_other_add(handle, DeviceMode::Pongo); break;
|
||||
case HOTPLUG_EVENT_PONGO_REMOVE: remove_device(srv, DeviceMode::Pongo); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ enum class DeviceMode
|
||||
None,
|
||||
Normal,
|
||||
Recovery,
|
||||
DFU
|
||||
DFU,
|
||||
Pongo,
|
||||
};
|
||||
|
||||
struct DeviceState
|
||||
|
||||
@@ -35,15 +35,16 @@
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
|
||||
constexpr int32_t APPLE_VID = 0x05AC;
|
||||
constexpr int32_t PID_DFU = 0x1227;
|
||||
constexpr int32_t PID_RECOVERY_1 = 0x1280;
|
||||
constexpr int32_t PID_RECOVERY_2 = 0x1281;
|
||||
constexpr int32_t PID_RECOVERY_3 = 0x1282;
|
||||
constexpr int32_t PID_RECOVERY_4 = 0x1283;
|
||||
constexpr int32_t APPLE_VID = 0x05AC;
|
||||
constexpr int32_t PID_DFU = 0x1227;
|
||||
constexpr int32_t PID_RECOVERY_1 = 0x1280;
|
||||
constexpr int32_t PID_RECOVERY_2 = 0x1281;
|
||||
constexpr int32_t PID_RECOVERY_3 = 0x1282;
|
||||
constexpr int32_t PID_RECOVERY_4 = 0x1283;
|
||||
constexpr int32_t PID_PONGO = 0x4141;
|
||||
|
||||
static const std::vector<int32_t> TARGET_PIDS = {
|
||||
PID_DFU, PID_RECOVERY_1, PID_RECOVERY_2, PID_RECOVERY_3, PID_RECOVERY_4
|
||||
PID_DFU, PID_RECOVERY_1, PID_RECOVERY_2, PID_RECOVERY_3, PID_RECOVERY_4, PID_PONGO
|
||||
};
|
||||
|
||||
static hotplug_callback_t gUserCallback = nullptr;
|
||||
@@ -56,6 +57,9 @@ static hotplug_event_t get_hotplug_event(int32_t pid, bool arrived) {
|
||||
if (pid == PID_DFU) {
|
||||
return arrived ? HOTPLUG_EVENT_DFU_ADD : HOTPLUG_EVENT_DFU_REMOVE;
|
||||
}
|
||||
if (pid == PID_PONGO) {
|
||||
return arrived ? HOTPLUG_EVENT_PONGO_ADD : HOTPLUG_EVENT_PONGO_REMOVE;
|
||||
}
|
||||
return arrived ? HOTPLUG_EVENT_RECOVERY_ADD : HOTPLUG_EVENT_RECOVERY_REMOVE;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@ typedef enum {
|
||||
HOTPLUG_EVENT_DFU_ADD,
|
||||
HOTPLUG_EVENT_DFU_REMOVE,
|
||||
HOTPLUG_EVENT_RECOVERY_ADD,
|
||||
HOTPLUG_EVENT_RECOVERY_REMOVE
|
||||
HOTPLUG_EVENT_RECOVERY_REMOVE,
|
||||
HOTPLUG_EVENT_PONGO_ADD,
|
||||
HOTPLUG_EVENT_PONGO_REMOVE,
|
||||
} hotplug_event_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in new issue
Block a user