I am successfully using the Infinity USB foot pedal (IN-USB2) to control VLC in the background, for transcription purposes. I type in a word processor, and am able to control VLC playing in the background, using my foot pedal. This solution requires the AutoHotkey scripting engine, and one of the following scripts:
32 bit:
Code: Select all
; This script allows you to use a USB foot pedal to control VLC in the
; background, in this case, for transcription. This script has been
; tested with a VEC Infinity IN-USB-2 3-function foot pedal. This
; particular foot pedal has 3 buttons, and, therefore, 6 programmable
; functions, as each button can be pressed or released.
;
; To use this script, save it as FootPedal32.ahk and launch it with
; AutoHotkey installed.
;
; See below for more information on customizing this script for VLC.
;
; This version of the script is for the 32-bit version of AutoHotkey.
;
; This script was taken from http://tinyurl.com/k5gylb2 combined with
; http://tinyurl.com/k5jc24e
;
; Thanks go out to all who contributed to this script, and the makers
; of AutoHotkey.
;
OnMessage(0x00FF, "InputMessage")
RegisterHIDDevice(12, 3) ; Register Foot Pedal
PedalLastPress := 0
Return
ProcessPedalInput(input)
{
global PedalLastPress
; The input are combinations of 1, 2, 4 with 00 appended to the end
; indicating which pedals are pressed.
; For example, pressing the leftmost pedal triggers input 100, middle pedal 200, etc.
; all three pedals presses together will trigger 700 (1 ^ 2 ^ 4 = 7)
; Release of pedal trigger an input indicating what pedals are still held down
input := input//100
If (input > PedalLastPress)
PressKey((PedalLastPress & input) ^ input)
; Else
; ReleaseKey((PedalLastPress & input) ^ PedalLastPress)
PedalLastPress := input
}
; The ControlSend command allows simulated keystrokes to be sent to any running
; program, even if it is running in the background. For more information on how
; it works, see http://www.autohotkey.com/docs/commands/ControlSend.htm
; For more information on which commands can be sent, and how to format them,
; see http://www.autohotkey.com/docs/commands/Send.htm
PressKey(bits)
{
SetTitleMatchMode, 2
If (bits & 1) ; left pedal
{
;Msgbox Left pedal pressed!
ControlSend,,{=}+{Left},VLC media player ;Normalizes playback speed, and rewinds 3 seconds
}
Else If (bits & 4) ; right pedal
{
;Msgbox Right pedal pressed!
ControlSend,,{]},VLC media player ;Increases playback speed by 0.1x increments
}
Else ; center pedal
{
;MsgBox Center pedal pressed!
ControlSend,,{Space},VLC media player ;Play/pause
}
}
; The following function should be uncommented & customized to your liking
; if you would like to utilize different actions upon releasing the foot
; pedal buttons
;ReleaseKey(bits)
;{
; ToolTip Releasing %bits%
; SetTitleMatchMode, 2
; If (bits & 1)
; MsgBox left pedal up!
; Else If (bits & 4)
; MsgBox Right pedal up!
; Else
; MsgBox Center pedal up!
;}
Mem2Hex( pointer, len )
{
A_FI := A_FormatInteger
SetFormat, Integer, Hex
Loop, %len%
{
Hex := *Pointer+0
StringReplace, Hex, Hex, 0x, 0x0
StringRight Hex, Hex, 2
hexDump := hexDump . hex
Pointer ++
}
SetFormat, Integer, %A_FI%
StringUpper, hexDump, hexDump
Return hexDump
}
; Keyboards are always Usage 6, Usage Page 1, Mice are Usage 2, Usage Page 1,
; HID devices specify their top level collection in the info block
RegisterHIDDevice(UsagePage,Usage)
{
; local RawDevice,HWND
RIDEV_INPUTSINK := 0x00000100
DetectHiddenWindows, on
HWND := WinExist("ahk_class AutoHotkey ahk_pid " DllCall("GetCurrentProcessId"))
DetectHiddenWindows, off
VarSetCapacity(RawDevice, 12)
NumPut(UsagePage, RawDevice, 0, "UShort")
NumPut(Usage, RawDevice, 2, "UShort")
NumPut(RIDEV_INPUTSINK, RawDevice, 4)
NumPut(HWND, RawDevice, 8)
Res := DllCall("RegisterRawInputDevices", "UInt", &RawDevice, UInt, 1, UInt, 12)
if (Res = 0)
MsgBox, Failed to register for HID Device
}
InputMessage(wParam, lParam, msg, hwnd)
{
RID_INPUT := 0x10000003
RIM_TYPEHID := 2
SizeofRidDeviceInfo := 32
RIDI_DEVICEINFO := 0x2000000b
DllCall("GetRawInputData", UInt, lParam, UInt, RID_INPUT, UInt, 0, "UInt *", Size, UInt, 16)
VarSetCapacity(Buffer, Size)
DllCall("GetRawInputData", UInt, lParam, UInt, RID_INPUT, UInt, &Buffer, "UInt *", Size, UInt, 16)
Type := NumGet(Buffer, 0 * 4)
Size := NumGet(Buffer, 1 * 4)
Handle := NumGet(Buffer, 2 * 4)
VarSetCapacity(Info, SizeofRidDeviceInfo)
NumPut(SizeofRidDeviceInfo, Info, 0)
Length := SizeofRidDeviceInfo
DllCall("GetRawInputDeviceInfo", UInt, Handle, UInt, RIDI_DEVICEINFO, UInt, &Info, "UInt *", SizeofRidDeviceInfo)
VenderID := NumGet(Info, 4 * 2)
Product := NumGet(Info, 4 * 3)
; tooltip %VenderID% %Product%
if (Type = RIM_TYPEHID)
{
SizeHid := NumGet(Buffer, (16 + 0))
InputCount := NumGet(Buffer, (16 + 4))
Loop %InputCount%
{
Addr := &Buffer + 24 + ((A_Index - 1) * SizeHid)
BAddr := &Buffer
Input := Mem2Hex(Addr, SizeHid)
If (VenderID = 1523 && Product = 255) ; need special function to process foot pedal input
ProcessPedalInput(Input)
Else If (IsLabel(Input))
{
Gosub, %Input%
}
}
}
}
Code: Select all
; This script allows you to use a USB foot pedal to control VLC in the
; background, in this case, for transcription. This script has been
; tested with a VEC Infinity IN-USB-2 3-function foot pedal. This
; particular foot pedal has 3 buttons, and, therefore, 6 programmable
; functions, as each button can be pressed or released.
;
; To use this script, save it as FootPedal64.ahk and launch it with
; AutoHotkey installed.
;
; See below for more information on customizing this script for VLC.
;
; This version of the script is for the 64-bit version of AutoHotkey.
;
; This script was taken from http://tinyurl.com/k5gylb2 combined with
; http://tinyurl.com/k5jc24e
;
; Thanks go out to all who contributed to this script, and the makers
; of AutoHotkey.
;
OnMessage(0x00FF, "InputMessage")
RegisterHIDDevice(12, 3) ; Register Foot Pedal
PedalLastPress := 0
Return
ProcessPedalInput(input)
{
global PedalLastPress
; The input are combinations of 1, 2, 4 with 00 appended to the end
; indicating which pedals are pressed.
; For example, pressing the leftmost pedal triggers input 100, middle pedal 200, etc.
; all three pedals presses together will trigger 700 (1 ^ 2 ^ 4 = 7)
; Release of pedal trigger an input indicating what pedals are still held down
input := input//100
If (input > PedalLastPress)
PressKey((PedalLastPress & input) ^ input)
; Else
; ReleaseKey((PedalLastPress & input) ^ PedalLastPress)
PedalLastPress := input
}
; The ControlSend command allows simulated keystrokes to be sent to any running
; program, even if it is running in the background. For more information on how
; it works, see http://www.autohotkey.com/docs/commands/ControlSend.htm
; For more information on which commands can be sent, and how to format them,
; see http://www.autohotkey.com/docs/commands/Send.htm
PressKey(bits)
{
SetTitleMatchMode, 2
If (bits & 1) ; left pedal
{
;Msgbox Left pedal pressed!
ControlSend,,{=}+{Left},VLC media player ;Normalizes playback speed, and rewinds 3 seconds
}
Else If (bits & 4) ; right pedal
{
;Msgbox Right pedal pressed!
ControlSend,,{]},VLC media player ;Increases playback speed by 0.1x increments
}
Else ; center pedal
{
;MsgBox Center pedal pressed!
ControlSend,,{Space},VLC media player ;Play/pause
}
}
; The following function should be uncommented & customized to your liking
; if you would like to utilize different actions upon releasing the foot
; pedal buttons
;ReleaseKey(bits)
;{
; ToolTip Releasing %bits%
; SetTitleMatchMode, 2
; If (bits & 1)
; MsgBox left pedal up!
; Else If (bits & 4)
; MsgBox Right pedal up!
; Else
; MsgBox Center pedal up!
;}
Mem2Hex( pointer, len )
{
A_FI := A_FormatInteger
SetFormat, Integer, Hex
Loop, %len%
{
Hex := *Pointer+0
StringReplace, Hex, Hex, 0x, 0x0
StringRight Hex, Hex, 2
hexDump := hexDump . hex
Pointer ++
}
SetFormat, Integer, %A_FI%
StringUpper, hexDump, hexDump
Return hexDump
}
; Keyboards are always Usage 6, Usage Page 1, Mice are Usage 2, Usage Page 1,
; HID devices specify their top level collection in the info block
RegisterHIDDevice(UsagePage,Usage)
{
; local RawDevice,HWND
RIDEV_INPUTSINK := 0x00000100
DetectHiddenWindows, on
HWND := WinExist("ahk_class AutoHotkey ahk_pid " DllCall("GetCurrentProcessId"))
DetectHiddenWindows, off
VarSetCapacity(RawDevice, 8 + A_PtrSize)
NumPut(UsagePage, RawDevice, 0, "UShort")
NumPut(Usage, RawDevice, 2, "UShort")
NumPut(RIDEV_INPUTSINK, RawDevice, 4, "UInt")
NumPut(HWND, RawDevice, 8, "UPtr")
Res := DllCall("RegisterRawInputDevices", "Ptr", &RawDevice, "UInt", 1, "UInt", 8 + A_PtrSize, "UInt")
if (Res = 0)
MsgBox, Failed to register for HID Device
}
InputMessage(wParam, lParam, msg, hwnd)
{
RID_INPUT := 0x10000003
RIM_TYPEHID := 2
SizeOfHeader := 8 + A_PtrSize + A_PtrSize
SizeofRidDeviceInfo := 32
RIDI_DEVICEINFO := 0x2000000b
DllCall("GetRawInputData", "Ptr", lParam, "UInt", RID_INPUT, "Ptr", 0, "UIntP", Size, "UInt", SizeOfHeader, "UInt")
VarSetCapacity(Buffer, Size)
DllCall("GetRawInputData", "Ptr", lParam, "UInt", RID_INPUT, "Ptr", &Buffer, "UIntP", Size, "UInt", SizeOfHeader, "UInt")
Type := NumGet(Buffer, 0 * 4, "UInt")
Size := NumGet(Buffer, 1 * 4, "UInt")
Handle := NumGet(Buffer, 2 * 4, "UPtr")
VarSetCapacity(Info, SizeofRidDeviceInfo)
NumPut(SizeofRidDeviceInfo, Info, 0)
Length := SizeofRidDeviceInfo
DllCall("GetRawInputDeviceInfo", "Ptr", Handle, "UInt", RIDI_DEVICEINFO, "Ptr", &Info, "UIntP", SizeofRidDeviceInfo)
VenderID := NumGet(Info, 4 * 2, "UInt")
Product := NumGet(Info, 4 * 3, "UInt")
; tooltip %VenderID% %Product%
if (Type = RIM_TYPEHID)
{
SizeHid := NumGet(Buffer, (SizeOfHeader + 0), "UInt")
InputCount := NumGet(Buffer, (SizeOfHeader + 4), "UInt")
Loop %InputCount%
{
Addr := &Buffer + SizeOfHeader + 8 + ((A_Index - 1) * SizeHid)
BAddr := &Buffer
Input := Mem2Hex(Addr, SizeHid)
If (VenderID = 1523 && Product = 255) ; need special function to process foot pedal input
ProcessPedalInput(Input)
Else If (IsLabel(Input))
{
Gosub, %Input%
}
}
}
}