Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename many global enums relating to input #38054

Merged
merged 2 commits into from
Mar 23, 2021

Conversation

aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Apr 20, 2020

Implements #16863 (comment) + the following 2 comments. Implements and closes godotengine/godot-proposals#1817.

  • ButtonList -> MouseButton and members now start with MOUSE_BUTTON_

  • KeyList -> Key and all members are the same.

  • JoyButtonList -> JoyButton and JoyAxisList -> JoyAxis.

  • MidiMessageList -> MIDIMessage for consistency with the above.

@Calinou

This comment has been minimized.

@aaronfranke aaronfranke force-pushed the enums branch 2 times, most recently from e378aab to fe4e82c Compare May 11, 2020 04:44
@aaronfranke aaronfranke force-pushed the enums branch 4 times, most recently from 6db1987 to aa96a61 Compare May 16, 2020 00:53
@aaronfranke aaronfranke requested a review from a team as a code owner March 23, 2021 00:26
}

JoyAxisList Input::_get_output_axis(String output) {
::JoyAxis Input::_get_output_axis(String output) {
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit unfortunate to have a name clash with the other JoyAxis. Not sure if/how to solve it, it's not too bad I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could rename struct JoyAxis to something else.

Copy link
Member

Choose a reason for hiding this comment

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

Good idea, maybe JoyAxisValue?

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Seems like a good change to me overall. Would like some extra opinions before merging though.

@akien-mga akien-mga requested a review from a team March 23, 2021 08:08
@@ -104,12 +104,12 @@ static Vector<_CoreConstant> _global_constants;

#endif

VARIANT_ENUM_CAST(KeyList);
VARIANT_ENUM_CAST(Key);
Copy link
Member

@akien-mga akien-mga Mar 23, 2021

Choose a reason for hiding this comment

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

Only remaining concern that I have is that some users might not be happy with the fairly generic (3 letter) Key identifier being taken in the global scope. Might lead to issues if one wants to name a class Key for a key item, or naming a public property Key in C# (which I think uses PascalCase for public properties).

Of course I agree that the name is correct for the enum and matches the constants' naming scheme. But that might be the reason why this (and other enums, for consistency) was named KeyList and not Key in the first place.

Copy link
Member Author

Choose a reason for hiding this comment

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

We also already have name conflicts between properties and non-properties in the core Godot API for C#.

One option is to make KeyList be the exception, or we could do something else like Keyboard or KeyCode. Key seems fine to me though.

Copy link
Member

Choose a reason for hiding this comment

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

KeyCode sounds good. InputEventKey has a property with this name.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I guess KeyCode might be fine. It does re-add an inconsistency, but to some extent the KeyList enumerated values are actually different from the other enums. They're internal keycodes while the rest are indices (0 to max).

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we have KEY_ENTER or KEY_CODE_ENTER?

Copy link
Member

Choose a reason for hiding this comment

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

KEY_ENTER

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, we can't use KeyCode, it conflicts with X11:

/usr/include/X11/X.h:108:23: note: 'KeyCode' has a previous declaration here
  108 | typedef unsigned char KeyCode;
      |                       ^~~~~~~

Copy link
Member

Choose a reason for hiding this comment

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

Let's give it a go with Key and see what happens. If it turns out problematic, we can just do the few renames necessary before the 4.0 release.

@akien-mga akien-mga merged commit 5238f13 into godotengine:master Mar 23, 2021
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename many enums relating to input, especially Button to MouseButton
4 participants