add support for "pixel-perfect" scrolling

This commit is contained in:
Unrud 2018-07-31 20:19:10 +02:00
parent 209eaf960d
commit c1509ac8fa
6 changed files with 57 additions and 19 deletions

View file

@ -44,7 +44,7 @@ const (
mouseeventfWheel uint32 = 0x800
mouseeventfHwheel uint32 = 0x1000
wheelDelta int = 120
scrollMult int = 6
)
type mouseInput struct {
@ -146,20 +146,20 @@ func (p *windowsPlugin) PointerMove(deltaX, deltaY int) error {
return nil
}
func (p *windowsPlugin) PointerScroll(stepsHorizontal, stepsVertical int) error {
func (p *windowsPlugin) PointerScroll(deltaHorizontal, deltaVertical int) error {
inputs := make([]mouseInput, 0, 2)
if stepsHorizontal != 0 {
if deltaHorizontal != 0 {
inputs = append(inputs, mouseInput{
typ: inputMouse,
dwFlags: mouseeventfHwheel,
mouseData: uint32(stepsHorizontal * wheelDelta),
mouseData: uint32(deltaHorizontal * scrollMult),
})
}
if stepsVertical != 0 {
if deltaVertical != 0 {
inputs = append(inputs, mouseInput{
typ: inputMouse,
dwFlags: mouseeventfWheel,
mouseData: uint32(stepsVertical * wheelDelta),
mouseData: uint32(deltaVertical * scrollMult),
})
}
if len(inputs) == 0 {
@ -172,3 +172,7 @@ func (p *windowsPlugin) PointerScroll(stepsHorizontal, stepsVertical int) error
}
return nil
}
func (p *windowsPlugin) PointerScrollFinish() error {
return nil
}