vPedal Windows API and C++ examples

Updated: 17 Dec 2015

Disclaimer:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

vPedal 2015API – by downloading the API you are agreeing to the conditions stated above. ( to install rename to .exe – 479kb )

the new version of the API has been tested on Win 7 / Win8.1 / Win10

YouTube Informational video

with both vP-1 + vP-4 MKII footpedals . This application allows you to control javascript in several popular browsers – Edge / IE11/ Chrome / Firefox

  1. Pls uninstall the any old versions /
  2. Download from the link above/ rename the attached ._xe to .exe
  3. run the installer < this installs a new ver ocx and app onto your pc
  4. Once installed you then need to run the application < there is a shortcut installed on the desktop.  IMPORTANT: Make sure you run vPedal 2015API.exe prior to using the foot pedal and your browser
  5. the Browser window must have focus

Link to vPedal Youtube channel – which has demo’s

vPedal Javascript Browser API Programmer Notes

Programmer Notes:

The Browser API is necessary to give today’s programmer with the utmost power to control the interactions between the vPedal and any internet platform, including embedded devices.

The concept behind the API is very simple. Due to the limitation of various security programs and browsers, a COM/ActiveX method was replaced with a much smarter alternative. Each browser in Windows operates as a Window, whether it be Microsoft Edge, Internet Explorer, FireFox, Chrome,,Safari, Opera and all variants including the earlier Spartan version in Windows 10.

A challenge was presented to the programmer. How can one solution control the active application’s web page and actually fire a JavaScript event, allowing the programmer to essentially – do anything?

The answer was developed via vPedal and its developers and looks like this to Windows.

notes1a

Essentially, the vPedal Listener Tray Icon is responsible for authenticating and allowing the vPedal to operate. The Browser in the Active Window is automatically detected. When you enter any key into a browser, whether it be a text box or any object, an event is triggered. For example if you type in “K” into a text box, the object in focus would receive 3 events. onKeyDown onKeyPress, and onKeyUp each with an event parameter passed with the ASCII Keycode of “K”, which is of course Character 75. So therefore any Javascript programmer would know that they can have an event on the HTML DOM element onKeyUp =”alert(event.keyCode);”

So, you would expect to see: notes2a

Javascript was chosen as it is more universal than any other scripting language. Despite the power of VBScript being capable, it is not universal to all browsers or usable on multiple platforms and devices, including mobile devices.

Now, obviously the onkeyUp event, using the event object gives you the ability to run code. This is triggered by the user. In this case, the vPedal must be the one to tell the browser. Without any plugins, how can this be so?

The vPedal Javascript API must be able to communicate with the active browser and simulate the above. Hence, on various events of the vPedal, the window events are passed the active window. Take the following script for example. This script gets fired on the <BODY> onkeyUp event.

Naturally in Windows it would be quite silly to rely on the K key to be a FootDown event. Therefore the API has been programmed to specifically require a reasonably impossible combination of keys that could not possibly interfere with either Windows or the Active Browser.

Therefore we rely on the alt, ctrl, and the shift key to be held at the same time Virtually. So the following code is the listener, and executes various code on combinations of inbound key events sent from the vPedal tray icon.

 

notes1

 

Therefore this is the virtual listener that then goes and chooses what to do at certain events. This is what happens. This code says if the user presses alt, ctrl, shift and 1-6 then run the respective commands. The parameter to the ExecuteCommand is not relevant to the functioning, but it distinguishes an action. Review the following code

notes2

 

notes3

This code captures the event and in this case, changes the contents of a Div. Also note: The absense n the above example of receiving a message in 30 seconds, sets the global variable isVpedalActive to False, otherwise True.
The above example is also written to do other media based events with player_a but for the purposes of the programmer, the main exercise here is to understand that:

notes4


Old SDK ActiveX info – now obsolete

ActiveX properties:

The following ActiveX properties are exposed to the programmer:

a) Interval – Defaults at 250ms. This is the interval which the control checks for events.

b) isPlaying –(Read Only) – Is True when playing, False when not playing.

c) isRewinding – (Read Only) – Is True when rewinding, False when not rewinding.

d) isFastForwarding (Read Only) – Is True when fast forwarding, False when not fast forwarding.


 

vpedaltest

vpedtest  ( right button save as ) is a zipped file of a testing application that can be used


Supported pedals:

vPedalAPI – it has been designed only to work with vPedals


 C++ Example Code

vPedals are a device that can be used for control of playback and it is easily configured. It is easy to program as you do not need to have any knowledge about physical device interface. vPedals are seem by the OS as a games joystick device

I am providing some codes based on Microsoft Visual C++ 6.0.

1. These codes include “mmsystem.h” to support MultiMedia in your project.

2.You can overwrite WindowProc() function in the window where you want to use FootPedal. (WindowProc function can process all messages that occur in the program)

3. The vPedals only use buttons 1 & 2 , button 1 for Rewind and button 2 for Fast Forward. If you Press the center part of the vPedal the buttons 1 & 2 are engaged simultaneously, for the play command.

The Program is as follows:

WindowProc(UINT message, WPARAM wParam, LPARAM lParam)

{

switch(message)

{

case MM_JOY1BUTTONDOWN: //one of the key is press

if ( (wParam & JOY_BUTTON1) && (wParam & JOY_BUTTON2) )

{

//to perform the play function

}

else if ( (UINT) wParam & JOY_BUTTON1 )

{

//to perform the rewind function

}

else if ( (UINT) wParam & JOY_BUTTON2 )

{

//to perform the fast forward function

}

break;

case WM_DESTROY:

// before closing the program window, Release capture on the joystick joyReleaseCapture( JOYSTICKID1 );

break

}

}


 The old version of the API:

Disclaimer:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 vPedal API old ver – by downloading the you are agreeing to the conditions stated above. ( to install rename to .exe – 439kb )


Old Version Basic Introduction

The vPedal SDK consists of the following components:

1. vpedalsdk.pdf – This basic user documentation. ( the same as this web page )

2. vpedalax.ocx – The standalone ActiveX/COM component that interacts with the vPedal

3. vPedal ActiveX Control Internet Explorer 11 Sample –  (right click mouse – save as .htm )

Note: this is a newer version than what is included in the zip file please use this:

An example of the vPedal SDK used to control a Windows Media Player session from within an IE HTML page.

ActiveX Events:

The following ActiveX events are exposed to the programmer:

a) OnPlayDown – Gets fired when the play pedal is pushed down.

b) OnPlayUp – Gets fired when the play pedal is released.

c) OnRewindDown – Gets fired when the rewind pedal is pushed down.

d) OnRewindUp – Gets fired when the rewind pedal is released.

e) OnFastForwardDown – Gets fired when the fast forward pedal is pushed down.

f) OnFastForwardUp – Gets fired when the fast forward pedal is released.

g) FastForwardNow – Gets fired ever 500ms if in fast forwarding mode. This is useful to inform the outside application that it should process a fast forwarding incremenet.

h) RewindNow – Gets fired ever 500ms if in rewinding mode. This is useful to inform the outside application that it should process a rewinding increment.

i) FootDown – (Advanced) – Gets fired when any pedal is down specifying the pedal.

j) FootUp – (Advanced) – Gets fired when any pedal is up specifying the pedal.

Old ver ActiveX properties:

The following ActiveX properties are exposed to the programmer:

a) Interval – Defaults at 250ms. This is the interval which the control checks for events.

b) isPlaying –(Read Only) – Is True when playing, False when not playing.

c) isRewinding – (Read Only) – Is True when rewinding, False when not rewinding.

d) isFastForwarding (Read Only) – Is True when fast forwarding, False when not fast forwarding.

e) Visible – (Read/Write) – Turns the visible control box on or off.

This example makes use of ActiveX events and Javascript.

The SDK has been tested to operate in a Windows 7 + 8.1 environments.

As with all ActiveX/COM components it is required that the component be registered on the end-users machine.

You must use the regsvr32.exe from SysWow64 Directory in Windows

to achieve this.

Please note the user should be either an Administrator or the regsvr32.exe command should be executed as an Administrator.

 Platforms:

As ActiveX is a widely used platform, the SDK should operate on a vast majority of languages that support event driven ActiveX components including but not limited to VC++, VB.NET, C#, VB5, VB6, IE, Netscape etc. It is also important to note that various platforms have additional security requirements. Internet Explorer does require the user to either accept or override ActiveX security warnings to successfully use this control.

This SDK has been tested on Win 7 Sp1 + win 8.1 64bit  as well as the 32 bit versions of Vista

 to show ActiveX responding to the operation of a vPedal


TIPS:

To remove message about allowing events: Registry settings

HKEY_CURRENT_USER -> SOFTWARE -> MICROSOFT -> WINDOWS -> CURRENTVERSION -> INTERNET SETTINGS -> ZONES -> 0 -> CREATE DWORD LABELLED 1201 WITH VALUE OF 0

To list the WMP properties. https://msdn2.microsoft.com/en-us/library/aa917499.aspx

see also https://msdn2.microsoft.com/en-us/library/aa908337.aspx


Extra information in using Google Chrome + Firefox with Activex

Go Back