Refresh rate switching using a remote!
#1
Hi All

I have recently started looking at XBMC on OSX in place of Plex which I have been running for a while. Mainly for 3 reasons:

* XBMC seems to be able to play DVDs in the HTPC drive
* XBMC does media flagging out of the box
* XBMC seems a LOT closer to doing refresh rate switching automatically.

Re this last point - I was able to set PLEX up to do refresh rate switching using my harmony remote. The steps were as follows:

1.) Download cscreen.zip from post #6 in this thread http://forums.macosxhints.com/showthread.php?t=59575

2.) Extract and put the csreen file in the usr/bin directory

3.) Created 2 applescripts that called cscreen with the parameters I required (24 and 50Hz refresh rates @ 1920x1080 32bit colour)

4.) Put these scripts in the Plex scripts folder

5.) Created the following Harmony.xml file and and put it in the Plex keymap folder.


Code:
<keymap>
  <global>
    <harmonyremote>
    
      <F11>Plex.RunScript(Run24Hz.applescript)</F11>
      <F13>Plex.RunScript(Run50Hz.applescript)</F13>

    </harmonyremote>
  </global>
</keymap>

Now, in Plex, when I use the button that corresponds to F11 and F13 on my harmony remote I can switch the refresh frequency from the comfort of the sofa!

What I want to do is replicate this in XBMC Cool

So far I have:

1.) Copied the scripts to the XBMC Scripts folder in the user/Library/Application Support/XBMC/Scripts folder.

(I can access these through "Scripts" in the XBMC GUI and run them successfully)

2.) Copied the Harmony XML file to user/Library/Application Support/XBMC/userdata/keymaps/ and changed Plex to XBMC in the xml file.

This is where I am stuck. I don't think I have the syntax correct for calling the scripts from the harmony.xml file in XBMC, in fact I am not even sure it should be called Harmony.xml! Can anyone point me in the right direction? Looking at the files in the system/keymap folder in XBMC it looks like Harmony support has been implemented in a different way than in PLEX. Can anyone confirm?


Thanks!!! Cool
Reply
#2
anyone ever find the source code for cscreen ? I'm pretty sure I know what it's doing but would still like a peek inside without having to disassemble it.
Reply
#3
I found this - its not complete but gives an idea of what its doing (not that I would know! Not a programmer or even close to being one Big Grin)

Code:
/*
* main.c
* newscreen
*
* Created by Jeffrey Osterman on 10/30/07.
* Copyright 2007 Jeffrey Osterman. All rights reserved.
* PROVIDED AS IS AND WITH NO WARRANTIES WHATSOEVER
*/

#include <ApplicationServices/ApplicationServices.h>

void MyDisplaySwitchToMode (CGDirectDisplayID display, CFDictionaryRef
mode);

int main (int argc, const char * argv[])
{
    int h;                                  //horizontal resolution
    int v;                                  //vertical resolution
    CFDictionaryRef switchMode;        //mode to swich to
    CGDirectDisplayID mainDisplay;     //ID of main display
  
  
    if (argc != 5)
    {
         printf("Expected 4 inputs, but only received %i\n", argc-1);
         return 0;
    }
  
    if (!strcmp(argv[1],"-h"))
         h=strtol(argv[2], NULL, 0);
    else if (!strcmp(argv[1],"-v"))
         v=strtol(argv[2], NULL, 0);
    else {
         printf("Error! Expected first argument to be -h or -v\n");
         return 0;
    }
  
    if (!strcmp(argv[3],"-h"))
         h=strtol(argv[4], NULL, 0);
    else if (!strcmp(argv[3],"-v"))
         v=strtol(argv[4], NULL, 0);
    else {
         printf("Error! Expected third argument to be -h or -v");
         return 0;
    }
  
    mainDisplay = CGMainDisplayID();
    switchMode = CGDisplayBestModeForParameters(mainDisplay, 32, h, v,
NULL);
    MyDisplaySwitchToMode (mainDisplay, switchMode);
    return 0;
}

void MyDisplaySwitchToMode (CGDirectDisplayID display, CFDictionaryRef
mode)
{
    CGDisplayConfigRef config;                                                      
// 1
    CGBeginDisplayConfiguration (&config);                                    
// 2
    CGConfigureDisplayMode (config, display, mode);                            
// 3
  
    CGCompleteDisplayConfiguration (config, kCGConfigureForSession );    
// 5
}

also found thid:

Code:
/*
* setgetscreenres.m
*
* juanfc 2009-04-13
* Based on newscreen
*    Created by Jeffrey Osterman on 10/30/07.
*    Copyright 2007 Jeffrey Osterman. All rights reserved.
*    PROVIDED AS IS AND WITH NO WARRANTIES WHATSOEVER
*    http://forums.macosxhints.com/showthread.php?t=59575
*
* COMPILE:
*    c++ setgetscreenres.m -framework ApplicationServices -o setgetscreenres
* USE:
*    setgetscreenres 1440 900
*/

#include <ApplicationServices/ApplicationServices.h>

bool MyDisplaySwitchToMode (CGDirectDisplayID display, CFDictionaryRef mode);

int main (int argc, const char * argv[])
{
    int    h;                             // horizontal resolution
    int v;                             // vertical resolution
    CFDictionaryRef switchMode;     // mode to switch to
    CGDirectDisplayID mainDisplay;  // ID of main display

    CFDictionaryRef CGDisplayCurrentMode(CGDirectDisplayID display);

    if (argc == 1) {
        CGRect screenFrame = CGDisplayBounds(kCGDirectMainDisplay);
        CGSize screenSize  = screenFrame.size;
        printf("%d %d\n", screenSize.width, screenSize.height);
        return 0;
    }
    if (argc != 3 || !(h = atoi(argv[1])) || !(v = atoi(argv[2])) ) {
        fprintf(stderr, "ERROR: Use %s horres vertres\n", argv[0]);
        return -1;
    }

    mainDisplay = CGMainDisplayID();

    switchMode = CGDisplayBestModeForParameters(mainDisplay, 32, h, v, NULL);

    if (! MyDisplaySwitchToMode(mainDisplay, switchMode)) {
        fprintf(stderr, "Error changing resolution to %d %d\n", h, v);
        return 1;
    }

    return 0;
}

bool MyDisplaySwitchToMode (CGDirectDisplayID display, CFDictionaryRef mode)
{
    CGDisplayConfigRef config;
    if (CGBeginDisplayConfiguration(&config) == kCGErrorSuccess) {
        CGConfigureDisplayMode(config, display, mode);
        CGCompleteDisplayConfiguration(config, kCGConfigureForSession );
        return true;
    }
    return false;
}

Can you point me to where I could find the XBMC config file for the harmony remote?
Reply
#4
Thanks for the code refs, I'll check into it.

Harmony support is in keymaps/joystick.Harmony.xml.
Reply
#5
Thanks - I will have a play later when all the relatives have gone home Laugh

I can't wait to see the auto refresh rate switching working on OSX, I have too many files now to remember what rates they are all at. I have been looking at using an NFO file to store the framerate so that it can be displayed by the skin so I at least know which rate to set it to manually.

If there is anything more I can do to help (testing etc) just drop me a PM - would be really happy to help!
Reply

Logout Mark Read Team Forum Stats Members Help
Refresh rate switching using a remote!0