philz
Joined: 05 Jun 2007 Posts: 87 Location: USA
|
Posted: Wed Dec 26, 2007 3:34 am Post subject: Turn your PSP into the ultimate mouse |
|
|
To do this you need the following things:
A PSP with homebrew capable firmware (I only tested it on 1.5 but the custom firmwares may work also)
WifiController Installed (FOLLOW THESE INSTRUCTIONS VERBATIM)
Run this script which is based on the joystick to mouse script.
| Code: | CoordMode, mouse, screen
Run, wifiserver.exe, C:\Users\Phil\Documents\AutoHotkey\WiFiController-0.4.4\PC, HIDE, pid ;change location to your copy of wifiserver.exe
menu, tray, nostandard ; the default tray menu
menu, tray, nodefault
menu, tray, add, Exit PSPmouse, exity
; Increase the following value to make the mouse cursor move faster:
JoyMultiplier = 0.20
; Decrease the following value to require less joystick displacement-from-center
; to start moving the mouse. However, you may need to calibrate your joystick
; -- ensuring it's properly centered -- to avoid cursor drift. A perfectly tight
; and centered joystick could use a value of 1:
JoyThreshold = 3
; Change the following to true to invert the Y-axis, which causes the mouse to
; move vertically in the direction opposite the stick:
InvertYAxis := false
; Change these values to use joystick button numbers other than 1, 2, and 3 for
; the left, right, and middle mouse buttons. Available numbers are 1 through 32.
; Use the Joystick Test Script to find out your joystick's numbers more easily.
ButtonLeft = 3
ButtonRight = 2
ButtonMiddle = 4
ButtonA = 12
ButtonB = 1
ButtonC = 6
ButtonD = 5
ButtonE = 7
ButtonF = 9
ButtonG = 10
ButtonH = 8
ButtonI = 11
; If your joystick has a POV control, you can use it as a mouse wheel. The
; following value is the number of milliseconds between turns of the wheel.
; Decrease it to have the wheel turn faster:
WheelDelay = 250
; If your system has more than one joystick, increase this value to use a joystick
; other than the first:
JoystickNumber = 1
; END OF CONFIG SECTION -- Don't change anything below this point unless you want
; to alter the basic nature of the script.
#SingleInstance
JoystickPrefix = %JoystickNumber%Joy
Hotkey, %JoystickPrefix%%ButtonLeft%, ButtonLeft
Hotkey, %JoystickPrefix%%ButtonRight%, ButtonRight
Hotkey, %JoystickPrefix%%ButtonMiddle%, ButtonMiddle
Hotkey, %JoystickPrefix%%ButtonA%, winmin
Hotkey, %JoystickPrefix%%Buttonb%, winswich
Hotkey, %JoystickPrefix%%Buttonc%, buttonc
Hotkey, %JoystickPrefix%%Buttond%, buttond
Hotkey, %JoystickPrefix%%Buttone%, buttone
Hotkey, %JoystickPrefix%%Buttonf%, Buttonf
Hotkey, %JoystickPrefix%%Buttong%, Buttong
Hotkey, %JoystickPrefix%%Buttonh%, Buttonh
Hotkey, %JoystickPrefix%%Buttoni%, Buttoni
;*** ;Calculate the axis displacements that are needed to start moving the cursor:
JoyThresholdUpper := 50 + JoyThreshold
JoyThresholdLower := 50 - JoyThreshold
if InvertYAxis
YAxisMultiplier = -1
else
YAxisMultiplier = 1
SetTimer, WatchJoystick, 10 ; Monitor the movement of the joystick.
GetKeyState, JoyInfo, %JoystickNumber%JoyInfo
IfInString, JoyInfo, P ; Joystick has POV control, so use it as a mouse wheel.
SetTimer, MouseWheel, %WheelDelay%
return ;* ; End of auto-execute section.
; The subroutines below do not use KeyWait because that would sometimes trap the
; WatchJoystick quasi-thread beneath the wait-for-button-up thread, which would
; effectively prevent mouse-dragging with the joystick.
buttonc: ;***
Send, {alt down}{right}{alt up}
return ;*
Buttond: ;***
Send, {alt down}{left}{alt up}
return ;*
buttone: ;***
if GetKeyState(JoystickPrefix . ButtonMiddle)
loop
{
Sleep, 10
if !GetKeyState(JoystickPrefix . Buttone)
break
Send, {wheelup}
}
else Send, {up}
return ;*
Buttonf: ;***
if GetKeyState(JoystickPrefix . ButtonMiddle)
loop
{
Sleep, 10
if !GetKeyState(JoystickPrefix . Buttonf)
break
Send, {wheeldown}
}
else Send, {down}
return ;*
Buttong: ;***
Send, {left}
return ;*
Buttonh: ;***
Send, {right}
return ;*
Buttoni: ;***
;swap := swap = 1 ? 0: 1
;if %swap%
WinMinimizeAll
;else WinRestoreall THIS COMMAND DOES NOT EXIST BUT WOULD BE VERY COOL
return ;*
winswich:
Send {Alt down}{tab}
SetTimer, waitwinswich, 10
return
waitwinswich: ;***
if GetKeyState(JoystickPrefix . Buttonb)
return
SetTimer, waitwinswich, off
Send, {alt up}
return ;*
winmin: ;***
mousegetpos, x, y, win
; Otherwise, the button has been released.
WinMinimize, ahk_id %win%
return ;*
ButtonLeft: ;***
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, left,,, 1, 0, D ; Hold down the left mouse button.
SetTimer, WaitForLeftButtonUp, 10
return ;*
ButtonRight: ;***
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, right,,, 1, 0, D ; Hold down the right mouse button.
SetTimer, WaitForRightButtonUp, 10
return ;*
ButtonMiddle: ;***
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, middle,,, 1, 0, D ; Hold down the right mouse button.
SetTimer, WaitForMiddleButtonUp, 10
return ;*
WaitForLeftButtonUp: ;***
if GetKeyState(JoystickPrefix . ButtonLeft)
return ; The button is still, down, so keep waiting.
; Otherwise, the button has been released.
SetTimer, WaitForLeftButtonUp, off
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, left,,, 1, 0, U ; Release the mouse button.
return ;*
WaitForRightButtonUp: ;***
if GetKeyState(JoystickPrefix . ButtonRight)
return ; The button is still, down, so keep waiting.
; Otherwise, the button has been released.
SetTimer, WaitForRightButtonUp, off
MouseClick, right,,, 1, 0, U ; Release the mouse button.
return ;*
WaitForMiddleButtonUp: ;***
if GetKeyState(JoystickPrefix . ButtonMiddle)
return ; The button is still, down, so keep waiting.
; Otherwise, the button has been released.
SetTimer, WaitForMiddleButtonUp, off
MouseClick, middle,,, 1, 0, U ; Release the mouse button.
return ;*
WatchJoystick: ;***
MouseNeedsToBeMoved := false ; Set default.
SetFormat, float, 03
GetKeyState, joyx, %JoystickNumber%JoyX
GetKeyState, joyy, %JoystickNumber%JoyY
if joyx > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaX := joyx - JoyThresholdUpper
}
else if joyx < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaX := joyx - JoyThresholdLower
}
else
DeltaX = 0
if joyy > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaY := joyy - JoyThresholdUpper
}
else if joyy < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaY := joyy - JoyThresholdLower
}
else
DeltaY = 0
if MouseNeedsToBeMoved
{
SetMouseDelay, -1 ; Makes movement smoother.
MouseMove, DeltaX * JoyMultiplier, DeltaY * JoyMultiplier * YAxisMultiplier, 0, R
}
return ;*
MouseWheel: ;***
GetKeyState, JoyPOV, %JoystickNumber%JoyPOV
if JoyPOV = -1 ; No angle.
return
if (JoyPOV > 31500 or JoyPOV < 4500) ; Forward
Send {WheelUp}
else if JoyPOV between 13500 and 22500 ; Back
Send {WheelDown}
return ;*
exity:
WinClose, ahk_pid %pid%
exitapp
return
|
DOCUMENTATION:
*Pressing X clicks the left mouse button
*Pressing O clicks the right mouse button
*Pressing [] clicks the middle mouse button for the scrolling compass thing
_____-If you press up on the D-pad while holding [] it sends mousewheelup
_____-the same works with down
*Pressing /\ (triangle) is the same as pressing alt-tab
_____-holding /\ and pressing left and right on the d-pad lets you scroll through the open windows
*the R-trigger goes forward in the browser
*the L-trigger goes back in the browser
*the start button closes the window under the cursor
*The Select button closes all windows like Win-M does
THINGS TO DO:
Create User interface for hotkey selection
Allow for multiple controllers[/list]
SPECIAL THANKS TO:
Conquer For this post
PPjoy
Autohotkey |
|