Control with Iphone and PocketPC
From AwkwardTV
NOTE: Apple's iPhone 2.0 can now remote-control iTunes on both Apple TV and a Mac or PC over wi-fi using Remote. That, and apps which can control Myth TV, are available for download in the App Store for 2.0+ users; the Remote app is free to install and use with an iTunes account.
[edit] Controlling the AppleTV with iPhone or PocketPC
There are currently 2 methods to control the AppleTV remotely, from an iPhone or a PocketPC.
[edit] 1. Controlling from iPhone/PocketPC using a browser (free, no keyboard)
This method was originally posted in www.picpoc.ro.
1) Install XAMPP
Notes:
a) If you run out of space on the root partition on the AppleTV, make a symlink from /Applications/xampp to /Users/frontrow/Applications/xampp.
b) It'd be wise to just start the Apache server with mampp startapache, because you may not need ProFTPD and MySQL.
2) install IRKeyboardEmu kernel extension from Brandon Holland site
3) edit /etc/sudoers and add the following line:
ALL ALL = NOPASSWD: /usr/sbin/sysctl
use visudo for this. copy over vim and the necessary library files from an Intel Mac with Tiger. Make a symbollic link to vim and name it vi. Then use visudo as a root
4) edit /etc/rc.local (or modify your favorite startup method) and add:
/sbin/kextload -v /System/Library/Extensions/IRKeyboardEmu.kext
5) download from here the webfiles and put them where you've setup your DocumentRoot in /Application/xampp/etc/httpd.conf file. Notes: remember to fully configure the httpd.conf. At least the 'DocumentRoot' and '<Directory "xxx">' stuff.
After that, all you should do is point the iPhone/PocketPC browser to your AppleTV IP. Your browser screen will display an image of the Apple remote.
[edit] 2. Controlling from Salling Clicker
Originally by Matt, posted in [1]
Can anyone post a step by step guide how to install Salling Clicker on the AppleTV?
Here is Matt's ATV Salling Clicker script:
property sIsHeld : false
property btnDown : false
property spd : 10
property scroll : 1
property scrollspeedup : 1
property zoom_mode : false
property the_model : ""
property the_class : ""
property the_text : ""
--- keymap
property keymap_map : {}
on get_keymap()
repeat with the_map in keymap_map
if a_model of the_map is the_model then return a_keymap of the_map
end repeat
set keymap_info to {leftMouseKeys:{"foo" as Unicode text}, rightMouseKeys:{"f" as Unicode text}, leftKeys:{"<?" as Unicode text}, rightKeys:{">?" as Unicode text}, upKeys:{"^?" as Unicode text}, downKeys:{"v?" as Unicode text}, scrollUpKeys:{"u" as Unicode text}, scrollDownKeys:{"d" as Unicode text}, toggleScrollZoomKeys:{"c" as Unicode text}, screenShotKeys:{":c" as Unicode text}}
set new_entry to {a_model:the_model, a_keymap:keymap_info}
set keymap_map to keymap_map & {new_entry}
return keymap_info
end get_keymap
--- keymap descriptor record
property keymap_help_map : {}
on get_keymap_help()
repeat with the_map in keymap_help_map
if a_model of the_map is the_model then return a_keymap_help of the_map
end repeat
set the_keymap to my get_keymap()
set keymap_info to {¬
{key_code:leftKeys of the_keymap, key_title:"Move left", key_description:"Moves the mouse pointer left."}, ¬
{key_code:rightKeys of the_keymap, key_title:"Move right", key_description:"Moves the mouse pointer right."}, ¬
{key_code:downKeys of the_keymap, key_title:"Move down", key_description:"Moves the mouse pointer towards the bottom."}, ¬
{key_code:upKeys of the_keymap, key_title:"Move up", key_description:"Moves the mouse pointer towards the top."}, ¬
{key_code:leftMouseKeys of the_keymap, key_title:"Click/Drag", key_description:"Clicks the mouse button. Hold to grab/hold the mouse button; click again to release."}, ¬
{key_code:rightMouseKeys of the_keymap, key_title:"Ctrl-click", key_description:"Clicks the mouse button. Hold to grab/hold the mouse button while holding ctrl; click again to release."}, ¬
{key_code:scrollUpKeys of the_keymap, key_title:"Scroll up", key_description:"Well. Scrolls up... in a document"}, ¬
{key_code:toggleScrollZoomKeys of the_keymap, key_title:"Toggles zoom/scroll", key_description:"Selects whether to zoom or scroll."}, ¬
{key_code:screenShotKeys of the_keymap, key_title:"Screen capture", key_description:"Takes a screen shot of the Mac display."}, ¬
{key_code:scrollDownKeys of the_keymap, key_title:"Scroll down", key_description:"Well. Scrolls down... in a document."} ¬
}
set new_entry to {a_model:the_model, a_keymap_help:keymap_info}
set keymap_help_map to keymap_help_map & {new_entry}
return keymap_info
end get_keymap_help
tell application "SEC Helper"
set the_model to model of current terminal
set the_class to deviceclass of current terminal
if supports pen of current terminal then
set the_class to deviceclass of current terminal
if the_class is "PalmOSHandheld" then
enter keypad mode text "Mouse Control" & return & "(use the blank area like you'd use a trackpad; use up/down to scroll)" with pen deltas
else
enter keypad mode text "Mouse Control and Hardware Keyboard" & return & "(use the blank area like you'd use a trackpad, use your slide out keyboard to enter text)" with pen deltas
end if
else
enter keypad mode text "Mouse Control" & return & return & "0 for Keyboard" & return & return & "* for Tab" & return & return & "# for Return"
end if
end tell
on keypad_was_dismissed()
tell application "SEC Helper"
simulate mouse button up number 1
simulate mouse button up number 2
end tell
end keypad_was_dismissed
on showHelp()
tell application "SEC Helper"
set the_keymap_info to my get_keymap_help()
show keypad help keymap the_keymap_info title "Mouse Help"
end tell
end showHelp
on begin_hold()
tell application "SEC Helper"
--show screen message "Grab"
set btnDown to true
simulate mouse button down number 1
if supports pen of current terminal then
push keypad text "Mouse Control" & return & "mouse button down" & return & "(tap pen to release)"
else
push keypad text "Mouse Control" & return & "mouse button down"
end if
end tell
end begin_hold
on end_hold()
tell application "SEC Helper"
--show screen message "Release"
set btnDown to false
simulate mouse button up number 1
if supports pen of current terminal then
push keypad text "Mouse Control" & return & "Mouse Control and Hardware Keyboard" & return & "(use the blank area like you'd use a trackpad, use your slide out keyboard to enter text)"
else
push keypad text "Mouse Control" & return & return & "0 for Keyboard" & return & return & "* for Tab" & return & return & "# for Return"
end if
end tell
end end_hold
on key_was_depressed(keyCode)
-- try
set the_keymap to my get_keymap()
tell application "SEC Helper"
if keyCode is in leftKeys of the_keymap then
simulate mouse movement x -|scroll| y 0 speed spd
else if keyCode is in rightKeys of the_keymap then
simulate mouse movement x |scroll| y 0 speed spd
else if keyCode is in upKeys of the_keymap then
simulate mouse movement x 0 y -|scroll| speed spd
else if keyCode is in downKeys of the_keymap then
simulate mouse movement x 0 y |scroll| speed spd
else if keyCode is in leftMouseKeys of the_keymap then
simulate mouse button down number 1
set sIsHeld to false
else if keyCode is in rightMouseKeys of the_keymap then
simulate mouse button down number 2
simulate mouse button up number 2
else if keyCode is in scrollUpKeys of the_keymap then
if zoom_mode then
simulate keyboard virtual keycode 24 modifiers {"option", "command"}
else
simulate mouse scroll wheel steps 10
end if
else if keyCode is in scrollDownKeys of the_keymap then
if zoom_mode then
simulate keyboard virtual keycode 27 modifiers {"option", "command"}
else
simulate mouse scroll wheel steps -10
end if
else if keyCode is "s" then
tell application "System Events"
keystroke return
end tell
else if keyCode is "<" then
tell application "System Events"
key code 123
end tell
else if keyCode is "," then
tell application "System Events"
key code 13
end tell
else if keyCode is ">" then
tell application "System Events"
key code 124
end tell
else if keyCode is "v" then
tell application "System Events"
key code 125
end tell
else if keyCode is "^" then
tell application "System Events"
key code 126
end tell
else if (count characters of keyCode) is 3 then
tell application "System Events"
keystroke (character 2 of keyCode)
end tell
else if (count characters of keyCode) is 1 then
tell application "System Events"
keystroke (keyCode)
end tell
else if keyCode is "0x0008" then --delete
tell application "System Events"
key code 51
end tell
else if keyCode is "0x0020" then
tell application "System Events"
keystroke space
end tell
else if keyCode is "0x0009" then
tell application "System Events"
keystroke tab
end tell
end if
end tell
-- on error
-- beep
-- end try
return true
end key_was_depressed
on affirmative_textfield_response(a_char)
set the_text to a_char
repeat with a_char in the_text
tell application "System Events"
keystroke a_char
end tell
end repeat
end affirmative_textfield_response
on key_was_released(keyCode)
set scroll to 1
-- try
set the_keymap to my get_keymap()
tell application "SEC Helper"
if keyCode is in toggleScrollZoomKeys of the_keymap then
my toggleScrollZoom()
else if keyCode is in screenShotKeys of the_keymap then
my capture_screen()
else if keyCode is in leftMouseKeys of the_keymap then
if sIsHeld is false then
if btnDown is true then
my end_hold()
end if
simulate mouse button up number 1
end if
else
simulate mouse stop
end if
end tell
-- on error
-- beep
-- end try
set sIsHeld to false
return true
end key_was_released
on key_is_repeating(keyCode)
-- try
set the_keymap to my get_keymap()
tell application "SEC Helper"
if keyCode is in leftKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x -|scroll| y 0 speed spd
else if keyCode is in rightKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x |scroll| y 0 speed spd
else if keyCode is in upKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x 0 y -|scroll| speed spd
else if keyCode is in downKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x 0 y |scroll| speed spd
end if
if (keyCode is in leftMouseKeys of the_keymap) and sIsHeld is false then
if btnDown is true then
my end_hold()
else
my begin_hold()
end if
end if
if keyCode is in scrollUpKeys of the_keymap then
if zoom_mode then
simulate keyboard virtual keycode 24 modifiers {"option", "command"}
else
simulate mouse scroll wheel steps 10
end if
else if keyCode is in scrollDownKeys of the_keymap then
if zoom_mode then
simulate keyboard virtual keycode 27 modifiers {"option", "command"}
else
simulate mouse scroll wheel steps -10
end if
end if
end tell
-- on error
-- beep
-- end try
set sIsHeld to true
end key_is_repeating
on toggleScrollZoom()
tell application "SEC Helper"
if zoom_mode then
show screen message "Scrolling"
set zoom_mode to false
else
show screen message "Zooming"
set zoom_mode to true
end if
end tell
end toggleScrollZoom
on accelerate_value(value)
if value > 8 or value < -8 then
set value to value * 4
else if value > 4 or value < -4 then
set value to value * 2
end if
return value
end accelerate_value
on pen_was_moved(x_delta, y_delta)
set x_delta to my accelerate_value(x_delta)
set y_delta to my accelerate_value(y_delta)
tell application "SEC Helper"
simulate mouse movement x x_delta y y_delta speed 0
end tell
end pen_was_moved
on pen_was_tapped()
tell application "SEC Helper"
if btnDown then
my end_hold()
else
simulate mouse button down number 1
simulate mouse button up number 1
end if
end tell
end pen_was_tapped
on pen_was_locked()
my begin_hold()
end pen_was_locked
on capture_screen()
set the destination_folder to (path to "pdoc")
set the destination_path to POSIX path of the destination_folder
try
repeat with i from 1 to 10000
set the file_name to ("screen" & (i as string) & ".pdf")
alias ((destination_folder as string) & file_name)
end repeat
on error
set the target_path to the destination_path & the file_name
end try
do shell script ("screencapture " & target_path)
set my_path to (POSIX file target_path)
set my_picture to read (alias my_path) as picture
tell application "SEC Helper"
if supports keypad images of current terminal then
--- If the terminal can't show pictures, immediately show the image on the Mac.
enter keypad mode text "Captured Screen:" & return & target_path image my_picture image size huge
else
show screen message "Saved at " & target_path duration 8.0
end if
end tell
end capture_screen
