Skip to content

Commit

Permalink
UI: Input - Added option to enable old SNES mouse movement
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed Jun 24, 2024
1 parent f429697 commit 6d020e0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Core/SNES/Input/SnesMouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ class SnesMouse : public BaseControlDevice
int32_t dx = mov.dx;
int32_t dy = mov.dy;

bool enableSmoothMouse = _emu->GetSettings()->GetInputConfig().EnableSmootherSnesMouse;
if(enableSmoothMouse) {
dx = mov.dx * (1 + _sensitivity);
dy = mov.dy * (1 + _sensitivity);
}

//These flags will maintain and report their last moved direction.
//It's a hardware quirk that the real mouse does. (unknown if any games rely on this)
if(dx != 0) { _leftFlag = dx < 0 ? 0x80 : 0; }
Expand All @@ -91,7 +97,7 @@ class SnesMouse : public BaseControlDevice
dx = std::min(std::abs(dx), 127);
dy = std::min(std::abs(dy), 127);

if(_sensitivity > 0) {
if(!enableSmoothMouse && _sensitivity > 0) {
dx = _sensitivityLut[_sensitivity - 1][std::min(7, dx)];
dy = _sensitivityLut[_sensitivity - 1][std::min(7, dy)];
}
Expand Down
1 change: 1 addition & 0 deletions Core/Shared/SettingTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ struct InputConfig
{
uint32_t ControllerDeadzoneSize = 2;
uint32_t MouseSensitivity = 1;
bool EnableSmootherSnesMouse;

InputDisplayPosition DisplayInputPosition = InputDisplayPosition::TopLeft;
bool DisplayInputPort[8] = { };
Expand Down
3 changes: 3 additions & 0 deletions UI/Config/InputConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class InputConfig : BaseConfig<InputConfig>
{
[Reactive] [MinMax(0, 4)] public UInt32 ControllerDeadzoneSize { get; set; } = 2;
[Reactive] [MinMax(0, 9)] public UInt32 MouseSensitivity { get; set; } = 5;
[Reactive] public bool EnableSmootherSnesMouse { get; set; } = false;
[Reactive] public bool HidePointerForLightGuns { get; set; } = false;

[Reactive] public InputDisplayPosition DisplayInputPosition { get; set; } = InputDisplayPosition.BottomRight;
Expand All @@ -37,6 +38,7 @@ public void ApplyConfig()
ConfigApi.SetInputConfig(new InteropInputConfig() {
ControllerDeadzoneSize = this.ControllerDeadzoneSize,
MouseSensitivity = this.MouseSensitivity,
EnableSmootherSnesMouse = this.EnableSmootherSnesMouse,
DisplayInputPosition = this.DisplayInputPosition,
DisplayInputPort1 = this.DisplayInputPort1,
DisplayInputPort2 = this.DisplayInputPort2,
Expand Down Expand Up @@ -221,6 +223,7 @@ public struct InteropInputConfig
{
public UInt32 ControllerDeadzoneSize;
public UInt32 MouseSensitivity;
[MarshalAs(UnmanagedType.I1)] public bool EnableSmootherSnesMouse;

public InputDisplayPosition DisplayInputPosition;
[MarshalAs(UnmanagedType.I1)] public bool DisplayInputPort1;
Expand Down
2 changes: 2 additions & 0 deletions UI/Localization/resources.en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@
<Control ID="lblDisplayPosition">Display position:</Control>
<Control ID="chkDisplayInputHorizontally">Horizontal display</Control>

<Control ID="tpgAdvanced">Advanced</Control>
<Control ID="chkHidePointerForLightGuns">Hide mouse pointer when using light guns</Control>
<Control ID="chkEnableSmootherSnesMouse">Enable smoother SNES mouse movement (not hardware-accurate)</Control>
</Form>
<Form ID="InputComboBox">
<Control ID="btnSetup">Setup</Control>
Expand Down
10 changes: 8 additions & 2 deletions UI/Views/InputConfigView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@
<TextBlock Text="{l:Translate lblHigh}" Grid.Column="2" />
</Grid>
</Grid>

<c:CheckBoxWarning Margin="0 10 0 0" IsChecked="{Binding Config.HidePointerForLightGuns}" Text="{l:Translate chkHidePointerForLightGuns}" />
</c:OptionSection>
</StackPanel>
</ScrollViewer>
Expand Down Expand Up @@ -97,5 +95,13 @@
</Grid>
</ScrollViewer>
</TabItem>
<TabItem Header="{l:Translate tpgAdvanced}">
<ScrollViewer AllowAutoHide="False" HorizontalScrollBarVisibility="Auto" Padding="0 0 2 0">
<StackPanel>
<CheckBox Content="{l:Translate chkEnableSmootherSnesMouse}" IsChecked="{Binding Config.EnableSmootherSnesMouse}" />
<c:CheckBoxWarning IsChecked="{Binding Config.HidePointerForLightGuns}" Text="{l:Translate chkHidePointerForLightGuns}" />
</StackPanel>
</ScrollViewer>
</TabItem>
</TabControl>
</UserControl>

0 comments on commit 6d020e0

Please sign in to comment.