Accesso rapido:  

Forum: VirtualDJ Plugins

Topic: Determining what custom button was pressed inside plugin C++ Code

Questo argomento è obsoleto e potrebbe contenere informazioni obsolete o errate.

First question, should I ask my C++ plugin programming questions here or under Tech Support?

Second and thanks for any help you can give me in determining how to create my own plugins. I wanted to get wet in this and create some basic plugins first and I want to start in the direction of creating a plugin which can get variables created during someone pressing a custom_button on a pad.


For example:
Pad 1 button has:

deck active play & set "$myVarFromPadButton1" 0.7


I guess I would like to start with this


HRESULT VDJ_API CMyPlugin8::OnParameter(int id)
{
switch(id)
{
case ID_BUTTON_1:
// what might I put here to get a variable for example $myVarFromPadButton1
//
// lastly for my testing what might I put here to run the action for PadButton1
// so I need to know how to execute an action in C++ from here


 

Inviato Tue 31 Jan 17 @ 9:04 pm
locoDogPRO InfinityModeratorMember since 2013
Here is the right place, check out the header there's SendCommand() and GetInfo() functions not at a machine to give you exact info.
 

Inviato Tue 31 Jan 17 @ 10:51 pm
SBDJPRO Infinity Member since 2006
double padButton1 = 0;
GetInfo("get_var $myVarFromPadButton1", &padButton1);


Also bear in mind if it's a button that OnParameter is called twice with the button ID, once for button down, once for button up. You can tell which by the value of the variable assigned to the button. Often you'll only want to execute an action on one of those ;)
 

Inviato Thu 02 Feb 17 @ 1:44 am
Thanks I'm trying to find time again to do some programming.
 

Inviato Thu 02 Feb 17 @ 9:56 pm
OK I got some time again and am working on this. So you say I can get a value when a button is down and up.

How can I do that with GetInfo or is it another technique?
 

Inviato Fri 10 Feb 17 @ 7:27 pm
Are you referring to something like this:
For example inside PadButton1 script
down ? set '$myPadPressed1' -1 : up ? set '$myPadPressed1' 1 : set '$myPadPressed1' 0



In the custom plugin:

double padButton1 = 0;
GetInfo("get_var $myPadPressed1", &padButton1);
switch ((int)padButton1)
{
case -1:
sprintf_s(parStatus, 32, "Pad 1 Down");
break;
case 0:
sprintf_s(parStatus, 32, "Pad 1 Stationary");
break;
case 1:
sprintf_s(parStatus, 32, "Pad 1 Up");
break;
}

 

Inviato Fri 10 Feb 17 @ 11:03 pm
SBDJPRO Infinity Member since 2006
If it's not a plugin button, then there's no event, you'll have to poll for it as per your code above. Bear in mind that most buttons don't have up/down/inactive states - they are usually either up or down. Velocity sensitive pads have extra information obviously.

Having just two states means your script is just:

set '$myPadPressed1' while_pressed

and then you can just poll for 0 or 1.
 

Inviato Sat 11 Feb 17 @ 6:11 pm
Thanks appreciate the input. Honestly I was hoping to determine the state of a non-plugin button (meaning mainly hotcue buttons) without having to put code in the buttons. I was even googling ways to have C++ determine the state of windows owned by other processes which might be a subclassing or hooking but I haven't done that in over 10 years and I'd have some major learning to do.
 

Inviato Sat 11 Feb 17 @ 8:38 pm


(Vecchi argomenti e forum sono automaticamente chiusi)