From 15dfc0496e464e908f978aac93dd0b9d60a73807 Mon Sep 17 00:00:00 2001 From: Florin9doi Date: Sat, 27 Jul 2024 11:38:02 +0300 Subject: [PATCH] USB: Remove unused HID data --- pcsx2/USB/qemu-usb/hid.cpp | 64 +++++++---------------------------- pcsx2/USB/qemu-usb/hid.h | 1 - pcsx2/USB/usb-hid/usb-hid.cpp | 2 -- 3 files changed, 12 insertions(+), 55 deletions(-) diff --git a/pcsx2/USB/qemu-usb/hid.cpp b/pcsx2/USB/qemu-usb/hid.cpp index 42a8d06213..ee66253d1f 100644 --- a/pcsx2/USB/qemu-usb/hid.cpp +++ b/pcsx2/USB/qemu-usb/hid.cpp @@ -302,42 +302,11 @@ static const uint8_t hid_usage_keys[0x100] = { bool hid_has_events(HIDState* hs) { - return hs->n > 0 || hs->idle_pending; -} - -#if 0 -// Unused -static void hid_idle_timer(void* opaque) -{ - HIDState* hs = (HIDState*)opaque; - - hs->idle_pending = true; - hs->event(hs); -} -#endif - -static void hid_del_idle_timer(HIDState* hs) -{ - /*if (hs->idle_timer) { - timer_del(hs->idle_timer); - timer_free(hs->idle_timer); - hs->idle_timer = NULL; - }*/ + return hs->n > 0; } void hid_set_next_idle(HIDState* hs) { - /*if (hs->idle) { - uint64_t expire_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + - NANOSECONDS_PER_SECOND * hs->idle * 4 / 1000; - if (!hs->idle_timer) { - hs->idle_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, hid_idle_timer, hs); - } - timer_mod_ns(hs->idle_timer, expire_time); - } - else { - hid_del_idle_timer(hs); - }*/ } static void hid_pointer_event(HIDState* hs, InputEvent* evt) @@ -532,10 +501,10 @@ static void hid_keyboard_process_keycode(HIDState* hs) if (hs->kbd.modifiers & (1 << 9)) { /* The hid_codes for the 0xe1/0x1d scancode sequence are 0xe9/0xe0. - * Here we're processing the second hid_code. By dropping bit 9 - * and setting bit 8, the scancode after 0x1d will access the - * second half of the table. - */ + * Here we're processing the second hid_code. By dropping bit 9 + * and setting bit 8, the scancode after 0x1d will access the + * second half of the table. + */ hs->kbd.modifiers ^= (1 << 8) | (1 << 9); return; } @@ -550,8 +519,8 @@ static void hid_keyboard_process_keycode(HIDState* hs) case 0xe6: case 0xe7: /* Ctrl_L/Ctrl_R, Shift_L/Shift_R, Alt_L/Alt_R, Win_L/Win_R. - * Handle releases here, or fall through to process presses. - */ + * Handle releases here, or fall through to process presses. + */ if (keycode & (1 << 7)) { hs->kbd.modifiers &= ~(1 << (hid_code & 0x0f)); @@ -561,11 +530,11 @@ static void hid_keyboard_process_keycode(HIDState* hs) case 0xe8: case 0xe9: /* USB modifiers are just 1 byte long. Bits 8 and 9 of - * hs->kbd.modifiers implement a state machine that detects the - * 0xe0 and 0xe1/0x1d sequences. These bits do not follow the - * usual rules where bit 7 marks released keys; they are cleared - * elsewhere in the function as the state machine dictates. - */ + * hs->kbd.modifiers implement a state machine that detects the + * 0xe0 and 0xe1/0x1d sequences. These bits do not follow the + * usual rules where bit 7 marks released keys; they are cleared + * elsewhere in the function as the state machine dictates. + */ hs->kbd.modifiers |= 1 << (hid_code & 0x0f); return; @@ -641,7 +610,6 @@ void hid_pointer_activate(HIDState* hs) { if (!hs->ptr.mouse_grabbed) { - //qemu_input_handler_activate(hs->s); hs->ptr.mouse_grabbed = 1; } } @@ -652,8 +620,6 @@ int hid_pointer_poll(HIDState* hs, uint8_t* buf, int len) int index; HIDPointerEvent* e; - hs->idle_pending = false; - hid_pointer_activate(hs); /* When the buffer is empty, return the last event. Relative @@ -745,8 +711,6 @@ int hid_pointer_poll(HIDState* hs, uint8_t* buf, int len) int hid_keyboard_poll(HIDState* hs, uint8_t* buf, int len) { - hs->idle_pending = false; - if (len < 2) { return 0; @@ -817,14 +781,10 @@ void hid_reset(HIDState* hs) hs->n = 0; hs->protocol = 1; hs->idle = 0; - hs->idle_pending = false; - hid_del_idle_timer(hs); } void hid_free(HIDState* hs) { - //qemu_input_handler_unregister(hs->s); - hid_del_idle_timer(hs); } void hid_init(HIDState* hs, int kind, HIDEventFunc event) diff --git a/pcsx2/USB/qemu-usb/hid.h b/pcsx2/USB/qemu-usb/hid.h index 433acf1033..e3d515e27a 100644 --- a/pcsx2/USB/qemu-usb/hid.h +++ b/pcsx2/USB/qemu-usb/hid.h @@ -312,7 +312,6 @@ struct HIDState int kind; int32_t protocol; uint8_t idle; - bool idle_pending; HIDEventFunc event; }; diff --git a/pcsx2/USB/usb-hid/usb-hid.cpp b/pcsx2/USB/usb-hid/usb-hid.cpp index 3e40771ffe..cd00a3422d 100644 --- a/pcsx2/USB/usb-hid/usb-hid.cpp +++ b/pcsx2/USB/usb-hid/usb-hid.cpp @@ -851,7 +851,6 @@ namespace usb_hid sw.Do(&s->hid.n); sw.Do(&s->hid.protocol); sw.Do(&s->hid.idle); - sw.Do(&s->hid.idle_pending); return !sw.HasError(); } @@ -914,7 +913,6 @@ namespace usb_hid sw.Do(&s->hid.n); sw.Do(&s->hid.protocol); sw.Do(&s->hid.idle); - sw.Do(&s->hid.idle_pending); return !sw.HasError(); }