Customizing gamepad interface

Moderators: TomKerekes, dynomotion

Post Reply
BillK
Posts: 6
Joined: Tue Sep 18, 2018 6:46 pm

Customizing gamepad interface

Post by BillK » Thu Oct 25, 2018 6:13 pm

I would like to get some different behaviors from my
Gamepad for jogging. I looked around in the kmotion
Directory and all I could find is joystick.dll.
Is there anything a user could do with visual studio to
modify jog behavior?
Is there a third party app that fits between the gamepad
And kmotioncnc that is recommended?
The most important change I need is that during xy
jogging only one axis should be moving. There are setup
situations where having any movement whatsoever
on the other axis is intolerable. Maybe I could have one
of the trigger buttons isolate x or y.
There are too many possibilities to just
ask for them. It would be best if this is something I can
experiment with.

User avatar
TomKerekes
Posts: 2540
Joined: Mon Dec 04, 2017 1:49 am

Re: Customizing gamepad interface

Post by TomKerekes » Thu Oct 25, 2018 6:36 pm

Hi BillK,

There isn't currently any way to customize the Gamepad functionality without altering KMotionCNC source.

If you wish to do that see:

int CKMotionCNCDlg::DoJoyStick() in <>\PC VC Examples\KMotionCNC\KMotionCNCDlg.cpp

You might try temporarily setting the Jog Speeds for the axes you do not wish to move to zero in order to inhibit motion of those axes.
Regards,

Tom Kerekes
Dynomotion, Inc.

BillK
Posts: 6
Joined: Tue Sep 18, 2018 6:46 pm

Re: Customizing gamepad interface

Post by BillK » Mon Oct 29, 2018 4:29 am

What is the ideal Visual studio to install ?
I had 2017. It did an import and had me add mfc 8.1
(probably) and rebuilt. There were some warnings but
no errors. It couldn’t find the exe to run and gave me
a long message about linker. I tried it with vs2015 but it also required an import of the project and it gave hundreds of errors.
Attachments
542F554E-ECB0-4724-BDA8-4E34FDB346A8.jpeg

User avatar
TomKerekes
Posts: 2540
Joined: Mon Dec 04, 2017 1:49 am

Re: Customizing gamepad interface

Post by TomKerekes » Mon Oct 29, 2018 5:33 pm

Hi BillK,

The projects are compatible with VS2015 without any upgrading. See here.

Make sure you are using our latest Release Version 4.34

VS2017 should also work but when Microsoft upgrades the project the Target Directory is not maintained correctly. So you will need to correct this.
Regards,

Tom Kerekes
Dynomotion, Inc.

greg9504
Posts: 20
Joined: Fri Mar 23, 2018 1:01 pm

Re: Customizing gamepad interface

Post by greg9504 » Wed Nov 07, 2018 1:34 am

Bill,

If you opened the solution/projects in 2017 then went back and tried to open/build in 2015 that is probably what is causing your build errors in 2015.

I'd suggest reinstalling to a new dir and building with 2015 again.

If you get that far I found that I had to modify the following code as the joystick was far too sensitive for my use. Even without touching the joystick I'd see it command very small moves. If I used other joystick software to validate the hardware it would not show any 'movement' ( A good online one is https://gamepadviewer.com/ ). Anyway here is what I modified:

Around line 5378 of KMotionInstallDir\PC VC Examples\KMotionCNC\KMotionCNCDlg.cpp

you'll find method:

Code: Select all

double CKMotionCNCDlg::DoJoyAxis(int axis, int joystick)
{
	double v;

	v = joystick-0x7fff;
	if (ThreadIsExecuting) v=0;
	if (fabs(v) < 1600) v=0;  // <- modify the 1600 value here to suit, higher values make joystick less 'sensitive'

	v *= m_JogSpeed[axis] * m_JogSpeedOverride[axis] * m_JogSpeedFactor / 32768.0;

	return v;
}
Modify the 1600 value, increase the value to make the joystick less sensitive. I ended up at 30000. For me this makes it so that if I'm slightly off while pushing on the joystick I only get movement in the dominate direction that I'm pushing the joystick. I'm using an Xbox 360 wireless controller.

To aid in debugging this might help, around line 4982 (just before the // handle external Jog commands) add:

Code: Select all

TRACE("new xpos %g\n", ji.dwXpos);
    TRACE("new ypos %g\n", ji.dwYpos);
    TRACE("new m_Joyvx %g\n", m_Joyvx);
    TRACE("new m_Joyvy %g\n", m_Joyvy);
Greg

Post Reply