I spent some time trying to work out the math myself, but as usual there is already a node for this, just wanted to share so it’s easier to find for future searchers:
article with a little more info:
Code, namely the Get Last Movement Input Vector node: