Skip to content

Commit b36a72b

Browse files
committed
Bugfixes and changelog update
1 parent e0bfca8 commit b36a72b

File tree

3 files changed

+62
-9
lines changed

3 files changed

+62
-9
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
Most recent updates will appear first.
44
This is a summary of new features and bugfixes. Read the README to learn how to use the features mentioned here.
55

6+
## 3.6.1
7+
8+
Fixing all the stuff I broke.
9+
10+
### Bugfixes
11+
12+
* Fix crash on Simultaneous press
13+
* Fix crash on command action
14+
* Improve handling of overlaping sim press and diag press
15+
* Fix SCROLL_WHEEL stick mode
16+
617
## 3.6.0
718

819
New features, bugfixes and all around improvements!

JoyShockMapper/include/DigitalButton.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ enum class BtnState
2626
SimRelease,
2727
DiagPressMaster,
2828
DiagPressSlave,
29-
DiagRelease,
3029
DblPressStart,
3130
DblPressNoPress,
3231
DblPressNoPressTap,

JoyShockMapper/src/DigitalButton.cpp

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ class ActiveMappingState : public DigitalButtonState
355355
{
356356
Released rel{ e.pressTime, e.turboTime, e.holdTime };
357357
react(rel);
358-
delete _nextState;
359358
// Redirect change of state to the caller of the Sync
360359
if (e.nextState == nullptr)
361360
{
@@ -374,14 +373,14 @@ class ActiveMappingState : public DigitalButtonState
374373
pimpl()->_masterPress = nullptr;
375374
pimpl()->_keyToRelease = *e.activeMapping;
376375
pimpl()->_nameToRelease = e.nameToRelease;
377-
378376
}
379377
else // release diagonal
380378
{
381379
// DEBUG_LOG << "Button " << pimpl()->_id << " releases active diagonal\n";
382380
pimpl()->ClearKey();
383381
}
384382
pimpl()->_press_times = e.pressTime;
383+
delete _nextState;
385384
_nextState = e.nextState;
386385
}
387386
}
@@ -514,7 +513,7 @@ class NoPress : public DigitalButtonState
514513
{
515514
DigitalButtonState::react(e);
516515
pimpl()->_press_times = e.time_now;
517-
if (pimpl()->_mapping.hasSimMappings())
516+
if (pimpl()->_mapping.hasSimMappings() && pimpl()->GetPressDurationMS(e.time_now) < SettingsManager::getV<float>(SettingID::SIM_PRESS_WINDOW)->value())
518517
{
519518
changeState<WaitSim>();
520519
}
@@ -709,6 +708,35 @@ class WaitSim : public DigitalButtonState
709708
// Start counting time between two start presses
710709
changeState<DblPressStart>();
711710
}
711+
else if (pimpl()->_mapping.hasDiagMappings())
712+
{
713+
size_t counter = 0;
714+
optional<MapIterator> diag = nullopt;
715+
for (auto btn = pimpl()->_context->_getMatchingDiagBtn(pimpl()->_id, diag); btn;
716+
btn = pimpl()->_context->_getMatchingDiagBtn(pimpl()->_id, diag))
717+
{
718+
// DEBUG_LOG << "Button " << pimpl()->_id << " enables diagonal press with " << btn->_id << " who is in state " << btn->getCurrentStateName() << '\n';
719+
pimpl()->_masterPress = btn;
720+
pimpl()->_nameToRelease = pimpl()->_mapping.getDiagPressName((*diag)->first);
721+
pimpl()->_keyToRelease = (*diag)->second.value();
722+
Sync sync;
723+
sync.nameToRelease = pimpl()->_nameToRelease;
724+
sync.activeMapping = &*pimpl()->_keyToRelease;
725+
sync.pressTime = e.time_now;
726+
sync.holdTime = e.holdTime;
727+
sync.turboTime = e.turboTime;
728+
sync.dblPressWindow = e.dblPressWindow;
729+
sync.nextState = new DiagPressMaster();
730+
pimpl()->_masterPress->sendEvent(sync);
731+
++*diag;
732+
counter++;
733+
}
734+
735+
if (counter > 0)
736+
changeState<DiagPressSlave>();
737+
else
738+
changeState<BtnPress>();
739+
}
712740
else // Handle regular press mapping
713741
{
714742
changeState<BtnPress>();
@@ -756,6 +784,26 @@ class SimRelease : public DigitalButtonState
756784
changeState<NoPress>();
757785
pimpl()->ClearKey();
758786
}
787+
788+
REACT(Sync)
789+
final
790+
{
791+
if (e.nextState != nullptr && e.activeMapping != nullptr)
792+
{
793+
Released rel{ e.pressTime, e.turboTime, e.holdTime };
794+
react(rel);
795+
// Redirect change of state to the caller of the Sync
796+
797+
// Activate Diagonal
798+
// DEBUG_LOG << "Button " << pimpl()->_id << " enables active diagonal as master\n";
799+
pimpl()->_masterPress = nullptr;
800+
pimpl()->_keyToRelease = *e.activeMapping;
801+
pimpl()->_nameToRelease = e.nameToRelease;
802+
pimpl()->_press_times = e.pressTime;
803+
delete _nextState;
804+
_nextState = e.nextState;
805+
}
806+
}
759807
};
760808

761809

@@ -810,11 +858,6 @@ class DiagPressSlave : public DigitalButtonState
810858
}
811859
};
812860

813-
class DiagRelease : public DigitalButtonState
814-
{
815-
DB_CONCRETE_STATE(DiagRelease)
816-
};
817-
818861
class DblPressStart : public pocket_fsm::NestedStateMachine<ActiveMappingState, DigitalButtonState>
819862
{
820863
DB_CONCRETE_STATE(DblPressStart)

0 commit comments

Comments
 (0)