static void bms_timer(void *opaque) { MouState *s = (MouState*)opaque; uint8_t irq_bit; /* Toggle the IRQ line if interrupts are enabled. */ irq_bit = BMS_IRQ_BIT(s->irq); if (s->port_c & irq_bit) { if (!(s->port_c & BMS_CTL_INT_DIS)) PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), s->irq, PDM_IRQ_LEVEL_LOW); s->port_c &= ~irq_bit; } else { s->port_c |= irq_bit; if (!(s->port_c & BMS_CTL_INT_DIS)) PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), s->irq, PDM_IRQ_LEVEL_HIGH); } /* Handle enabling/disabling of the mouse interface. */ if (s->port_c & BMS_CTL_INT_DIS) { if (s->disable_counter) --s->disable_counter; if (s->disable_counter == 0 && s->mouse_enabled) { s->mouse_enabled = false; bms_update_downstream_status(s); } } else { s->disable_counter = 8; /* Re-arm the disable countdown. */ if (!s->mouse_enabled) { s->mouse_enabled = true; bms_update_downstream_status(s); } } }
/** * Set the emulated hardware to a known initial state. */ static void bms_reset(MouState *pThis) { /* Clear the device setup. */ pThis->port_a = pThis->port_b = 0; pThis->port_c = BMS_CTL_INT_DIS; /* Interrupts disabled. */ pThis->ctrl_port = 0x91; /* Default 8255A setup. */ /* Clear motion/button state. */ pThis->cnt_held = false; pThis->mouse_dx = pThis->mouse_dy = 0; pThis->mouse_buttons = 0; pThis->mouse_buttons_reported = 0; pThis->disable_counter = 0; pThis->irq_toggle_counter = 1000; if (pThis->mouse_enabled) { pThis->mouse_enabled = false; bms_update_downstream_status(pThis); } }