Skip to content

Commit 9380d07

Browse files
authored
Custom keys and fixes (#25)
* Add customizable shift key mappings and enhance keyboard settings UI. * Improve key labels for Alt/Option on macOS and validation messages. * Update label: Rename "Device" to "Gamepad" in PreferencesView. * Update `Light` theme color palette for improved contrast and consistency. * Handle meta key state in `KeyboardHook` to prevent unintended key processing. * Add support for handling extended keyboard keys in emulator settings and input processing. * Remove unused Settings menu item and related event handler. * Set minimum dimensions for MainWindow and adjust layout for improved alignment. * Update MainMenu padding, refactor pointer event handlers, and remove unused PreferencesView property. * Change `OpenPreferencesWindow` method from public to private in `MainWindowViewModel`. * Refactor PreferencesView layout and enhance keyboard handling logic in KeyboardHook.
1 parent b6c8c87 commit 9380d07

14 files changed

+479
-187
lines changed

src/Spectron/App.axaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
<NativeMenu.Menu>
99
<NativeMenu>
1010
<NativeMenuItem Header="About Spectron" Click="AboutMenuItem_OnClick" />
11-
<NativeMenuItemSeparator/>
12-
<NativeMenuItem Header="Settings..." Gesture="Cmd+," Click="SettingsMenuItem_OnClick"/>
1311
</NativeMenu>
1412
</NativeMenu.Menu>
1513

1614
<Application.Styles>
1715
<FluentTheme>
1816
<FluentTheme.Palettes>
19-
<ColorPaletteResources x:Key="Light" Accent="#ff0073cf" AltHigh="White" AltLow="White" AltMedium="White" AltMediumHigh="White" AltMediumLow="White" BaseHigh="Black" BaseLow="#ffcccccc" BaseMedium="#ff898989" BaseMediumHigh="#ff5d5d5d" BaseMediumLow="#ff737373" ChromeAltLow="#ff5d5d5d" ChromeBlackHigh="Black" ChromeBlackLow="#ffcccccc" ChromeBlackMedium="#ff5d5d5d" ChromeBlackMediumLow="#ff898989" ChromeDisabledHigh="#ffcccccc" ChromeDisabledLow="#ff898989" ChromeGray="#ff737373" ChromeHigh="#ffcccccc" ChromeLow="#ffececec" ChromeMedium="#ffe6e6e6" ChromeMediumLow="#ffececec" ChromeWhite="White" ListLow="#ffe6e6e6" ListMedium="#ffcccccc" RegionColor="White" />
17+
<ColorPaletteResources x:Key="Light" Accent="#ff0073cf" AltHigh="White" AltLow="White" AltMedium="White" AltMediumHigh="White" AltMediumLow="White" BaseHigh="Black" BaseLow="#ffc8c8c8" BaseMedium="#ff878787" BaseMediumHigh="#ff5b5b5b" BaseMediumLow="#ff717171" ChromeAltLow="#ff5b5b5b" ChromeBlackHigh="Black" ChromeBlackLow="#ffc8c8c8" ChromeBlackMedium="#ff5b5b5b" ChromeBlackMediumLow="#ff878787" ChromeDisabledHigh="#ffc8c8c8" ChromeDisabledLow="#ff878787" ChromeGray="#ff717171" ChromeHigh="#ffc8c8c8" ChromeLow="#ffebebeb" ChromeMedium="#ffe4e4e4" ChromeMediumLow="#ffebebeb" ChromeWhite="White" ListLow="#ffe4e4e4" ListMedium="#ffc8c8c8" RegionColor="#ffd8d8d8" />
2018
<ColorPaletteResources x:Key="Dark" Accent="#ffcc4d11" AltHigh="Black" AltLow="Black" AltMedium="Black" AltMediumHigh="Black" AltMediumLow="Black" BaseHigh="White" BaseLow="#ff2f7bad" BaseMedium="#ff8dbfdf" BaseMediumHigh="#ffa5d0ec" BaseMediumLow="#ff5e9dc6" ChromeAltLow="#ffa5d0ec" ChromeBlackHigh="Black" ChromeBlackLow="#ffa5d0ec" ChromeBlackMedium="Black" ChromeBlackMediumLow="Black" ChromeDisabledHigh="#ff2f7bad" ChromeDisabledLow="#ff8dbfdf" ChromeGray="#ff76aed3" ChromeHigh="#ff76aed3" ChromeLow="#ff093b73" ChromeMedium="#ff134b82" ChromeMediumLow="#ff266b9f" ChromeWhite="White" ListLow="#ff134b82" ListMedium="#ff2f7bad" RegionColor="#ff030a12" />
2119
</FluentTheme.Palettes>
2220
</FluentTheme>

src/Spectron/App.axaml.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,4 @@ private void AboutMenuItem_OnClick(object? sender, EventArgs e)
6060
var aboutView = new AboutView();
6161
aboutView.ShowDialog(MainWindow);
6262
}
63-
64-
private void SettingsMenuItem_OnClick(object? sender, EventArgs e)
65-
{
66-
if (MainWindow == null)
67-
{
68-
return;
69-
}
70-
71-
MainWindowViewModel?.OpenPreferencesWindow();
72-
}
7363
}

src/Spectron/Controls/GamepadControlsMapping.axaml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<converters:TypeMatchConverter x:Key="TypeMatchConverter"/>
1313
</UserControl.Resources>
1414

15-
<Grid RowDefinitions="*,50">
15+
<Grid ColumnDefinitions="*,100">
1616
<DataGrid Name="DataGrid"
1717
ItemsSource="{Binding Mappings}"
1818
Margin="10"
@@ -30,19 +30,19 @@
3030

3131
<DataGrid.Columns>
3232
<DataGridTextColumn Header="Button" Binding="{Binding Name}" Width="200"/>
33-
<DataGridTemplateColumn Header="Action" >
33+
<DataGridTemplateColumn Header="Action" Width="*">
3434
<DataGridTemplateColumn.CellTemplate>
3535
<DataTemplate>
3636
<TextBlock
37-
Width="250"
37+
HorizontalAlignment="Stretch"
3838
Padding="10 0 0 0"
3939
Text="{Binding SelectedAction.Name}" VerticalAlignment="Center" />
4040
</DataTemplate>
4141
</DataGridTemplateColumn.CellTemplate>
4242
<DataGridTemplateColumn.CellEditingTemplate>
4343
<DataTemplate>
4444
<ComboBox
45-
Width="250"
45+
HorizontalAlignment="Stretch"
4646
VerticalAlignment="Center"
4747
Padding="10 0 0 0"
4848
ItemsSource="{Binding Actions}"
@@ -75,7 +75,24 @@
7575
</DataGrid.Columns>
7676
</DataGrid>
7777

78-
<TextBlock Grid.Row="1" TextAlignment="Left" Margin="10 0 0 0" Text="Press a button to locate the mapping" FontSize="10" VerticalAlignment="Top"/>
79-
<Button Grid.Row="1" HorizontalAlignment="Right" Margin="0 0 10 0" Content="Defaults" Command="{Binding SetDefaultMappingCommand}"/>
78+
<StackPanel
79+
Grid.Column="1"
80+
Margin="0 0 0 10"
81+
VerticalAlignment="Bottom">
82+
83+
<TextBlock
84+
Text="Press gamepad button to find the mapping"
85+
TextWrapping="Wrap"
86+
HorizontalAlignment="Center"
87+
TextAlignment="Center"
88+
Margin="0 0 0 20"
89+
Opacity=".6"
90+
FontSize="12"/>
91+
92+
<Button
93+
Content="Defaults"
94+
HorizontalAlignment="Center"
95+
Command="{Binding SetDefaultMappingCommand}"/>
96+
</StackPanel>
8097
</Grid>
8198
</UserControl>

src/Spectron/Controls/MainMenu.axaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
<converters:ValueEqualityConverter x:Key="ValueEqualityConverter"/>
1919
</UserControl.Resources>
2020

21+
<UserControl.Styles>
22+
<Style Selector="MenuItem">
23+
<Setter Property="Padding" Value="10 6 10 6"/>
24+
</Style>
25+
</UserControl.Styles>
26+
2127
<Menu Focusable="False">
2228
<MenuItem Header="File" Padding="10 0 10 0" IsTabStop="False" Focusable="False">
2329
<MenuItem Header="Load..." InputGesture="{OnPlatform Ctrl+O, macOS=Cmd+O}" Command="{Binding LoadFileCommand}"/>

0 commit comments

Comments
 (0)