Skip to content

Commit 3752d75

Browse files
committed
Use log scale for rumble.
1 parent cbf3312 commit 3752d75

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

SerialPrograms/Source/Controllers/RumbleListener.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class RumbleWatcher : public ExternalInferenceCallback, public RumbleListener{
2323
// For now, the magnitudes are all over the place and inconsistent.
2424
// So the only thing this can really do is detect is *any* rumble is
2525
// happening. The magnitudes are trash.
26-
RumbleWatcher(ControllerType& controller, double magnitude_threshold = 10)
26+
RumbleWatcher(ControllerType& controller, double magnitude_threshold = 2)
2727
: ExternalInferenceCallback("RumbleWatcher")
2828
, m_controller(controller)
2929
, m_magnitude_threshold(magnitude_threshold)

SerialPrograms/Source/NintendoSwitch/Controllers/Joycon/NintendoSwitch_Joycon.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "Controllers/Joystick.h"
1212
#include "Controllers/ControllerTypes.h"
1313
#include "Controllers/Controller.h"
14-
#include "Controllers/RumbleListener.h"
1514
#include "NintendoSwitch/Controllers/NintendoSwitch_ControllerButtons.h"
1615

1716
namespace PokemonAutomation{

SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_OemController.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,19 @@ PABotBase2_OemController::PABotBase2_OemController(
190190
}
191191
if (!str_right.empty()){
192192
if (!str.empty()){
193-
str += ", ";
193+
str += " - ";
194194
}
195195
str += "Right = ";
196196
str += str_right;
197197
}
198198

199-
double magnitude =
200-
left.lo_amp * left.lo_freq + left.hi_amp * left.hi_freq +
201-
right.lo_amp * right.lo_freq + right.hi_amp * right.hi_freq;
199+
double energy =
200+
left.lo_amp * left.lo_freq * left.lo_freq +
201+
left.hi_amp * left.hi_freq * left.hi_freq +
202+
right.lo_amp * right.lo_freq * right.lo_freq +
203+
right.hi_amp * right.hi_freq * right.hi_freq;
204+
205+
double magnitude = std::log10(energy + 1);
202206

203207
if (m_on_rumble){
204208
m_on_rumble(magnitude);

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
#include "CommonTools/OCR/OCR_RawPaddleOCR.h"
174174
#include "CommonTools/Images/ImageTools.h"
175175
#include "PokemonFRLG/Inference/PokemonFRLG_BattleSelectionArrowDetector.h"
176+
#include "Controllers/RumbleListener.h"
176177

177178

178179

0 commit comments

Comments
 (0)