experimental: extra controller stuff such as start button dialog

This commit is contained in:
Dexrn ZacAttack
2025-03-04 06:29:39 -08:00
parent 7d23b411fd
commit c2bd1acb05
4 changed files with 79 additions and 5 deletions

View File

@@ -279,6 +279,41 @@ namespace WinDurango.UI.Controls
startButton.Tapped += (_, _) => StartApp(); startButton.Tapped += (_, _) => StartApp();
} }
public async void ShowControllerInteractDialog()
{
ContentDialog dialog = new ContentDialog();
dialog.XamlRoot = App.MainWindow.Content.XamlRoot;
dialog.Title = _package.DisplayName;
StackPanel optionsPanel = new StackPanel();
optionsPanel.HorizontalAlignment = HorizontalAlignment.Center;
dialog.Content = optionsPanel;
TextBlock textBlock = new TextBlock();
textBlock.Text = "NON-FUNCTIONAL";
// todo: onclick for all
// we need to either move the uninstall options somewhere else or figure out a way to make it work with controller
Button uninstallButton = new Button();
uninstallButton.Content = "Uninstall";
uninstallButton.Margin = new Thickness(0, 0, 0, 10);
Button manageSavesButton = new Button();
manageSavesButton.Content = "Manage saves";
manageSavesButton.Margin = new Thickness(0, 0, 0, 10);
Button manageModsButton = new Button();
manageModsButton.Content = "Manage mods";
manageModsButton.Margin = new Thickness(0, 0, 0, 10);
optionsPanel.Children.Add(textBlock);
optionsPanel.Children.Add(uninstallButton);
optionsPanel.Children.Add(manageSavesButton);
optionsPanel.Children.Add(manageModsButton);
await dialog.ShowAsync();
}
public async void StartApp() public async void StartApp()

View File

@@ -20,6 +20,13 @@ namespace WinDurango.UI
public AppsListPage AppsListPage; public AppsListPage AppsListPage;
public SettingsPage SettingsPage; public SettingsPage SettingsPage;
public AboutPage AboutPage; public AboutPage AboutPage;
public AppMode currentMode;
public enum AppMode
{
DESKTOP,
CONTROLLER
}
private void NavigationInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args) private void NavigationInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{ {
@@ -141,6 +148,12 @@ namespace WinDurango.UI
} }
} }
public void SwitchMode(AppMode mode)
{
currentMode = mode;
navView.PaneDisplayMode = currentMode == AppMode.CONTROLLER ? NavigationViewPaneDisplayMode.Top : NavigationViewPaneDisplayMode.LeftCompact;
}
private void SetupTitleBar() private void SetupTitleBar()
{ {
AppWindowTitleBar titleBar = AppWindow.TitleBar; AppWindowTitleBar titleBar = AppWindow.TitleBar;

View File

@@ -151,29 +151,37 @@ namespace WinDurango.UI.Pages
private void OnAppListPage_Loaded(object sender, RoutedEventArgs e) private void OnAppListPage_Loaded(object sender, RoutedEventArgs e)
{ {
Gamepad.GamepadAdded += onGamepadAdded; Gamepad.GamepadAdded += OnGamepadAdded;
Gamepad.GamepadRemoved += OnGamepadRemoved; Gamepad.GamepadRemoved += OnGamepadRemoved;
} }
private void OnGamepadRemoved(object sender, Gamepad e) private void OnGamepadRemoved(object sender, Gamepad e)
{ {
Logger.WriteInformation("Controller disconnected");
gamepad = null; gamepad = null;
this.DispatcherQueue.TryEnqueue(() =>
{
App.MainWindow.SwitchMode(MainWindow.AppMode.DESKTOP);
});
} }
private void onGamepadAdded(object sender, Gamepad e) private void OnGamepadAdded(object sender, Gamepad e)
{ {
Logger.WriteInformation("Controller connected");
gamepad = e; gamepad = e;
ListenGamepadInput();
this.DispatcherQueue.TryEnqueue(() => this.DispatcherQueue.TryEnqueue(() =>
{ {
if (appList.Children.Count > 0) if (appList.Children.Count > 0)
{ {
appList.Children[currentIndex].Focus(FocusState.Keyboard); appList.Children[currentIndex].Focus(FocusState.Keyboard);
} }
App.MainWindow.SwitchMode(MainWindow.AppMode.CONTROLLER);
}); });
ListenGamepadInput();
} }
// can we make this work everywhere, like in content dialogs?
private async void ListenGamepadInput() private async void ListenGamepadInput()
{ {
while (gamepad != null) while (gamepad != null)
@@ -183,9 +191,12 @@ namespace WinDurango.UI.Pages
bool moveLeft = gamepadInput.LeftThumbstickX < -0.5 || (gamepadInput.Buttons & GamepadButtons.DPadLeft) != 0; bool moveLeft = gamepadInput.LeftThumbstickX < -0.5 || (gamepadInput.Buttons & GamepadButtons.DPadLeft) != 0;
bool moveUp = gamepadInput.LeftThumbstickY > 0.5 || (gamepadInput.Buttons & GamepadButtons.DPadUp) != 0; bool moveUp = gamepadInput.LeftThumbstickY > 0.5 || (gamepadInput.Buttons & GamepadButtons.DPadUp) != 0;
bool moveDown = gamepadInput.LeftThumbstickY < -0.5 || (gamepadInput.Buttons & GamepadButtons.DPadDown) != 0; bool moveDown = gamepadInput.LeftThumbstickY < -0.5 || (gamepadInput.Buttons & GamepadButtons.DPadDown) != 0;
bool start = (gamepadInput.Buttons & GamepadButtons.Menu) != 0; // start as in the button, not start package
bool view = (gamepadInput.Buttons & GamepadButtons.View) != 0; // TODO: on click it should switch between the navigationview, bottom docked bar, and apps list (needs handling for other pages)
bool actionClicked = (gamepadInput.Buttons & GamepadButtons.A) != 0; bool actionClicked = (gamepadInput.Buttons & GamepadButtons.A) != 0;
// feel like we should have like event listeners or whatever
// actionClicked += whatever
if (actionClicked && inputProcessed) if (actionClicked && inputProcessed)
{ {
inputProcessed = false; inputProcessed = false;
@@ -197,6 +208,19 @@ namespace WinDurango.UI.Pages
}); });
} }
// disabled until controller support works
// also pressing start twice will crash cuz 2 contentdialogs
//if (start && inputProcessed)
//{
// inputProcessed = false;
// this.DispatcherQueue.TryEnqueue(() =>
// {
// var appTile = appList.Children[currentIndex] as AppTile;
// appTile.ShowControllerInteractDialog();
// inputProcessed = true;
// });
//}
if ((moveRight || moveLeft || moveUp || moveDown) && inputProcessed) if ((moveRight || moveLeft || moveUp || moveDown) && inputProcessed)
{ {
inputProcessed = false; inputProcessed = false;
@@ -213,7 +237,7 @@ namespace WinDurango.UI.Pages
private void MoveFocus(int xOffset, int yOffset) private void MoveFocus(int xOffset, int yOffset)
{ {
bool firstInput = lastInput == 0; bool firstInput = lastInput == 0;
if (lastInput > DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - 200) if (lastInput > DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - 10)
{ {
inputProcessed = true; inputProcessed = true;
return; return;

View File

@@ -19,6 +19,8 @@ For building you'll need Visual Studio 2022 with the following:
- [X] Scan for already installed EraOS/XUWP stuff - [X] Scan for already installed EraOS/XUWP stuff
- [X] Allow for any existing installed package to be added to the applist - [X] Allow for any existing installed package to be added to the applist
- [ ] Built in updater - [ ] Built in updater
- [ ] Controller support
- [ ] Setup program (maybe MSIX?)
- [ ] Fitting place for extra xbox-specific info - [ ] Fitting place for extra xbox-specific info
- [ ] Resize content to fit to screen - [ ] Resize content to fit to screen
- [X] Allow for search - [X] Allow for search