-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add gamepad light indicator extension #143
base: gh-pages
Are you sure you want to change the base?
Changes from all commits
e6cfd46
2a7d14d
16fb917
2044611
56a5576
2c92bb9
e8f4dd0
12c2ca7
d988007
e839fae
af0ddeb
de4aade
d7c79f6
313072d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -334,6 +334,116 @@ <h2><dfn>GamepadPose</dfn> Interface</h2> | |||||
</dd> | ||||||
</dl> | ||||||
</section> | ||||||
|
||||||
<section> | ||||||
<h2><dfn>GamepadLightIndicatorType</dfn> Enum</h2> | ||||||
<p> | ||||||
This enum defines the type of light indicators supported by gamepads. | ||||||
</p> | ||||||
|
||||||
<pre class="idl"> | ||||||
enum GamepadLightIndicatorType { | ||||||
"on-off", | ||||||
"rgb" | ||||||
}; | ||||||
</pre> | ||||||
|
||||||
<dl data-dfn-for="GamepadLightIndicatorType"> | ||||||
<dt>"<dfn>on-off</dfn>"</dt> | ||||||
<dd> | ||||||
Light indicator that supports a single color. | ||||||
</dd> | ||||||
|
||||||
<dt>"<dfn>rgb</dfn>"</dt> | ||||||
<dd> | ||||||
Light indicator that supports multiple colors. | ||||||
</dd> | ||||||
</dl> | ||||||
</section> | ||||||
|
||||||
<section> | ||||||
<h2><dfn>GamepadLightColor</dfn> dictionary</h2> | ||||||
<p> | ||||||
This represents the color of a light indicator. | ||||||
</p> | ||||||
|
||||||
<pre class="idl"> | ||||||
dictionary GamepadLightColor { | ||||||
octet red = 0; | ||||||
octet green = 0; | ||||||
octet blue = 0; | ||||||
}; | ||||||
</pre> | ||||||
|
||||||
<dl data-dfn-for="GamepadLightColor"> | ||||||
<dt><dfn>red</dt> member</dfn> | ||||||
<dd> | ||||||
Red component of the light color, or non-zero value for an | ||||||
<code>on-off</code> light indicator that indicates ON. | ||||||
</dd> | ||||||
|
||||||
<dt><dfn>green</dt> member</dfn> | ||||||
<dd> | ||||||
Blue component of the light color, or non-zero value for an | ||||||
<code>on-off</code> light indicator that indicates ON. | ||||||
</dd> | ||||||
|
||||||
<dt><dfn>blue</dt> member</dfn> | ||||||
<dd> | ||||||
Green component of the light color, or non-zero value for an | ||||||
<code>on-off</code> light indicator that indicates ON. | ||||||
</dd> | ||||||
</dl> | ||||||
</section> | ||||||
|
||||||
<section> | ||||||
<h2><dfn>GamepadLightIndicator</dfn></h2> | ||||||
<p> | ||||||
This interface defines a light indicator. | ||||||
</p> | ||||||
|
||||||
<pre class="idl"> | ||||||
[Exposed=Window, SecureContext] | ||||||
interface GamepadLightIndicator { | ||||||
readonly attribute GamepadLightIndicatorType type; | ||||||
|
||||||
Promise<undefined> setColor(GamepadLightColor color); | ||||||
}; | ||||||
</pre> | ||||||
|
||||||
<dl data-dfn-for="GamepadLightIndicator"> | ||||||
<dt><dfn>type</dt></dfn> | ||||||
<dd> | ||||||
Type of light indicator supported by the gamepad. | ||||||
</dd> | ||||||
|
||||||
<dt><dfn>setColor()</dt> method</dfn> | ||||||
<dd> | ||||||
<p> | ||||||
Sets the color of a light indicator, or sets the light indicator to ON | ||||||
or OFF. | ||||||
</p> | ||||||
|
||||||
<p> | ||||||
For <code>on-off</code> light indicators, one or more non zero values | ||||||
denotes the light indicator is on, whereas a zero value for all | ||||||
components indicates the light indicator is off. | ||||||
</p> | ||||||
|
||||||
<p> | ||||||
For RGB light indicators, one or more non zero values specify the | ||||||
color of the light indicator, whereas all zero values indicate the | ||||||
light indicator is OFF. | ||||||
</p> | ||||||
|
||||||
<p> | ||||||
The returned Promise will resolve <code>true</code> when setting the | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if this can be guaranteed to succeed. @nondebug, do you have an opinion about this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We typically don't get a signal that the color was changed successfully so we shouldn't claim that in the spec. I think we should reword this so we resolve when the LED color change command is sent and reject if the command couldn't be sent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so yeah... it shouldn't resolve with We probably need to rewrite this whole section. I'd suggest having a look at: Basically, we need to do a few checks that can cause the promise to reject... the controller has been disconnected/no longer available, etc. There might be a SecurityError if the permission has been changed before while (true) {
x.setColor(randomRGB());
} Rate limit? Drop requests on the floor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed this and couldn't come up with any compelling reasons to keep the Promise. It's unlikely that we'll receive any error indication from the device and there isn't any way we can lose permission for a Gamepad. Let's remove the promise and treat setColor as fire-and-forget. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
color has succeeded, and will reject the device API error code on | ||||||
failure. | ||||||
Comment on lines
+441
to
+442
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to reject with a an actual DOM Exception of some kind. I think this is overly broad/underspecified tho... |
||||||
</p> | ||||||
</dd> | ||||||
</dl> | ||||||
</section> | ||||||
|
||||||
<section data-dfn-for="GamepadTouch"> | ||||||
<h2><dfn>GamepadTouch</dfn> Interface</h2> | ||||||
|
@@ -397,6 +507,7 @@ <h2>Partial <dfn>Gamepad</dfn> Interface</h2> | |||||
readonly attribute GamepadHand hand; | ||||||
readonly attribute FrozenArray<GamepadHapticActuator> hapticActuators; | ||||||
readonly attribute GamepadPose? pose; | ||||||
readonly attribute FrozenArray<GamepadLightIndicator> lightIndicators; | ||||||
readonly attribute FrozenArray<GamepadTouch>? touchEvents; | ||||||
}; | ||||||
</pre> | ||||||
|
@@ -423,6 +534,11 @@ <h2>Partial <dfn>Gamepad</dfn> Interface</h2> | |||||
<code>null</code>. | ||||||
</dd> | ||||||
|
||||||
<dt><dfn>lightIndicators</dfn></dt> | ||||||
<dd> | ||||||
A list of all light indicators in the gamepad. The array is empty if | ||||||
the gamepad does not have, or does not support, a light indicator. | ||||||
</dd> | ||||||
<dt><dfn>touchEvents</dfn></dt> | ||||||
<dd> | ||||||
A list of touch events generated from all touch surfaces. <code>null</code> | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should investigate what existing color objects we could use from the platform here.