P.I. Engineering User Forum

Product Support, Technical Questions and Answers, and Examples for P.I. Engineering Products

You are not logged in.

#1 2017-01-04 17:41:56

AlvinAiley
Member
Registered: 2017-01-04
Posts: 2

SDK keyboard Click

Hi I am new to X-Keys and have been playing around with the PIHidDotName file that was provided in C# for XK-16/8/4 stick. I have been trying to get the keys to flash when a certain button is clicked (i.e. if i press the 1st button on X-keys i only want that button to flash). I have been using the callback for me to see the data and I notice this when I press the first button data= 00 01 01 (01) 00 00 00 00 01 9B 9F 00 ....
I noticed that the value in the paranthesis corresponds to that button push. How can I implement that value in the code.

Thanks

Offline

#2 2017-01-05 09:38:10

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 164
Website

Re: SDK keyboard Click

Hi there,

Long story short, bit-masking. Long story longer: Check out the sample here for the XK-24 with parsing button presses exampled. It shows the necessary logic. https://www.dropbox.com/s/b4slp75fvmfd7 … s.zip?dl=0

Note we do have .NET components that enable you to implement the X-keys into your code without bothering with bit-masking. If this isn't something you want to tackle that may be a better way to do it.


Amber from P.I. Engineering

Offline

#3 2017-01-05 12:56:30

AlvinAiley
Member
Registered: 2017-01-04
Posts: 2

Re: SDK keyboard Click

Hi Amber thanks for the help I will definitely try the bit masking. In terms of using the .NET components for the button press would I need to use the ReadData(ref byte[]).

Thanks

Offline

#4 2017-01-05 14:26:13

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 164
Website

Re: SDK keyboard Click

If you use the .NET components you would not use any of the code currently in the SDK sample you are using. There's a different sample that implements the component. Getting a button press through the component looks like this, with case 1001 being button 1, case 1002 being button 2, etc.:

        private void HandleButtons(XK16_8_4.XKeyEventArgs e)
        {
            //Handle state changes of the buttons
            if (e.PressState == true) //button press
            {
                switch (e.CID)
                {
                    case 1001:
                        lblButton01.Text = "01-dn";
                        break;
                    case 1002:
                        lblButton02.Text = "02-dn";
                        break;
                    case 1003:
                        lblButton03.Text = "03-dn";
                        break;
                }
            }
       }

These were created to streamline the interface for developers as bit-masking isn't exactly second nature for most of us.

You can find the .NET component sample on your hard drive here (if installed to the default location): C:\Program Files (x86)\PI Engineering\P.I. Engineering SDK\XK-16 Stick\.NET Component


Amber from P.I. Engineering

Offline

Board footer

Powered by FluxBB