xlib, remove delay when holding down a key - x11

I've just created a simple demo in opengl that involves movement and rotation of the camera. The problem is in the controls. There is a delay between the first time and second time that the keypress is registered when I am holding down the key. After that there is no delay between the times the keypress is registered. I'm using XCheckMaskEvent() to get the keypress events (the function returns automatically if their are no events in the queue). It is exactly like the pause in a word processor when holding down a key like the "a" key. Does anyone know how to eliminate this pause?
My XCheckMaskEvent() function looks like:
XCheckMaskEvent(display, ExposureMask | KeyPressMask, &report);

'xset` can be used to set the rate and delay for repeating keypress events for a held-down key:
http://www.x.org/archive/current/doc/man/man1/xset.1.xhtml
Example here:
http://linuxforcynics.com/how-to/set-keyboard-repeat-delay-and-rate

Related

GTK4 under rust, trying to find which mouse pointer and whether there are modifer keys pressed

I'm writing a gtk4 application in rust, and I'd like to get the mouse key that was clicked and any modifier keys at the time. My GestureClick handler has .buttons(0) to accept input from all buttons, but the event object does not seem to have any way to determine the source of the event. The event just gives the GestureClick object, location, and click count. Does it need to have a separate handler for each button?
In addition, I'd like to use modifier keys like shift and ctrl to modify the action. This does not seem to be available (at least, I haven't been able to find it). Would I need to monitor keypress events to keep track of the state myself? I'm pretty sure X reports the state of the modifier keys on click events, gtk doesn't?
Thanks

vb6 win 10 keypress failure

I'm constructing a mouse centric form of cut and paste. the user points to an object with the mouse and types a single key to initiate an action. the Object being pointed to is in a picture box which is part of a form and keypreview is set to true for the form. Form_keypress is being used to trap the key being pressed. Pic_mousemove is tracking the mouse position.
but keypress is not reliably trapping the keys. control C works most of the time but not always. control L seems to work most of the time. control S list doesn't work at all. neither does control U.
I've tried moving to regular letters with no success. I've tried using keypress in the picture box; that didn't work either. The behavior is the same in the IDE and from the executable.
what's it take to get a reliable answer?

Globally identify last time modifier key was pressed

I have a bit of an odd question pertaining to Windows: is there any way to globally determine the last time that any key, or in particular, the modifier key (aka alt) was pressed without resorting to drivers or kernel-mode code?
Some background: I have registered a global shortcut (alt+`) and successfully run code when it is executed. Currently, I use some heuristics that are very much fallible to determine if the user is repeatedly pressing and releasing the backtick key while the alt key is consistently held down or if the user has pressed and released both since the last time my hotkey handler was called.
I wish to more-precisely ascertain whether or not the alt key has been released since the last time my handler was called. Being able to uniquely identify the time of the last alt keypress is an obvious solution. Another is somehow hooking on to each alt key press to record that info, which I do not believe is possible.
I'm open to all ideas and suggestions!
You can install a global low-level keyboard hook (by calling SetWindowsHookEx, passing a LowLevelKeyboardProc). This allows you to globally monitor the WM_KEYUP event for the VK_MENU, VK_LMENU and/or VK_RMENU key. Together with the timestamp recorded in the hotkey handler you can determine, whether the hotkey is part of the same Alt sequence or a new one: If the timestamp of the WM_KEYUP event is larger than previous hotkey input, the user started a new Alt+` sequence, otherwise it's a continuation of the same sequence.

Is it possible to detect when a cell becomes the active cell?

In Calc, I'd like to trigger an event when a specific cell becomes the active cell. I see no way to do that.
Here's the situation:
After entering a payment in a specific cell (say A5) and hitting enter, I'd like to programatically put the current time in the cell immediately below it (A6) - the new active cell. I'd like to detect leaving that cell (A6) or entering the cell below (A7) without modifying the contents of A6 or A7.
I want to use the elapsed time between the enter keystrokes to change the way the sheet reacts.
$10 (enter)
(immediate enter)
Signals that the transaction is over.
$10 (enter)
(wait a second)
(enter)
Signals the transaction isn't over.
The time difference between the double enter keystrokes determines what happens next.
This spreadsheet has 6600 lines of macro code that makes it function, and I'm already relying heavily on event handling, but it only works on a modified cell. In this case, I'm not modifying A6 or A7, but I want to trigger an event that lets me know they have become the active cells.
There is an example of a Calc selection changed event handler here:
http://www.pitonyak.org/OOME_3_0.odt
For example, search for "Start listening for selection change events."
I would expect this to do what you want. That said, I consider listeners fragile.

X11: Removing event from queue

I'm creating an FPS demo using an Engine called: Gameplay. I'm currently trying to define a captureMouse() function into the engine so the player can look around the map. I've already been able to pin the cursor to the center of the window and turn it invisible, but as I move the mouse the screen (camera) seems to "vibrate" as it moves around. After a lot of tinkering with X11 functions I figured that the XWarpPointer() function I'm using to warp the cursor back to the center of the window is adding a "mouse moved" event to the event queue.
X11 Question: How can I identify and remove an event from the event queue before it is captured by the event cycle?
Question: Has anyone been a similar problem and solved in a different manner? If so, what did you do?
I'm sorry if I'm not being clear. I have no extensive knowledge of X11, but I really need to add this to the engine so I can, in turn, add it to my game.
I guess you're using XtAppMainLoop to handle your events.
This is actually a call to XtAppNextEvent followed by XtDispatchEvent.
If you replace the XtAppMainLoop with a loop calling XtAppNextEvent to get the next event and check its type (the type field of the XEvent structure).
If you want to handle the event call XtDispatchEvent, do nothing to ignore it.
The loop needs to exit when XtAppGetExitFlag returns true (or add your own exit flag).

Resources