aboutsummaryrefslogtreecommitdiff
path: root/games/jumpy/files/patch-gilrs
blob: 7f77e8b54cecd5bc1ba0c9b02643b36c97ebc0a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
Temporarily revert https://gitlab.com/gilrs-project/gilrs/-/commit/7cd001dacfb1
until https://gitlab.com/gilrs-project/gilrs/-/issues/145

error[E0432]: unresolved import `nix::sys::epoll`
  --> cargo-crates/gilrs-core-0.5.5/src/platform/linux/gamepad.rs:21:15
   |
21 | use nix::sys::epoll::{EpollEvent, EpollFlags, EpollOp};
   |               ^^^^^ could not find `epoll` in `sys`

error[E0432]: unresolved import `nix::sys::eventfd`
  --> cargo-crates/gilrs-core-0.5.5/src/platform/linux/gamepad.rs:22:15
   |
22 | use nix::sys::eventfd::EfdFlags;
   |               ^^^^^^^ could not find `eventfd` in `sys`

error[E0432]: unresolved imports `nix::sys::epoll`, `nix::sys::eventfd`
  --> cargo-crates/gilrs-core-0.5.5/src/platform/linux/gamepad.rs:23:16
   |
23 | use nix::sys::{epoll, eventfd};
   |                ^^^^^  ^^^^^^^
   |                |      |
   |                |      no `eventfd` in `sys`
   |                |      help: a similar name exists in the module: `event`
   |                no `epoll` in `sys`

--- Cargo.lock.orig	2024-01-20 00:55:59 UTC
+++ Cargo.lock
@@ -2469,9 +2469,9 @@ name = "gilrs"
 
 [[package]]
 name = "gilrs"
-version = "0.10.4"
+version = "0.10.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d8b2e57a9cb946b5d04ae8638c5f554abb5a9f82c4c950fd5b1fee6d119592fb"
+checksum = "62fd19844d0eb919aca41d3e4ea0e0b6bf60e1e827558b101c269015b8f5f27a"
 dependencies = [
  "fnv",
  "gilrs-core",
@@ -2482,23 +2482,22 @@ name = "gilrs-core"
 
 [[package]]
 name = "gilrs-core"
-version = "0.5.10"
+version = "0.5.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0af1827b7dd2f36d740ae804c1b3ea0d64c12533fb61ff91883005143a0e8c5a"
+checksum = "5ccc99e9b8d63ffcaa334c4babfa31f46e156618a11f63efb6e8e6bcb37b830d"
 dependencies = [
  "core-foundation",
- "inotify 0.10.2",
  "io-kit-sys",
  "js-sys",
  "libc",
  "libudev-sys",
  "log",
- "nix 0.27.1",
+ "nix 0.26.4",
  "uuid",
  "vec_map",
  "wasm-bindgen",
  "web-sys",
- "windows 0.52.0",
+ "windows 0.46.0",
 ]
 
 [[package]]
@@ -2823,17 +2822,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "inotify"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fdd168d97690d0b8c412d6b6c10360277f4d7ee495c5d0d5d5fe0854923255cc"
-dependencies = [
- "bitflags 1.3.2",
- "inotify-sys",
- "libc",
-]
-
-[[package]]
 name = "inotify-sys"
 version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2875,9 +2863,9 @@ name = "io-kit-sys"
 
 [[package]]
 name = "io-kit-sys"
-version = "0.4.0"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4769cb30e5dcf1710fc6730d3e94f78c47723a014a567de385e113c737394640"
+checksum = "9b2d4429acc1deff0fbdece0325b4997bdb02b2c245ab7023fd5deca0f6348de"
 dependencies = [
  "core-foundation-sys",
  "mach2",
@@ -3477,17 +3465,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "nix"
-version = "0.27.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
-dependencies = [
- "bitflags 2.4.1",
- "cfg-if",
- "libc",
-]
-
-[[package]]
 name = "nohash-hasher"
 version = "0.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3524,7 +3501,7 @@ dependencies = [
  "crossbeam-channel",
  "filetime",
  "fsevent-sys",
- "inotify 0.9.6",
+ "inotify",
  "kqueue",
  "libc",
  "log",
@@ -5956,16 +5933,6 @@ dependencies = [
  "windows-implement",
  "windows-interface",
  "windows-targets 0.48.5",
-]
-
-[[package]]
-name = "windows"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
-dependencies = [
- "windows-core",
- "windows-targets 0.52.0",
 ]
 
 [[package]]
--- cargo-crates/gilrs-0.10.2/examples/ev.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-0.10.2/examples/ev.rs
@@ -9,6 +9,8 @@ use std::process;
 use gilrs::GilrsBuilder;
 
 use std::process;
+use std::thread;
+use std::time::Duration;
 
 fn main() {
     env_logger::init();
@@ -29,15 +31,12 @@ fn main() {
     let repeat_filter = Repeat::new();
 
     loop {
-        while let Some(ev) = gilrs
-            .next_event_blocking(None)
-            .filter_ev(&repeat_filter, &mut gilrs)
-        {
+        while let Some(ev) = gilrs.next_event().filter_ev(&repeat_filter, &mut gilrs) {
             gilrs.update(&ev);
             println!("{:?}", ev);
         }
 
-        if gilrs.counter() % 25 == 0 {
+        if gilrs.counter() % 250 == 0 {
             for (id, gamepad) in gilrs.gamepads() {
                 println!(
                     "Power info of gamepad {}({}): {:?}",
@@ -49,5 +48,6 @@ fn main() {
         }
 
         gilrs.inc();
+        thread::sleep(Duration::from_millis(33));
     }
 }
--- cargo-crates/gilrs-0.10.2/examples/gui.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-0.10.2/examples/gui.rs
@@ -290,7 +290,6 @@ fn main() {
 
 #[cfg(not(target_arch = "wasm32"))]
 fn main() {
-    env_logger::init();
     let native_options = eframe::NativeOptions {
         initial_window_size: Some(Vec2::new(1024.0, 768.0)),
         ..Default::default()
--- cargo-crates/gilrs-0.10.2/src/gamepad.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-0.10.2/src/gamepad.rs
@@ -30,7 +30,6 @@ use std::{
     error,
     fmt::{self, Display},
     sync::mpsc::Sender,
-    time::Duration,
 };
 
 pub use gilrs_core::PowerInfo;
@@ -153,30 +152,15 @@ impl Gilrs {
 
     /// Returns next pending event. If there is no pending event, `None` is
     /// returned. This function will not block current thread and should be safe
-    /// to call in async context. Doesn't block the thread it is run in
+    /// to call in async context.
     pub fn next_event(&mut self) -> Option<Event> {
-        self.next_event_inner(false, None)
-    }
-
-    /// Same as [Gilrs::next_event], but blocks the thread it is run in. Useful
-    /// for apps that aren't run inside a loop and just react to the user's input,
-    /// like GUI apps.
-    ///
-    /// ## Platform support
-    ///
-    /// This function is not supported on web and will always panic.
-    pub fn next_event_blocking(&mut self, timeout: Option<Duration>) -> Option<Event> {
-        self.next_event_inner(true, timeout)
-    }
-
-    fn next_event_inner(&mut self, is_blocking: bool, blocking_timeout: Option<Duration>) -> Option<Event> {
         use crate::ev::filter::{axis_dpad_to_button, deadzone, Filter, Jitter};
 
         let ev = if self.default_filters {
             let jitter_filter = Jitter::new();
             loop {
                 let ev = self
-                    .next_event_priv(is_blocking, blocking_timeout)
+                    .next_event_priv()
                     .filter_ev(&axis_dpad_to_button, self)
                     .filter_ev(&jitter_filter, self)
                     .filter_ev(&deadzone, self);
@@ -188,7 +172,7 @@ impl Gilrs {
                 }
             }
         } else {
-            self.next_event_priv(is_blocking, blocking_timeout)
+            self.next_event_priv()
         };
 
         if self.update_state {
@@ -201,17 +185,11 @@ impl Gilrs {
     }
 
     /// Returns next pending event.
-    fn next_event_priv(&mut self, is_blocking: bool, blocking_timeout: Option<Duration>) -> Option<Event> {
+    fn next_event_priv(&mut self) -> Option<Event> {
         if let Some(ev) = self.events.pop_front() {
             Some(ev)
         } else {
-            let event = if is_blocking {
-                self.inner.next_event_blocking(blocking_timeout)
-            } else {
-                self.inner.next_event()
-            };
-
-            match event {
+            match self.inner.next_event() {
                 Some(RawEvent { id, event, time }) => {
                     trace!("Original event: {:?}", RawEvent { id, event, time });
                     let id = GamepadId(id);
--- cargo-crates/gilrs-core-0.5.7/Cargo.toml.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/Cargo.toml
@@ -64,7 +64,6 @@ features = [
 version = "0.26.2"
 features = [
     "ioctl",
-    "event",
 ]
 default-features = false
 
--- cargo-crates/gilrs-core-0.5.7/examples/ev_core.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/examples/ev_core.rs
@@ -5,7 +5,7 @@ fn main() {
 
     let mut gilrs = Gilrs::new().unwrap();
     loop {
-        while let Some(ev) = gilrs.next_event_blocking(None) {
+        while let Some(ev) = gilrs.next_event() {
             println!("{:?}", ev);
         }
     }
--- cargo-crates/gilrs-core-0.5.7/src/lib.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/src/lib.rs
@@ -116,11 +116,6 @@ impl Gilrs {
         self.inner.next_event()
     }
 
-    /// Returns oldest event, waiting for new event if necessary.
-    pub fn next_event_blocking(&mut self, timeout: Option<Duration>) -> Option<Event> {
-        self.inner.next_event_blocking(timeout)
-    }
-
     /// Borrows `Gamepad` or return `None` if index is invalid. Returned gamepad may be disconnected.
     pub fn gamepad(&self, id: usize) -> Option<&Gamepad> {
         unsafe {
--- cargo-crates/gilrs-core-0.5.7/src/platform/default/gamepad.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/src/platform/default/gamepad.rs
@@ -11,7 +11,6 @@ use std::fmt::{Display, Formatter, Result as FmtResult
 use uuid::Uuid;
 
 use std::fmt::{Display, Formatter, Result as FmtResult};
-use std::time::Duration;
 
 #[derive(Debug)]
 pub struct Gilrs {}
@@ -22,10 +21,6 @@ impl Gilrs {
     }
 
     pub(crate) fn next_event(&mut self) -> Option<Event> {
-        None
-    }
-
-    pub(crate) fn next_event_blocking(&mut self, timeout: Option<Duration>) -> Option<Event> {
         None
     }
 
--- cargo-crates/gilrs-core-0.5.7/src/platform/linux/ff.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/src/platform/linux/ff.rs
@@ -12,7 +12,6 @@ use super::ioctl::{self, ff_effect, ff_replay, ff_rumb
 use std::{mem, slice};
 
 use super::ioctl::{self, ff_effect, ff_replay, ff_rumble_effect, input_event};
-use nix::errno::Errno;
 use std::time::Duration;
 
 #[derive(Debug)]
@@ -111,12 +110,10 @@ impl Drop for Device {
         let effect = self.effect as ::libc::c_int;
 
         if let Err(err) = unsafe { ioctl::eviocrmff(self.file.as_raw_fd(), effect) } {
-            if err != Errno::ENODEV {
-                error!(
-                    "Failed to remove effect of gamepad {:?}: {}",
-                    self.file, err
-                )
-            }
+            error!(
+                "Failed to remove effect of gamepad {:?}: {}",
+                self.file, err
+            )
         };
     }
 }
--- cargo-crates/gilrs-core-0.5.7/src/platform/linux/gamepad.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/src/platform/linux/gamepad.rs
@@ -17,33 +17,22 @@ use vec_map::VecMap;
 use uuid::Uuid;
 use vec_map::VecMap;
 
-use nix::errno::Errno;
-use nix::sys::epoll::{EpollEvent, EpollFlags, EpollOp};
-use nix::sys::eventfd::EfdFlags;
-use nix::sys::{epoll, eventfd};
-use std::collections::VecDeque;
 use std::ffi::CStr;
 use std::fmt::{Display, Formatter, Result as FmtResult};
-use std::fs::File;
-use std::io::Write;
 use std::mem::{self, MaybeUninit};
 use std::ops::Index;
 use std::os::raw::c_char;
-use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd, RawFd};
 use std::str;
 use std::sync::mpsc;
 use std::sync::mpsc::{Receiver, Sender};
 use std::time::{Duration, SystemTime, UNIX_EPOCH};
 use std::{error, thread};
 
-const HOTPLUG_DATA: u64 = u64::MAX;
-
 #[derive(Debug)]
 pub struct Gilrs {
     gamepads: Vec<Gamepad>,
-    epoll: OwnedFd,
+    event_counter: usize,
     hotplug_rx: Receiver<HotplugEvent>,
-    to_check: VecDeque<usize>,
 }
 
 impl Gilrs {
@@ -66,27 +55,9 @@ impl Gilrs {
         unsafe { en.add_match_property(cstr_new(b"ID_INPUT_JOYSTICK\0"), cstr_new(b"1\0")) }
         en.scan_devices();
 
-        let epoll =
-            epoll::epoll_create().map_err(|e| errno_to_platform_error(e, "creating epoll fd"))?;
-        let epoll = unsafe { OwnedFd::from_raw_fd(epoll) };
-
-        let hotplug_event = eventfd::eventfd(1, EfdFlags::EFD_NONBLOCK)
-            .map_err(|e| errno_to_platform_error(e, "creating eventfd"))?;
-        epoll::epoll_ctl(
-            epoll.as_raw_fd(),
-            EpollOp::EpollCtlAdd,
-            hotplug_event,
-            &mut EpollEvent::new(EpollFlags::EPOLLIN | EpollFlags::EPOLLET, HOTPLUG_DATA),
-        )
-        .map_err(|e| errno_to_platform_error(e, "adding evevntfd do epoll"))?;
-
         for dev in en.iter() {
             if let Some(dev) = Device::from_syspath(&udev, &dev) {
                 if let Some(gamepad) = Gamepad::open(&dev) {
-                    let idx = gamepads.len();
-                    gamepad
-                        .register_fd(epoll.as_raw_fd(), idx as u64)
-                        .map_err(|e| errno_to_platform_error(e, "registering gamepad in epoll"))?;
                     gamepads.push(gamepad);
                 }
             }
@@ -110,96 +81,49 @@ impl Gilrs {
                 }
             };
 
-            handle_hotplug(hotplug_tx, monitor, hotplug_event)
+            handle_hotplug(hotplug_tx, monitor)
         });
 
         Ok(Gilrs {
             gamepads,
-            epoll,
+            event_counter: 0,
             hotplug_rx,
-            to_check: VecDeque::new(),
         })
     }
 
     pub(crate) fn next_event(&mut self) -> Option<Event> {
-        self.next_event_impl(Some(Duration::new(0, 0)))
-    }
-
-    pub(crate) fn next_event_blocking(&mut self, timeout: Option<Duration>) -> Option<Event> {
-        self.next_event_impl(timeout)
-    }
-
-    fn next_event_impl(&mut self, timeout: Option<Duration>) -> Option<Event> {
-        let mut check_hotplug = false;
-
-        if self.to_check.is_empty() {
-            let mut events = [EpollEvent::new(EpollFlags::empty(), 0); 16];
-            let timeout = if let Some(timeout) = timeout {
-                timeout.as_millis().try_into().expect("timeout too large")
-            } else {
-                -1
-            };
-
-            let n = match epoll::epoll_wait(self.epoll.as_raw_fd(), &mut events, timeout) {
-                Ok(n) => n,
-                Err(e) => {
-                    error!("epoll failed: {}", e);
-                    return None;
-                }
-            };
-
-            if n == 0 {
-                return None;
-            }
-
-            for event in events {
-                if event.events().contains(EpollFlags::EPOLLIN) {
-                    if event.data() == HOTPLUG_DATA {
-                        check_hotplug = true;
-                    } else {
-                        self.to_check.push_back(event.data() as usize);
-                    }
-                }
-            }
+        if let Some(event) = self.handle_hotplug() {
+            return Some(event);
         }
 
-        if check_hotplug {
-            if let Some(event) = self.handle_hotplug() {
-                return Some(event);
-            }
-        }
-
-        while let Some(idx) = self.to_check.front().copied() {
-            let gamepad = match self.gamepads.get_mut(idx) {
+        loop {
+            let gamepad = match self.gamepads.get_mut(self.event_counter) {
                 Some(gp) => gp,
                 None => {
-                    warn!("Somehow got invalid index from event");
-                    self.to_check.pop_front();
+                    self.event_counter = 0;
                     return None;
                 }
             };
 
             if !gamepad.is_connected {
-                self.to_check.pop_front();
+                self.event_counter += 1;
                 continue;
             }
 
             match gamepad.event() {
                 Some((event, time)) => {
                     return Some(Event {
-                        id: idx,
+                        id: self.event_counter,
                         event,
                         time,
                     });
                 }
                 None => {
-                    self.to_check.pop_front();
+                    self.event_counter += 1;
                     continue;
                 }
             };
         }
-
-        None
     }
 
     pub fn gamepad(&self, id: usize) -> Option<&Gamepad> {
@@ -219,17 +143,9 @@ impl Gilrs {
                         .iter()
                         .position(|gp| gp.uuid() == gamepad.uuid && !gp.is_connected)
                     {
-                        if let Err(e) = gamepad.register_fd(self.epoll.as_raw_fd(), id as u64) {
-                            error!("Failed to add gamepad to epoll: {}", e);
-                        }
                         self.gamepads[id] = *gamepad;
                         Some(Event::new(id, EventType::Connected))
                     } else {
-                        if let Err(e) =
-                            gamepad.register_fd(self.epoll.as_raw_fd(), self.gamepads.len() as u64)
-                        {
-                            error!("Failed to add gamepad to epoll: {}", e);
-                        }
                         self.gamepads.push(*gamepad);
                         Some(Event::new(self.gamepads.len() - 1, EventType::Connected))
                     }
@@ -240,15 +156,6 @@ impl Gilrs {
                         .iter()
                         .position(|gp| devpath == gp.devpath && gp.is_connected)
                     {
-                        if let Err(e) = epoll::epoll_ctl(
-                            self.epoll.as_raw_fd(),
-                            EpollOp::EpollCtlDel,
-                            self.gamepads[id].fd,
-                            &mut EpollEvent::empty(),
-                        ) {
-                            error!("Failed to remove disconnected gamepad from epoll: {}", e);
-                        }
-
                         self.gamepads[id].disconnect();
                         return Some(Event::new(id, EventType::Disconnected));
                     } else {
@@ -267,9 +174,7 @@ enum HotplugEvent {
     Removed(String),
 }
 
-fn handle_hotplug(sender: Sender<HotplugEvent>, monitor: Monitor, event: RawFd) {
-    let mut event = unsafe { File::from_raw_fd(event) };
-
+fn handle_hotplug(sender: Sender<HotplugEvent>, monitor: Monitor) {
     loop {
         if !monitor.wait_hotplug_available() {
             continue;
@@ -291,15 +196,12 @@ fn handle_hotplug(sender: Sender<HotplugEvent>, monito
                 None => continue,
             };
 
-            let mut sent = false;
-
             if action == cstr_new(b"add\0") {
                 if let Some(gamepad) = Gamepad::open(&dev) {
                     if sender.send(HotplugEvent::New(Box::new(gamepad))).is_err() {
                         debug!("All receivers dropped, ending hot plug loop.");
                         break;
                     }
-                    sent = true;
                 }
             } else if action == cstr_new(b"remove\0") {
                 if let Some(devnode) = dev.devnode() {
@@ -308,21 +210,11 @@ fn handle_hotplug(sender: Sender<HotplugEvent>, monito
                             debug!("All receivers dropped, ending hot plug loop.");
                             break;
                         }
-                        sent = true;
                     } else {
                         warn!("Received event with devnode that is not valid utf8: {devnode:?}")
                     }
                 }
             }
-
-            if sent {
-                if let Err(e) = event.write(&0u64.to_ne_bytes()) {
-                    error!(
-                        "Failed to notify other thread about new hotplug events: {}",
-                        e
-                    );
-                }
-            }
         }
     }
 }
@@ -468,15 +360,6 @@ impl Gamepad {
         Some(gamepad)
     }
 
-    fn register_fd(&self, epoll: RawFd, data: u64) -> Result<(), Errno> {
-        epoll::epoll_ctl(
-            epoll,
-            EpollOp::EpollCtlAdd,
-            self.fd,
-            &mut EpollEvent::new(EpollFlags::EPOLLIN, data),
-        )
-    }
-
     fn collect_axes_and_buttons(&mut self) {
         let mut key_bits = [0u8; (KEY_MAX / 8) as usize + 1];
         let mut abs_bits = [0u8; (ABS_MAX / 8) as usize + 1];
@@ -596,7 +479,7 @@ impl Gamepad {
 
     fn battery_fd(dev: &Device) -> (i32, i32) {
         use std::ffi::OsStr;
-        use std::fs::{self};
+        use std::fs::{self, File};
         use std::os::unix::ffi::OsStrExt;
         use std::os::unix::io::IntoRawFd;
         use std::path::Path;
@@ -952,7 +835,6 @@ enum Error {
 enum Error {
     UdevCtx,
     UdevEnumerate,
-    Errno(Errno, &'static str),
 }
 
 impl Display for Error {
@@ -960,16 +842,11 @@ impl Display for Error {
         match *self {
             Error::UdevCtx => f.write_str("Failed to create udev context"),
             Error::UdevEnumerate => f.write_str("Failed to create udev enumerate object"),
-            Error::Errno(e, ctx) => f.write_fmt(format_args!("{} failed: {}", ctx, e)),
         }
     }
 }
 
 impl error::Error for Error {}
-
-fn errno_to_platform_error(errno: Errno, ctx: &'static str) -> PlatformError {
-    PlatformError::Other(Box::new(Error::Errno(errno, ctx)))
-}
 
 const KEY_MAX: u16 = 0x2ff;
 #[allow(dead_code)]
--- cargo-crates/gilrs-core-0.5.7/src/platform/macos/gamepad.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/src/platform/macos/gamepad.rs
@@ -24,7 +24,6 @@ use std::thread;
 use std::sync::mpsc::{self, Receiver, Sender};
 use std::sync::{Arc, Mutex};
 use std::thread;
-use std::time::Duration;
 
 #[derive(Debug)]
 pub struct Gilrs {
@@ -79,22 +78,7 @@ impl Gilrs {
     }
 
     pub(crate) fn next_event(&mut self) -> Option<Event> {
-        let event = self.rx.try_recv().ok();
-        self.handle_event(event)
-    }
-
-    pub(crate) fn next_event_blocking(&mut self, timeout: Option<Duration>) -> Option<Event> {
-        let event = if let Some(timeout) = timeout {
-            self.rx.recv_timeout(timeout).ok()
-        } else {
-            self.rx.recv().ok()
-        };
-
-        self.handle_event(event)
-    }
-
-    fn handle_event(&mut self, event: Option<(Event, Option<IOHIDDevice>)>) -> Option<Event> {
-        match event {
+        match self.rx.try_recv().ok() {
             Some((event, Some(device))) => {
                 if event.event == EventType::Connected {
                     if self.gamepads.get(event.id).is_some() {
--- cargo-crates/gilrs-core-0.5.7/src/platform/wasm/gamepad.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/src/platform/wasm/gamepad.rs
@@ -7,7 +7,6 @@ use std::fmt::{Display, Formatter, Result as FmtResult
 
 use std::collections::VecDeque;
 use std::fmt::{Display, Formatter, Result as FmtResult};
-use std::time::Duration;
 
 use uuid::Uuid;
 use wasm_bindgen::JsCast;
@@ -161,10 +160,6 @@ impl Gilrs {
         }
 
         self.event_cache.pop_front()
-    }
-
-    pub(crate) fn next_event_blocking(&mut self, timeout: Option<Duration>) -> Option<Event> {
-        unimplemented!("next_event_blocking is not supported on web. Use next_event.")
     }
 
     pub fn gamepad(&self, id: usize) -> Option<&Gamepad> {
--- cargo-crates/gilrs-core-0.5.7/src/platform/windows_wgi/gamepad.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/src/platform/windows_wgi/gamepad.rs
@@ -198,55 +198,36 @@ impl Gilrs {
     }
 
     pub(crate) fn next_event(&mut self) -> Option<Event> {
-        self.rx
-            .try_recv()
-            .ok()
-            .map(|wgi_event: WgiEvent| self.handle_event(wgi_event))
-    }
+        self.rx.try_recv().ok().map(|wgi_event: WgiEvent| {
+            // Find the index of the gamepad in our vec or insert it
+            let id = self
+                .gamepads
+                .iter()
+                .position(
+                    |gamepad| match wgi_event.raw_game_controller.NonRoamableId() {
+                        Ok(id) => id == gamepad.non_roamable_id,
+                        _ => false,
+                    },
+                )
+                .unwrap_or_else(|| {
+                    self.gamepads.push(Gamepad::new(
+                        self.gamepads.len() as u32,
+                        wgi_event.raw_game_controller,
+                    ));
+                    self.gamepads.len() - 1
+                });
 
-    pub(crate) fn next_event_blocking(&mut self, timeout: Option<Duration>) -> Option<Event> {
-        if let Some(timeout) = timeout {
-            self.rx
-                .recv_timeout(timeout)
-                .ok()
-                .map(|wgi_event: WgiEvent| self.handle_event(wgi_event))
-        } else {
-            self.rx
-                .recv()
-                .ok()
-                .map(|wgi_event: WgiEvent| self.handle_event(wgi_event))
-        }
-    }
-
-    fn handle_event(&mut self, wgi_event: WgiEvent) -> Event {
-        // Find the index of the gamepad in our vec or insert it
-        let id = self
-            .gamepads
-            .iter()
-            .position(
-                |gamepad| match wgi_event.raw_game_controller.NonRoamableId() {
-                    Ok(id) => id == gamepad.non_roamable_id,
-                    _ => false,
-                },
-            )
-            .unwrap_or_else(|| {
-                self.gamepads.push(Gamepad::new(
-                    self.gamepads.len() as u32,
-                    wgi_event.raw_game_controller,
-                ));
-                self.gamepads.len() - 1
-            });
-
-        match wgi_event.event {
-            EventType::Connected => self.gamepads[id].is_connected = true,
-            EventType::Disconnected => self.gamepads[id].is_connected = false,
-            _ => (),
-        }
-        Event {
-            id,
-            event: wgi_event.event,
-            time: wgi_event.time,
-        }
+            match wgi_event.event {
+                EventType::Connected => self.gamepads[id].is_connected = true,
+                EventType::Disconnected => self.gamepads[id].is_connected = false,
+                _ => (),
+            }
+            Event {
+                id,
+                event: wgi_event.event,
+                time: wgi_event.time,
+            }
+        })
     }
 
     pub fn gamepad(&self, id: usize) -> Option<&Gamepad> {
--- cargo-crates/gilrs-core-0.5.7/src/platform/windows_xinput/gamepad.rs.orig	1970-01-01 00:00:00 UTC
+++ cargo-crates/gilrs-core-0.5.7/src/platform/windows_xinput/gamepad.rs
@@ -72,24 +72,7 @@ impl Gilrs {
 
     pub(crate) fn next_event(&mut self) -> Option<Event> {
         let ev = self.rx.try_recv().ok();
-        self.handle_evevnt(ev);
 
-        ev
-    }
-
-    pub(crate) fn next_event_blocking(&mut self, timeout: Option<Duration>) -> Option<Event> {
-        let ev = if let Some(tiemout) = timeout {
-            self.rx.recv_timeout(tiemout).ok()
-        } else {
-            self.rx.recv().ok()
-        };
-
-        self.handle_evevnt(ev);
-
-        ev
-    }
-
-    fn handle_evevnt(&mut self, ev: Option<Event>) {
         if let Some(ev) = ev {
             match ev.event {
                 EventType::Connected => self.gamepads[ev.id].is_connected = true,
@@ -97,6 +80,8 @@ impl Gilrs {
                 _ => (),
             }
         }
+
+        ev
     }
 
     pub fn gamepad(&self, id: usize) -> Option<&Gamepad> {