termux / termux-x11

Termux X11 add-on application.
https://termux.dev
GNU General Public License v3.0
2.09k stars 312 forks source link

Mouse capture #223

Closed IntinteDAO closed 1 year ago

IntinteDAO commented 1 year ago

This is probably impossible, but I prefer to ask myself.

The idea is to capture all mouse events so that, for example, you can play FPS on Termux X11 in the future.

1) On Android 4.4 (required Root) the QIII4A engine supported such an option officially, but I don't think it works with newer Androids.

2) It seems to me that partly similar functionality is present in the XServer XSDL (with me at least) and this can be seen in Motorola Ready Now (it is worth confirming if it works in DeX and globally), when there is a window with information about the connection to the XServer the mouse cursor does not appear and the XServer itself "blocks" the Android mouse. If it's not a bug or anything, maybe it's possible to write Termux X11 in such a way that the cursor in Termux X11 can move, but that Android thinks it's not moving or something similar.

twaik commented 1 year ago

On Android 4.4 (required Root) the QIII4A engine supported such an option officially, but I don't think it works with newer Androids.

As far as I know we can make libinput with disabled udev do that, but it will require adb/root client. It is already in TODO list, next to hardware keyboard capturer.

It seems to me that partly similar functionality is present in the XServer XSDL

It is possible to do that without root, but it can possibly break Dex mode. I am not sure if I will do that. But I possibly will find out if it works...

shiumano commented 1 year ago

It would be good if we could capture the mouse as in the already created games that support mouse control (Minecraft Bedrock Edition and osu!lazer). Also, if we could send mouse movements directly to the Linux system, we might be able to obliterate mouse acceleration in the Android OS...

twaik commented 1 year ago

Fixed by https://github.com/termux/termux-x11/commit/ee2224e474ce0c184de7a2c9c454c658f8afe249.

nakele commented 1 year ago

@twaik First, thank you for implementing Pointer lock or mouse capture, it seems to capture the mouse while using Samsung Dex.

I noticed that Firefox or Dosbox-x (the only 2 I've tested) dont behave correctly when the mouse is captured. It still behaves as if the mouse is not captured. Are my expectations wrong? Is there something missing that I dont understand or I maybe I dont understand how it works.

I can see the mouse has been captured by the Termux:X11 App (window) > I open Firefox > Go to website to test mouse capture at https://mdn.github.io/dom-examples/pointer-lock/ but I see that the "red ball" in the demo page goes crazy.

Expected result should be: move mouse left> ball goes left, move mouse up> ball goes up. What I see: move mouse>ball goes the distance of "the invisible mouse position" and the center of the screen/window.

It seems that the mouse pointer, upon capturing, it's not kept in the middle of the screen.

twaik commented 1 year ago

termux-x11 receives absolute pointer coordinates even in the case of touchpad mode so it always looks like pointer can not be locked. I'll check what I can do.

kde-yyds commented 1 year ago

is it possible to implement this?

twaik commented 1 year ago

Maybe

twaik commented 1 year ago

Fixed by https://github.com/termux/termux-x11/commit/d8b965a9b859ab9f6db8b1e4e2aed42ea5addd6b

nakele commented 1 year ago

Tested briefly in browser and it works. Great thank you.