Hacker News new | past | comments | ask | show | jobs | submit | more EsportToys's comments login

Thank you! Another applet I made that I personally think is neat, although I see why it's not something many would care about, is the MouseTray[0] utility that gives me a quick "volume popup" but for mouse cursor speeds, it makes it quite easy for me to switch between using a mouse normally and drawing precisely without needing to reaching for my tablet.

Although it didn't get as much attention as my other utility, it's actually the app that I'm most happy about having made.

[0] https://github.com/esporttoys/mousetray


Thanks! It was actually inspired by rvaiya's warpd [0] which has a similar grid mode but with quadrants instead.

I thought that needing to choose out of four quadrants at once is a bit overwhelming on cognitive load for something that is meant to be a subconscious extension of your hands, so instead I just unified it with the arrow keys as a "shrink in this direction" choice rather than "choose one of four quadrants".

Changing it to bisection/binary partitioning also means that don't need any visual aids as it's exceedingly simple to see which edge your target is the closest to.

[0] https://github.com/rvaiya/warpd


Hi! Thanks for building so many useful utilities!

I tried your TPMouse a few months ago, but had two problems:

1. I couldn't figure out how to remap F/E/R in grid mode to, e.g., A/S/D (left/middle/right). I tried editing the code but didn't get anywhere.

2. CapsLk G/Q didn't work for on my PC and the longer shortcuts were a bit too inconvenient for me.

Would you consider adding a brief document about customizing TPMouse to you repo?


I'm actually in the process of reworking it so that the keybinds can be fully remapped via a GUI. In fact, LibreScroll is my first step experimenting with multi-process delegation that will enable that functionality, since the current way of having to edit the code directly in scattered locations is very much not ergonomic.

In the meantime, for the current version of TPMouse on the dev branch, to change the remapping of arrows and mouse buttons, you need to edit `keybinds.au3` in three spots:

1. the virtual-key constant at the static array at the top

2. the hotkey string at the static array at the top

3. (this is really poor UX I know) in the static struct declaration inside the respective callback function, change the referenced virtual-key constant.

The list of virtual key codes can be found in `vkeys.au3`:

https://github.com/EsportToys/TPMouse/blob/dev/vkeys.au3

So for example, to remap mouse1 from F to A, I need to do the following:

Line 10:

    <<< before >>>
           $mb1    = [ $VK_F     , '{f}'     , callback_f     ] , _

    <<< after >>>
           $mb1    = [ $VK_A     , '{a}'     , callback_f     ] , _
Lin 68:

    <<< before >>>
     Local Static $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;'), $vkey = DllStructSetData($struct,'VKey',$VK_F)

    <<< after >>>
     Local Static $struct = DllStructCreate('ushort MakeCode;ushort Flags;ushort VKey;'), $vkey = DllStructSetData($struct,'VKey',$VK_A)

As for changing the activation hotkeys, if you wish to use a different modifier other than CapsLk, change the vkey code on line 74, 90, and line 107 of TPMouse.au3; for example, to change it from CapsLk to Alt:

Line 74:

    <<< before >>>
       Case $VK_CAPS

    <<< after >>>
       Case $VK_ALT
Line 90:

    <<< before >>>
               If $VK_Q = $struct.VKey And Not ( $sks($VK_CAPS) Or ($sks($VK_LSHIFT) And $sks($VK_RSHIFT)) ) Then Return

    <<< after >>>
               If $VK_Q = $struct.VKey And Not ( $sks($VK_ALT) Or ($sks($VK_LSHIFT) And $sks($VK_RSHIFT)) ) Then Return
Line 107:

    <<< before >>>
               If $sks($VK_CAPS) Or ($sks($VK_LSHIFT) And $sks($VK_RSHIFT)) Then

    <<< after >>> 
               If $sks($VK_ALT) Or ($sks($VK_LSHIFT) And $sks($VK_RSHIFT)) Then


Thanks for the explanation! I got it working!

One last feature request: currently, the grid mode doesn't seem to support multiple monitors, i.e., it only splits the screen where the mouse pointer is. Would that be possible to add a "teleport" feature? For example, pressing CTRL-J would teleport the mouse pointer, say, 75% of the screen's resolution to the left. If there are two monitors, the pointer would be moved to the screen on the left in at most two teleports. If there is only one monitor, then it would move the pointer close to its left edge. (There would be similar "teleports" for CTRL-I, CTRL-K, and CTRL-L to support different display set-ups.) In theory, this can be accomplished by switching to the inertia mode, but that's not very convenient. I would contribute some code myself if TPMouse were written in Python, but I can't help with .au3 :/

Thanks for again for the explanation and being so receptive!


I'm curious about what you think of Hold mode vs Flick mode? I personally use Flick mode myself but thought that it might confuse the user on first-impression, so I have it default to Hold mode to be on the safe side.


Thank you for the kind words! I’ve never used Linux before, I wonder if it will work well with Wine since this script only uses very old WinAPIs, namely SendInput+RawInput+ClipCursor, and native win32 controls/tray, I would imagine that wine would have pretty good coverage of them.


So what you’re saying is, TCP is better than UDP?


I highly recommend anything in Finite Element Methods, it gives you an immediate grounding to a concrete application. I personally really benefitted a lot in the following YouTube lecture series:

https://www.math.colostate.edu/~bangerth/videos.html


Fun fact: this is only valid for domains that have a notion of "selfness", i.e. that there is such thing as an "identity matrix" for the quantities.

Consider the following square matrix:

            TSLA APPL GOOG MSFT    
    Alice | 100   5     0    1
    Bob   |  0    30   100   5
    Carol |  2    2     2    2
    Dan   |  0    0     0  1000
An input vector of stock prices gives an output vector of net worths. However, that is about the only way you can use this matrix. You cannot transform the table arbitrarily and still have it make sense, such as applying a rotation matrix -- it is nonsensical to speak of a rotation from Tesla-coordinates to Google-coordinates. The input and output vectors lacks tensor transformation symmmetries, so they are not tensors.

This is also why Principal Component Analysis and other data science notions in the same vein are pseudoscience (unless you evaluate the logarithm of the quantities, but nobody seems to recognize the significance of unit dimensions and multiplicative vs additive quantities)


There's a little more nuance:

1. Technically, the table you shared is better thought of as a two-dimensional tensor, rather than a "graph-like matrix" -- which as you point out must be a linear map from a (vector) space to itself.

2. While not technically "Principal Component Analysis", one could do "Singular Value Decomposition" for an arbitrarily shaped 2-tensor. Further, there are other decomposition schemes that make sense for more generic tensors.

3. (Rotations / linear combinations in such spaces) Given a table of stock holdings, it can be sensible to talk about linear combinations / rotations etc. Eg: The "singular vectors" in this space could give you a decomposition in terms of companies held simultaneously by people (eg: SAAS, energy sector, semiconductors, entertainment, etc). Likewise, singular vectors on the other side would tell you the typical holding patterns among people (and clustering people by those, eg. retired pensioner invested for steady income stream, young professional investing for long-term capital growth, etc). As it turns out, this kind of approximate (low-rank) factorization is at the heart of recommender systems.


Yeah, this is also the case if the table is not square as the values can't represent edges any more. So its more something like the rows and columns should index the same "thing".

By the way by changing the graph representation we can give meaning even to non square matrices as described in this article https://www.math3ma.com/blog/matrices-probability-graphs


I think the most common application is describing mesh connectivity in Finite Element Methods, where each entry in the matrix represents the influence each node has on each other. Basically any N^2 table can be constructed to describe the general dependency of components in any simulation or systems in genera.


Another notable example is the PageRank algorithm [0] where you consider the graph where nodes are web pages and edges are links between them and you can build an adjacency matrix of this graph and with this algorithm sort the pages based "popularity" (which pages have more links pointing to them intuitively)

Let's say that in most cases you have a graph and you consider the corresponding matrix. Doing the inverse is not as useful in practice except in some cases as explained in the article.

[0]: https://en.wikipedia.org/wiki/PageRank


You make a good point about types of matrices that a graph representation makes sense with but it seems a bit much to say that PCA is pseudoscience?

If you had a lot of people and a lot of stocks, a low-rank representation of the matrix (probably not PCA per se with that particular matrix, but something closely related) could convey a lot of information about, e.g., submarkets and how they're valuated together. Or not, depending on how those prices covary over time.


I disagree... there are more ways you can use this matrix to creatively extract information out of it.

For instance, you can normalize along the columns, and build a "recommender system" using matrix factorization.

With that, when a new person comes with a portfolio, the system will output a probability for this new person to acquire the other assets he doesn't have.

It's (the very basic) idea of how Netflix recommends movies.


When I try to get this point across about techniques like the PCA, I like to show that the measurement units strongly affect the inference.

Really, if your conclusions change depending on whether you measure in inches or centimeters, there’s something wrong with the analysis!


I would disagree and here is why:

> When I try to get this point across about techniques like the PCA, I like to show that the measurement units strongly affect the inference.

In such a case the problem is not with PCA but with application. PCA is just a rotation of the original coordinate system that projects the data on new axes which are aligned with the directions of highest variability. It is not the job of PCA to parse out the origin of that variability (is it because of different units, or different effects).

> Really, if your conclusions change depending on whether you measure in inches or centimeters, there’s something wrong with the analysis!

To get a statistical distance one should: subtract the mean if the measurements differ in origin; divide by standard deviation if the measurements differ in scale; rotate (or equivalently compute Mahalanobis distance) if the measurements are dependant (co-vary). The PCA itself is closely related to Mahalanobis distance: Euclidian distance on PCA-transformed data should be equivalent to Mahalanobis distance on the original data. So, saying that something is wrong with PCA because it doesn't take units of measurement into account is close to saying that something is wrong with dividing by standard deviation because it doesn't subtract the mean.


Is the effect of measurement units eliminated by applying something like zero mean unit variance normalization prior to dimensionality reduction?


I dunno, there are some semi-useful things you can do.

For example, the transform from (Alive, Bob, Carol, Dan) to (Male, Female) is linear -- it's another matrix that you can compose with the individual-ownership one you have here.

Or, call your individual-ownership matrix A, and say that P is the covariance of daily changes to prices of the four stocks listed. Then A P A' is the covariance of daily changes to the peoples' wealths. The framing as linear algebra hasn't been useless.

I kinda get what you're saying though. Like, why would powers of this matrix be useful? It only makes sense if there's some implicit transform between prices and people, or vice versa, that happens to be an identity matrix.

You can make up a story. Say the people can borrow on margin some fraction of their wealth. Then say that they use that borrowing to buy stock, and that that borrowing affects prices. Composing all these transforms, you could get from price to price, and then ask what the dynamics are as the function is iterated.

But, ok, "I'm just going to do an SVD of the matrix and put it in a slide" isn't going to tell anybody much.

Maybe there's a use for a rank-one approximation to this system? Like, "this is pretty close to a situation where there's a single ETF with those stocks in these proportions, and where the people own the following numbers of shares in the ETF"? Maybe if you have millions of people and millions of stocks and wanted to simulate this "stock market" at 100Hz on a TI-83?

I dunno. You can make up stories.


Is there any domain where you can apply arbitrary transformations on a table and still make sense? I feel there is some depth in your argument that I cannot infer just by the content of your comment and I would be keen to look further into it. I.e in you domain example, a currency would be coordinate and you can move to alternate currencies? Would that be the identity you look for?


looks like Manim.


I had written a Windows script for adding three-finger drag[0] that I use daily, perhaps it could provide some inspiration.

Basically, it is an independent subscriber to RawInput messages that only keeps track of whether or not to send three-finger drag, and posts emulated mouse messages using SendInput. I have a few other scripts that each run as independent userland processes that only monitors their own trigger and nothing else.

Tangentially, my TPMouse[1] script implemented inertia in a framerate-independent way so that it uses very little resource while having perfect simulation stability.

A previous discussion where I explained the analytic derivation for this low-resource exact-solution damped inertia can be seen in [10]

[0] https://github.com/EsportToys/PrecisionThreeFingerDrag/blob/...

[1] https://github.com/EsportToys/TPMouse

[10] https://old.reddit.com/r/Trackballs/comments/ym9q2t/tpmouse_...


Fun fact: every videogame on Windows is potentially a userspace keylogger if you let it run in the background while, e.g. browsing the web etc.

Basically, any application that uses the Raw Input API can request to receive raw device events even when the application is not running in the foreground, by using the RIDEV_INPUTSINK flag.

The app will then receive every raw device input packet that the hardware sends to the system, replete with timestamps[0] and your mouse position when the event happened[1].

In the case of keyboards it would provide the virtuak-key codes and scancodes[10].

Rawinput is used by modern FPS game like Valorant[11], so if you leave it running in the background it may potentially be able to observe your every single keystroke while you use your browser, enter passwords, etc.

TPMouse, my opensource trackball-emulation script that lets you use the homerow as a trackball for your cursor[100], uses Raw Input with the RIDEV_INPUTSINK option so that it runs entirely in userspace without needing to hook to low level drivers.

It is certainly a double-edged sword -- for open source it's a convenience blessing since what you're running can be inspected directly, but in the case of close-sourced games like Valorant you're relying on your trust of Riot Games's intentions and competence.

[0] https://learn.microsoft.com/en-us/windows/win32/api/winuser/...

[1] https://learn.microsoft.com/en-us/windows/win32/api/winuser/...

[10] https://learn.microsoft.com/en-us/windows/win32/api/winuser/...

[11] https://playvalorant.com/en-gb/news/game-updates/valorant-pa...

[100] https://github.com/EsportToys/TPMouse


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: