Skip to content

Commit

Permalink
#479 #496 Rework update, config download, LGS install
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Laurendeau committed May 2, 2018
1 parent 71740ac commit 6135522
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 30 deletions.
8 changes: 4 additions & 4 deletions Makedefs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GIMXCONFIGEDITOR_LDFLAGS = -L../shared/gimxconfigeditor \
$(GIMXTIMER_LDFLAGS) \
$(GIMXPOLL_LDFLAGS) \
$(GIMXCONTROLLER_LDFLAGS)
GIMXCONFIGUPDATER_LDFLAGS = -L../shared/gimxconfigupdater
GIMXCONFIGUPDATER_LDFLAGS = -L../shared/gimxdownloader -L../shared/gimxconfigupdater
GIMXCONTROLLER_LDFLAGS = -L../shared/gimxcontroller
GIMXLOG_LDFLAGS = -L../shared/gimxlog
GIMXHID_LDFLAGS = $(GIMXLOG_LDFLAGS) -L../shared/gimxhid
Expand All @@ -31,14 +31,14 @@ GIMXTIMER_LDFLAGS = $(GIMXLOG_LDFLAGS) -L../shared/gimxtimer
GIMXUHID_LDFLAGS = $(GIMXLOG_LDFLAGS) -L../shared/gimxuhid
GIMXUSB_LDFLAGS = $(GIMXLOG_LDFLAGS) -L../shared/gimxusb
GIMXGPP_LDFLAGS = $(GIMXLOG_LDFLAGS) -L../shared/gimxgpp
GIMXUPDATER_LDFLAGS = -L../shared/gimxupdater
GIMXUPDATER_LDFLAGS = -L../shared/gimxdownloader -L../shared/gimxupdater

GIMXCONFIGEDITOR_LDLIBS = -lgimxconfigeditor \
$(GIMXINPUT_LDLIBS) \
$(GIMXTIMER_LDLIBS) \
$(GIMXPOLL_LDLIBS) \
$(GIMXCONTROLLER_LDLIBS)
GIMXCONFIGUPDATER_LDLIBS = -lgimxconfigupdater
GIMXCONFIGUPDATER_LDLIBS = -lgimxdownloader -lgimxconfigupdater
GIMXCONTROLLER_LDLIBS = -lgimxcontroller
GIMXLOG_LDLIBS = -lgimxlog
GIMXHID_LDLIBS = $(GIMXLOG_LDLIBS) -lgimxhid
Expand All @@ -50,7 +50,7 @@ GIMXTIMER_LDLIBS = $(GIMXLOG_LDLIBS) -lgimxtimer
GIMXUHID_LDLIBS = $(GIMXLOG_LDLIBS) -lgimxuhid
GIMXUSB_LDLIBS = $(GIMXLOG_LDLIBS) -lgimxusb
GIMXGPP_LDLIBS = $(GIMXLOG_LDLIBS) -lgimxgpp
GIMXUPDATER_LDLIBS = -lgimxupdater
GIMXUPDATER_LDLIBS = -lgimxdownloader -lgimxupdater

ifeq ($(OS),Windows_NT)
GIMXINPUT_CPPFLAGS += `sdl2-config --cflags`
Expand Down
20 changes: 10 additions & 10 deletions core/include/haptic/common/ff_lg.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
#define USB_PRODUCT_ID_LOGITECH_FORMULA_YELLOW 0xc202 // no force feedback
#define USB_PRODUCT_ID_LOGITECH_FORMULA_GP 0xc20e // no force feedback
#define USB_PRODUCT_ID_LOGITECH_FORMULA_FORCE 0xc291 // i-force protocol
#define USB_PRODUCT_ID_LOGITECH_FORMULA_FORCE_GP 0xc293
#define USB_PRODUCT_ID_LOGITECH_DRIVING_FORCE 0xc294
#define USB_PRODUCT_ID_LOGITECH_MOMO_WHEEL 0xc295
#define USB_PRODUCT_ID_LOGITECH_DFP_WHEEL 0xc298
#define USB_PRODUCT_ID_LOGITECH_G25_WHEEL 0xc299
#define USB_PRODUCT_ID_LOGITECH_DFGT_WHEEL 0xc29a
#define USB_PRODUCT_ID_LOGITECH_G27_WHEEL 0xc29b
#define USB_PRODUCT_ID_LOGITECH_FORMULA_FORCE_GP 0xc293 // classic protocol
#define USB_PRODUCT_ID_LOGITECH_DRIVING_FORCE 0xc294 // classic protocol
#define USB_PRODUCT_ID_LOGITECH_MOMO_WHEEL 0xc295 // classic protocol
#define USB_PRODUCT_ID_LOGITECH_DFP_WHEEL 0xc298 // classic protocol
#define USB_PRODUCT_ID_LOGITECH_G25_WHEEL 0xc299 // classic protocol
#define USB_PRODUCT_ID_LOGITECH_DFGT_WHEEL 0xc29a // classic protocol
#define USB_PRODUCT_ID_LOGITECH_G27_WHEEL 0xc29b // classic protocol
#define USB_PRODUCT_ID_LOGITECH_WII_WHEEL 0xc29c // rumble only
#define USB_PRODUCT_ID_LOGITECH_MOMO_WHEEL2 0xca03
#define USB_PRODUCT_ID_LOGITECH_MOMO_WHEEL2 0xca03 // classic protocol
#define USB_PRODUCT_ID_LOGITECH_VIBRATION_WHEEL 0xca04 // rumble only
#define USB_PRODUCT_ID_LOGITECH_G920_WHEEL 0xc262 // hid++ protocol
#define USB_PRODUCT_ID_LOGITECH_G29_PC_WHEEL 0xc24f // not sure about this one...
#define USB_PRODUCT_ID_LOGITECH_G920_WHEEL 0xc262 // hid++ protocol only
#define USB_PRODUCT_ID_LOGITECH_G29_PC_WHEEL 0xc24f // classic protocol
#define USB_PRODUCT_ID_LOGITECH_G29_PS4_WHEEL 0xc260 // classic protocol with 1 byte offset

#define FF_LG_OUTPUT_REPORT_SIZE 7
Expand Down
19 changes: 13 additions & 6 deletions launcher/SetupManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ SetupManager::~SetupManager() {

}

static int progress_callback(void *clientp, Updater::UpdaterStatus status, double progress, double total) {
return ((SetupManager *) clientp)->onUpdateProgress(status, progress, total);
}

int SetupManager::onUpdateProgress(Updater::UpdaterStatus status, double progress, double total) {
wxString message;
switch (status) {
Expand Down Expand Up @@ -59,6 +55,11 @@ void SetupManager::cleanDownload() {
progressDialog = NULL;
}

#ifdef WIN32
static int progress_callback(void *clientp, Updater::UpdaterStatus status, double progress, double total) {
return ((SetupManager *) clientp)->onUpdateProgress(status, progress, total);
}

#define USB_VENDOR_ID_LOGITECH 0x046d

#define USB_PRODUCT_ID_LOGITECH_FORMULA_YELLOW 0xc202 // no force feedback
Expand Down Expand Up @@ -137,7 +138,7 @@ static s_device_manager_ids ids[] =

void SetupManager::run() {

std::set<std::pair<const char *, const char *>> managers;
std::set<std::pair<const char *, const char *> > managers;

struct ghid_device_info *devs, *cur_dev;

Expand Down Expand Up @@ -169,7 +170,8 @@ void SetupManager::run() {

ghid_exit();

for (auto it = managers.begin(); it != managers.end(); ++it) {
std::set<std::pair<const char *, const char *> >::iterator it;
for (it = managers.begin(); it != managers.end(); ++it) {
int answer = wxMessageBox(_("A device requires the following component: \n")
+ wxString(it->first, wxConvUTF8) + _("\nDownload and install?"), _("Confirm"), wxYES_NO);
if (answer == wxNO) {
Expand All @@ -187,3 +189,8 @@ void SetupManager::run() {
}

}
#else
void SetupManager::run() {

}
#endif
14 changes: 7 additions & 7 deletions shared/gimxdownloader/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ std::string Downloader::getProgress(double progress, double total) {
}

Downloader::Downloader() :
m_callback(NULL), m_clientp(NULL), m_progress(0), m_curl_handle(nullptr), m_lastUpdate(0) {
m_callback(NULL), m_clientp(NULL), m_progress(0), m_curl_handle(NULL), m_lastUpdate(0) {
curl_global_init (CURL_INIT_FLAGS);
}

Expand All @@ -54,14 +54,14 @@ Downloader::~Downloader() {

void Downloader::initCurlHandle(const std::string& url) {

if (m_curl_handle != nullptr) {
if (m_curl_handle != NULL) {
curl_easy_cleanup(m_curl_handle);
m_curl_handle = nullptr;
m_curl_handle = NULL;
}

m_curl_handle = curl_easy_init();

if (m_curl_handle != nullptr) {
if (m_curl_handle != NULL) {
struct curl_slist * headers = NULL;
headers = curl_slist_append(headers, "Accept: application/vnd.github.v3+json");
headers = curl_slist_append(headers, "Accept: */*");
Expand Down Expand Up @@ -124,7 +124,7 @@ Downloader::DownloaderStatus Downloader::download(const std::string& url, std::s

/* cleanup curl stuff */
curl_easy_cleanup(m_curl_handle);
m_curl_handle = nullptr;
m_curl_handle = NULL;

if (chunk.memory)
free(chunk.memory);
Expand Down Expand Up @@ -174,7 +174,7 @@ int Downloader::progress(double dlnow, double dltotal) {
}
}

time_t now = time(nullptr);
time_t now = time(NULL);

if (!forceProgress && now - m_lastUpdate < 1)
{
Expand Down Expand Up @@ -232,7 +232,7 @@ Downloader::DownloaderStatus Downloader::download(const std::string& url, const
CURLcode res = curl_easy_perform(m_curl_handle);

curl_easy_cleanup(m_curl_handle);
m_curl_handle = nullptr;
m_curl_handle = NULL;

fclose(outfile);

Expand Down
5 changes: 2 additions & 3 deletions shared/gimxupdater/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ Updater::UpdaterStatus Updater::update(std::string url, ProgressCallback callbac
return UpdaterStatusInstallFailed;
}

UpdaterStatus status = UpdaterStatusOk;

while (WaitForSingleObject(shExInfo.hProcess, 1000) == WAIT_TIMEOUT) {
if (clientCallback(clientData, UpdaterStatusInstallPending, 0, 0) != 0) {
status = UpdaterStatusCancelled;
Expand All @@ -154,6 +152,7 @@ Updater::UpdaterStatus Updater::update(std::string url, ProgressCallback callbac

CloseHandle(shExInfo.hProcess);
#else
(void)wait;
std::string cmd = "";
cmd.append("xdg-open ");
cmd.append(tempFile);
Expand All @@ -165,5 +164,5 @@ Updater::UpdaterStatus Updater::update(std::string url, ProgressCallback callbac
}
#endif

return status;
return UpdaterStatusOk;
}

0 comments on commit 6135522

Please sign in to comment.