Showing posts with label remote. Show all posts
Showing posts with label remote. Show all posts

Sunday, January 9, 2011

XBMC and NVidia's TwinView

I was looking for a decent media center - mostly to watch movies with an overhead projector connected to a PC. The PC is running Linux and I would like to be able to select a movie, change the volume, pause etc with my Medion (read: cheap, RF, USB connected) remote. One day I stumbled upon XBMC. It turned out to be a decent piece of software. Configuring the remote was easy. But...

I must mention here that my display setup uses the NVidia's TwinView, which serves me well. My main LCD monitor is connected through a D-Sub while the beamer via HDMI. They form a dual-screen setup with the beamer on the right of the LCD.

But there is always a catch... Actually two of them.
  1. XBMC's fullscreen ignores TwinView, so it spans both displays, or the other display is turned off. 
  2. There is video tearing visible while XBMC is running on the beamber, there is no tearing if it runs on the LCD.
The first issue can be fixed by making XBMC use so-called windowed mode. It appears as a window then. Having a window and using wmctrl it is possible to make it look like fullscreen.
The second issue regard configuring the NVdia in a proper way which makes OpenGL sync to the specified display instead of the first one. It can be achieved by exporting two environment variables __GL_SYNC_TO_VBLANK=1 and __GL_SYNC_DISPLAY=name_of_the_display_to_sync_to.

So here comes my magical bash script which launches the XBMC with a proper syncing enabled and shifts it to the beamer making the window fullscreen (mind that the beamer is on the right of the LCD, and the LCD is 1280x1024).

Enjoy.
#!/bin/bash

move_and_fullscreen(){
  NAME='XBMC Media Center'

  while [ -z "`wmctrl -l | grep \"$NAME\"`" ]
  do
      sleep 1
  done

  wmctrl -r "$NAME" -e '0,1280,-1,-1,-1'
  wmctrl -r "$NAME" -b toggle,fullscreen
}

move_and_fullscreen &
__GL_SYNC_TO_VBLANK=1 __GL_SYNC_DISPLAY_DEVICE=DFP-0 SDL_VIDEO_ALLOW_SCREENSAVER=0 exec xbmc

Update: As of XBMC 10.1 I had to add SDL_VIDEO_ALLOW_SCREENSAVER=0 to disable screensaver while running XBMC. The above approach uses the windowed mode of XBMC which enables system screensaver now - it kicks in while watching movies :( (the screensaver is disabled in the fullscreen mode only).

Thursday, January 21, 2010

Medion X10 remote and Linux

I've recently bought a remote for my PC. I thought it would be quite convenient to have one especially that it could be quite handy during watching DVDs.

I picked an inexpensive, radio operated, USB Medion X10 - around $10.

After plugging the USB dongle it turned out that the remote becomes a HID - dobling the keyboard. It was nice but not exactly what I needed. I want to have a remote control for my multimedia pplications - not to control the computer.

So here comes the magic word LIRC: Linux InfraRed Control.  It's a little bit misleading since the remote has nothing to do with InfraRed, but LIRC is actually an infrastructure which allows to control applications with remote controls. So I installed lirc:
apt-get install lirc
Upon configuration I selected ATI/NVidia/X10 RF Remote, and voila... the remote stopped working as a HID. Now I need to comeup with proper configurations for my multimedia applications. Here comes a complete config file /etc/lirc/lircrc I came up with:

begin
    remote = Medion_MD8800
    prog = xine
    button = DVD_Menu
    config = RootMenu
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Up
    config = EventUp
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Down
    config = EventDown
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Left
    config = EventLeft
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Right
    config = EventRight
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Vol_Up
    config = Volume+
    repeat = 1
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Vol_Down
    config = Volume-
    repeat = 1
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = OK
    config = EventSelect
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Mute
    config = Mute
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Info
    config = OSDStreamInfos
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Rewind
    config = SeekRelative-15
    repeat = 1
    delay = 5
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Play
    config = Play
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Forward
    config = SeekRelative+15
    repeat = 1
    delay = 5
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Pause
    config = Pause
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Power
    config = Quit
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = xine
    button = Stop
    config = Stop
    repeat = 0
    delay = 0
end

begin
    prog = Rhythmbox
    remote = *
    button = Play
    repeat = 1
    config = play
end

begin
    prog = Rhythmbox
    remote = *
    button = Pause
    repeat = 0
    config = pause
end

begin
    prog = Rhythmbox
    remote = *
    button = KEY_PLAYPAUSE
    repeat = 1
    config = playpause
end

begin
    prog = Rhythmbox
    remote = *
    button = Stop
    repeat = 1
    config = stop
end


begin
    prog = Rhythmbox
    remote = *
    button = Next
    repeat = 0
    config = next
end

begin
    prog = Rhythmbox
    remote = *
    button = Prev
    repeat = 0
    config = previous
end

begin
    prog = Rhythmbox
    remote = *
    button = Rewind
    repeat = 1
    delay = 5
    config = seek_backward
end

begin
    prog = Rhythmbox
    remote = *
    button = Vol_Up
    repeat = 5
    config = volume_up
end

begin
    prog = Rhythmbox
    remote = *
    button = Vol_Down
    repeat = 5
    config = volume_down
end

begin
    prog = Rhythmbox
    remote = *
    button = Power
    repeat = 1
    config = quit
end

begin
    remote = Medion_MD8800
    prog = totem
    button = DVD_Menu
    config = play_dvd
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Power
    config = quit
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Up
    config = up
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Down
    config = down
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Left
    config = left
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Right
    config = right
    repeat = 0
    delay = 0
end

begin
        prog = totem
        remote = Medion_MD8800
        button = OK
        repeat = 1
        config = select
end

begin
        prog = totem
        remote = Medion_MD8800
        button = DVD_Menu
        repeat = 0
        config = menu
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Vol_Up
    config = volume_up
    repeat = 5
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Vol_Down
    config = volume_down
    repeat = 5
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Mute
    config = mute
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Back
    config = quit
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Info
    config = show_playing
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Rewind
    config = seek_backward
    repeat = 1
    delay = 5
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Play
    config = play_pause
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Forward
    config = seek_forward
    repeat = 1
    delay = 5
end

begin
    remote = Medion_MD8800
    prog = totem
    button = Pause
    config = pause
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Power
    config = quit
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Up
    config = seek +60 0
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Down
    config = seek -60 0
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Left
    config = seek -6 0
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Right
    config = seek +6 0
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Vol_Up
    config = volume +1
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Vol_Down
    config = volume -1
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = OK
    config = pause
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Mute
    config = mute
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Rewind
    config = seek -30 0
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Play
    config = pause
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Forward
    config = seek +30 0
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Pause
    config = pause
    repeat = 0
    delay = 0
end

begin
    remote = Medion_MD8800
    prog = mplayer
    button = Stop
    config = quit
    repeat = 0
    delay = 0
end

Mind that it enables remote control for xine, rythmbox, totem and mplayer (rythmobox, and totem must have the lirc support enabled to work, see Edit/Plugins). Enjoy.