XKBSET mousekeys is buggy - linux

So i run mousekeys using the same command every time:
xkbset ma 60 10 10 5 2
yet every time i strike / or -, mousekey's start glitching.
The glitch is:
when i use the numpad to move my mouse, instead of moving fluently, it starts to jump down. For example before i strike the / and - keys the numpad moves the mouse smoothly only several pixels at a time... when i strike any of those two keys, then the mouse pointer starts to move around 100 pixels.
Update
I now notice that when i have my universal access screen open, when i hit either of the two buttons, the mouse keys on/off switch turns to on. I feel as if this was the problem... is there a way to prevent that?

Related

How to keep mouse keys around

My platform is Linux, and there is a shortcut Alt + Left Shift + Num Lock to enable mouse keys TEMPORARILY. They say this feature is provided by X server, so it can be used on all desktop environments based on X. The problem is that the effect doesn't last long. The keypad will switch back to normal keypad automatically, and cannot be used to emulate a mouse. Therefore, whenever I want to move the cursor, the result may become scrolling to the bottom of the current document, which is annoying. Is there any way to prevent X from switching the keypad back to its original keypad function automatically? Thanks.

How to make horizontal scrolling one character at a time

Not sure if I'm wording the question right.
That's why I had a hard time finding the answer on google, like I usually do.
I have my vim set to never wrap lines. Keeps code cleaner.
But I don't like that if I'm moving the cursor across a line and get to the edge of the screen, the view jumps so that where I was at is now in the middle of the screen.
Is there a way to make it not do that? Like, so it just goes one character at a time
(or if I'm traveling by word, one word at a time, etc. Just so if I go the edge of the screen, the cursor stays at the edge of the screen, and the page moves inward under it)?
You could check out the 'sidescroll' setting:
'sidescroll' 'ss' number (default 0)
The minimal number of columns to scroll horizontally. Used only when
the 'wrap' option is off and the cursor is moved off of the screen.
When it is zero the cursor will be put in the middle of the screen.
When using a slow terminal set it to a large number or 0. When using
a fast terminal use a small number or 1. Not used for "zh" and "zl"
commands.

Xtst and usleep

I'm using the Xtst extentsion to type and do stuff using the mouse
I have not encoutnered any problems untill I started using xtst to move and click the mouse.
for example, here's a set of action:
move 359,216 & click (XTestFakeMotionEvent(display,-1,359,216,0);)
move 378,213 & click
move 376,391 & click
type amousa1990#gmail.com, adel_ahmed#something.com (the string is broken down into characters and then XTestFakeKeyEvent(display, keycode, True, 0); this code has been working fine for the past couple of months, til I started using mouse movements and clicks
move 438,727 & click
plenty of other clicks
what happens is all mouse movements work fine, the typing events are not sent/synced
unless I use usleep of:
100 before each letter typed
500 before each click
700000 before each mouse movements
mouse movement usleeps are slowing down the app severely
the code is as follows for mouse movement:
XFlush(display);
usleep(700000);
XTestFakeMotionEvent(display,-1,x_coordinate,y_coordinate,0);
XFlush(display);
XCloseDisplay(display);
should I keep the display open and use a pointer instead(I'm calling these functions within a function)
should I flush more/less often
thanks
I think keyboard Auto repeat settings in your desktop environment, may have an impact on the behaviour of the program

Three.js First Person Controls moves the camera all the time

The game I'm designing currently requires a first person controller and luckily Three.js offers that class as well.
However I can't stop the camera from flying around. I know that the mouse movement causes the fly because it happens as soon as I move the mouse. But reading the js code,I cant find the attribue which causes this movement. Here is how I initiate the controls:
controls = new THREE.FirstPersonControls(camera);
controls.movementSpeed = 0.1;
controls.lookSpeed = 0.001;
controls.lookVertical = true;
I do not want the view direction to change when I am not moving the mouse.
any idea ?
Keep in mind that the FPS style mouse movement in webGL is usable rather only in a full screen mode. If an application runs in a standard windowed mode, the cursor is visible, and the application can not detect cursor movements that cross the edge of the window. This makes it impossible to look around in the FPS style (look movement stops when the cursors reaches the window edge).
This is probably the main reason why a PointerLockControls demo asks you to switch to the full screen mode.
With FirstPersonControls the look movement continues when the mouse reaches the edge. Such approach works well in the windowed mode.
You might want to use the PointerLockControls instead
See an example here:
https://github.com/mrdoob/three.js/blob/master/examples/misc_controls_pointerlock.html

I need to draw a line moving with the cursor, but I want to avoid redrawing the whole window every 100ms

I have a program which displays a ruler on the screen, and with Xlib it polls for the cursor position every 100ms and updates the display. The display consists of numbers/lines etc, in particular a line indicating the position of the cursor (which is why it updates).
The problem is that the old line needs to be erased and the content underneath restored, so I have to redraw the whole window to reflect a change in position. Doing this 10 times a second results in a very flickery program.
I could only redraw the ruler after I have confirmed that the cursor is in a position to change the indicator line (i.e. within the bounds of the ruler), but it would still flicker pretty bad when it was updating.
Sort of a noob to GTK and Xlib and all, any advice would be appreciated.
Code is at https://github.com/zjmichen/zRuler
Well you have arrived at one of the earliest problems faced when cursors were being implemented!! Cursor changes are so frequent that redrawing full window every time just doesn't make any sense! Coming to your problem, look at what is needed & what exactly you are doing. Do you need to update the full window when cursor moves? No. You need to update only a section of the window so don't update the whole window. Off the top, I can think of 2 ways of reducing flicker:
1. Simple way is to make use of GdkCursor. Create a new cursor from the pixmap (Sample provided on the developer page) with the shape of your need, a line in your case. Associate cursor with the GdkWindow of your application's main window. This way you don't have to track cursor & draw the line. The cursor itself will appear as the line (so you don't to bother about clearing & redrawing it). Now in the timer callback where you redraw the complete window, redraw only the component which has to be updated on cursor position change. This should hopefully reduce the flicker as you are not drawing all the components.
2. In case you don't want to use GdkCursor, you could create a separate transparent window on top of application window dedicated to cursor. In this approach you can update only the cursor window & the component in the application window which is to updated on change in cursor position. This way other components in the application window are not redrawn each time & this hopefully should also be able to reduce flicker.
Hope this helps!

Resources