%
% custom anyremote cfg for basic XBMC Media Center use
% 
% Thanks to Everthon Valadão (http://mobilevs.blogspot.com) for this cfg.file
%

% STATUS unknown
% XTEST yes
% SOUND mixer
% ENV no
% ALL_IN_ONE 

GuiAppName=XBox_Media_Center
GuiAppBinary=xbmc
GuiAppRun= A=`ps -ef|grep xbmc|grep -v grep`; if [ "x$A" = "x" ]; then echo NOK; else echo OK; fi
GuiAppIcon=xbmc.png
GuiAppType=Application
GuiAppProtocols=Server

%curl --data-binary '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}' -H 'content-type: application/json;' http://localhost:8080/jsonrpc
%curl --data-binary '{"jsonrpc": "2.0", "method": "Player.Play' -H 'content-type: application/json;' http://localhost:8080/jsonrpc
%curl --data-binary '{"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "album", "artist", "season", "episode", "duration", "showtitle", "tvshowid", "thumbnail", "file", "fanart", "streamdetails"], "playerid": 1 }, "id": "VideoGetItem"}' -H 'content-type: application/json;' http://localhost:8080/jsonrpc
%curl --data-binary '{"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "album", "artist", "file", "fanart"], "playerid": 0 }, "id": "AudioGetItem"}' -H 'content-type: application/json;' http://localhost:8080/jsonrpc
%curl --data-binary '{"jsonrpc": "2.0", "method": "Playlist.GetPlaylists", "id": 1}' -H 'content-type: application/json;' http://localhost:8080/jsonrpc

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Macro(SETUP_DEFAULT_POWER_MANAGEMENT);\
	Macro(SETUP_DEFAULT_MIXER);

(Connect)=\
	Make(mode,xbmc);

[Mode]=xbmc

(EnterMode)=\
	Set(icons,XBMC,1,play,2,up,3,refresh,4,left,5,plus,6,right,7,fit,8,down,9,fullscreen,*,question,0,folder,#,no);\
	Set(layout,default,keypad_only);\
	Macro(XBMC_MENU);\
	Macro(XBMC_RUN);
	
Cancel=\
    Make(exit);

XBMC_MENU=\
	Set(menu,replace,Previous,Info,Exit Menu,PowerMgmt);\
    Macro(ALLIN1MENU)

Previous=\
	Macro(XBMC_CANCEL);

Exit Menu=\
	Macro(XBMC_EXIT_MENU);
	
Info=\
	Macro(XBMC_INFO);

Back=\
	Set(text,close);\
	Macro(XBMC_MENU)

1=Make(mode,xbmc_player);
2=Macro(XBMC_UP);
3=Macro(XBMC_CANCEL);

4=Macro(XBMC_LEFT);
5=Macro(XBMC_OK);
6=Macro(XBMC_RIGHT);

7=Macro(XBMC_INFO)
8=Macro(XBMC_DOWN);
9=Macro(XBMC_ZOOM)

* *=Set(text,replace,Help,1 Switch to player mode\n2 Up\n3 Previous Menu\n4 Left\n5 Ok (Enter)\n6 Right\n7 Information\n8 Down\n9 Zoom\n** Help\n*1 Options\n*0 Windowed/Fullscreen\n*# Run/Quit);
* 0=Macro(XBMC_FULLSCREEN);
* 1=Macro(XBMC_OPTIONS);
* #=Macro(XBMC_RUN_STOP)
%* 2=Emulate(key,Page_Up)
%* 8=Emulate(key,Page_Down)
0=Macro(XBMC_MAINMENU);
#=Macro(XBMC_EXIT_MENU);

% redefine joystick keys
UP    =Macro(XBMC_UP)
DOWN  =Macro(XBMC_DOWN)
LEFT  =Macro(XBMC_LEFT)
RIGHT =Macro(XBMC_RIGHT)
FIRE  =Macro(XBMC_OK);

XBMC_RUN=\
	Exec(P=`ps -ef|grep "xbmc/xbmc.bin"|grep -v grep|grep -v edit|grep -v anyremote`; if [ "x$P" = "x" ]; then xbmc& fi);

XBMC_RUN_STOP=\
	Exec(P=`ps -ef|grep "xbmc/xbmc.bin"|grep -v grep|grep -v edit|grep -v anyremote`; if [ "x$P" = "x" ]; then xbmc& else killall xbmc; fi);

XBMC_UP          =Emulate(key,Up);
XBMC_DOWN        =Emulate(key,Down);
XBMC_LEFT        =Emulate(key,Left);
XBMC_RIGHT       =Emulate(key,Right);
XBMC_OK          =Emulate(key,Return)

XBMC_INFO        =Emulate(key,i)
XBMC_VISUALIZAT  =Emulate(key,Tab)
XBMC_ZOOM        =Emulate(key,z)
XBMC_FULLSCREEN  =Emulate(key,backslash)

XBMC_ACTIONS     =Emulate(key,m)
XBMC_OPTIONS     =Emulate(key,c)

XBMC_MAINMENU    =Emulate(key,Escape)
XBMC_CANCEL      =Emulate(key,BackSpace)
XBMC_EXIT_MENU   =Emulate(key,s)



[ModeEnd]

[Mode]=xbmc_player

(EnterMode)=\
        Set(layout,default);\
	Set(status,);\
	Set(title,);\
	Set(icons,XBMC,\
		1,vol_down,\
		2,mute,\
		3,vol_up,\
		4,rewind,\
		5,play,\
		6,forward,\
		7,prev,\
		8,stop,\
		9,next,\
		*,question,\
		0,pause,\
		#,file);\
	Set(menu,replace,Subtitle);
	
Subtitle=Emulate(key,t)

1=Macro(DEFAULT_VOLUME_DOWN)
2=Macro(DEFAULT_TOGGLE_MUTE)
3=Macro(DEFAULT_VOLUME_UP)

% Rewind-Play-FastForward
4=Emulate(key,R);
5=Emulate(key,P);
6=Emulate(key,F);

% Prev-Stop-Next
7=Emulate(key,comma);
8=Emulate(key,X);Make(mode,xbmc);
9=Emulate(key,period);

% Help-Pause-Switch to control mode
* *=Set(text,replace,Help,1 Vol-\n2 Mute\n3 Vol+\n4 Rwd\n5 Play\n6 FF\n7 Prew\n8 Stop\n9 Next\n* * Help\n0 Pause\n# Switch to control mode);
0=Emulate(key,space);
#=Make(mode,xbmc);


%XBMC_VOL_DOWN=Macro(DEFAULT_VOLUME_DOWN)
%XBMC_MUTE=Macro(DEFAULT_TOGGLE_MUTE)
%XBMC_VOL_UP=Macro(DEFAULT_VOLUME_UP)
%% XBMC_VOL_UP      =Emulate(key,plus,key,plus,key,plus)
%% XBMC_VOL_DOWN    =Emulate(key,minus,key,minus,key,minus)
%XBMC_PLAY_PAUSE  =Emulate(key,P)
%XBMC_STOP        =Emulate(key,X)
%XBMC_PREVIOUS    =Emulate(key,comma)
%XBMC_NEXT        =Emulate(key,period)
%XBMC_SUBTITLE    =Emulate(key,t)
%XBMC_RWD         =Emulate(key,r)

[End]
