Skip to content

Commit

Permalink
Add window event handlers for gamepad connect/disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
msub2 committed Feb 12, 2024
1 parent cc05dd9 commit 237f537
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/script/dom/macros.rs
Expand Up @@ -515,6 +515,8 @@ macro_rules! window_event_handlers(
event_handler!(unhandledrejection, GetOnunhandledrejection,
SetOnunhandledrejection);
event_handler!(unload, GetOnunload, SetOnunload);
event_handler!(gamepadconnected, GetOngamepadconnected, SetOngamepadconnected);
event_handler!(gamepaddisconnected, GetOngamepaddisconnected, SetOngamepaddisconnected);
);
(ForwardToWindow) => (
window_owned_event_handler!(afterprint, GetOnafterprint,
Expand All @@ -541,6 +543,8 @@ macro_rules! window_event_handlers(
window_owned_event_handler!(unhandledrejection, GetOnunhandledrejection,
SetOnunhandledrejection);
window_owned_event_handler!(unload, GetOnunload, SetOnunload);
window_owned_event_handler!(gamepadconnected, GetOngamepadconnected, SetOngamepadconnected);
window_owned_event_handler!(gamepaddisconnected, GetOngamepaddisconnected, SetOngamepaddisconnected);
);
);

Expand Down
6 changes: 6 additions & 0 deletions components/script/dom/webidls/Gamepad.webidl
Expand Up @@ -27,3 +27,9 @@ enum GamepadHand {
"left",
"right"
};

// https://www.w3.org/TR/gamepad/#extensions-to-the-windoweventhandlers-interface-mixin
partial interface mixin WindowEventHandlers {
attribute EventHandler ongamepadconnected;
attribute EventHandler ongamepaddisconnected;
};

0 comments on commit 237f537

Please sign in to comment.