Exemplo n.º 1
0
void
FBView::MouseWheelChanged(BMessage *msg)
{
	float dy;
	if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK) {
		if(dy<0)
			mplayer_put_key(MOUSE_BTN3);
        else
            mplayer_put_key(MOUSE_BTN4);
	}
}
Exemplo n.º 2
0
void menu_audio(ULONG menucode)
{
	switch (ITEMNUM(menucode))
	{
		case ID_mute:
			mp_input_queue_cmd(mp_input_parse_cmd("mute"));
			break;
		case ID_volume_up:
			mplayer_put_key(KEY_VOLUME_UP);
			break;
		case ID_volume_down:
			mplayer_put_key(KEY_VOLUME_DOWN);
			break;
	}
}
Exemplo n.º 3
0
/**
 * \brief Dispatch incoming window events and handle them.
 *
 * This function should be placed inside libvo's function "check_events".
 *
 * Global libvo variables changed:
 * vo_dwidth:  new window client area width
 * vo_dheight: new window client area height
 *
 * \return int with these flags possibly set, take care to handle in the right order
 *         if it matters in your driver:
 *
 * VO_EVENT_RESIZE = The window was resized. If necessary reinit your
 *                   driver render context accordingly.
 * VO_EVENT_EXPOSE = The window was exposed. Call e.g. flip_frame() to redraw
 *                   the window if the movie is paused.
 */
int vo_w32_check_events(void) {
    MSG msg;
    event_flags = 0;
    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    if (WinID >= 0) {
        BOOL res;
        RECT r;
        POINT p;
        res = GetClientRect(vo_window, &r);
        if (res && (r.right != vo_dwidth || r.bottom != vo_dheight)) {
            vo_dwidth = r.right; vo_dheight = r.bottom;
            event_flags |= VO_EVENT_RESIZE;
        }
        p.x = 0; p.y = 0;
        ClientToScreen(vo_window, &p);
        if (p.x != vo_dx || p.y != vo_dy) {
            vo_dx = p.x; vo_dy = p.y;
            event_flags |= VO_EVENT_MOVE;
        }
        res = GetClientRect(WinID, &r);
        if (res && (r.right != vo_dwidth || r.bottom != vo_dheight))
            MoveWindow(vo_window, 0, 0, r.right, r.bottom, FALSE);
        if (!IsWindow(WinID))
            // Window has probably been closed, e.g. due to program crash
            mplayer_put_key(KEY_CLOSE_WIN);
    }

    return event_flags;
}
Exemplo n.º 4
0
/**
 * \brief Dispatch incoming window events and handle them.
 *
 * This function should be placed inside libvo's function "check_events".
 *
 * \return int with these flags possibly set, take care to handle in the right order
 *         if it matters in your driver:
 *
 * VO_EVENT_RESIZE = The window was resized. If necessary reinit your
 *                   driver render context accordingly.
 * VO_EVENT_EXPOSE = The window was exposed. Call e.g. flip_frame() to redraw
 *                   the window if the movie is paused.
 */
int vo_w32_check_events(struct vo *vo)
{
    struct vo_w32_state *w32 = vo->w32;
    MSG msg;
    w32->event_flags = 0;
    while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) {
        TranslateMessage(&msg);
        DispatchMessageW(&msg);
    }
    if (vo->opts->WinID >= 0) {
        BOOL res;
        RECT r;
        POINT p;
        res = GetClientRect(w32->window, &r);
        if (res && (r.right != vo->dwidth || r.bottom != vo->dheight)) {
            vo->dwidth = r.right; vo->dheight = r.bottom;
            w32->event_flags |= VO_EVENT_RESIZE;
        }
        p.x = 0; p.y = 0;
        ClientToScreen(w32->window, &p);
        if (p.x != w32->window_x || p.y != w32->window_y) {
            w32->window_x = p.x; w32->window_y = p.y;
        }
        res = GetClientRect(WIN_ID_TO_HWND(vo->opts->WinID), &r);
        if (res && (r.right != vo->dwidth || r.bottom != vo->dheight))
            MoveWindow(w32->window, 0, 0, r.right, r.bottom, FALSE);
        if (!IsWindow(WIN_ID_TO_HWND(vo->opts->WinID)))
            // Window has probably been closed, e.g. due to program crash
            mplayer_put_key(vo->key_fifo, MP_KEY_CLOSE_WIN);
    }

    return w32->event_flags;
}
Exemplo n.º 5
0
bool getch2(struct mp_fifo *fifo)
{
    int r = getch2_internal();
    if (r >= 0)
	mplayer_put_key(fifo, r);
    return true;
}
Exemplo n.º 6
0
int sdl_default_handle_event(SDL_Event *event)
{
    int mpkey;
    if (!event) {
        int res = reinit ? VO_EVENT_REINIT : 0;
        reinit = 0;
        return res;
    }
    switch (event->type) {
    case SDL_VIDEORESIZE:
        vo_dwidth  = event->resize.w;
        vo_dheight = event->resize.h;
        return VO_EVENT_RESIZE;

    case SDL_VIDEOEXPOSE:
        return VO_EVENT_EXPOSE;

    case SDL_MOUSEMOTION:
        vo_mouse_movement(event->motion.x, event->motion.y);
        break;

    case SDL_MOUSEBUTTONDOWN:
        if (!vo_nomouse_input)
            mplayer_put_key((MOUSE_BTN0 + event->button.button - 1) | MP_KEY_DOWN);
        break;

    case SDL_MOUSEBUTTONUP:
        if (!vo_nomouse_input)
            mplayer_put_key(MOUSE_BTN0 + event->button.button - 1);
        break;

    case SDL_KEYDOWN:
        mpkey = lookup_keymap_table(keysym_map, event->key.keysym.sym);
        if (!mpkey &&
            event->key.keysym.unicode > 0 &&
            event->key.keysym.unicode < 128)
            mpkey = event->key.keysym.unicode;
        if (mpkey)
            mplayer_put_key(mpkey);
        break;

    case SDL_QUIT:
        mplayer_put_key(KEY_CLOSE_WIN);
        break;
    }
    return 0;
}
Exemplo n.º 7
0
void
FBView::MouseDown(BPoint point)
{
	uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons");
    int32 clicks = Window()->CurrentMessage()->FindInt32("clicks");
	
	if( buttons & B_PRIMARY_MOUSE_BUTTON ) {
		if(clicks==1)
			mplayer_put_key(MOUSE_BTN0);
		else {
			vo_fs = !vo_fs;
     	 	((MWindow*)Window())->SetFullscreen(vo_fs);	
     	 	mplayer_put_key(MOUSE_BTN0);
		}			
	}
	if( buttons & B_SECONDARY_MOUSE_BUTTON ) {
		mplayer_put_key(clicks==1?MOUSE_BTN2:MOUSE_BTN2_DBL);
	}
	if( buttons &  B_TERTIARY_MOUSE_BUTTON ) {
		mplayer_put_key(clicks==1?MOUSE_BTN1:MOUSE_BTN1_DBL);
	}	
}
Exemplo n.º 8
0
void 
MWindow::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case B_KEY_DOWN:
		{
			uint32 code = message->FindInt32("key");
			uint32 raw_char = message->FindInt32("raw_char");

			switch (raw_char) {
				case B_ESCAPE:
					if(vo_fs==1) {
						vo_fs = !vo_fs;
	     	 			SetFullscreen(vo_fs);
					} else {
		     	 		mplayer_put_key(KEY_ESC);
					}
					break;
				case B_LEFT_ARROW:
					mplayer_put_key(KEY_LEFT);
					break;
				case B_RIGHT_ARROW:
					mplayer_put_key(KEY_RIGHT);
					break;
				case B_UP_ARROW:
					mplayer_put_key(KEY_UP);
					break;					
				case B_DOWN_ARROW:
					mplayer_put_key(KEY_DOWN);
					break;
				case B_FUNCTION_KEY:
					mplayer_put_key(KEY_F+code-1);
					break;
				case B_ENTER:
					mplayer_put_key(KEY_ENTER);
					break;					
				default:
					mplayer_put_key(raw_char);
					break;
					
			}     	 	
			break;
		}	
		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Exemplo n.º 9
0
//default keyboard event handler
static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
    OSStatus result = noErr;
	UInt32 class = GetEventClass (event);
	UInt32 kind = GetEventKind (event); 

	result = CallNextEventHandler(nextHandler, event);
	
	if(class == kEventClassKeyboard)
	{
		char macCharCodes;
		UInt32 macKeyCode;
		UInt32 macKeyModifiers;
	
		GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(macCharCodes), NULL, &macCharCodes);
		GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(macKeyCode), NULL, &macKeyCode);
		GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macKeyModifiers), NULL, &macKeyModifiers);
		
		if(macKeyModifiers != 256)
		{
			if (kind == kEventRawKeyRepeat || kind == kEventRawKeyDown)
			{
				int key = convert_key(macKeyCode, macCharCodes);
				if(key != -1)
					mplayer_put_key(key);
			}
		}
		else if(macKeyModifiers == 256)
		{
			switch(macCharCodes)
			{
				case '[': SetWindowAlpha(theWindow, winAlpha-=0.05); break;
				case ']': SetWindowAlpha(theWindow, winAlpha+=0.05); break;		
			}	
		}
		else
			result = eventNotHandledErr;
	}
	
    return result;
}
Exemplo n.º 10
0
void uiEvent(int ev, float param)
{
    int iparam     = (int)param;
    mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext);
    float aspect;
    char cmd[40];

    switch (ev) {
/* user events */
    case evExit:
        mplayer(MPLAYER_EXIT_GUI, EXIT_QUIT, 0);
        break;

    case evLoadURL:
        gtkShow(evLoadURL, NULL);
        break;

    case ivSetAudio:

        if (!mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam)
            break;

        mp_property_do("switch_audio", M_PROPERTY_SET, &iparam, guiInfo.mpcontext);
        break;

    case ivSetVideo:

        if (!mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam)
            break;

        mp_property_do("switch_video", M_PROPERTY_SET, &iparam, guiInfo.mpcontext);
        break;

    case ivSetSubtitle:
        mp_property_do("sub", M_PROPERTY_SET, &iparam, guiInfo.mpcontext);
        break;

#ifdef CONFIG_CDDA
    case ivSetCDTrack:
        guiInfo.Track = iparam;

    case evPlayCD:
        guiInfo.StreamType = STREAMTYPE_CDDA;
        goto play;
#endif
#ifdef CONFIG_VCD
    case ivSetVCDTrack:
        guiInfo.Track = iparam;

    case evPlayVCD:
        guiInfo.StreamType = STREAMTYPE_VCD;
        goto play;
#endif
#ifdef CONFIG_DVDREAD
    case ivSetDVDSubtitle:
        dvdsub_id = iparam;
        uiEvent(ivPlayDVD, 0);
        break;

    case ivSetDVDAudio:
        audio_id = iparam;
        uiEvent(ivPlayDVD, 0);
        break;

    case ivSetDVDChapter:
        guiInfo.Chapter = iparam;
        uiEvent(ivPlayDVD, 0);
        break;

    case ivSetDVDTitle:
        guiInfo.Track   = iparam;
        guiInfo.Chapter = 1;
        guiInfo.Angle   = 1;
        uiEvent(ivPlayDVD, 0);
        break;

    case evPlayDVD:
        guiInfo.Chapter = 1;
        guiInfo.Angle   = 1;

    case ivPlayDVD:
        guiInfo.StreamType = STREAMTYPE_DVD;
        goto play;
#endif
#ifdef CONFIG_TV
    case evPlayTV:
        guiInfo.StreamType = guiTV[gui_tv_digital].StreamType;
        goto play;
#endif
    case evPlay:
    case evPlaySwitchToPause:
play:

        if (guiInfo.Playing != GUI_PAUSE) {
            MediumPrepare(guiInfo.StreamType);

            switch (guiInfo.StreamType) {
            case STREAMTYPE_FILE:
            case STREAMTYPE_STREAM:
            case STREAMTYPE_PLAYLIST:

                if (!guiInfo.Track)
                    guiInfo.Track = 1;

                guiInfo.MediumChanged = GUI_MEDIUM_NEW;
                guiInfo.PlaylistNext  = !guiInfo.Playing;

                break;

            case STREAMTYPE_CDDA:
            case STREAMTYPE_VCD:
            case STREAMTYPE_DVD:
            case STREAMTYPE_TV:
            case STREAMTYPE_DVB:

                if (!guiInfo.Track)
                    guiInfo.Track = (guiInfo.StreamType == STREAMTYPE_VCD ? 2 : 1);

            case STREAMTYPE_BINCUE:   // track 0 is OK and will auto-select first media data track
                guiInfo.MediumChanged = GUI_MEDIUM_SAME;

                break;
            }
        }

        uiPlay();
        break;

    case evPause:
    case evPauseSwitchToPlay:
        uiPause();
        break;

    case evStop:
        guiInfo.Playing = GUI_STOP;
        uiState();
        break;

    case evLoadPlay:
        uiLoadPlay = True;

//      guiInfo.StreamType=STREAMTYPE_FILE;
    case evLoad:
        gtkShow(evLoad, NULL);
        break;

    case evLoadSubtitle:
        gtkShow(evLoadSubtitle, NULL);
        break;

    case evDropSubtitle:
        nfree(guiInfo.SubtitleFilename);
        mplayerLoadSubtitle(NULL);
        break;

    case evLoadAudioFile:
        gtkShow(evLoadAudioFile, NULL);
        break;

    case evPlayImage:
        gtkShow(evPlayImage, NULL);
        break;

    case evPrev:
        uiPrev();
        break;

    case evNext:
        uiNext();
        break;

    case evPlaylist:
        gtkShow(evPlaylist, NULL);
        break;

    case evSkinBrowser:
        gtkShow(evSkinBrowser, skinName);
        break;

    case evAbout:
        gtkShow(evAbout, NULL);
        break;

    case evPreferences:
        gtkShow(evPreferences, NULL);
        break;

    case evEqualizer:
        gtkShow(evEqualizer, NULL);
        break;

    case evForward10min:
        uiRelSeek(600);
        break;

    case evBackward10min:
        uiRelSeek(-600);
        break;

    case evForward1min:
        uiRelSeek(60);
        break;

    case evBackward1min:
        uiRelSeek(-60);
        break;

    case evForward10sec:
        uiRelSeek(10);
        break;

    case evBackward10sec:
        uiRelSeek(-10);
        break;

    case evSetMoviePosition:
        guiInfo.Position = param;
        uiPctSeek(guiInfo.Position);
        break;

    case evIncVolume:
        mplayer_put_key(KEY_VOLUME_UP);
        break;

    case evDecVolume:
        mplayer_put_key(KEY_VOLUME_DOWN);
        break;

    case evMute:
        mixer_mute(mixer);
        break;

    case evSetVolume:
    case ivSetVolume:
        guiInfo.Volume = param;
        {
            float l = guiInfo.Volume * (100.0 - guiInfo.Balance) / 50.0;
            float r = guiInfo.Volume * guiInfo.Balance / 50.0;
            mixer_setvolume(mixer, FFMIN(l, guiInfo.Volume), FFMIN(r, guiInfo.Volume));
        }

        if (ev == ivSetVolume)
            break;

        if (osd_level) {
            osd_visible = (GetTimerMS() + 1000) | 1;
            vo_osd_progbar_type  = OSD_VOLUME;
            vo_osd_progbar_value = guiInfo.Volume * 256.0 / 100.0;
            vo_osd_changed(OSDTYPE_PROGBAR);
        }

        break;

    case evSetBalance:
    case ivSetBalance:
        guiInfo.Balance = param;
        mixer_setbalance(mixer, (guiInfo.Balance - 50.0) / 50.0);     // transform 0..100 to -1..1
        uiEvent(ivSetVolume, guiInfo.Volume);

        if (ev == ivSetBalance)
            break;

        if (osd_level) {
            osd_visible = (GetTimerMS() + 1000) | 1;
            vo_osd_progbar_type  = OSD_BALANCE;
            vo_osd_progbar_value = guiInfo.Balance * 256.0 / 100.0;
            vo_osd_changed(OSDTYPE_PROGBAR);
        }

        break;

    case evMenu:
        /*if (guiApp.menuIsPresent)   NOTE TO MYSELF: Uncomment only after mouse
         * {                                            pointer and cursor keys work
         * gtkShow( ivHidePopUpMenu,NULL );            with this menu from skin as
         * uiMenuShow( 0,0 );                          they do with normal menus.
         * }
         * else*/gtkShow(ivShowPopUpMenu, NULL);
        break;

    case evIconify:

        switch (iparam) {
        case 0:
            wsWindowIconify(&guiApp.mainWindow);
            break;

        case 1:
            wsWindowIconify(&guiApp.videoWindow);
            break;
        }

        break;

    case evHalfSize:

        if (guiInfo.VideoWindow && guiInfo.Playing) {
            if (guiApp.videoWindow.isFullScreen) {
                uiFullScreen();
            }

            wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2);
            btnSet(evFullScreen, btnReleased);
        }

        break;

    case evDoubleSize:

        if (guiInfo.VideoWindow && guiInfo.Playing) {
            if (guiApp.videoWindow.isFullScreen) {
                uiFullScreen();
            }

            wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2);
            wsWindowMoveWithin(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y);
            btnSet(evFullScreen, btnReleased);
        }

        break;

    case evNormalSize:

        if (guiInfo.VideoWindow && guiInfo.Playing) {
            if (guiApp.videoWindow.isFullScreen) {
                uiFullScreen();
            }

            wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight);
            btnSet(evFullScreen, btnReleased);
            break;
        } else if (!guiApp.videoWindow.isFullScreen)
            break;

    case evFullScreen:

        if (guiInfo.VideoWindow && (guiInfo.Playing || !iparam)) {
            uiFullScreen();

            if (!guiApp.videoWindow.isFullScreen)
                wsWindowResize(&guiApp.videoWindow, iparam ? guiInfo.VideoWidth : guiApp.video.width, iparam ? guiInfo.VideoHeight : guiApp.video.height);
        }

        if (guiApp.videoWindow.isFullScreen)
            btnSet(evFullScreen, btnPressed);
        else
            btnSet(evFullScreen, btnReleased);

        break;

    case evSetAspect:

        switch (iparam) {
        case 2:
            aspect = 16.0f / 9.0f;
            break;

        case 3:
            aspect = 4.0f / 3.0f;
            break;

        case 4:
            aspect = 2.35f;
            break;

        case 1:
        default:
            aspect = -1;
            break;
        }

        snprintf(cmd, sizeof(cmd), "pausing_keep switch_ratio %f", aspect);
        mp_input_queue_cmd(mp_input_parse_cmd(cmd));

        break;

    case evSetRotation:

        switch (iparam) {
        case 90:
            guiInfo.Rotation = 1;
            break;

        case -90:
            guiInfo.Rotation = 2;
            break;

        case 180:
            guiInfo.Rotation = 8;
            break;

        case 0:
        default:
            guiInfo.Rotation = -1;
            break;
        }

        guiInfo.MediumChanged = GUI_MEDIUM_SAME;

        break;

/* timer events */
    case ivRedraw:
    {
        unsigned int now = GetTimerMS();

        if ((now > last_redraw_time) &&
            (now < last_redraw_time + GUI_REDRAW_WAIT) &&
            !uiPlaybarFade && (iparam == 0))
            break;

        last_redraw_time = now;
    }
        uiMainRender = True;
        wsWindowRedraw(&guiApp.mainWindow);
        wsWindowRedraw(&guiApp.playbarWindow);
        break;

/* system events */
    case evNone:
        mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: evNone\n");
        break;

    default:
        mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: unknown event %d, param %.2f\n", ev, param);
        break;
    }
}
Exemplo n.º 11
0
static void check_events(void)
{
    struct timeval  tv = {0, 0};
    ggi_event       event;
    ggi_event_mask  mask;

    if ((mask = ggiEventPoll(ggi_conf.vis, emAll, &tv))) {
        if (ggiEventRead(ggi_conf.vis, &event, emAll) != 0) {
            mp_dbg(MSGT_VO, MSGL_DBG3,
                   "type: %4x, origin: %4x, "
                   "sym: %4x, label: %4x, button=%4x\n",
                   event.any.origin, event.any.type, event.key.sym,
                   event.key.label, event.key.button);

            switch (event.any.type) {
            case evKeyPress:
                switch (event.key.sym) {
                case GIIK_PAsterisk:    /* PStar */
                case GIIUC_Asterisk:
                    mplayer_put_key('*');
                    break;
                case GIIK_PSlash:
                case GIIUC_Slash:
                    mplayer_put_key('/');
                    break;
                case GIIK_PPlus:
                case GIIUC_Plus:
                    mplayer_put_key('+');
                    break;
                case GIIK_PMinus:
                case GIIUC_Minus:
                    mplayer_put_key('-');
                    break;
                case GIIUC_o:
                case GIIUC_O:
                    mplayer_put_key('o');
                    break;
                case GIIUC_g:
                case GIIUC_G:
                    mplayer_put_key('g');
                    break;
                case GIIUC_z:
                case GIIUC_Z:
                    mplayer_put_key('z');
                    break;
                case GIIUC_x:
                case GIIUC_X:
                    mplayer_put_key('x');
                    break;
                case GIIUC_m:
                case GIIUC_M:
                    mplayer_put_key('m');
                    break;
                case GIIUC_d:
                case GIIUC_D:
                    mplayer_put_key('d');
                    break;
                case GIIUC_q:
                case GIIUC_Q:
                    mplayer_put_key('q');
                    break;
                case GIIUC_h:
                case GIIUC_H:
                    mplayer_put_key('h');
                    break;
                case GIIUC_l:
                case GIIUC_L:
                    mplayer_put_key('l');
                    break;
                case GIIUC_Space:
                case GIIUC_p:
                case GIIUC_P:
                    mplayer_put_key('p');
                    break;
                case GIIK_Up:
                    mplayer_put_key(KEY_UP);
                    break;
                case GIIK_Down:
                    mplayer_put_key(KEY_DOWN);
                    break;
                case GIIK_Left:
                    mplayer_put_key(KEY_LEFT);
                    break;
                case GIIK_Right:
                    mplayer_put_key(KEY_RIGHT);
                    break;
                case GIIK_PageUp:
                    mplayer_put_key(KEY_PAGE_UP);
                    break;
                case GIIK_PageDown:
                    mplayer_put_key(KEY_PAGE_DOWN);
                    break;
                default:
                    break;
                }   /* switch */

                break;
            }   /* switch */
        }   /* if */
    }   /* if */
    return;
}
Exemplo n.º 12
0
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
                                LPARAM lParam)
{
    if (message == WM_NCCREATE) {
        CREATESTRUCT *cs = (void*)lParam;
        SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)cs->lpCreateParams);
    }
    struct vo *vo = (void*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
    // message before WM_NCCREATE, pray to Raymond Chen that it's not important
    if (!vo)
        return DefWindowProcW(hWnd, message, wParam, lParam);
    struct vo_w32_state *w32 = vo->w32;

    switch (message) {
        case WM_ERASEBKGND: // no need to erase background seperately
            return 1;
        case WM_PAINT:
            w32->event_flags |= VO_EVENT_EXPOSE;
            break;
        case WM_MOVE: {
            POINT p = {0};
            ClientToScreen(w32->window, &p);
            w32->window_x = p.x;
            w32->window_y = p.y;
            mp_msg(MSGT_VO, MSGL_V, "[vo] move window: %d:%d\n",
                   w32->window_x, w32->window_y);
            break;
        }
        case WM_SIZE: {
            w32->event_flags |= VO_EVENT_RESIZE;
            RECT r;
            GetClientRect(w32->window, &r);
            vo->dwidth = r.right;
            vo->dheight = r.bottom;
            mp_msg(MSGT_VO, MSGL_V, "[vo] resize window: %d:%d\n",
                   vo->dwidth, vo->dheight);
            break;
        }
        case WM_SIZING:
            if (vo->opts->keepaspect && !vo->opts->fs && vo->opts->WinID < 0) {
                RECT *rc = (RECT*)lParam;
                // get client area of the windows if it had the rect rc
                // (subtracting the window borders)
                RECT r = *rc;
                subtract_window_borders(w32->window, &r);
                int c_w = r.right - r.left, c_h = r.bottom - r.top;
                float aspect = vo->aspdat.asp;
                int d_w = c_h * aspect - c_w;
                int d_h = c_w / aspect - c_h;
                int d_corners[4] = { d_w, d_h, -d_w, -d_h };
                int corners[4] = { rc->left, rc->top, rc->right, rc->bottom };
                int corner = get_resize_border(wParam);
                if (corner >= 0)
                    corners[corner] -= d_corners[corner];
                *rc = (RECT) { corners[0], corners[1], corners[2], corners[3] };
                return TRUE;
            }
            break;
        case WM_CLOSE:
            mplayer_put_key(vo->key_fifo, MP_KEY_CLOSE_WIN);
            break;
        case WM_SYSCOMMAND:
            switch (wParam) {
                case SC_SCREENSAVE:
                case SC_MONITORPOWER:
                    mp_msg(MSGT_VO, MSGL_V, "vo: win32: killing screensaver\n");
                    return 0;
            }
            break;
        case WM_KEYDOWN:
        case WM_SYSKEYDOWN: {
            int mpkey = lookup_keymap_table(vk_map, wParam);
            if (mpkey)
                mplayer_put_key(vo->key_fifo, mpkey | mod_state(vo));
            if (wParam == VK_F10)
                return 0;
            break;
        }
        case WM_CHAR:
        case WM_SYSCHAR: {
            int mods = mod_state(vo);
            int code = wParam;
            // Windows enables Ctrl+Alt when AltGr (VK_RMENU) is pressed.
            // E.g. AltGr+9 on a German keyboard would yield Ctrl+Alt+[
            // Warning: wine handles this differently. Don't test this on wine!
            if (key_state(vo, VK_RMENU))
                mods &= ~(MP_KEY_MODIFIER_CTRL | MP_KEY_MODIFIER_ALT);
            // Apparently Ctrl+A to Ctrl+Z is special cased, and produces
            // character codes from 1-26. Work it around.
            // Also, enter/return (including the keypad variant) and CTRL+J both
            // map to wParam==10. As a workaround, check VK_RETURN to
            // distinguish these two key combinations.
            if ((mods & MP_KEY_MODIFIER_CTRL) && code >= 1 && code <= 26
                && !key_state(vo, VK_RETURN))
                code = code - 1 + (mods & MP_KEY_MODIFIER_SHIFT ? 'A' : 'a');
            if (code >= 32 && code < (1<<21)) {
                mplayer_put_key(vo->key_fifo, code | mods);
                // At least with Alt+char, not calling DefWindowProcW stops
                // Windows from emitting a beep.
                return 0;
            }
            break;
        }
        case WM_LBUTTONDOWN:
            if (!vo->opts->nomouse_input && (vo->opts->fs || (wParam & MK_CONTROL)))
            {
                mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN0 | mod_state(vo));
                break;
            }
            if (!vo->opts->fs) {
                ReleaseCapture();
                SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
                return 0;
            }
            break;
        case WM_MBUTTONDOWN:
            if (!vo->opts->nomouse_input)
                mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN1 | mod_state(vo));
            break;
        case WM_RBUTTONDOWN:
            if (!vo->opts->nomouse_input)
                mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN2 | mod_state(vo));
            break;
        case WM_MOUSEMOVE:
            vo_mouse_movement(vo, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
            break;
        case WM_MOUSEWHEEL:
            if (!vo->opts->nomouse_input) {
                int x = GET_WHEEL_DELTA_WPARAM(wParam);
                if (x > 0)
                    mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN3 | mod_state(vo));
                else
                    mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN4 | mod_state(vo));
            }
            break;
        case WM_XBUTTONDOWN:
            if (!vo->opts->nomouse_input) {
                int x = HIWORD(wParam);
                if (x == 1)
                    mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN5 | mod_state(vo));
                else // if (x == 2)
                    mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN6 | mod_state(vo));
            }
            break;
    }

    return DefWindowProcW(hWnd, message, wParam, lParam);
}
Exemplo n.º 13
0
static void check_events (void)
{
    unsigned int cev;

    if ((cev = caca_get_event(CACA_EVENT_ANY)))
    {
	if (cev & CACA_EVENT_RESIZE)
	{
	    caca_refresh();
	    resize();
	} else if (cev & CACA_EVENT_KEY_RELEASE)
	{
	    int key = (cev & 0x00ffffff);
	    enum caca_feature cf;

	    switch (key) {
	    case 'd':
	    case 'D':
	      /* Toggle dithering method */
	      cf = 1 + caca_get_feature(CACA_DITHERING);
	      if (cf > CACA_DITHERING_MAX)
		  cf = CACA_DITHERING_MIN;
	      caca_set_feature(cf);
	      osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
	      break;

	    case 'a':
	    case 'A':
	      /* Toggle antialiasing method */
	      cf = 1 + caca_get_feature(CACA_ANTIALIASING);
	      if (cf > CACA_ANTIALIASING_MAX)
		  cf = CACA_ANTIALIASING_MIN;
	      caca_set_feature(cf);
	      osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
	      break;

	    case 'b':
	    case 'B':
	      /* Toggle background method */
	      cf = 1 + caca_get_feature(CACA_BACKGROUND);
	      if (cf > CACA_BACKGROUND_MAX)
		  cf = CACA_BACKGROUND_MIN;
	      caca_set_feature(cf);
	      osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
	      break;

	    case CACA_KEY_UP:
	      mplayer_put_key(KEY_UP);
	      break;
	    case CACA_KEY_DOWN:
	      mplayer_put_key(KEY_DOWN);
	      break;
	    case CACA_KEY_LEFT:
	      mplayer_put_key(KEY_LEFT);
	      break;
	    case CACA_KEY_RIGHT:
	      mplayer_put_key(KEY_RIGHT);
	      break;
	    case CACA_KEY_ESCAPE:
	      mplayer_put_key(KEY_ESC);
	      break;
	    case CACA_KEY_PAGEUP:
	      mplayer_put_key(KEY_PAGE_UP);
	      break;
	    case CACA_KEY_PAGEDOWN:
	      mplayer_put_key(KEY_PAGE_DOWN);
	      break;
	    case CACA_KEY_RETURN:
	      mplayer_put_key(KEY_ENTER);
	      break;
	    case CACA_KEY_HOME:
	      mplayer_put_key(KEY_HOME);
	      break;
	    case CACA_KEY_END:
	      mplayer_put_key(KEY_END);
	      break;
	    default:
	      if (key <= 255)
		  mplayer_put_key (key);
	      break;
	    }
	}
    }
}
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message){
	    case WM_DESTROY:
			PostQuitMessage(0);
			return 0;
	    case WM_CLOSE:
			mplayer_put_key(KEY_CLOSE_WIN);
			break;
		case WM_WINDOWPOSCHANGED:
           {
                int tmpheight=0;
                /*calculate new window rect*/
                 if(!vo_fs){
                 RECT rd;
                 POINT point_window;
                 if(!hWnd)hWnd=hwnd;
                 ShowCursor(TRUE);
                 point_window.x = 0;
                 point_window.y = 0;
                 ClientToScreen(hWnd,&point_window);
                 GetClientRect(hWnd,&rd);

                 vo_dwidth=rd.right - rd.left;
                 vo_dheight=rd.bottom - rd.top;
                 vo_dx =point_window.x;
                 vo_dy =point_window.y;
          //       aspect(&vo_dwidth, &vo_dheight, A_NOZOOM);

                 /* keep aspect on resize, borrowed from vo_directx.c */
                 tmpheight = ((float)vo_dwidth/window_aspect);
                 tmpheight += tmpheight % 2;
                 if(tmpheight > vo_dheight)
                 {
                     vo_dwidth = ((float)vo_dheight*window_aspect);
                     vo_dwidth += vo_dwidth % 2;
                 }
                 else vo_dheight = tmpheight;
                 rd.right = rd.left + vo_dwidth;
                 rd.bottom = rd.top + vo_dheight;

                 if(rd.left < 0) rd.left = 0;
                 if(rd.right > vo_screenwidth) rd.right = vo_screenwidth;
                 if(rd.top < 0) rd.top = 0;
                 if(rd.bottom > vo_screenheight) rd.bottom = vo_screenheight;

                 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0);
                 SetWindowPos(hWnd, HWND_TOPMOST, vo_dx+rd.left, vo_dy+rd.top, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER);
               }
               else {
                 if(ShowCursor(FALSE)>=0)while(ShowCursor(FALSE)>=0){}
                 aspect(&vo_dwidth, &vo_dheight, A_ZOOM);
                 vo_dx = (vo_screenwidth - vo_dwidth)/2;
                 vo_dy = (vo_screenheight - vo_dheight)/2;
               }
               /*update vidix*/
               /* FIXME: implement runtime resize/move if possible, this way is very ugly! */
	           vidix_stop();
	           if(vidix_init(image_width, image_height, vo_dx, vo_dy, vo_dwidth, vo_dheight, image_format, vo_depthonscreen, vo_screenwidth, vo_screenheight) != 0)
	               mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s\n", strerror(errno));
               /*set colorkey*/
               vidix_start();
               mp_msg(MSGT_VO, MSGL_V, "[winvidix] window properties: pos: %dx%d, size: %dx%d\n",vo_dx, vo_dy, vo_dwidth, vo_dheight);
               if(vidix_grkey_support()){
                 vidix_grkey_get(&gr_key);
	             gr_key.key_op = KEYS_PUT;
	             gr_key.ckey.op = CKEY_TRUE;
	             if(vo_fs)gr_key.ckey.red = gr_key.ckey.green = gr_key.ckey.blue = 0;
                 else {
                   gr_key.ckey.red = gr_key.ckey.blue = 255;
                   gr_key.ckey.green = 0;
	             }
                 vidix_grkey_set(&gr_key);
               }

           }
           break;
        case WM_SYSCOMMAND:
	        switch (wParam){
                case SC_SCREENSAVE:
		        case SC_MONITORPOWER:
                    return 0;
			 }
             break;
        case WM_KEYDOWN:
			switch (wParam){
				case VK_LEFT:
					{mplayer_put_key(KEY_LEFT);break;}
                case VK_UP:
					{mplayer_put_key(KEY_UP);break;}
                case VK_RIGHT:
					{mplayer_put_key(KEY_RIGHT);break;}
	            case VK_DOWN:
					{mplayer_put_key(KEY_DOWN);break;}
	            case VK_TAB:
					{mplayer_put_key(KEY_TAB);break;}
		        case VK_CONTROL:
					{mplayer_put_key(KEY_CTRL);break;}
		        case VK_DELETE:
					{mplayer_put_key(KEY_DELETE);break;}
		        case VK_INSERT:
					{mplayer_put_key(KEY_INSERT);break;}
		        case VK_HOME:
					{mplayer_put_key(KEY_HOME);break;}
		        case VK_END:
					{mplayer_put_key(KEY_END);break;}
		        case VK_PRIOR:
			        {mplayer_put_key(KEY_PAGE_UP);break;}
		        case VK_NEXT:
			        {mplayer_put_key(KEY_PAGE_DOWN);break;}
		        case VK_ESCAPE:
					{mplayer_put_key(KEY_ESC);break;}
			}
            break;
        case WM_CHAR:
			mplayer_put_key(wParam);
			break;
    }
	return DefWindowProc(hwnd, message, wParam, lParam);
}
Exemplo n.º 15
0
void getch2(struct mp_fifo *fifo)
{
    int r = getch2_internal();
    if (r >= 0)
	mplayer_put_key(fifo, r);
}
Exemplo n.º 16
0
Arquivo: getch2.c Projeto: maletor/mpv
bool getch2(struct mp_fifo *fifo)
{
    int retval = read(0, &getch2_buf[getch2_len], BUF_LEN-getch2_len);
    /* Return false on EOF to stop running select() on the FD, as it'd
     * trigger all the time. Note that it's possible to get temporary
     * EOF on terminal if the user presses ctrl-d, but that shouldn't
     * happen if the terminal state change done in getch2_enable()
     * works.
     */
    if (retval < 1)
        return retval;
    getch2_len += retval;

    while (getch2_len > 0 && (getch2_len > 1 || getch2_buf[0] != 27)) {
        int i, len, code;

        /* First find in the TERMCAP database: */
        for (i = 0; i < getch2_key_db; i++) {
            if ((len = getch2_keys[i].len) <= getch2_len)
                if(memcmp(getch2_keys[i].chars, getch2_buf, len) == 0) {
                    code = getch2_keys[i].code;
                    goto found;
                }
        }
        /* We always match some keypress here, with length 1 if nothing else.
         * Since some of the cases explicitly test remaining buffer length
         * having a keycode only partially read in the buffer could incorrectly
         * use the first byte as an independent character.
         * However the buffer is big enough that this shouldn't happen too
         * easily, and it's been this way for years without many complaints.
         * I see no simple fix as there's no easy test which would tell
         * whether a string must be part of a longer keycode. */
        len = 1;
        code = getch2_buf[0];
        /* Check the well-known codes... */
        if (code != 27) {
            if (code == 'A'-64) code = MP_KEY_HOME;
            else if (code == 'E'-64) code = MP_KEY_END;
            else if (code == 'D'-64) code = MP_KEY_DEL;
            else if (code == 'H'-64) code = MP_KEY_BS;
            else if (code == 'U'-64) code = MP_KEY_PGUP;
            else if (code == 'V'-64) code = MP_KEY_PGDWN;
            else if (code == 8 || code==127) code = MP_KEY_BS;
            else if (code == 10 || code==13) {
                if (getch2_len > 1) {
                    int c = getch2_buf[1];
                    if ((c == 10 || c == 13) && (c != code))
                        len = 2;
                }
                code = MP_KEY_ENTER;
            } else {
                int utf8len = bstr_parse_utf8_code_length(code);
                if (utf8len > 0 && utf8len <= getch2_len) {
                    struct bstr s = { getch2_buf, utf8len };
                    int unicode = bstr_decode_utf8(s, NULL);
                    if (unicode > 0) {
                        len = utf8len;
                        code = unicode;
                    }
                }
            }
        }
        else if (getch2_len > 1) {
            int c = getch2_buf[1];
            if (c == 27) {
                code = MP_KEY_ESC;
                len = 2;
                goto found;
            }
            if (c >= '0' && c <= '9') {
                code = c-'0'+MP_KEY_F;
                len = 2;
                goto found;
            }
            if (getch2_len >= 4 && c == '[' && getch2_buf[2] == '[') {
                int c = getch2_buf[3];
                if (c >= 'A' && c < 'A'+12) {
                    code = MP_KEY_F+1 + c-'A';
                    len = 4;
                    goto found;
                }
            }
            if ((c == '[' || c == 'O') && getch2_len >= 3) {
                int c = getch2_buf[2];
                const int ctable[] = {
                    MP_KEY_UP, MP_KEY_DOWN, MP_KEY_RIGHT, MP_KEY_LEFT, 0,
                    MP_KEY_END, MP_KEY_PGDWN, MP_KEY_HOME, MP_KEY_PGUP, 0, 0, MP_KEY_INS, 0, 0, 0,
                    MP_KEY_F+1, MP_KEY_F+2, MP_KEY_F+3, MP_KEY_F+4};
                if (c >= 'A' && c <= 'S')
                    if (ctable[c - 'A']) {
                        code = ctable[c - 'A'];
                        len = 3;
                        goto found;
                    }
            }
            if (getch2_len >= 4 && c == '[' && getch2_buf[3] == '~') {
                int c = getch2_buf[2];
                const int ctable[8] = {MP_KEY_HOME, MP_KEY_INS, MP_KEY_DEL, MP_KEY_END, MP_KEY_PGUP, MP_KEY_PGDWN, MP_KEY_HOME, MP_KEY_END};
                if (c >= '1' && c <= '8') {
                    code = ctable[c - '1'];
                    len = 4;
                    goto found;
                }
            }
            if (getch2_len >= 5 && c == '[' && getch2_buf[4] == '~') {
                int i = getch2_buf[2] - '0';
                int j = getch2_buf[3] - '0';
                if (i >= 0 && i <= 9 && j >= 0 && j <= 9) {
                    const short ftable[20] = {
                        11,12,13,14,15, 17,18,19,20,21,
                        23,24,25,26,28, 29,31,32,33,34 };
                    int a = i*10 + j;
                    for (i = 0; i < 20; i++)
                        if (ftable[i] == a) {
                            code = MP_KEY_F+1 + i;
                            len = 5;
                            goto found;
                        }
                }
            }
        }
    found:
        getch2_len -= len;
        for (i = 0; i < getch2_len; i++)
            getch2_buf[i] = getch2_buf[len+i];
        mplayer_put_key(fifo, code);
    }
    return true;
}
Exemplo n.º 17
0
//default mouse event handler
static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
    OSStatus result = noErr;
	UInt32 class = GetEventClass (event);
	UInt32 kind = GetEventKind (event); 

	result = CallNextEventHandler(nextHandler, event);
	
	if(class == kEventClassMouse)
	{
		WindowPtr tmpWin;
		Point mousePos;
		Point winMousePos;

		GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mousePos);
		GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &winMousePos);

		switch (kind)
		{
			case kEventMouseMoved:
			{
				if(vo_quartz_fs)
				{
					CGDisplayShowCursor(kCGDirectMainDisplay);
					mouseHide = FALSE;
				}
			}
			break;
			
			case kEventMouseWheelMoved:
			{
				int wheel;
				short part;
				
				GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(int), 0, &wheel);

				part = FindWindow(mousePos,&tmpWin);
				
				if(part == inContent)
				{
					if(wheel > 0)
						mplayer_put_key(MOUSE_BTN3);
					else
						mplayer_put_key(MOUSE_BTN4);
				}
			}
			break;
			
			case kEventMouseDown:
			{
				EventMouseButton button;
				short part;
				Rect bounds;
				
				GetWindowPortBounds(theWindow, &bounds);
				GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button);
				
				part = FindWindow(mousePos,&tmpWin);
				
				if( (winMousePos.h > (bounds.right - 15)) && (winMousePos.v > (bounds.bottom)) )
				{
					if(!vo_quartz_fs)
					{
						GrowWindow(theWindow, mousePos, NULL);
					}
				}
				else if(part == inMenuBar)
				{
					MenuSelect(mousePos);
					HiliteMenu(0);
				}
				else if(part == inContent)
				{
					switch(button)
					{ 
						case 1: mplayer_put_key(MOUSE_BTN0);break;
						case 2: mplayer_put_key(MOUSE_BTN2);break;
						case 3: mplayer_put_key(MOUSE_BTN1);break;
				
						default:result = eventNotHandledErr;break;
					}
				}
			}		
			break;
			
			case kEventMouseUp:
			break;
			
			case kEventMouseDragged:
			break;
				
			default:result = eventNotHandledErr;break;
		}
	}

    return result;
}
Exemplo n.º 18
0
//default window event handler
static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
    OSStatus result = noErr;
	uint32_t d_width;
	uint32_t d_height;
	UInt32 class = GetEventClass (event);
	UInt32 kind = GetEventKind (event); 

	result = CallNextEventHandler(nextHandler, event);
	
	aspect(&d_width,&d_height,A_NOZOOM);

	if(class == kEventClassCommand)
	{
		HICommand theHICommand;
		GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof( HICommand ), NULL, &theHICommand );
		
		switch ( theHICommand.commandID )
		{
			case kHICommandQuit:
				mplayer_put_key(KEY_CLOSE_WIN);
				break;
				
			case kHalfScreenCmd:
					if(vo_quartz_fs)
					{
						vo_fs = (!(vo_fs)); window_fullscreen();
					}
						
					SizeWindow(theWindow, (d_width/2), ((d_width/movie_aspect)/2), 1);
					window_resized();
				break;

			case kNormalScreenCmd:
					if(vo_quartz_fs)
					{
						vo_fs = (!(vo_fs)); window_fullscreen();
					}
						
					SizeWindow(theWindow, d_width, (d_width/movie_aspect), 1);
					window_resized();
				break;

			case kDoubleScreenCmd:
					if(vo_quartz_fs)
					{
						vo_fs = (!(vo_fs)); window_fullscreen();
					}
						
					SizeWindow(theWindow, (d_width*2), ((d_width/movie_aspect)*2), 1);
					window_resized();
				break;

			case kFullScreenCmd:
				vo_fs = (!(vo_fs)); window_fullscreen();
				break;

			case kKeepAspectCmd:
				vo_keepaspect = (!(vo_keepaspect));
				CheckMenuItem (aspectMenu, 1, vo_keepaspect);
				window_resized();
				break;
				
			case kAspectOrgCmd:
				movie_aspect = old_movie_aspect;
				if(!vo_quartz_fs)
				{
					SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
				}
				window_resized();
				break;
				
			case kAspectFullCmd:
				movie_aspect = 4.0f/3.0f;
				if(!vo_quartz_fs)
				{
					SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
				}
				window_resized();
				break;
				
			case kAspectWideCmd:
				movie_aspect = 16.0f/9.0f;
				if(!vo_quartz_fs)
				{
					SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
				}
				window_resized();
				break;
				
			case kPanScanCmd:
				vo_panscan = (!(vo_panscan));
				CheckMenuItem (aspectMenu, 2, vo_panscan);
				window_panscan();
				window_resized();
				break;
			
			default:
				result = eventNotHandledErr;
				break;
		}
	}
	else if(class == kEventClassWindow)
static void
check_events(void) {
    /*
     * any events?
     * called by show_image and mplayer
     */
    int key;
    while ((key=aa_getevent(c,0))!=AA_NONE ){
	if (key>255){
	    /* some conversations */
	    switch (key) {
		case AA_UP:
		    mplayer_put_key(KEY_UP);
		    break;
		case AA_DOWN:
		    mplayer_put_key(KEY_DOWN);
		    break;
		case AA_LEFT:
		    mplayer_put_key(KEY_LEFT);
		    break;
		case AA_RIGHT:
		    mplayer_put_key(KEY_RIGHT);
		    break;
		case AA_ESC:
		    mplayer_put_key(KEY_ESC);
		    break;
		case 65765:
		    mplayer_put_key(KEY_PAGE_UP);
		    break;
		case 65766:
		    mplayer_put_key(KEY_PAGE_DOWN);
		    break;
		default:
		    continue; /* aa lib special key */
		    break;
	    }
	}
	if (key=='a' || key=='A'){
	    aaconfigmode=!aaconfigmode;
	    osdmessage(MESSAGE_DURATION, 1, "aa config mode is now %s",
		    aaconfigmode==1 ? "on. use keys 5-7" : "off");
	}
	if (aaconfigmode==1) {
	    switch (key) {
		/* AA image controls */
		case '5':
		    fast=!fast;
		    osdmessage(MESSAGE_DURATION, 1, "Fast mode is now %s", fast==1 ? "on" : "off");
		    break;
		case '6':
		    if (p->dither==AA_FLOYD_S){
			p->dither=AA_NONE;
			osdmessage(MESSAGE_DURATION, 1, "Dithering: Off");
		    }else if (p->dither==AA_NONE){
			p->dither=AA_ERRORDISTRIB;
			osdmessage(MESSAGE_DURATION, 1, "Dithering: Error Distribution");
		    }else if (p->dither==AA_ERRORDISTRIB){
			p->dither=AA_FLOYD_S;
			osdmessage(MESSAGE_DURATION, 1, "Dithering: Floyd Steinberg");
		    }
		    break;
		case '7':
		    p->inversion=!p->inversion;
		    osdmessage(MESSAGE_DURATION, 1, "Invert mode is now %s",
				p->inversion==1 ? "on" : "off");
		    break;

		default :
		    /* nothing if we're interested in?
		     * the mplayer should handle it!
		     */
		    mplayer_put_key(key);
		    break;
	    }
	}// aaconfigmode
	else mplayer_put_key(key);
    }
}
Exemplo n.º 20
0
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
    RECT r;
    POINT p;
    int mpkey;
    switch (message) {
        case WM_ERASEBKGND: // no need to erase background seperately
            return 1;
        case WM_PAINT:
            event_flags |= VO_EVENT_EXPOSE;
            break;
        case WM_MOVE:
            p.x = 0;
            p.y = 0;
            ClientToScreen(vo_window, &p);
            vo_dx = p.x;
            vo_dy = p.y;
            break;
        case WM_SIZE:
            event_flags |= VO_EVENT_RESIZE;
            GetClientRect(vo_window, &r);
            vo_dwidth = r.right;
            vo_dheight = r.bottom;
            break;
        case WM_WINDOWPOSCHANGING:
            if (vo_keepaspect && !vo_fs && WinID < 0) {
              WINDOWPOS *wpos = lParam;
              int xborder, yborder;
              r.left = r.top = 0;
              r.right = wpos->cx;
              r.bottom = wpos->cy;
              AdjustWindowRect(&r, GetWindowLong(vo_window, GWL_STYLE), 0);
              xborder = (r.right - r.left) - wpos->cx;
              yborder = (r.bottom - r.top) - wpos->cy;
              wpos->cx -= xborder; wpos->cy -= yborder;
              aspect_fit(global_vo, &wpos->cx, &wpos->cy, wpos->cx, wpos->cy);
              wpos->cx += xborder; wpos->cy += yborder;
            }
            return 0;
        case WM_CLOSE:
            mplayer_put_key(KEY_CLOSE_WIN);
            break;
        case WM_SYSCOMMAND:
            switch (wParam) {
                case SC_SCREENSAVE:
                case SC_MONITORPOWER:
                    mp_msg(MSGT_VO, MSGL_V, "vo: win32: killing screensaver\n");
                    return 0;
            }
            break;
        case WM_KEYDOWN:
            mpkey = lookup_keymap_table(vk_map, wParam);
            if (mpkey)
                mplayer_put_key(mpkey);
            break;
        case WM_CHAR:
            mplayer_put_key(wParam);
            break;
        case WM_LBUTTONDOWN:
            if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) {
                mplayer_put_key(MOUSE_BTN0);
                break;
            }
            if (!vo_fs) {
                ReleaseCapture();
                SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
                return 0;
            }
            break;
        case WM_MBUTTONDOWN:
            if (!vo_nomouse_input)
                mplayer_put_key(MOUSE_BTN1);
            break;
        case WM_RBUTTONDOWN:
            if (!vo_nomouse_input)
                mplayer_put_key(MOUSE_BTN2);
            break;
        case WM_MOUSEMOVE:
            if (enable_mouse_movements) {
                char cmd_str[40];
                snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i",
                        GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
                mp_input_queue_cmd(global_vo->input_ctx, mp_input_parse_cmd(cmd_str));
            }
            break;
        case WM_MOUSEWHEEL:
            if (!vo_nomouse_input) {
                int x = GET_WHEEL_DELTA_WPARAM(wParam);
                if (x > 0)
                    mplayer_put_key(MOUSE_BTN3);
                else
                    mplayer_put_key(MOUSE_BTN4);
                break;
            }
    }

    return DefWindowProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 21
0
bool
MWindow::QuitRequested()
{
	mplayer_put_key(KEY_CLOSE_WIN);
	return true;
}
Exemplo n.º 22
0
void getch2(void)
{
    int retval = read(0, &getch2_buf[getch2_len], BUF_LEN-getch2_len);
    if (retval < 1)
        return;
    getch2_len += retval;

    while (getch2_len > 0 && (getch2_len > 1 || getch2_buf[0] != 27)) {
        int i, len, code;

        /* First find in the TERMCAP database: */
        for (i = 0; i < getch2_key_db; i++) {
            if ((len = getch2_keys[i].len) <= getch2_len)
                if(memcmp(getch2_keys[i].chars, getch2_buf, len) == 0) {
                    code = getch2_keys[i].code;
                    goto found;
                }
        }
        /* We always match some keypress here, with length 1 if nothing else.
         * Since some of the cases explicitly test remaining buffer length
         * having a keycode only partially read in the buffer could incorrectly
         * use the first byte as an independent character.
         * However the buffer is big enough that this shouldn't happen too
         * easily, and it's been this way for years without many complaints.
         * I see no simple fix as there's no easy test which would tell
         * whether a string must be part of a longer keycode. */
        len = 1;
        code = getch2_buf[0];
        /* Check the well-known codes... */
        if (code != 27) {
            if (code == 'A'-64) code = KEY_HOME;
            else if (code == 'E'-64) code = KEY_END;
            else if (code == 'D'-64) code = KEY_DEL;
            else if (code == 'H'-64) code = KEY_BS;
            else if (code == 'U'-64) code = KEY_PGUP;
            else if (code == 'V'-64) code = KEY_PGDWN;
            else if (code == 8 || code==127) code = KEY_BS;
            else if (code == 10 || code==13) {
                if (getch2_len > 1) {
                    int c = getch2_buf[1];
                    if ((c == 10 || c == 13) && (c != code))
                        len = 2;
                }
                code = KEY_ENTER;
            }
        }
        else if (getch2_len > 1) {
            int c = getch2_buf[1];
            if (c == 27) {
                code = KEY_ESC;
                len = 2;
                goto found;
            }
            if (c >= '0' && c <= '9') {
                code = c-'0'+KEY_F;
                len = 2;
                goto found;
            }
            if (getch2_len >= 4 && c == '[' && getch2_buf[2] == '[') {
                int c = getch2_buf[3];
                if (c >= 'A' && c < 'A'+12) {
                    code = KEY_F+1 + c-'A';
                    len = 4;
                    goto found;
                }
            }
            if ((c == '[' || c == 'O') && getch2_len >= 3) {
                int c = getch2_buf[2];
                const short ctable[] = {
                    KEY_UP, KEY_DOWN, KEY_RIGHT, KEY_LEFT, 0,
                    KEY_END, KEY_PGDWN, KEY_HOME, KEY_PGUP, 0, 0, KEY_INS, 0, 0, 0,
                    KEY_F+1, KEY_F+2, KEY_F+3, KEY_F+4};
                if (c >= 'A' && c <= 'S')
                    if (ctable[c - 'A']) {
                        code = ctable[c - 'A'];
                        len = 3;
                        goto found;
                    }
            }
            if (getch2_len >= 4 && c == '[' && getch2_buf[3] == '~') {
                int c = getch2_buf[2];
                const int ctable[8] = {KEY_HOME, KEY_INS, KEY_DEL, KEY_END, KEY_PGUP, KEY_PGDWN, KEY_HOME, KEY_END};
                if (c >= '1' && c <= '8') {
                    code = ctable[c - '1'];
                    len = 4;
                    goto found;
                }
            }
            if (getch2_len >= 5 && c == '[' && getch2_buf[4] == '~') {
                int i = getch2_buf[2] - '0';
                int j = getch2_buf[3] - '0';
                if (i >= 0 && i <= 9 && j >= 0 && j <= 9) {
                    const short ftable[20] = {
                        11,12,13,14,15, 17,18,19,20,21,
                        23,24,25,26,28, 29,31,32,33,34 };
                    int a = i*10 + j;
                    for (i = 0; i < 20; i++)
                        if (ftable[i] == a) {
                            code = KEY_F+1 + i;
                            len = 5;
                            goto found;
                        }
                }
            }
        }
    found:
        getch2_len -= len;
        for (i = 0; i < getch2_len; i++)
            getch2_buf[i] = getch2_buf[len+i];
        mplayer_put_key(code);
    }
}
Exemplo n.º 23
0
static void check_events(struct vo *vo)
{
    caca_event_t cev;
    while (caca_get_event(display, CACA_EVENT_ANY, &cev, 0)) {

        switch (cev.type) {
        case CACA_EVENT_RESIZE:
            caca_refresh_display(display);
            resize();
            break;
        case CACA_EVENT_QUIT:
            mplayer_put_key(vo->key_fifo, KEY_CLOSE_WIN);
            break;
        case CACA_EVENT_MOUSE_MOTION:
            vo_mouse_movement(vo, cev.data.mouse.x, cev.data.mouse.y);
            break;
        case CACA_EVENT_MOUSE_PRESS:
            if (!vo_nomouse_input)
                mplayer_put_key(vo->key_fifo,
                        (MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_DOWN);
            break;
        case CACA_EVENT_MOUSE_RELEASE:
            if (!vo_nomouse_input)
                mplayer_put_key(vo->key_fifo,
                                MOUSE_BTN0 + cev.data.mouse.button - 1);
            break;
        case CACA_EVENT_KEY_PRESS:
        {
            int key = cev.data.key.ch;
            int mpkey = lookup_keymap_table(keysym_map, key);
            const char *msg_name;

            if (mpkey)
                mplayer_put_key(vo->key_fifo, mpkey);
            else
            switch (key) {
            case 'd':
            case 'D':
                /* Toggle dithering algorithm */
                set_next_str(caca_get_dither_algorithm_list(dither),
                             &dither_algo, &msg_name);
                caca_set_dither_algorithm(dither, dither_algo);
                osdmessage(MESSAGE_DURATION, "Using %s", msg_name);
                break;

            case 'a':
            case 'A':
                /* Toggle antialiasing method */
                set_next_str(caca_get_dither_antialias_list(dither),
                             &dither_antialias, &msg_name);
                caca_set_dither_antialias(dither, dither_antialias);
                osdmessage(MESSAGE_DURATION, "Using %s", msg_name);
                break;

            case 'h':
            case 'H':
                /* Toggle charset method */
                set_next_str(caca_get_dither_charset_list(dither),
                             &dither_charset, &msg_name);
                caca_set_dither_charset(dither, dither_charset);
                osdmessage(MESSAGE_DURATION, "Using %s", msg_name);
                break;

            case 'c':
            case 'C':
                /* Toggle color method */
                set_next_str(caca_get_dither_color_list(dither),
                             &dither_color, &msg_name);
                caca_set_dither_color(dither, dither_color);
                osdmessage(MESSAGE_DURATION, "Using %s", msg_name);
                break;

            default:
                if (key <= 255)
                    mplayer_put_key(vo->key_fifo, key);
                break;
            }
        }
        }
    }
}