Can't reconfigure the hotkeys for the control buttons.

Moderators: TomKerekes, dynomotion

Post Reply
AlexSV
Posts: 14
Joined: Mon Jun 24, 2024 4:05 pm

Can't reconfigure the hotkeys for the control buttons.

Post by AlexSV » Fri Dec 20, 2024 11:48 pm

Hello Tom!

I'm trying to configure the jog and step buttons in the Screen Editor so that pressing the arrow, page up/down, +, - keys on the keyboard would trigger the step mode, and their combination with the CTRL key would trigger the run mode, which is the opposite of how it's done by default. I can't change it. Is there a way to configure this?

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

Re: Can't reconfigure the hotkeys for the control buttons.

Post by TomKerekes » Sat Dec 21, 2024 1:09 am

Hi Alex,

That functionality is hard coded. To change that behaviour you would need to modify the function:

Code: Select all

int DoCheckShiftAndKey(int Key,WPARAM wParam, LPARAM lParam, CMotionButton &Button, CMotionButton &Button2, CMotionButton &ButtonStep)
Then re-compile KMotionCNC.

3 Screen buttons act in a group that share the same hotkey. That function decides based on the shift and control states which buttons to press or release.
Regards,

Tom Kerekes
Dynomotion, Inc.

AlexSV
Posts: 14
Joined: Mon Jun 24, 2024 4:05 pm

Re: Can't reconfigure the hotkeys for the control buttons.

Post by AlexSV » Sat Dec 21, 2024 7:09 am

Where is this function located? Does it require Visual Studio ?

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

Re: Can't reconfigure the hotkeys for the control buttons.

Post by TomKerekes » Sat Dec 21, 2024 7:43 am

You can locate it by doing a find-in-files search such as the one in Visual Studio.

Yes you would need Visual Studio 2022
Regards,

Tom Kerekes
Dynomotion, Inc.

AlexSV
Posts: 14
Joined: Mon Jun 24, 2024 4:05 pm

Re: Can't reconfigure the hotkeys for the control buttons.

Post by AlexSV » Sun Dec 22, 2024 7:54 am

I adjusted the function, everything seems to work.
Thanks!

Code: Select all

int DoCheckShiftAndKey(int Key,WPARAM wParam, LPARAM lParam, CMotionButton &Button, CMotionButton &Button2, CMotionButton &ButtonStep)
{
	if (wParam == VK_SHIFT)  
	{
		if (lParam & 0x80000000)
		{
			// shift went up  
			if (Button2.DrawPushed)
			{
				Button.HandleButtonDown();
				Button2.HandleButtonUp();
			}
		}
		else
		{
			// shift went down 
			if (Button.DrawPushed)
			{
				Button2.HandleButtonDown();
				Button.HandleButtonUp();
			}
		}
	}

	if (Key == wParam)
	{
		if (GetKeyState(VK_CONTROL)&0x80000000) 
		{
		
		if (lParam & 0x80000000)
			{
				if (Button.DrawPushed)
				{
					Button.HandleButtonUp();
				}
			}
			else
			{
				if (!Button.DrawPushed)
				{
					Button.HandleButtonDown();
				}
			}
		}
		else if (GetKeyState(VK_SHIFT)&0x80000000)  
		{
			if (lParam & 0x80000000)
			{
				if (Button2.DrawPushed)
				{
					Button2.HandleButtonUp();
				}
			}
			else
			{
				if (!Button2.DrawPushed)
				{
					Button2.HandleButtonDown();
				}
			}
		}
		else    
		{
			
			if ((lParam & 0x80000000)==0)
			{
				// arrow key was pressed while 
				ButtonStep.HandleButtonDown();
			}
			else
			{
				// arrow key was released while 
				ButtonStep.HandleButtonUp();
		} 
			
		}
		return 1;
	}
	return 0;
}

Post Reply