⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_quartzevents.m

📁 网络MPEG4IP流媒体开发源代码
💻 M
📖 第 1 页 / 共 2 页
字号:
             SDL_PrivateKeyboard (SDL_PRESSED, &key);             /* If this was Caps Lock, we need some additional voodoo to make SDL happy */             if (bit == NSAlphaShiftKeyMask)                  SDL_PrivateKeyboard (SDL_RELEASED, &key);        }    }    current_mods = newMods;}static void QZ_DoActivate (_THIS){    in_foreground = YES;    /* Regrab the mouse, only if it was previously grabbed */    if ( current_grab_mode == SDL_GRAB_ON ) {        QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);        CGAssociateMouseAndMouseCursorPosition (0);    }    /* Hide the mouse cursor if inside the app window */    if (!QZ_cursor_visible) {        HideCursor ();    }    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);}static void QZ_DoDeactivate (_THIS) {    in_foreground = NO;    /* Ungrab mouse if it is grabbed */    if ( current_grab_mode == SDL_GRAB_ON ) {        CGAssociateMouseAndMouseCursorPosition (1);    }    /* Show the mouse cursor */    if (!QZ_cursor_visible) {        ShowCursor ();    }    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);}static void QZ_PumpEvents (_THIS){    int firstMouseEvent;    CGMouseDelta dx, dy;    NSDate *distantPast;    NSEvent *event;    NSRect winRect;    NSRect titleBarRect;    NSAutoreleasePool *pool;    pool = [ [ NSAutoreleasePool alloc ] init ];    distantPast = [ NSDate distantPast ];    winRect = NSMakeRect (0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h);    titleBarRect = NSMakeRect (0, SDL_VideoSurface->h, SDL_VideoSurface->w,                                SDL_VideoSurface->h + 22);        /* send the first mouse event in absolute coordinates */    firstMouseEvent = 1;        /* accumulate any additional mouse moved events into one SDL mouse event */    dx = 0;    dy = 0;        do {            /* Poll for an event. This will not block */        event = [ NSApp nextEventMatchingMask:NSAnyEventMask                                    untilDate:distantPast                                    inMode: NSDefaultRunLoopMode dequeue:YES ];            if (event != nil) {            unsigned int type;            BOOL isForGameWin;                #define DO_MOUSE_DOWN(button, sendToWindow) do {                                 \                            if ( in_foreground ) {                                           \                                if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) ||           \                                    NSPointInRect([event locationInWindow], winRect) )       \                                        SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);  \                            }                                                                \                            else {                                                           \                                QZ_DoActivate (this);                                        \                            }                                                                \                            [ NSApp sendEvent:event ];                                       \            } while(0)                        #define DO_MOUSE_UP(button, sendToWindow) do {                      \                            if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) ||  \                    !NSPointInRect([event locationInWindow], titleBarRect) )    \                        SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0);    \                            [ NSApp sendEvent:event ];                          \            } while(0)                        type = [ event type ];            isForGameWin = (qz_window == [ event window ]);            switch (type) {                            case NSLeftMouseDown:                    if ( getenv("SDL_HAS3BUTTONMOUSE") ) {                        DO_MOUSE_DOWN (1, 1);                    } else {                        if ( NSCommandKeyMask & current_mods ) {                            last_virtual_button = 3;                            DO_MOUSE_DOWN (3, 0);                        }                        else if ( NSAlternateKeyMask & current_mods ) {                            last_virtual_button = 2;                            DO_MOUSE_DOWN (2, 0);                        }                        else {                            DO_MOUSE_DOWN (1, 1);                        }                    }                    break;                case NSOtherMouseDown: DO_MOUSE_DOWN (2, 0); break;                case NSRightMouseDown: DO_MOUSE_DOWN (3, 0); break;                case NSLeftMouseUp:                    if ( last_virtual_button != 0 ) {                        DO_MOUSE_UP (last_virtual_button, 0);                        last_virtual_button = 0;                    }                    else {                        DO_MOUSE_UP (1, 1);                    }                    break;                case NSOtherMouseUp:   DO_MOUSE_UP (2, 0);     break;                case NSRightMouseUp:   DO_MOUSE_UP (3, 0);     break;                case NSSystemDefined:                    /*                        Future: up to 32 "mouse" buttons can be handled.                        if ([event subtype] == 7) {                            unsigned int buttons;                            buttons = [ event data2 ];                    */                    break;                case NSLeftMouseDragged:                case NSRightMouseDragged:                case NSOtherMouseDragged: /* usually middle mouse dragged */                case NSMouseMoved:                    if (current_grab_mode == SDL_GRAB_ON) {                                        /*                            If input is grabbed, the cursor doesn't move,                            so we have to call the lowlevel window server                            function. This is less accurate but works OK.                                                 */                        CGMouseDelta dx1, dy1;                        CGGetLastMouseDelta (&dx1, &dy1);                        dx += dx1;                        dy += dy1;                    }                    else if (warp_flag) {                                        /*                            If we just warped the mouse, the cursor is frozen for a while.                            So we have to use the lowlevel function until it                            unfreezes. This really helps apps that continuously                            warp the mouse to keep it in the game window. Developers should                            really use GrabInput, but our GrabInput freezes the HW cursor,                            which doesn't cut it for some apps.                        */                        Uint32 ticks;                                        ticks = SDL_GetTicks();                        if (ticks - warp_ticks < 150) {                                            CGMouseDelta dx1, dy1;                            CGGetLastMouseDelta (&dx1, &dy1);                            dx += dx1;                            dy += dy1;                        }                        else {                                            warp_flag = 0;                        }                    }                    else if (firstMouseEvent) {                                                /*                            Get the first mouse event in a possible                            sequence of mouse moved events. Since we                            use absolute coordinates, this serves to                            compensate any inaccuracy in deltas, and                            provides the first known mouse position,                            since everything after this uses deltas                        */                        NSPoint p = [ event locationInWindow ];                        QZ_PrivateCocoaToSDL(this, &p);                                                SDL_PrivateMouseMotion (0, 0, p.x, p.y);                        firstMouseEvent = 0;                    }                    else {                                            /*                            Get the amount moved since the last drag or move event,                            add it on for one big move event at the end.                        */                        dx += [ event deltaX ];                        dy += [ event deltaY ];                    }                    break;                case NSScrollWheel:                    if (NSPointInRect([ event locationInWindow ], winRect)) {                        float dy;                        Uint8 button;                        dy = [ event deltaY ];                        if ( dy > 0.0 ) /* Scroll up */                            button = SDL_BUTTON_WHEELUP;                        else /* Scroll down */                            button = SDL_BUTTON_WHEELDOWN;			/* For now, wheel is sent as a quick down+up */                        SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);                        SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0);                    }                    break;                case NSKeyUp:                    QZ_DoKey (this, SDL_RELEASED, event);                    break;                case NSKeyDown:                    QZ_DoKey (this, SDL_PRESSED, event);                    break;                case NSFlagsChanged:                    QZ_DoModifiers(this, [ event modifierFlags ] );                    break;                case NSAppKitDefined:                    switch ( [ event subtype ] ) {                        case NSApplicationActivatedEventType:                            QZ_DoActivate (this);                            break;                        case NSApplicationDeactivatedEventType:                            QZ_DoDeactivate (this);                            break;                    }                    [ NSApp sendEvent:event ];                    break;                    /* case NSApplicationDefined: break; */                    /* case NSPeriodic: break; */                    /* case NSCursorUpdate: break; */                default:                    [ NSApp sendEvent:event ];            }        }    } while (event != nil);        /* handle accumulated mouse moved events */    if (dx != 0 || dy != 0)        SDL_PrivateMouseMotion (0, 1, dx, dy);        [ pool release ];}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -