Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32
K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #55736] Fri, 04 December 2020 20:32 Go to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

As the title explains, the Ctrl+semicolon and Ctrl+Period keys share the same constant value and this results in error in Win32 if they are both used in the same switch statement.

See, Win32Keys.h, ln: 118, 119:
K_CTRL_PERIOD    = K_CTRL|0xbe|K_DELTA,
K_CTRL_SEMICOLON = K_CTRL|0xbe|K_DELTA,



Best regards,
Oblivion


Re: K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #55772 is a reply to message #55736] Fri, 11 December 2020 16:14 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks, fixed.
Re: K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #55793 is a reply to message #55772] Mon, 14 December 2020 20:47 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Mirek,

There seems to be another problem with function key handling, specifically on X11:

In X11Proc.cpp, Key release the "keysym" variable (which is unsigned long) is either uninitalized or can return values > 64K. This messes the upper word of K_ keys where the keyflags reside and basically renders the modified function keys ([SHIFT]CTRL/ALT+FN) unusable on X11.

For example, CTRL + F5:

K_CTRL_F5|K_KEYUP = 0x13ffc2
actual key        = 0xffffffc2


This seems to be a quick work-around, but unfortunately, I have little time now to investigate its possible side-effects (I believe, we don't use the upper word of keysym at this point):

CtrlCore/X11Proc.cpp:270
			keysym &= 0xFFFF; <---- ADDED
			if(keysym >= '0' && keysym <= '9' && (chr == 0 || GetCtrl() || GetAlt())) {
				DispatchKey(KEYtoK(keysym - '0' + K_0)|up, count);
				return;
			}
			if(chr >= 1 && chr < 32) {
				DispatchKey(KEYtoK(chr - 1 + K_CTRL_A)|up, count);
				return;
			}
			if(keysym >= 0xff80 && keysym <= 0xffb9 && chr) {
				DispatchKey(KEYtoK(chr)|up, count);
				return;
			}
			if(keysym >= 0xff00 && chr < 128 ||
			   (GetCtrl() || GetAlt()) && keysym >= 0x20 && keysym < 0x7f) {
				if(keysym >= 'a' && keysym <= 'z')
					keysym = keysym - 'a' + 'A';
				DispatchKey(KEYtoK(keysym|K_DELTA)|up, count);
				return;
			}





Best regards,
Oblivion


Re: K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #55794 is a reply to message #55772] Mon, 14 December 2020 22:48 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Below code seems to allow numpad, editpad, cursor keys with modifiers on X11:

			static struct { KeySym keysym; dword key; } tab[] = {
				{ XK_ISO_Left_Tab, K_TAB|K_SHIFT },
				{ XK_BackSpace,    K_BACKSPACE },
				{ XK_Tab,          K_TAB       },
				{ XK_Return,       K_ENTER     },
				{ XK_KP_Enter,     K_ENTER     },
				{ XK_Escape,       K_ESCAPE    },
				{ XK_space,        K_SPACE     },
				{ XK_Pause,        K_BREAK     },
				{ XK_Scroll_Lock,  K_SCROLL    },
				{ XK_Home,         K_HOME      },
				{ XK_End,          K_END       },
				{ XK_Left,         K_LEFT      },
				{ XK_Up,           K_UP        },
				{ XK_Right,        K_RIGHT     },
				{ XK_Down,         K_DOWN      },
				{ XK_Prior,        K_PRIOR     },
				{ XK_Next,         K_NEXT      },
				{ XK_Page_Up,      K_PAGEUP    },
				{ XK_Page_Down,    K_PAGEDOWN  },
				{ XK_Insert,       K_INSERT    },
				{ XK_KP_Space,     K_SPACE     },
				{ XK_KP_Tab,       K_TAB       },
				{ XK_KP_Enter,     K_ENTER     },
				{ XK_KP_F1,        K_F1        },
				{ XK_KP_F2,        K_F2        },
				{ XK_KP_F3,        K_F3        },
				{ XK_KP_F4,        K_F4        },
				{ XK_KP_Home,      K_HOME      },
				{ XK_KP_Left,      K_LEFT      },
				{ XK_KP_Up,        K_UP        },
				{ XK_KP_Right,     K_RIGHT     },
				{ XK_KP_Down,      K_DOWN      },
				{ XK_KP_Page_Up,   K_PAGEUP    },
				{ XK_KP_Page_Down, K_PAGEDOWN  },
				{ XK_KP_End,       K_END       },
				{ XK_KP_Begin,     K_HOME      },
				{ XK_KP_Insert,    K_INSERT    },
				{ XK_KP_Delete,    K_DELETE    },
				{ XK_KP_Multiply,  K_MULTIPLY  },
				{ XK_KP_Add,       K_ADD       },
				{ XK_KP_Separator, K_SEPARATOR },
				{ XK_KP_Subtract,  K_SUBTRACT  },
				{ XK_KP_Decimal,   K_DECIMAL   },
				{ XK_KP_Divide,    K_DIVIDE    },
			};
			for(int i = 0; i < __countof(tab); i++)
				if(tab[i].keysym == keysym) {
					DispatchKey(KEYtoK(tab[i].key)|up, count);
					return;
				}
			if(GetShift() && chr == 0) {
				static dword k[] = { 41, 33, 64, 35, 36, 37, 94, 38, 42, 40 };
				for(int i = 0; i < 10; i++)
					if(keysym == k[i]) {
						DispatchKey(KEYtoK(i + K_0)|up, count);
						return;
					}
			}
		#ifndef PLATFORM_OSX11
			if(GetCtrl() || GetAlt()) { // fix Ctrl+Shift+1 etc...
				keysym = decode((int)event->xkey.keycode, 0xa, '1', 0xb, '2', 0xc, '3', 0xd, '4',
				                0xe, '5', 0xf, '6', 0x10, '7', 0x11, '8', 0x12, '9', 0x13, '0',
				                keysym);
			}
		#endif
			// DLOG("keysym: " << keysym << " " << (char)keysym);
			keysym &= 0xFFFF;
			if(keysym >= '0' && keysym <= '9' && (chr == 0 || GetCtrl() || GetAlt())) {
				DispatchKey(KEYtoK(keysym - '0' + K_0)|up, count);
				return;
			}
			if(chr >= 1 && chr < 32) {
				DispatchKey(KEYtoK(chr - 1 + K_CTRL_A)|up, count);
				return;
			}
			if(keysym >= 0xff80 && keysym <= 0xffb9 && chr) {
				DispatchKey(KEYtoK(chr)|up, count);
				return;
			}
			if(keysym >= 0xff00 && chr < 128 ||
			   (GetCtrl() || GetAlt()) && keysym >= 0x20 && keysym < 0x7f) {
				if(keysym >= 'a' && keysym <= 'z')
					keysym = keysym - 'a' + 'A';
				DispatchKey(KEYtoK(keysym|K_DELTA)|up, count);
				return;
			}

			if((chr == 32 || chr == 9 || chr == 13) && !pressed)
				DispatchKey(chr|K_KEYUP, count);
			if(chr && pressed) {
				DispatchKey(chr, count);
				for(int ii = 1; ii < wtext.GetLength(); ii++)
					DispatchKey(wtext[ii], count);
			}
		}
		break;



Best regards,
Oblivion


Re: K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #55831 is a reply to message #55794] Fri, 18 December 2020 15:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks for investigating this. Do you think it would be possible to post here a complete set of changed files to fix X11?

Mirek
Re: K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #55833 is a reply to message #55831] Fri, 18 December 2020 18:12 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

I've attached the patch.

After further investigating, the problem turned out to be simpler to solve. The culprit seems to be decode().
When keysym is returned as default, it is truncated and the higher bytes were invalidated (filled with 0xff).

Changing this:

keysym = decode((int)event->xkey.keycode, 0xa, '1', 0xb, '2', 0xc, '3', 0xd, '4',
		                0xe, '5', 0xf, '6', 0x10, '7', 0x11, '8', 0x12, '9', 0x13, '0',
		                keysym);



to this, solved the problem:


	
keysym = decode((int)event->xkey.keycode,
		0x0a, 0x31,
		0x0b, 0x32,
		0x0c, 0x33,
		0x0d, 0x34,
		0x0e, 0x35,
		0x0f, 0x36,
		0x10, 0x37,
		0x11, 0x38,
		0x12, 0x39,
		0x13, 0x30, keysym);



Best regards,
Oblivion




[Updated on: Fri, 18 December 2020 19:09]

Report message to a moderator

Re: K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #55849 is a reply to message #55833] Tue, 22 December 2020 15:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thank you, patch applied.
Re: K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #56136 is a reply to message #55849] Sun, 31 January 2021 12:07 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Mirek,

I have further investigated the key handling on X!!, and found that numpad virtual keycodes are not propagated properly:

Here is the current situation:

- When Numlock is ON, the characters corresponing to the numpad keys (0-9, +-/*,) are dispatched. This is fine, nothing wrong here.

- However, when the same keys are pressed with CTRL or ALT modifier, they SHOULD send numpad keycodes, e.g, K_NUMPAD0-K_NUMPAD_9, and operators (K_ADD, K_SUBTRACT, etc.). This is the default behaviour of Upp on Windows and GTK (I don't have a Mac)

- But this is not happening on X11. Character codes are dispatched regardless of modifiers

So, I made a patch to remedy this problem. The patch, I believe, is at least a fix for some regression, if not an overall improvement in X11 key handling code.

Pleease review.


Best regards,
Oblivion


[Updated on: Sun, 31 January 2021 12:15]

Report message to a moderator

Re: K_CTRL_SEMICOLON and K_CTRL_PERIOD keys share the same constant value on Win32 [message #56192 is a reply to message #56136] Sun, 07 February 2021 10:25 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks, applied.

Mirek
Previous Topic: Problem with specific HW configuration
Next Topic: Ctrl Transparency, backpaint, ...
Goto Forum:
  


Current Time: Thu Mar 28 23:28:01 CET 2024

Total time taken to generate the page: 0.02199 seconds