Original Post
🔒 Locked
snap-to mouse
Advertisement
Ok, never done this, but I think you could do something like this.
1. Check if the mousepointer is in the area
2. Calc which pixels are to be snapped to.
3. Move mousepointer to nearest snappable pixel
I don''t think it can be much harder. The hardets part should be to calc which pixels to snap to. But should not prove to be very hard either.
Hope it helps
1. Check if the mousepointer is in the area
2. Calc which pixels are to be snapped to.
3. Move mousepointer to nearest snappable pixel
I don''t think it can be much harder. The hardets part should be to calc which pixels to snap to. But should not prove to be very hard either.
Hope it helps
To retrieve mouse data, use DirectInput (naturally). The SDK docs have the tutorial that explains how to set up DI and how to get both immediate and buffered data from it, as well as their format.
To draw the cursor, you need a cursor image and the ''hotspot''. Hotspot is the position within the cursor image that should coincide with the current mouse position. For example, hotspot for the standard arrow cursor is somethere close to its top-left corner, and the hotspot of a crosshair cursor is in its center. Once you know the current mouse coordinate and the hotspot coordinates, calculate the position at which the cursor bitmap starts so that its hotspot coincides with the cursor position and draw it there. You can use a textured quad, for example.
Note that since DirectInput works directly with hardware, it doesn''t know what "screen" is. Therefore it''s your job to constrain mouse cursor to screen. You can use a simple point-rect test.
To draw the cursor, you need a cursor image and the ''hotspot''. Hotspot is the position within the cursor image that should coincide with the current mouse position. For example, hotspot for the standard arrow cursor is somethere close to its top-left corner, and the hotspot of a crosshair cursor is in its center. Once you know the current mouse coordinate and the hotspot coordinates, calculate the position at which the cursor bitmap starts so that its hotspot coincides with the cursor position and draw it there. You can use a textured quad, for example.
Note that since DirectInput works directly with hardware, it doesn''t know what "screen" is. Therefore it''s your job to constrain mouse cursor to screen. You can use a simple point-rect test.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement