PDA

View Full Version : Sofa Control Script



ookees
December 18th, 2008, 04:09 AM
Has anyone gotten Sofa Control to work properly with Boxee. I was able to take the Sofa Control XBMC Applescript and get it to work mostly with Boxee, the only thing is the menu button wont work while Sofa Control is enabled.

Here is the script below:

(*
Copyright 2008, Gravity

Description: Description
Author: Gravity, Another Author
Product-URL: http://someproduct.com

Mapping:
* Plus/Minus: Next/Previous track
* Left/Right: Move selection
* Left/Right Hold: Move selection
* Play: Play current selected album
* Play Hold: Toggle Fullscreen

Menu:
* Function A

*)

on rcActivate()
-- this code is executed when the script is activated
-- typically the target application gets activated
--tell "Sofa Control"
-- tell application to set enabled to false
--end tell
--return
ignoring application responses
tell the application "Boxee" to activate
end ignoring

-- setup action mappings
tell active sofascript of application "Sofa Control"
make new action with properties {title:"Item Exit", script function:"itemExit", closes menu:true, button:menu pressed, number of clicks:2}
make new action with properties {title:"Show Info", script function:"showInfo", closes menu:true, button:play pressed, number of clicks:2}

end tell

end rcActivate

on showInfo()
-- send F6 to Boxee
simulate keycode 97
end showInfo

on itemExit()
-- send F7 to Boxee
simulate keycode 98

end itemExit

on rcMinus()
(*
Code that is executed when the Minus button is pressed.
*)
-- send Down Arrow to Boxee
simulate keycode 125
end rcMinus
on rcPlus()
(*
Code that is executed when the Plus button is pressed.
*)
-- send Up Arrow to Boxee
simulate keycode 126
end rcPlus
on rcRight()
(*
Code that is executed when the Right button is pressed.
*)
-- send Right Arrow to Boxee
simulate keycode 124

end rcRight
on rcLeft()
(*
Code that is executed when the Left button is pressed.
*)
-- send Left Arrow to Boxee
simulate keycode 123
end rcLeft


on rcPlay()
(*
Code that is executed when the Play button is pressed.
*)
-- send Return to Boxee
simulate keycode 36
end rcPlay

on rcMenu()
(*
Code is be executed when the Menu button is pressed.

A menu is an Applescript list of string values. It can also contain lists,
each of which will be displayed as a submenu. For example:

set menuList to {"list", "of", "values", {"Submenu item", "Item 1", "Item 2"}}

To display a menu to the user use: choose from menuList

User choices from a menu are returned in the rcValueFromMenuChosen handler.
*)
-- send F1 to Boxee
simulate keycode 122
end rcMenu

on rcHoldPlay()
(*
Code that is executed when the Play button is pressed and held
for a couple of seconds.
*)
-- send \ to Boxee
simulate keystroke "\\"
end rcHoldPlay

on rcHoldPlus(holdCounter)
(*
Code that is executed when the Plus button is being held.

This code will be called repeatedly as long as the button is held. The
variable "holdCounter" will be incremented, starting at one (1), for
as long as the button is held down. The "holdCounter" will be zero "0"
when the user releases the button.
*)
-- send F4 to Boxee
simulate keycode 118

-- Add a small delay so that we do not go up too fast
delay 0.2
end rcHoldPlus

on rcHoldMinus(holdCounter)
(*
Code that is executed when the Minus button is being held.

This code will be called repeatedly as long as the button is held. The
variable "holdCounter" will be incremented, starting at one (1), for
as long as the button is held down. The "holdCounter" will be zero "0"
when the user releases the button.
*)
-- send F5 to Boxee
simulate keycode 96

-- Add a small delay so that we do not go down too fast
delay 0.2
end rcHoldMinus


on rcHoldLeft(holdCounter)
(*
Code that is executed when the Left button is being held.

This code will be called repeatedly as long as the button is held. The
variable "holdCounter" will be incremented, starting at one (1), for
as long as the button is held down. The "holdCounter" will be zero "0"
when the user releases the button.
*)
-- send F2 to Boxee
simulate keycode 120

-- Add a small delay so that we have time to unclick the button
delay 0.5
end rcHoldLeft


on rcHoldRight(holdCounter)
(*
Code is executed when the Right button is being held.

This code will be called repeatedly as long as the button is held. The
variable "holdCounter" will be incremented, starting at one (1), for
as long as the button is held down. The "holdCounter" will be zero "0"
when the user releases the button.
*)
-- send F3 to Boxee
simulate keycode 99

end rcHoldRight


Any help getting the menu button to function correctly with Boxee and Sofa Control would be greatly appreciated.:)

mig
December 26th, 2008, 12:04 PM
Hi, i got Boxee working by copying the Plex script.
All i had to do extra is remap the escape/menu key.
Because that wouldn't work.
Other than that, all worked from the start.

ookees
December 27th, 2008, 01:54 AM
Thanks, I didn't know what I was doing with the scripts but I figured it out. I edited the XBMC script and it worked.