As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label mouse. Show all posts

I was really bored and somehow I decided to make a heatmap out of X cursor position in terminal. The following image shows the result and here is a video:

https://lh6.googleusercontent.com/-Iqlh5J3Relc/UmJgkhY9XQI/AAAAAAAAFQ4/fUdM-1pGQo4/s800/xcinfo-heatmap.png

This is just for fun, nothing really useful. The X cursor position is translated into terminal window space, then heating up and the heat would also cool down as time goes by. The heat scale is the rainbow hues, which I roughly calculated into 256 terminal colors.

If you are interested in xcinfo, it might be useful if you need to script with X cursor infomation. I had not touched the code more than a year ago until now.

xcinfo is a utilization I use for bzen2, it was hosted on GitHub alongside my dotfiles. Because of this one-liner, I decided to move it to its own repository and expand it with a few examples.

That one-liner snaps a screenshot after detecting mouse movements. I like this idea, though it has no use for me. I think its more or less for security measure. The method it uses is to read the device file of X pointer, it has pros but also the cons. I decided to write an alternative using xcinfo, which becomes an example of xcinfo.

I am sure some of you who write shell scripts has hard time to get X cursor information, mainly the X and Y position. I was not aware of any handy program for getting those two numbers. Thats why I wrote that little C code in the first place last year.

The information which xcinfo provides should cover most of your usage, the cursor position and screen size. If you need more, open a feature request issue, I will see what I can do about. A pull request, that would be even better.

By the way, I have also worked on a fun example, you can also read the examples section on project website.

It always is a wonderful experience when you witness an evolution. Since the invention of typewriter, only low-skilled users would require 10 fingers to operate on a keyboard. Until today, it remains perfectly true.

As technology progresses, computer entered our daily life and has been dominating every corner in the entire world since then. At the beginning of commercial computing, only the people like secretaries, data entry, or code monkeys would require having no skill of the 10-finger typing whilst bosses only use 1 finger or 2 fingers to type in.

Using 1 finger or 2 fingers are the hardest way to type, because, firstly, you need to clear the field. You need a clear view of keyboard, so you can locate the key you are about to press. Imagining that there are around 100 keys on the board, you need to spot them as fast as you can. And for aged keyboard, the printing would have worn out, you may have to guess which one is correct key, this only demonstrate how skillful of 1-or-2-finger typer is.

After a desired key is spotted, the typer's motor skill kicks in, he or she presses the key with quick and precise press, then immediately retreats from the keyboard.

At this moment, the task hasn't been completed, far from it. The typer must change the focus from keyboard to monitor, the typer's eyes have to adapt such dramatic change in a short time. Seeking for the new typed letter on the screen where the cursor at which typer has to remember before typing.

Once confirmed, then repeat the process. As you can see, 1-or-2-finger is more skillful than 10-finger typer, who only stares at the screen all the time and type like nothing, there is no skill in them.

After the mouse device invented, till today, it's basically a three-button pointer device. Some 1-or-2-finger typers evolve into more skillful, then now may only use only one hand to control the whole computer, which is the same hand control the mouse.

Using a mouse is even harder then typing. The main goal is to find the Next button on the screen, which isn't always on the screen or it could be hard to be seen. Often times, the mouse users have to combine different types of controlling skills, suck as double-click, right-click, drag-and-drop, etc. On keyboard, it's only one, press.

Later, the mobile devices has become more important for one's life. Screen gets smaller as well as the keyboard, physical or virtual, the typer's skill is forced to evolve once more.

Then, the groundbreaking device was invented, the mighty iPhone and later iPad. Typer is no longer a typer, but a toucher. With only one finger to operate, as you can guess, it requires smarter people to use such devices. They have to learn new gestures in order to operate, such as slide. Fortunately, multi-touch is added later for people less skilled, who used to 10-finger typing.

Not only the devices evolve, but also the web. Less than a year ago, Google began a process to unify its products' designs starting with its navigation bar, Gmail, Google Groups, Google Reader, and more has already adopted. Things got bigger, such as buttons, that's good for toucher to touch. The looks is more like designs on *pad, like a millions of websites have already imitated *pad design. A more recent example is the Google+: Toward a simpler, more beautiful Google.

Google was wrong about it, it never was simpler. Such design requires users' long-trained skills. For users who have trained themselves from 10-finger typing to 1-finger touching, then it is simpler. But for newcomers, it requires a long period of training. Unfortunately, for less skilled 10-finger typer, the old aged and stubborned users who just won't die, but there is no resolution for them.

In foreseeable future, human may no longer need any fingers to operate a computer. However, it requires more skillful person to operate without a finger as it already is proved with decades of computing history as described above.

https://i.ytimg.com/vi/jorqvmbgFaA/maxresdefault.jpg

A quick update on x11grabr. Now the mouse click has been rendered in different shape and colors. Everything is still fixed in code.

Another not quite related thing about x11grabr is I am currently using it to stream and it works normally. However, I know it would have problem if audio stream is included. I am 99.999% sure it will be out of sync. Right now, I dont have audio streamed.

I still dont know how I should deal with this. I might ask on mailing list later. One resolution is to grab audio in x11grabr, but I will need to learn container and also how to combine video and audio.

https://i.ytimg.com/vi/zOYb6iyXqs8/maxresdefault.jpg

I have wanted x11grab to be able to do things like recordMyDesktop and it does even better, because the mouse following in recordMyDesktop somewhat annoying when you watch the video you just make. The grabbing region moves as your mouse moves, which can give viewers headaches.

I did try to submit a patch to FFmpeg about a week ago when I first finished with little success, but I didnt get any response. So I decided to just fork it and do whatever I like. I can maintain my own copy since x11grab.c is pretty independent from other parts of FFmpeg.

Its so strange, when I searched for this mouse feature but I never read someone talked about. It looks as if everyone accepts that FFmpegs x11grab should have nothing to do with your mouse. I just dont get it, why didnt anyone wants that?

The funny unrelated thing I found during searching is some people even try to use xwininfo to get the window region, so they can supply to FFmpeg to grab that region. Thats so bad because most likely the video size isnt going to be a standard video size. It 99.999% would be something like 987x836, even you does a conversion to standard video size, its still bad because you does another encoding and resize/rescale with ratio remained your video.

Screencast is better not to be resized, in my opinion, pixel-to-pixel is the best.

Its sad that recordMyDesktop (rMD) seems like a dead project, no more commits. I see some people submitted patches and they would not be applied in anyway. I had thought about to send a email to the admin, but didnt do it.

With my own patch to x11grab, FFmpeg does better. I can output any kind of format I want. With rMD, you have only one format, which sometimes I have problem with.

Aside from this, I want to mention about forking on GitHub. I begin to like it, I forked a few projects and did my own changes to those projects. I didnt try to send a pull requests because I dont care and I dont want to wait for a reaction. I just maintain my own fork.

On GitHub, the Network tab is very useful, I can see what commits I dont have. I wish other hosting services [whispering Google] can have same Network tab. I dont particularly like Git, but I learned a few things since I started to fork and there is a plenty a lot about Git to learn. I never learned how to use CVS, but SVN is so easy to learn; same goes to Git vs. Hg, Git so complicated, so many commands and options, but now its changed.

I recently found out you can use xinput to enable or disable an input device. I used to use synclient to disable my touchpad, or using this tricky way to disable my laptop keyboard.

The first step to get device name or id of the device:

% xinput list
 Virtual core pointer                          id=2    [master pointer  (3)]
    Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
    USB Optical Mouse                         id=8    [slave  pointer  (2)]
    SynPS/2 Synaptics TouchPad                id=7    [slave  pointer  (2)]
 Virtual core keyboard                         id=3    [master keyboard (2)]
     Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
     Sleep Button                              id=9    [slave  keyboard (3)]
     Power Button                              id=10   [slave  keyboard (3)]
     Video Bus                                 id=11   [slave  keyboard (3)]
     AT Translated Set 2 keyboard              id=6    [slave  keyboard (3)]

For touchpad, the device name is 'SynPS/2 Synaptics TouchPad' and id is 7; for keyboard, they are 'AT Translated Set 2 keyboard' and 6. Next step is to know the properties of a device:

% xinput list-props 'AT Translated Set 2 keyboard'
Device 'AT Translated Set 2 keyboard':
        Device Enabled (127):   1

This keyboard only has a property 'Device Enabled' whose value is 1, that means this keyboard is enabled. To test disabling:

sleep 0.1 ; xinput set-prop 'AT Translated Set 2 keyboard' 'Device Enabled' 0 ; sleep 5 ; xinput set-prop 'AT Translated Set 2 keyboard' 'Device Enabled' 1

The first sleep 0.1 is to prevent enter keypress being repeatedly sent somehow when you directly disable the keyboard, I am guessing when you hit the enter and the command is executed, meaning the keyboard is disabled, but the keyup event is not yet sent, so X still thinks the enter key is pressed down.

Another simple way is to use id, so you dont need long device name:

sleep 0.1 ; xinput set-prop 8 127 0 ; sleep 5 ; xinput set-prop 8 127 1

8 is id of this keyboard and 127 is the property id of 'Device Enabled'. When you list properties of device using list-props, the numbers after property names are the property ids. It seems that 'Device Enabled' always has id 127, but device id is not always the same. It depends on device attached time, who shows up first who gets next available id.

One more thing to note: I dont need root privilege to set property value.

For a long time, if I recall correctly, mouse clicks are not registered in Flash's setting dialog since Adobe released the 64-bit version.

I recently cleaned up all cookies, GrooveShark asked to lift the cache size. I was unable to give it that permission because Flash doesn't want my clicks. If you press Tab key, you will see a yellow box moving around but no keys is able to do the same as a mouse click.

I finally found the resolution. In this web interface, I was able to give GrooveShark what it needs:

flash settings

Note: The Settings Manager that you see above is an image; it is not the actual Settings Manager. Click the tabs will not see different panels, and click the options in the panels will not change your Adobe Flash Player settings.

Since I started to use Firefox, there is one thing that kept bothering me. When you click with mouses middle button on empty places, Firefox will try to open it as a URL. It seems to be very convienient when you copy a URL somewhere else, then you switch back to Firefox and press middle button. However, that is really rather used. Most of time, just Address Not Found.

So, open about:config, type middlemouse.contentLoadURL, then set it to false.