Skip to content

Conversation

@Perksey
Copy link
Member

@Perksey Perksey commented Jan 29, 2022

No description provided.

@Perksey Perksey marked this pull request as ready for review January 29, 2022 22:37
@Perksey Perksey requested a review from a team January 29, 2022 22:37
@Perksey Perksey added this to the 3.0 milestone Jan 29, 2022
@Perksey Perksey added area-Documentation Improvements or additions to documentation proposal labels Jan 29, 2022
Copy link
Member

@HurricanKai HurricanKai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should consider writing a comment somewhere that all states should be readonly
Sorry for the many "See above" comments. I just want to make sure we don't miss anything in a follow-up review.

public JoystickButtonState Buttons { get; init; }
public DualReadOnlyList<Vector2> Thumbsticks { get; init; }
public DualReadOnlyList<float> Triggers { get; init; }
public IReadOnlyList<IMotor> VibrationMotors { get; } // forwards to forwards Device.VibrationMotors for ease of use
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved above

```cs
public struct GamepadState
{
public IGamepad Device { get; init; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved above

Co-authored-by: Kai Jellinghaus <contact@kaij.tech>
@Perksey Perksey requested a review from HurricanKai January 30, 2022 21:52
@ThomasMiz
Copy link
Contributor

ThomasMiz commented Jan 30, 2022

I don't see the reason why devices expose only a State struct. I don't see why it's better than just putting those things directly on the interface (such as IGamepad, IMouse). At least from the user perspective it's definitely nicer.

I'm also not sold on the events getting separated from the object they originate from. What is the benefit of all these design decisions?

Comment on lines +220 to +233
One final point to note is that throughout the rest of the proposal the following type will be used:

```cs
public struct InputReadOnlyList<T> : IReadOnlyList<T>
{
public InputReadOnlyList(IReadOnlyList<T> other);
}
```

The Silk.NET team wishes to reserve the right to add more constructors to this type as it sees fit.

This exists so that, should the Silk.NET choose to, we can optimize the lookup of elements while ensuring things like indexers are inlined and don't result in a virtual call if our implementation allows us to do so.

**INFORMATIVE TEXT:** For example, for joystick and mouse buttons we could use a fixed-sized bit buffer where each bit represents an individual button: 1 for pressed, 0 for unpressed. But for something like keyboard input where there are a large amount of keys, we can't do that and will likely use `Memory<T>` instead.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well this doesn't suggest anything as it's informative text, all the proposal cares about is that it's a list, it's a struct, and is constructible from another list.

We have reserved the right to make more constructors above, which will allow us to make fast paths available to external backends.

It is my intention for this type to be constructible from any IReadOnlyList<T>, hence why I have specified that constructor here.

INFORMATIVE TEXT: Yeah, we'll likely be making a size trade-off for the fast path as you're right we can't have different implementations/memory layout per T.

This is an implementation detail that shouldn't impact the proposal - as far as the proposal is concerned there is no fast path, slow path, etc.

```cs
public struct MouseState
{
public IMouse Device { get; init; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really want isolation though, as that will just annoy users who don't care about immutability or isolation, some users just want to be able to get something that represents a mouse and check whether that has a button pressed, or move a cursor.

public IMouse Device { get; init; }
public MouseButtonState Buttons { get; init; }
public ICursorConfiguration Cursor { get; } // forwards to Device.Cursor
public Vector2 Position { get; set; } // all sets after the first set forward to Device.SetPosition
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the real question is, how to we expose the device then? The input context today doesn't expose the devices any other way.

We'd have to essentially have the lists iterate a (IMouse Device, MouseState State) which at that point they are just as tied as they would be if IMouse is in here.

No matter what we do, someone somewhere will complain when they set the position, either via Device.SetPosition, the original Position setter, whatever; that the state is not updated. I'm leaning more towards just implicitly updating the state if the user explicitly changes it to alleviate confusion.

@Perksey
Copy link
Member Author

Perksey commented Feb 10, 2022

@ThomasMiz @HurricanKai all comments have been addressed

@Perksey Perksey requested a review from ThomasMiz February 11, 2022 15:24
@Perksey
Copy link
Member Author

Perksey commented Feb 11, 2022

Are you two happy with this? If so approval would be appreciated!

@Perksey Perksey requested a review from ThomasMiz February 11, 2022 22:28
Co-authored-by: ThomasMiz <32400648+ThomasMiz@users.noreply.github.com>
Perksey and others added 2 commits February 12, 2022 16:08
Co-authored-by: ThomasMiz <32400648+ThomasMiz@users.noreply.github.com>
@Perksey Perksey merged commit c36dc5d into proposal/all-3.0-proposals Feb 13, 2022
@Perksey Perksey deleted the proposal/3.0-input branch February 13, 2022 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Documentation Improvements or additions to documentation proposal

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants