Skip to content

Commit

Permalink
fixed device renaming in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Reksotiv committed Nov 4, 2020
1 parent 3ec8dae commit 0d2dd5b
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 834 deletions.
849 changes: 34 additions & 815 deletions FreeJoyQt.pro.user

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion centered_cbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ void CenteredCBox::paintEvent (QPaintEvent * event)
}

QFontMetricsF font_metric(property("font").value<QFont>());
option.rect.setLeft(option.rect.center().x() - arrow_width/2.5 - font_metric.width(option.currentText)/2);
option.rect.setLeft(option.rect.center().x() - arrow_width/2.5f - font_metric.width(option.currentText)/2);
painter.drawControl(QStyle::CE_ComboBoxLabel, option);
}
15 changes: 14 additions & 1 deletion hiddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void HidDevice::ReadConfigFromDevice(uint8_t *buffer)
config_request_buffer[1] += 1;
hid_write(handle_read, config_request_buffer, 2);
report_count++;

qDebug()<<"Config"<<report_count<<"received";
if (config_request_buffer[1] > CONFIG_COUNT)
{
break;
Expand All @@ -198,6 +198,12 @@ void HidDevice::ReadConfigFromDevice(uint8_t *buffer)
}
}
qDebug()<<"read report_count ="<<report_count<<"/"<<CONFIG_COUNT;
if (report_count == CONFIG_COUNT){
qDebug() << "All config received";
} else {
qDebug() << "ERROR, not all config received";
}

if (report_count == CONFIG_COUNT) {
current_work_ = REPORT_ID_JOY;
emit configReceived(true);
Expand Down Expand Up @@ -247,6 +253,7 @@ void HidDevice::WriteConfigToDevice(uint8_t *buffer)

hid_write(handle_read, config_out_buffer, BUFFSIZE);
report_count++;
qDebug()<<"Config"<<report_count<<"sent";

if (buffer[1] == CONFIG_COUNT){
break;
Expand All @@ -267,6 +274,12 @@ void HidDevice::WriteConfigToDevice(uint8_t *buffer)
}
}
qDebug()<<"write report_count ="<<report_count<<"/"<<CONFIG_COUNT;
if (report_count == CONFIG_COUNT){
qDebug() << "All config sent";
} else {
qDebug() << "ERROR, not all config sent";
}

if (report_count == CONFIG_COUNT) {
current_work_ = REPORT_ID_JOY;
emit configSent(true);
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);

// global
QString app_version = "0.5.1"; // тупо, надо в дефайне?
QString app_version = "0.5.2"; // тупо, надо в дефайне?
QSettings app_settings( "FreeJoySettings.conf", QSettings::IniFormat );
DeviceConfig device_config;

Expand Down
12 changes: 11 additions & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ border-bottom: 1px solid rgb(190, 190, 190);
<property name="geometry">
<rect>
<x>410</x>
<y>20</y>
<y>30</y>
<width>101</width>
<height>31</height>
</rect>
Expand Down Expand Up @@ -670,6 +670,16 @@ u
g</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>240</x>
<y>200</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
</widget>
</item>
Expand Down
30 changes: 15 additions & 15 deletions reportconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <cstring>
#include "reportconverter.h"

static int reportSuccess = 0;
//static int reportSuccess = 0;

void ReportConverter::GamepadReport( uint8_t * gamepad_buf)
{
Expand Down Expand Up @@ -208,13 +208,13 @@ std::vector<uint8_t> ReportConverter::SendConfigToDevice(uint8_t request_config_



if (config_in_cnt == 16) {
qDebug() << "All config sent";
reportSuccess = 0;
// } else if (config_in_cnt == 16) {
// qDebug() << "ERRRROORRR!!!!!!!!!!!!! \nERRRROORRR!!!!!!!!!!!!!\n" << "reportSuccess SEND= " << reportSuccess;
// reportSuccess = 0;
}
// if (config_in_cnt == 16) {
// qDebug() << "All config sent";
// reportSuccess = 0;
// // } else if (config_in_cnt == 16) {
// // qDebug() << "ERRRROORRR!!!!!!!!!!!!! \nERRRROORRR!!!!!!!!!!!!!\n" << "reportSuccess SEND= " << reportSuccess;
// // reportSuccess = 0;
// }

std::vector<uint8_t> vec_buf(64);
for(int i = 0; i < 64; ++i){
Expand Down Expand Up @@ -416,13 +416,13 @@ dev_config_t ReportConverter::GetConfigFromDevice(uint8_t * hid_buf)
break;
}

if (hid_buf[1] == 16)
{
//if (reportSuccess != 16) qDebug() << "ERRRROORRR!!!!!!!!!!!!! \nERRRROORRR!!!!!!!!!!!!!\n" << "reportSuccess = " << reportSuccess;
//else
qDebug() << "All config received";
reportSuccess = 0;
}
// if (hid_buf[1] == 16)
// {
// //if (reportSuccess != 16) qDebug() << "ERRRROORRR!!!!!!!!!!!!! \nERRRROORRR!!!!!!!!!!!!!\n" << "reportSuccess = " << reportSuccess;
// //else
// qDebug() << "All config received";
// reportSuccess = 0;
// }
return tmp_dev_config;
}

Expand Down
5 changes: 5 additions & 0 deletions widgets/advancedsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ void AdvancedSettings::WriteToConfig()
gEnv.pDeviceConfig->config.device_name[i] = '\0';
}
}
#ifdef Q_OS_WIN
// remove device name in registry
QString path("HKEY_CURRENT_USER\\System\\CurrentControlSet\\Control\\MediaProperties\\PrivateProperties\\Joystick\\OEM\\VID_0483&PID_%1");
QSettings(path.arg(ui->lineEdit_PID->text()), QSettings::NativeFormat).remove("OEMName");
#endif
// usb exchange period
gEnv.pDeviceConfig->config.exchange_period_ms = ui->spinBox_USBExchangePeriod->value();
}

0 comments on commit 0d2dd5b

Please sign in to comment.