Xbox controller plugin not sending button press to other plu

This is where you talk about Plugins. How they are made and how they work, show examples.

Xbox controller plugin not sending button press to other plu

Postby ger21 » Sun Aug 13, 2023 4:31 pm

My 2022 screenset has a lot of screen elements controlled by a plugin, and the plugin also does probing, Z auto zero, and several other functions. One of my users is telling me that when he configures the XBox controller plugin to activate a screen button, it's not working. If I setup Hotkeys for the buttons (10670 & 10672), they work correctly.
Is the XBox pluging doing something different, or do I need to change my plugin for it to work?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Xbox controller plugin not sending button press to other

Postby eabrust » Sun Aug 13, 2023 7:27 pm

Hey Ger,

Can you clarify which Xbox plugin you're referring to, the one that comes w/ UCCNC, or my version ?

regards
Eric
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 357
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: Xbox controller plugin not sending button press to other

Postby ger21 » Sun Aug 13, 2023 9:13 pm

Hi Eric.
I see that it's your plugin. Any idea's? I can send you a link to the screenset if that will help.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Xbox controller plugin not sending button press to other

Postby ger21 » Mon Aug 14, 2023 5:00 pm

@dezsoe @cncdrive

Eric did some testing for me, and apparently, for Callbutton() to work in a plugin, the button number must be 20,000-20999, the same as a macro? Is this by design, or a consequence of the limited range for macros?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Xbox controller plugin not sending button press to other

Postby cncdrive » Wed Aug 16, 2023 2:04 am

Yes, thats the range for macro calls, but the Callbutton should also work with the standard built functions.
cncdrive
Site Admin
 
Posts: 4901
Joined: Tue Aug 12, 2014 11:17 pm

Re: Xbox controller plugin not sending button press to other

Postby ger21 » Wed Aug 16, 2023 2:10 am

But if my functions in my plugin, which are activated by buttons out of range, Callbutton will not trigger them.
So I guess I need to change my button numbers to the 20,000-20,999 range, even though I'm not using macros?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Xbox controller plugin not sending button press to other

Postby dezsoe » Tue Aug 22, 2023 8:20 am

Callbutton triggers any button number. There's no difference between any numbers: even the internal button calls trigger the Buttonpress_event.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Xbox controller plugin not sending button press to other

Postby ger21 » Tue Aug 22, 2023 10:55 am

My plugin has code that runs when button 10670 is pressed.
If another plugin (or even my own plugin) uses Callbutton(10670), the code will not run. It will run from a hotkey, or a screen button, but not from Callbutton().
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Xbox controller plugin not sending button press to other

Postby dezsoe » Tue Aug 22, 2023 5:29 pm

OK, I wrote a quick test plugin. The Buttonpress_event contains the following lines:

Code: Select all
            DebugInfo("Button pressed: " + ButtonNumber.ToString());
            if (ButtonNumber == 1)
                UC.Callbutton(10670);

And here are the results after creating a button using button number 1, pressing reset, home all and then the new button:

Code: Select all
<CallbuttonTest> [ButtonPressedEvent] Button pressed: 144
<CallbuttonTest> [ButtonPressedEvent] Button pressed: 113
<CallbuttonTest> [ButtonPressedEvent] Button pressed: 1
<CallbuttonTest> [ButtonPressedEvent] Button pressed: 10670

Notes:
- DebugInfo writes to the console.
- The name of the event handler is different, but it is called by the Buttonpress_event in a try-catch.
- Button 10670 was "pressed" by the Callbutton.

Writing about the try-catch: if your plugin throws an exception in the Buttonpress_event then you'll have the same result as if the event wasn't called. Try to catch exceptions in your handler, maybe, that is the problem.

Code: Select all
        public void Buttonpress_event(int ButtonNumber, bool OnScreen)
        {
            try
            {
                // Do your stuff here
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Xbox controller plugin not sending button press to other

Postby ger21 » Tue Aug 22, 2023 6:07 pm

I don't think you understand what the issue is.
Eric's XBox plugin allows you to assign button numbers to the xbox controller buttons.
When his X Box plugin does a Callbutton(10670), the code in my plugin for my button 10670, does not run. my screen button works, and I can create a hotkey to run button 10670, but Callbutton() from another plugin (or macro I think) will not runthe code.
According to Eric, if the button number is between 20,000-20999, it will work.

Write two plugins, and add a button 10670 and 10671 on the screen.
Plugin 1:

do something when button 10670 is pressed.

Plugin 2:
When button 10671 is pressed, do Callbutton(10670)

The second plugin will not run the code in the first plugin.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Next

Return to Plugins

Who is online

Users browsing this forum: No registered users and 3 guests