By default, all the pointer events are absorbed by the mouse itself. I want to change this in such a way that all these events will be handled by mouse wheel(and not the mouse itself). For example:
pointerexited: when mouse wheel rotate and exit one button in uwp.
note: my final objective is to disable all other sources of pointer and just keep the mouse wheel.
Related
I am developing a 3D game with a custom chat console using Unity and UFPS,
https://assetstore.unity.com/packages/tools/game-toolkits/ufps-ultimate-fps-106748
Everything is working, but running on Android TV with a joystick, keyboard and mouse we want to control which input affects what.
So we want the dialog to only be able to interact with the mouse.
and the joystick to only interact with the game/player.
Original the mouse was controlling the players looking, and able to select the dialog.
I was able to disable the mouse from controlling the player by,
Unity menu, Edit, Project Settings, Input
Then finding the "Mouse X" and Mouse Y" input events and renaming the ones with the mouse input to "Mouse XX", and leaving the joystick axis events for "Mouse X" so the joystick can still control the players looking.
Now I am having the opposite issue, the joystick and the arrow keyboard keys are toggling the selection in the dialog, and the joystick button/space key trigger selection in the dialog. I want to disable this so only the mouse can interact with the dialog and the joystick on controls the player movement.
I tried changing the Input for "Horizontal" "Vertical" by renaming to "Horizontal xxx". This works, but then the joystick is also not controlling the player movement. So how can I make these separate events.
I cannot find any code listening to "Horizontal" or "Vertical" events, these seem to be hardwired in Unity some how??
If I am understanding you correctly, you want to disable all input other than a mouse click on UI elements. On the EventySystem object in your scene, select it and on the component EventSystem there is a toggle called Send Navigation Event. If you uncheck this box, it will disable all gamepad/keyboard interactions with UI and only allow mouse inputs to select UI.
Okay so there are plenty of samples for mouse global hooking.
My issue is how can I add a timer/delay for mouse movement.
What is the way of doing this? I thought maybe I should Thread.Sleep() on detecting WM_MOUSEMOVE ?
if (MouseMessages.WM_MOUSEMOVE == (MouseMessages)wParam)
{
Thread.Sleep(delay)
}
Thanks.
i'm afraid you cannot slow down the mouse movement in this way.
Here you are just notified of a new mouse position, the system doesn't care what you do with this notification and how long it takes to complete, or if it sleeps.
I suppose you should "record" the mouse position every "delay" time, and then every time a new WM_MOUSEMOVE event arrives (and the coordinates are different from the record ones), then you should "reset" the mouse cursor position to the saved coordinates.
of course, this until the WM_MOUSEMOVE arrives within "delay" time. Otherwise just record a new position and wait for the next event.
.NET have the Cursor.Position property that should allow you to move the mouse cursor where you want, other languages should have their analogous, but i've never tried it and i'm not sure it operates correctly in your "global" context.
anyway messing around with the cursor position is something that can make the user very upset
maybe you don't want to stop completely the cursor for "delay" time, maybe you want to linear interpolate the new position with the previous one with a <1 factor? this will slow down the mouse but with a smoother effect.
I am trying to zoom a custom usercontrol which contains a polygon, say paralellogram, which I created with the help of four points with X,Y coordinate but, when I try to zoom it on mouse move event, it stays at the same position and doesn't work out. Any suggestions ?
Is there a way to smooth out the mouse movements? I want to remove all the small jitter in normal mouse moving with the hand, like you can never draw a clean line in paint because of you hand doing small jittering movements.
This might be hard to understand what I mean, but if you know zbrush they have a feature that is called lazy mouse http://www.pixologic.com/docs/index.php/Lazy_Mouse im looking for a way to recreate this inside my app. I can read the mouse position with Cursor.Position but I don't find a way to average out these numbers before they get sent to the pointer on the screen.
This is only possible if you can delay the effect of the mouse movement slightly. You record the points of the mouse movement at a certain frequency and then average them out to a line. Then use that line to draw whatever you need. You wont be able to directly set the mouse cursor to the averaged position as that would then feedback into your program as a new mouse movement.
Make sure you build it so you can tweak how long you delay the mouse movement, and how aggressive the averaging is (say by restricting the number of points it includes), and the frequency at which you record mouse movements (this is could affect cpu usage if its too frequent).
You will of course have to create some sort of abstraction for the mouse in your application and create a way for the application to get hold of it. (I would be trying to keep this as similar as possible to normal winforms/wpf so I could revert the change and just use mouse movement directly if needed).
I need to freeze the windows mouse cursor on the screen, so it stays hovered over a specific UI element. While the mouse is in this frozen state, I would still like to be able to interact with the UI using a "fake" mouse pointer.
Currently, I've got a low level mouse hook that prevents WM_MOUSEMOVE messages from being passed along, effectively stopping all real mouse movement. However, when I don't pass along the updated coordinates, windows actually sends me the old coordinates in a separate WM_MOUSEMOVE message, as if to correct for the fact that the mouse didn't move.
Any idea on either how to prevent Windows from sending me these corrected coordinates, or another approach of how I can freeze the actual mouse curosr and still allow the physical mouse to control a "Fake" cursor?
You can suppress mouse cursor movement by using DirectInput exclusive mode.
You should acquire mouse input device when cursor movement must be suppressed. This will block windows cursor movement but you can get messages for your fake cursor using DirectInput API.
If you move the mouse cursor position in response to a WM_MOUSEMOVE message, to put the mouse back to where you want it, you will get another mouse move message because the mouse has been moved again (because you moved it). To stop this, don't set the mouse position if it is already in the right place.
You may also want to clip the mouse position to your window and get exclusive access to it.
Why don't you just draw an image of the cursor at the place you want it frozen, then set the real mouse cursor to be hidden (Cursor.Hide IIRC).
It's not clear to me what you are trying to do, perhaps making a tutorial for your app and you want to show mouse movements, etc. Perhaps this library will be useful:
http://www.codeproject.com/KB/system/globalmousekeyboardlib.aspx