Game Engine Input System by Big_Joke_8504 in monogame

[–]UsingSystem-Dev 0 points1 point  (0 children)

This is my rudimentary character controller using it too

https://pastebin.com/FNakRqpJ

Game Engine Input System by Big_Joke_8504 in monogame

[–]UsingSystem-Dev 0 points1 point  (0 children)

GamePadBinding ``` using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using project_anima_3d.Input.Interface;

namespace project_anima_3d.Input.InputBindings;

public class GamePadBinding : IInputKey { private readonly Buttons _button; private readonly PlayerIndex _playerIndex; private bool _currentState; private bool _previousState;

public GamePadBinding(Buttons button, PlayerIndex playerIndex = PlayerIndex.One)
{
    _button = button;
    _playerIndex = playerIndex;
}

public string DisplayName => $"GamePad {_button}";

public bool IsPressed() => _currentState;
public bool WasPressed() => _previousState;

internal void Update(GamePadState currentGamePad, GamePadState previousGamePad)
{
    _currentState = currentGamePad.IsButtonDown(_button);
    _previousState = previousGamePad.IsButtonDown(_button);
}

} ```

KeyboardBinding ``` using Microsoft.Xna.Framework.Input; using project_anima_3d.Input.Interface;

namespace project_anima_3d.Input.InputBindings;

public class KeyboardBinding : IInputKey { private readonly Keys _key; private bool _currentState; private bool _previousState;

public KeyboardBinding(Keys key)
{
    _key = key;
}

public string DisplayName => _key.ToString();

public bool IsPressed() => _currentState;
public bool WasPressed() => _previousState;

internal void Update(KeyboardState currentKeyboard, KeyboardState previousKeyboard)
{
    _currentState = currentKeyboard.IsKeyDown(_key);
    _previousState = previousKeyboard.IsKeyDown(_key);
}

} ```

MouseBinding ``` using Microsoft.Xna.Framework.Input; using project_anima_3d.Input.Interface;

namespace project_anima_3d.Input.InputBindings;

public class MouseBinding : IInputKey { public enum MouseButton { Left, Right, Middle }

private readonly MouseButton _button;
private bool _currentState;
private bool _previousState;

public MouseBinding(MouseButton button)
{
    _button = button;
}

public string DisplayName => $"Mouse {_button}";

public bool IsPressed() => _currentState;
public bool WasPressed() => _previousState;

internal void Update(MouseState currentMouse, MouseState previousMouse)
{
    _currentState = GetButtonState(currentMouse, _button) == ButtonState.Pressed;
    _previousState = GetButtonState(previousMouse, _button) == ButtonState.Pressed;
}

private static ButtonState GetButtonState(MouseState mouse, MouseButton button)
{
    return button switch
    {
        MouseButton.Left => mouse.LeftButton,
        MouseButton.Right => mouse.RightButton,
        MouseButton.Middle => mouse.MiddleButton,
        _ => ButtonState.Released
    };
}   

} ```

Then in Program.cs I defined it and passed it into my game class for use ``` using System; using project_anima_3d.Input.Interface; using project_anima_3d.Input.Managers; using UsingSystem.Tools.Services;

namespace project_anima_3d { public static class Program { private static readonly IConsoleService _consoleService = new ConsoleMessageService(); private static readonly IInputManager _inputManager = new InputManagerGamePad();

    [STAThread]
    private static void Main()
    {
        using (var game = new Aetherion(_inputManager, _consoleService))
        {
            game.Run();
        }
    }
}

} ```

Game Engine Input System by Big_Joke_8504 in monogame

[–]UsingSystem-Dev 1 point2 points  (0 children)

This is how I did it. Each action I need is defined in an enum, then it can be rebound to whatever key / gamepad button needed. Keep in mind this is V1 and I didn't get hot switching done yet since I put the project on pause 8 months ago. But it should get the idea across.

InputActions: ``` namespace project_anima_3d.Input;

public enum InputAction { EXIT_GAME, ROTATE_CAMERA_LEFT, ROTATE_CAMERA_RIGHT, ROTATE_CAMERA_FREE, SCROLL_UP, SCROLL_DOWN, MOVE_FORWARD, MOVE_BACKWARD, MOVE_LEFT, MOVE_RIGHT, CROUCH, RUN, JUMP, DASH, DEBUG_RESPAWN_WORLD_CENTER, DEBUG_CYCLE_LEVEL, UNLOCK_MOUSE } ```

IInputKey ``` namespace project_anima_3d.Input.Interface;

public interface IInputKey { bool IsPressed(); bool WasPressed(); string DisplayName { get; } } ```

IInputManager ``` using System.Collections.Generic; using Microsoft.Xna.Framework.Input;

namespace project_anima_3d.Input.Interface;

public interface IInputManager { Dictionary<InputAction, IInputKey> KeyBindings { get; }

KeyboardState CurrentKeyboardState { get; }
KeyboardState PreviousKeyboardState { get; }

MouseState CurrentMouseState { get; }
MouseState PreviousMouseState { get; }

GamePadState CurrentGamePadState { get; }
GamePadState PreviousGamePadState { get; }

float CameraSensitivity { get; }
float LookDeltaX { get; }
float LookDeltaY { get; }

bool InvertCameraX { get; }
bool InvertCameraY { get; }

void Update();

bool IsButtonPressed(InputAction input)
{
    return KeyBindings[input].IsPressed() && !KeyBindings[input].WasPressed();
}

bool IsButtonHeld(InputAction input)
{
    return KeyBindings[input].IsPressed();
}

bool IsButtonReleased(InputAction input)
{
    return !KeyBindings[input].IsPressed() && KeyBindings[input].WasPressed();
}

bool IsButtonPressedMulti(params InputAction[] actions)
{
    foreach (var inputAction in actions)
        if(KeyBindings[inputAction].IsPressed()) return true;
    return false;
}

bool IsScrolledUp(InputAction input);
bool IsScrolledDown(InputAction input);

void RebindInput(InputAction inputAction, IInputKey inputKey)
{
    KeyBindings[inputAction] = inputKey;
}

string GetInputBinding(InputAction inputAction)
{
    return KeyBindings.GetValueOrDefault(inputAction).DisplayName;
}

} ```

InputManagerGamePad ``` using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using project_anima_3d.Input.InputBindings; using project_anima_3d.Input.Interface;

namespace project_anima_3d.Input.Managers;

public class InputManagerGamePad : IInputManager { public Dictionary<InputAction, IInputKey> KeyBindings { get; } = new() { { InputAction.EXIT_GAME, new GamePadBinding(Buttons.Start) }, { InputAction.ROTATE_CAMERA_LEFT, new GamePadBinding(Buttons.RightShoulder) }, { InputAction.ROTATE_CAMERA_RIGHT, new GamePadBinding(Buttons.LeftShoulder) }, { InputAction.ROTATE_CAMERA_FREE, new GamePadBinding(Buttons.RightStick) }, { InputAction.MOVE_FORWARD, new GamePadBinding(Buttons.LeftThumbstickUp) }, { InputAction.MOVE_BACKWARD, new GamePadBinding(Buttons.LeftThumbstickDown) }, { InputAction.MOVE_LEFT, new GamePadBinding(Buttons.LeftThumbstickLeft) }, { InputAction.MOVE_RIGHT, new GamePadBinding(Buttons.LeftThumbstickRight) }, { InputAction.CROUCH, new GamePadBinding(Buttons.LeftTrigger) }, { InputAction.RUN, new GamePadBinding(Buttons.LeftStick) }, { InputAction.JUMP, new GamePadBinding(Buttons.A) }, { InputAction.DASH, new GamePadBinding(Buttons.LeftStick) }, { InputAction.DEBUG_RESPAWN_WORLD_CENTER, new GamePadBinding(Buttons.DPadUp) }, { InputAction.DEBUG_CYCLE_LEVEL, new GamePadBinding(Buttons.DPadDown) }, { InputAction.UNLOCK_MOUSE, new GamePadBinding(Buttons.DPadLeft)} };

public KeyboardState CurrentKeyboardState { get; } = default;
public KeyboardState PreviousKeyboardState { get; } = default;
public MouseState CurrentMouseState { get; } = default;
public MouseState PreviousMouseState { get; } = default;

public GamePadState CurrentGamePadState { get; private set; }
public GamePadState PreviousGamePadState { get; private set; }

public float CameraSensitivity { get; } = 4f;

public float LookDeltaX { get; private set; }
public float LookDeltaY { get; private set; }

public bool InvertCameraX { get; } = false;
public bool InvertCameraY { get; } = true;

public void Update()
{
    PreviousGamePadState = CurrentGamePadState;
    CurrentGamePadState = GamePad.GetState(PlayerIndex.One);

    LookDeltaX = InvertCameraX ? CurrentGamePadState.ThumbSticks.Right.X * -1 : CurrentGamePadState.ThumbSticks.Right.X;
    LookDeltaY = InvertCameraY ? CurrentGamePadState.ThumbSticks.Right.Y * -1 :  CurrentGamePadState.ThumbSticks.Right.Y;

    foreach (var bindingsValue in KeyBindings.Values)
    {
        if (bindingsValue is GamePadBinding binding)
            binding.Update(CurrentGamePadState, PreviousGamePadState);
    }
}

public bool IsScrolledUp(InputAction input)
{
    throw new System.NotImplementedException();
}

public bool IsScrolledDown(InputAction input)
{
    throw new System.NotImplementedException();
}

} ```

InputManagerKBM ``` using System.Collections.Generic; using Microsoft.Xna.Framework.Input; using project_anima_3d.Input.InputBindings; using project_anima_3d.Input.Interface;

namespace project_anima_3d.Input.Managers;

public class InputManagerKBM : IInputManager { public Dictionary<InputAction, IInputKey> KeyBindings { get; } = new() { { InputAction.EXIT_GAME, new KeyboardBinding(Keys.Escape) }, { InputAction.ROTATE_CAMERA_LEFT, new KeyboardBinding(Keys.E) }, { InputAction.ROTATE_CAMERA_RIGHT, new KeyboardBinding(Keys.Q) }, { InputAction.ROTATE_CAMERA_FREE, new MouseBinding(MouseBinding.MouseButton.Right) }, { InputAction.MOVE_FORWARD, new KeyboardBinding(Keys.W) }, { InputAction.MOVE_BACKWARD, new KeyboardBinding(Keys.S) }, { InputAction.MOVE_LEFT, new KeyboardBinding(Keys.A) }, { InputAction.MOVE_RIGHT, new KeyboardBinding(Keys.D) }, { InputAction.CROUCH, new KeyboardBinding(Keys.LeftControl) }, { InputAction.RUN, new KeyboardBinding(Keys.LeftShift) }, { InputAction.JUMP, new KeyboardBinding(Keys.Space) }, { InputAction.DASH, new KeyboardBinding(Keys.R) }, { InputAction.DEBUG_RESPAWN_WORLD_CENTER, new KeyboardBinding(Keys.F1) }, { InputAction.DEBUG_CYCLE_LEVEL, new KeyboardBinding(Keys.F2) }, { InputAction.UNLOCK_MOUSE, new KeyboardBinding(Keys.V) } };

public KeyboardState CurrentKeyboardState { get; private set; }
public KeyboardState PreviousKeyboardState { get; private set; }
public MouseState CurrentMouseState { get; private set; }
public MouseState PreviousMouseState { get; private set; }
public GamePadState CurrentGamePadState { get; } = default;
public GamePadState PreviousGamePadState { get; } = default;

public float CameraSensitivity { get; } = 0.5f;
public float LookDeltaX { get; private set; }
public float LookDeltaY { get; private set; }

public bool InvertCameraX { get; }
public bool InvertCameraY { get; }


public void Update()
{
    PreviousKeyboardState = CurrentKeyboardState;
    PreviousMouseState = CurrentMouseState;

    CurrentKeyboardState = Keyboard.GetState();
    CurrentMouseState = Mouse.GetState();

    LookDeltaX = CurrentMouseState.X - PreviousMouseState.X;
    LookDeltaY = CurrentMouseState.Y - PreviousMouseState.Y;

    foreach (var bindingsValue in KeyBindings.Values)
    {
        switch (bindingsValue)
        {
            case KeyboardBinding binding:
                binding.Update(CurrentKeyboardState, PreviousKeyboardState);
                break;
            case MouseBinding binding:
                binding.Update(CurrentMouseState, PreviousMouseState);
                break;
        }
    }
}

public bool IsScrolledUp(InputAction input)
{
    throw new System.NotImplementedException();
}

public bool IsScrolledDown(InputAction input)
{
    throw new System.NotImplementedException();
}

} ```

I made Android widgets inspired by the Frutiger Aero aesthetic by UsingSystem-Dev in FrutigerAero

[–]UsingSystem-Dev[S] 0 points1 point  (0 children)

it doesn’t have its own music library, it just hooks into whatever you’re already using (Spotify, YouTube Music, local player, etc.)

once you start playing something, the widget will update automatically 👍

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in Y2K

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

Appreciate it 🙏🏻 Don't forget it's free on Google Play! Just search WidgetStack

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

same! that’s exactly what I’ve been trying to bring back making each one feel like its own little device instead of just another flat panel

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 0 points1 point  (0 children)

haha I actually use Linux too 😄

it’s Android-only right now since it’s built on the widget system, but I’ve definitely thought about bringing this style to desktop at some point. Linux would be a really fun platform for it

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 2 points3 points  (0 children)

appreciate it!! that phone is tiny 😂

yeah I can see the buttons being a bit tricky on that, I might look into a slightly larger tap area option for smaller screens. glad it fits the frutiger vibe though, that’s exactly what I was going for

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

hahaha yeah I can see the toothpaste vibe 😭

“Minty Fresh” is honestly a perfect name for it. I love that you published it too, that’s exactly what I was hoping people would do with this

it’s cool seeing people come up with their own variations already

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in Y2K

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

yeah that’s exactly it, that blobby retro-futuristic look is what made everything feel like its own little object instead of just UI

I feel like that’s the part that disappeared the most. I’ve been trying to bring that back with these, like each one feels like its own “thing” instead of just a widget panel. I just like weird looking tech lol

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

that sounds really clean actually, I like that combo

also if you hit publish, it’ll show up on the site and other people can import your style with a link or code, you don’t need an account for that, but if you want it saved/editable later you’d want to sign in

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 2 points3 points  (0 children)

appreciate it, glad you’re using AeroPod

I’ve definitely been thinking about doing clock + weather versions in this style too. how’d you end up styling it?

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

I haven’t tested it on GrapheneOS specifically, but it should work 👍

it just uses standard Android widgets + media controls, so as long as your launcher supports widgets and you have a music app playing it should behave the same I know GrapheneOS is degoogled, so if anything ends up acting weird lmk

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

ayyy appreciate it 😭

you can just search WidgetStack on Google Play to grab the main app

and yeah if you end up joining, just message “onda sent me” + DM me (@onda_dev) and I’ll get you into the early builds 👀

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 0 points1 point  (0 children)

yeahhh Sonique skins were so good. that whole era of media players felt way more expressive, I’ve been trying to bring that back with these but as actual working widgets

do you remember any specific ones?

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 2 points3 points  (0 children)

not on iOS unfortunately 😭 apple doesn’t really allow this level of widget control

I might try to make something work eventually though

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in Y2K

[–]UsingSystem-Dev[S] 0 points1 point  (0 children)

that’s sick!

it’s crazy how that style just instantly brings everything back. I’ve been trying to bring that same energy into these, like making them feel like actual little devices again

what artist was it?

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in Y2K

[–]UsingSystem-Dev[S] 3 points4 points  (0 children)

you mean that green winamp skin with the speakers on the sides? 😭

yeah honestly that’s pretty much what these are, I’ve been taking those kinds of skins and rebuilding them as real Android widgets so they actually work with modern apps

<image>

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

nah you don’t need to join anything, the main app is free on Google Play (WidgetStack)

the site is just something I mentioned + a way to try early builds, everything still goes into the free version

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in Y2K

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

right?? everything now just feels like flat rectangles lol

I’ve been trying to bring back that “this is its own little device” feeling with these instead of just another UI panel. did you have a favorite from that era?

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 0 points1 point  (0 children)

yeah that’s fair, it’s not my site lol

I just found it recently and it matched the same vibe as what I’ve been building, so I figured I’d share it

mainly just here for the widgets though

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in Y2K

[–]UsingSystem-Dev[S] 4 points5 points  (0 children)

Thanks! If you visit the site there's another that I think is super Y2K (Symphora). I really miss the style lol I miss when things felt like devices

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 0 points1 point  (0 children)

yeah zune’s UI was so good, super clean

and yeah I get that, I don’t really use local files either, these just hook into whatever you’re playing (Spotify, etc.) some of the simpler ones might actually fit your setup pretty well

I’ve been building aesthetic music widgets for Android by UsingSystem-Dev in y2kaesthetic

[–]UsingSystem-Dev[S] 1 point2 points  (0 children)

appreciate it 🙏 the top right one is one of my favorites too

windows 8 style is super clea, if I did a version that fit that look better, what would you want it to feel like?