This repository was archived by the owner on Feb 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-11
lines changed Expand file tree Collapse file tree 1 file changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -107,17 +107,18 @@ impl HidApi {
107
107
let enumeration = ffi:: hid_enumerate ( 0 , 0 ) ;
108
108
{
109
109
let mut current_device = enumeration;
110
-
111
- ' do_while: loop {
112
-
113
- device_vector. push ( conv_hid_device_info ( current_device) ) ;
114
-
115
- if ( * current_device) . next . is_null ( ) {
116
- break ' do_while;
117
- } else {
118
- current_device = ( * current_device) . next ;
119
- }
120
- }
110
+ if !current_device. is_null ( ) {
111
+ ' do_while: loop {
112
+
113
+ device_vector. push ( conv_hid_device_info ( current_device) ) ;
114
+
115
+ if ( * current_device) . next . is_null ( ) {
116
+ break ' do_while;
117
+ } else {
118
+ current_device = ( * current_device) . next ;
119
+ }
120
+ }
121
+ }
121
122
}
122
123
123
124
ffi:: hid_free_enumeration ( enumeration) ;
@@ -422,3 +423,12 @@ impl<'a> HidDevice<'a> {
422
423
unsafe { wchar_to_string ( buf[ ..res] . as_ptr ( ) ) }
423
424
}
424
425
}
426
+
427
+ #[ test]
428
+ fn smoke ( ) {
429
+ let api = HidApi :: new ( ) . unwrap ( ) ;
430
+ // Print out information about all connected devices
431
+ for device in & api. devices ( ) {
432
+ println ! ( "{:#?}" , device) ;
433
+ }
434
+ }
You can’t perform that action at this time.
0 commit comments