From 937872f98f0ed5897861fcaa4892d941ba91be9b Mon Sep 17 00:00:00 2001 From: wwwwwwzx Date: Sun, 2 Feb 2020 23:53:06 -0800 Subject: [PATCH] Configure with default delay & detach controller when disconnect --- README.md | 11 +++-------- UI/mainwindow.cpp | 5 ++++- nxcontroller_cfw.cpp | 9 +++++++++ nxcontroller_cfw.h | 2 ++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 334e824..98c01a9 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ [![Build status](https://ci.appveyor.com/api/projects/status/ecv4u4e0x18w9qfc?svg=true)](https://ci.appveyor.com/project/wwwwwwzx/nxcontroller) PC/Linux [![Build Status](https://travis-ci.com/wwwwwwzx/NXController.svg?branch=master)](https://travis-ci.com/wwwwwwzx/NXController) MacOS - - - ## Use keyboard to play Switch games ![](https://i.imgur.com/kqO9mKC.png) @@ -15,13 +12,11 @@ - Via wifi connection: [sys-botbase](https://github.com/olliz0r/sys-botbase) - Modified console only - Read and write memory - ![img](https://i.imgur.com/7xM4CQu.png) - - + ![img](https://i.imgur.com/7xM4CQu.png) ## Customize your button settings Default button configuration is the same as yuzu: ![](https://i.imgur.com/chgS50t.png) -## To do -- Add scripts for botting +## sys-botbase C# botting client +check https://github.com/kwsch/SysBot.NET diff --git a/UI/mainwindow.cpp b/UI/mainwindow.cpp index 73954eb..4920983 100644 --- a/UI/mainwindow.cpp +++ b/UI/mainwindow.cpp @@ -64,6 +64,7 @@ void MainWindow::on_B_Connect_clicked() { } else { if (!b.connect(ui->ipaddress->text())) return; + b.configuresleep(0, 50); // Default setting setMaximumHeight(210); setMinimumHeight(210); setting.setValue("settings/ip", ui->ipaddress->text()); @@ -79,8 +80,10 @@ void MainWindow::on_B_Connect_clicked() { void MainWindow::on_B_Disconnect_clicked() { if (ui->RB_Serial->isChecked()) c.close(); - else + else { + b.detachController(); b.close(); + } setMinimumHeight(135); setMaximumHeight(135); resize(380, 135); diff --git a/nxcontroller_cfw.cpp b/nxcontroller_cfw.cpp index 0ba4f8d..2c64dcc 100644 --- a/nxcontroller_cfw.cpp +++ b/nxcontroller_cfw.cpp @@ -45,6 +45,15 @@ void nxcontroller_cfw::release(QString button) { send("release " + button); } +void nxcontroller_cfw::detachController() { + send("detachController"); +} + +void nxcontroller_cfw::configuresleep(int mainLoopSleepTime, int buttonClickSleepTime) { + send("configure mainLoopSleepTime " + QString::number(mainLoopSleepTime)); + send("configure buttonClickSleepTime " + QString::number(buttonClickSleepTime)); +} + QString nxcontroller_cfw::tohex(short n) { return QString(n < 0 ? "-" : "") + "0x" + QString::number(abs(n), 16); } diff --git a/nxcontroller_cfw.h b/nxcontroller_cfw.h index 9bf7f92..b35475b 100644 --- a/nxcontroller_cfw.h +++ b/nxcontroller_cfw.h @@ -28,6 +28,8 @@ class nxcontroller_cfw { void press(QString button); void click(QString button); void release(QString button); + void detachController(); + void configuresleep(int mainLoopSleepTime, int buttonClickSleepTime); void LStick(short x, short y); void RStick(short x, short y); QString peek(uint offset, uint size);