Esempio n. 1
0
// Mouse button
static void postevent_mb(io_connect_t event, int button, int down){
    NXEventData mb;
    memset(&mb, 0, sizeof(mb));
    mb.compound.subType = NX_SUBTYPE_AUX_MOUSE_BUTTONS;
    mb.compound.misc.L[0] = (1 << button);
    mb.compound.misc.L[1] = down ? (1 << button) : 0;
    postevent(event, NX_SYSDEFINED, &mb, 0, 0, !down);
    // Mouse presses actually generate two events, one with a bitfield of buttons, one with a button number
    memset(&mb, 0, sizeof(mb));
    UInt32 type;
    mb.mouse.buttonNumber = button;
    switch(button){
    case 0:
        type = down ? NX_LMOUSEDOWN : NX_LMOUSEUP;
        break;
    case 1:
        type = down ? NX_RMOUSEDOWN : NX_RMOUSEUP;
        break;
    default:
        type = down ? NX_OMOUSEDOWN : NX_OMOUSEUP;
    }
    if(down)
        mb.mouse.pressure = 255;
    postevent(event, type, &mb, 0, 0, 1);
}
Esempio n. 2
0
// Mouse axis
static void postevent_mm(io_connect_t event, int x, int y, int use_accel, uchar buttons){
    NXEventData mm;
    memset(&mm, 0, sizeof(mm));
    UInt32 type = NX_MOUSEMOVED;
    if(use_accel)
        mouse_accel(event, &x, &y);
    mm.mouseMove.dx = x;
    mm.mouseMove.dy = y;
    if(buttons != 0){
        // If a button is pressed, the event type changes
        if(buttons & 1)
            type = NX_LMOUSEDRAGGED;
        else if(buttons & 2)
            type = NX_RMOUSEDRAGGED;
        else
            type = NX_OMOUSEDRAGGED;
        // Pick the button index based on the lowest-numbered button
        int button = 0;
        while(!(buttons & 1)){
            button++;
            buttons >>= 1;
        }
        mm.mouse.pressure = 255;
        mm.mouse.buttonNumber = button;
    }
    postevent(event, type, &mm, 0, kIOHIDSetRelativeCursorPosition, 1);
}
Esempio n. 3
0
// Keypress
static void postevent_kp(io_connect_t event, int kbflags, int scancode, int down, int is_flags, int is_repeat){
    NXEventData kp;
    memset(&kp, 0, sizeof(kp));
    UInt32 type;
    IOOptionBits flags = kbflags;
    IOOptionBits options = 0;
    if(IS_MEDIA(scancode)){
        kp.compound.subType = (scancode != KEY_POWER ? NX_SUBTYPE_AUX_CONTROL_BUTTONS : NX_SUBTYPE_POWER_KEY);
        kp.compound.misc.L[0] = (scancode - KEY_MEDIA) << 16 | (down ? 0x0a00 : 0x0b00) | is_repeat;
        type = NX_SYSDEFINED;
    } else {
        if(is_flags){
            // Modifier (shift, ctrl, etc)
            type = NX_FLAGSCHANGED;
            options = kIOHIDSetGlobalEventFlags;
        } else
            // Standard key
            type = down ? NX_KEYDOWN : NX_KEYUP;
        kp.key.repeat = is_repeat;
        kp.key.keyCode = scancode;
        kp.key.origCharSet = kp.key.charSet = NX_ASCIISET;
        if(IS_NUMPAD(scancode))
            flags |= NX_NUMERICPADMASK;
        else if(scancode == kVK_Help)
            flags |= NX_HELPMASK;
    }
    postevent(event, type, &kp, flags, options);
}
Esempio n. 4
0
File: i_video.c Progetto: jezze/doom
void I_StartTic(void)
{

    SDL_Event Event;

    while (SDL_PollEvent(&Event))
        postevent(&Event);

}
Esempio n. 5
0
void clearkeys(usbdevice* kb){
    // Send keyup events for every scancode in the keymap
    for(int key = 0; key < N_KEYS; key++){
        int scan = keymap_system[key].scan;
        if(scan < 0 || IS_MEDIA(scan))
            continue;
        postevent(kb->event, 0, scan, 0, 0, 0);
    }
}
Esempio n. 6
0
// Mouse wheel
static void postevent_wheel(io_connect_t event, int use_accel, int value){
    NXEventData mm;
    memset(&mm, 0, sizeof(mm));
    if(use_accel){
        wheel_accel(event, &value, &mm.scrollWheel.fixedDeltaAxis1, &mm.scrollWheel.pointDeltaAxis1);
        mm.scrollWheel.deltaAxis1 = value;
    } else {
        // If acceleration is disabled, use a fixed delta of 3
        mm.scrollWheel.deltaAxis1 = value * 3;
    }
    postevent(event, NX_SCROLLWHEELMOVED, &mm, 0, 0, 0);
}
Esempio n. 7
0
void os_keypress(usbdevice* kb, int scancode, int down){
    // Check for modifier keys and update flags
    int flags = 0;
    // Keep a separate list of left/right side modifiers - combine them below
    IOOptionBits* side = (scancode == KEY_RIGHTSHIFT || scancode == KEY_RIGHTCTRL || scancode == KEY_RIGHTMETA || scancode == KEY_RIGHTALT) ? &kb->rflags : &kb->lflags;
    CGEventFlags mod = 0;
    if(scancode == KEY_CAPSLOCK){
        if(down)
            kb->lflags ^= NX_ALPHASHIFTMASK;
        flags = 1;
    } else if(scancode == KEY_LEFTSHIFT || scancode == KEY_RIGHTSHIFT){
        mod = NX_SHIFTMASK;
        mod |= (scancode == KEY_LEFTSHIFT) ? NX_DEVICELSHIFTKEYMASK : NX_DEVICERSHIFTKEYMASK;
        flags = 1;
    } else if(scancode == KEY_LEFTCTRL || scancode == KEY_RIGHTCTRL){
        mod = NX_CONTROLMASK;
        mod |= (scancode == KEY_LEFTCTRL) ? NX_DEVICELCTLKEYMASK : NX_DEVICERCTLKEYMASK;
        flags = 1;
    } else if(scancode == KEY_LEFTMETA || scancode == KEY_RIGHTMETA){
        mod = NX_COMMANDMASK;
        mod |= (scancode == KEY_LEFTMETA) ? NX_DEVICELCMDKEYMASK : NX_DEVICERCMDKEYMASK;
        flags = 1;
    } else if(scancode == KEY_LEFTALT || scancode == KEY_RIGHTALT){
        mod = NX_ALTERNATEMASK;
        mod |= (scancode == KEY_LEFTALT) ? NX_DEVICELALTKEYMASK : NX_DEVICERALTKEYMASK;
        flags = 1;
    }

    if(flags){
        // Update flags when a modifier key is pressed
        if(down)
            *side |= mod;
        else
            *side &= ~mod;
        kb->eventflags = kb->lflags | kb->rflags;
        kb->lastkeypress = KEY_NONE;
    } else {
        // For any other key, trigger key repeat
        if(down){
            long repeat = repeattime(kb->event, 1);
            if(repeat > 0){
                kb->lastkeypress = scancode;
                clock_gettime(CLOCK_MONOTONIC, &kb->keyrepeat);
                timespec_add(&kb->keyrepeat, repeat);
            } else
                kb->lastkeypress = KEY_NONE;
        } else
            kb->lastkeypress = KEY_NONE;
    }

    postevent(kb->event, kb->eventflags, scancode, down, flags, 0);
}
Esempio n. 8
0
void keyretrigger(usbdevice* kb){
    int scancode = kb->lastkeypress;
    if(scancode < 0)
        return;
    // Retrigger the last-pressed key
    postevent(kb->event, kb->eventflags, scancode, 1, 0, 1);
    // Set next key repeat time
    long repeat = repeattime(kb->event, 0);
    if(repeat > 0)
        timespec_add(&kb->keyrepeat, repeat);
    else
        kb->lastkeypress = KEY_NONE;
}
Esempio n. 9
0
static void postevent_kp(io_connect_t event, int kbflags, int scancode, int down, int is_flags, int is_repeat){
    NXEventData kp;
    memset(&kp, 0, sizeof(kp));
    UInt32 type;
    IOOptionBits flags = kbflags;
    IOOptionBits options = 0;
    if(scancode == KEY_CAPSLOCK){
        // Caps lock emits NX_FLAGSCHANGED when pressed, but also NX_SYSDEFINED on both press and release
        kp.compound.subType = NX_SUBTYPE_AUX_CONTROL_BUTTONS;
        kp.compound.misc.L[0] = aux_key_data(NX_KEYTYPE_CAPS_LOCK, down, is_repeat);
        postevent(event, NX_SYSDEFINED, &kp, flags, options, 1);
        if(!down)
            return;
        memset(&kp, 0, sizeof(kp));
    }
    if(IS_MEDIA(scancode)){
        kp.compound.subType = (scancode != KEY_POWER ? NX_SUBTYPE_AUX_CONTROL_BUTTONS : NX_SUBTYPE_POWER_KEY);
        kp.compound.misc.L[0] = aux_key_data(scancode - KEY_MEDIA, down, is_repeat);
        type = NX_SYSDEFINED;
    } else {
        if(is_flags){
            // Modifier (shift, ctrl, etc)
            type = NX_FLAGSCHANGED;
            options = kIOHIDSetGlobalEventFlags;
        } else
            // Standard key
            type = down ? NX_KEYDOWN : NX_KEYUP;
        kp.key.repeat = is_repeat;
        kp.key.keyCode = scancode;
        kp.key.origCharSet = kp.key.charSet = NX_ASCIISET;
        if(IS_NUMPAD(scancode))
            flags |= NX_NUMERICPADMASK;
        else if(scancode == kVK_Help)
            flags |= NX_HELPMASK;
    }
    postevent(event, type, &kp, flags, options, !down || is_repeat);
    // Don't print errors on key up or key repeat ^
}
Esempio n. 10
0
/*---------------------------------------------------------------------------*/
wxSQLBook::~wxSQLBook()
{
    if (wxGetApp().GetSavePerspective())
    {
        wxString perspective = GetAuiManager().SavePerspective();
        wxGetApp().SetParamStr(PARAM_SQL_PERSPECTIVE, perspective);
    }

    GetAuiManager().UnInit();
    if (m_AutoClose)
    {
        wxCommandEvent postevent(wxEVT_COMMAND_MENU_SELECTED, ID_MNU_CLOSE_DB);
        wxPostEvent(wxGetApp().GetTopWindow(), postevent);
    }
}
Esempio n. 11
0
/*
 * Drop a record off the front of a sockbuf
 * and move the next record to the front.
 */
void
sbdroprecord(struct sockbuf *sb)
{
        struct mbuf *m, *mn;

        m = sb->sb_mb;
        if (m) {
                sb->sb_mb = m->m_nextpkt;
                do {
                        sbfree(sb, m);
                        MFREE(m, mn);
                        m = mn;
                } while (m);
        }
        SB_EMPTY_FIXUP(sb);
        postevent(0, sb, EV_RWBYTES);
}
Esempio n. 12
0
// Mouse wheel
static void postevent_wheel(io_connect_t event, int value){
    NXEventData mm;
    memset(&mm, 0, sizeof(mm));
    mm.scrollWheel.deltaAxis1 = value;
    postevent(event, NX_SCROLLWHEELMOVED, &mm, 0, 0);
}