Skip to content

Commit 17eab63

Browse files
authored
added WebHID to web-sys (#2617)
1 parent d83d33c commit 17eab63

16 files changed

+1880
-2
lines changed

crates/web-sys/Cargo.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,18 @@ HashChangeEvent = ["Event"]
531531
HashChangeEventInit = []
532532
Headers = []
533533
HeadersGuardEnum = []
534+
Hid = ["EventTarget"]
535+
HidCollectionInfo = []
536+
HidConnectionEvent = ["Event"]
537+
HidConnectionEventInit = []
538+
HidDevice = ["EventTarget"]
539+
HidDeviceFilter = []
540+
HidDeviceRequestOptions = []
541+
HidInputReportEvent = ["Event"]
542+
HidInputReportEventInit = []
543+
HidReportInfo = []
544+
HidReportItem = []
545+
HidUnitSystem = []
534546
HiddenPluginEventInit = []
535547
History = []
536548
HitRegionOptions = []
@@ -923,6 +935,7 @@ ReadableStreamByobReader = []
923935
ReadableStreamDefaultReadResult = []
924936
ReadableStreamDefaultReader = []
925937
ReadableStreamGetReaderOptions = []
938+
ReadableStreamIteratorOptions = []
926939
ReadableStreamReaderMode = []
927940
ReadableWritablePair = []
928941
RecordingState = []
@@ -1248,7 +1261,7 @@ TouchInit = []
12481261
TouchList = []
12491262
TrackEvent = ["Event"]
12501263
TrackEventInit = []
1251-
TransformStream = ["ReadableStream", "WritableStream"]
1264+
TransformStream = []
12521265
TransitionEvent = ["Event"]
12531266
TransitionEventInit = []
12541267
Transport = []
@@ -1319,8 +1332,8 @@ VrSubmitFrameResult = []
13191332
VttCue = ["EventTarget", "TextTrackCue"]
13201333
VttRegion = []
13211334
WakeLock = []
1335+
WakeLockSentinel = ["EventTarget"]
13221336
WakeLockType = []
1323-
WakeLockSentinel = []
13241337
WatchAdvertisementsOptions = []
13251338
WaveShaperNode = ["AudioNode", "EventTarget"]
13261339
WaveShaperOptions = []
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
5+
#[wasm_bindgen]
6+
extern "C" {
7+
# [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = HID , typescript_type = "HID")]
8+
#[derive(Debug, Clone, PartialEq, Eq)]
9+
#[doc = "The `Hid` class."]
10+
#[doc = ""]
11+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HID)"]
12+
#[doc = ""]
13+
#[doc = "*This API requires the following crate features to be activated: `Hid`*"]
14+
#[doc = ""]
15+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
16+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
17+
pub type Hid;
18+
#[cfg(web_sys_unstable_apis)]
19+
# [wasm_bindgen (structural , method , getter , js_class = "HID" , js_name = onconnect)]
20+
#[doc = "Getter for the `onconnect` field of this object."]
21+
#[doc = ""]
22+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HID/onconnect)"]
23+
#[doc = ""]
24+
#[doc = "*This API requires the following crate features to be activated: `Hid`*"]
25+
#[doc = ""]
26+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
27+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
28+
pub fn onconnect(this: &Hid) -> Option<::js_sys::Function>;
29+
#[cfg(web_sys_unstable_apis)]
30+
# [wasm_bindgen (structural , method , setter , js_class = "HID" , js_name = onconnect)]
31+
#[doc = "Setter for the `onconnect` field of this object."]
32+
#[doc = ""]
33+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HID/onconnect)"]
34+
#[doc = ""]
35+
#[doc = "*This API requires the following crate features to be activated: `Hid`*"]
36+
#[doc = ""]
37+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
38+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
39+
pub fn set_onconnect(this: &Hid, value: Option<&::js_sys::Function>);
40+
#[cfg(web_sys_unstable_apis)]
41+
# [wasm_bindgen (structural , method , getter , js_class = "HID" , js_name = ondisconnect)]
42+
#[doc = "Getter for the `ondisconnect` field of this object."]
43+
#[doc = ""]
44+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HID/ondisconnect)"]
45+
#[doc = ""]
46+
#[doc = "*This API requires the following crate features to be activated: `Hid`*"]
47+
#[doc = ""]
48+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
49+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
50+
pub fn ondisconnect(this: &Hid) -> Option<::js_sys::Function>;
51+
#[cfg(web_sys_unstable_apis)]
52+
# [wasm_bindgen (structural , method , setter , js_class = "HID" , js_name = ondisconnect)]
53+
#[doc = "Setter for the `ondisconnect` field of this object."]
54+
#[doc = ""]
55+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HID/ondisconnect)"]
56+
#[doc = ""]
57+
#[doc = "*This API requires the following crate features to be activated: `Hid`*"]
58+
#[doc = ""]
59+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
60+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
61+
pub fn set_ondisconnect(this: &Hid, value: Option<&::js_sys::Function>);
62+
#[cfg(web_sys_unstable_apis)]
63+
# [wasm_bindgen (method , structural , js_class = "HID" , js_name = getDevices)]
64+
#[doc = "The `getDevices()` method."]
65+
#[doc = ""]
66+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HID/getDevices)"]
67+
#[doc = ""]
68+
#[doc = "*This API requires the following crate features to be activated: `Hid`*"]
69+
#[doc = ""]
70+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
71+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
72+
pub fn get_devices(this: &Hid) -> ::js_sys::Promise;
73+
#[cfg(web_sys_unstable_apis)]
74+
#[cfg(feature = "HidDeviceRequestOptions")]
75+
# [wasm_bindgen (method , structural , js_class = "HID" , js_name = requestDevice)]
76+
#[doc = "The `requestDevice()` method."]
77+
#[doc = ""]
78+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HID/requestDevice)"]
79+
#[doc = ""]
80+
#[doc = "*This API requires the following crate features to be activated: `Hid`, `HidDeviceRequestOptions`*"]
81+
#[doc = ""]
82+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
83+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
84+
pub fn request_device(this: &Hid, options: &HidDeviceRequestOptions) -> ::js_sys::Promise;
85+
}
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
5+
#[wasm_bindgen]
6+
extern "C" {
7+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = HIDCollectionInfo)]
8+
#[derive(Debug, Clone, PartialEq, Eq)]
9+
#[doc = "The `HidCollectionInfo` dictionary."]
10+
#[doc = ""]
11+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
12+
#[doc = ""]
13+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
14+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
15+
pub type HidCollectionInfo;
16+
}
17+
#[cfg(web_sys_unstable_apis)]
18+
impl HidCollectionInfo {
19+
#[doc = "Construct a new `HidCollectionInfo`."]
20+
#[doc = ""]
21+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
22+
#[doc = ""]
23+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
24+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
25+
pub fn new() -> Self {
26+
#[allow(unused_mut)]
27+
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
28+
ret
29+
}
30+
#[cfg(web_sys_unstable_apis)]
31+
#[doc = "Change the `children` field of this object."]
32+
#[doc = ""]
33+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
34+
#[doc = ""]
35+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
36+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
37+
pub fn children(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
38+
use wasm_bindgen::JsValue;
39+
let r = ::js_sys::Reflect::set(
40+
self.as_ref(),
41+
&JsValue::from("children"),
42+
&JsValue::from(val),
43+
);
44+
debug_assert!(
45+
r.is_ok(),
46+
"setting properties should never fail on our dictionary objects"
47+
);
48+
let _ = r;
49+
self
50+
}
51+
#[cfg(web_sys_unstable_apis)]
52+
#[doc = "Change the `featureReports` field of this object."]
53+
#[doc = ""]
54+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
55+
#[doc = ""]
56+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
57+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
58+
pub fn feature_reports(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
59+
use wasm_bindgen::JsValue;
60+
let r = ::js_sys::Reflect::set(
61+
self.as_ref(),
62+
&JsValue::from("featureReports"),
63+
&JsValue::from(val),
64+
);
65+
debug_assert!(
66+
r.is_ok(),
67+
"setting properties should never fail on our dictionary objects"
68+
);
69+
let _ = r;
70+
self
71+
}
72+
#[cfg(web_sys_unstable_apis)]
73+
#[doc = "Change the `inputReports` field of this object."]
74+
#[doc = ""]
75+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
76+
#[doc = ""]
77+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
78+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
79+
pub fn input_reports(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
80+
use wasm_bindgen::JsValue;
81+
let r = ::js_sys::Reflect::set(
82+
self.as_ref(),
83+
&JsValue::from("inputReports"),
84+
&JsValue::from(val),
85+
);
86+
debug_assert!(
87+
r.is_ok(),
88+
"setting properties should never fail on our dictionary objects"
89+
);
90+
let _ = r;
91+
self
92+
}
93+
#[cfg(web_sys_unstable_apis)]
94+
#[doc = "Change the `outputReports` field of this object."]
95+
#[doc = ""]
96+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
97+
#[doc = ""]
98+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
99+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
100+
pub fn output_reports(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
101+
use wasm_bindgen::JsValue;
102+
let r = ::js_sys::Reflect::set(
103+
self.as_ref(),
104+
&JsValue::from("outputReports"),
105+
&JsValue::from(val),
106+
);
107+
debug_assert!(
108+
r.is_ok(),
109+
"setting properties should never fail on our dictionary objects"
110+
);
111+
let _ = r;
112+
self
113+
}
114+
#[cfg(web_sys_unstable_apis)]
115+
#[doc = "Change the `type` field of this object."]
116+
#[doc = ""]
117+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
118+
#[doc = ""]
119+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
120+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
121+
pub fn type_(&mut self, val: u8) -> &mut Self {
122+
use wasm_bindgen::JsValue;
123+
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("type"), &JsValue::from(val));
124+
debug_assert!(
125+
r.is_ok(),
126+
"setting properties should never fail on our dictionary objects"
127+
);
128+
let _ = r;
129+
self
130+
}
131+
#[cfg(web_sys_unstable_apis)]
132+
#[doc = "Change the `usage` field of this object."]
133+
#[doc = ""]
134+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
135+
#[doc = ""]
136+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
137+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
138+
pub fn usage(&mut self, val: u16) -> &mut Self {
139+
use wasm_bindgen::JsValue;
140+
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("usage"), &JsValue::from(val));
141+
debug_assert!(
142+
r.is_ok(),
143+
"setting properties should never fail on our dictionary objects"
144+
);
145+
let _ = r;
146+
self
147+
}
148+
#[cfg(web_sys_unstable_apis)]
149+
#[doc = "Change the `usagePage` field of this object."]
150+
#[doc = ""]
151+
#[doc = "*This API requires the following crate features to be activated: `HidCollectionInfo`*"]
152+
#[doc = ""]
153+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
154+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
155+
pub fn usage_page(&mut self, val: u16) -> &mut Self {
156+
use wasm_bindgen::JsValue;
157+
let r = ::js_sys::Reflect::set(
158+
self.as_ref(),
159+
&JsValue::from("usagePage"),
160+
&JsValue::from(val),
161+
);
162+
debug_assert!(
163+
r.is_ok(),
164+
"setting properties should never fail on our dictionary objects"
165+
);
166+
let _ = r;
167+
self
168+
}
169+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
5+
#[wasm_bindgen]
6+
extern "C" {
7+
# [wasm_bindgen (extends = Event , extends = :: js_sys :: Object , js_name = HIDConnectionEvent , typescript_type = "HIDConnectionEvent")]
8+
#[derive(Debug, Clone, PartialEq, Eq)]
9+
#[doc = "The `HidConnectionEvent` class."]
10+
#[doc = ""]
11+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HIDConnectionEvent)"]
12+
#[doc = ""]
13+
#[doc = "*This API requires the following crate features to be activated: `HidConnectionEvent`*"]
14+
#[doc = ""]
15+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
16+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
17+
pub type HidConnectionEvent;
18+
#[cfg(web_sys_unstable_apis)]
19+
#[cfg(feature = "HidDevice")]
20+
# [wasm_bindgen (structural , method , getter , js_class = "HIDConnectionEvent" , js_name = device)]
21+
#[doc = "Getter for the `device` field of this object."]
22+
#[doc = ""]
23+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HIDConnectionEvent/device)"]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `HidConnectionEvent`, `HidDevice`*"]
26+
#[doc = ""]
27+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
28+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
29+
pub fn device(this: &HidConnectionEvent) -> HidDevice;
30+
}

0 commit comments

Comments
 (0)