Skip to content

Commit

Permalink
USB: Remove unused HID data
Browse files Browse the repository at this point in the history
  • Loading branch information
Florin9doi authored and lightningterror committed Aug 5, 2024
1 parent 3a55653 commit 15dfc04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 55 deletions.
64 changes: 12 additions & 52 deletions pcsx2/USB/qemu-usb/hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand All @@ -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));
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pcsx2/USB/qemu-usb/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ struct HIDState
int kind;
int32_t protocol;
uint8_t idle;
bool idle_pending;
HIDEventFunc event;
};

Expand Down
2 changes: 0 additions & 2 deletions pcsx2/USB/usb-hid/usb-hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 15dfc04

Please sign in to comment.