예제 #1
0
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);
        }
    }
}
    LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d, buttons_state=0x%x\n",
             __PRETTY_FUNCTION__, dx, dy, dz, dw, buttons_state));

    /* Only record X/Y movement and buttons. */
    pThis->mouse_dx += dx;
    pThis->mouse_dy += dy;
    pThis->mouse_buttons = buttons_state;
}

static DECLCALLBACK(void) bmsTimerCallback(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
{
    MouState   *pThis = PDMINS_2_DATA(pDevIns, MouState *);
    uint8_t     irq_bit;

    /* Toggle the IRQ line if interrupts are enabled. */
    irq_bit = BMS_IRQ_BIT(pThis->irq);

    if (pThis->port_c & irq_bit)
    {
        if (!(pThis->port_c & BMS_CTL_INT_DIS))
            PDMDevHlpISASetIrq(pThis->CTX_SUFF(pDevIns), pThis->irq, PDM_IRQ_LEVEL_LOW);
        pThis->port_c &= ~irq_bit;
    }
    else
    {
        pThis->port_c |= irq_bit;
        if (!(pThis->port_c & BMS_CTL_INT_DIS))
            PDMDevHlpISASetIrq(pThis->CTX_SUFF(pDevIns), pThis->irq, PDM_IRQ_LEVEL_HIGH);
    }

    /* Handle enabling/disabling of the mouse interface. */