News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Mouse movement

Started by Farabi, July 15, 2009, 10:48:43 AM

Previous topic - Next topic

Farabi

Im making a mouse function, the task is I want to know if the value of X and Y are positive or negative and after it determined it the cursor reseted to the center of application, Its work, but when I set the cursor to the window center it keep give me a positive value. I am missing something?

.elseif uMsg==WM_MOUSEMOVE
mov eax,lParam
movzx edx,ax
mov MOUSE.x,edx
shr eax,16
movzx edx,ax
mov MOUSE.y,edx


invoke GetWindowRect,hWnd,addr r
invoke ClipCursor,addr r
invoke GetCursorPos,addr p
mov ecx,r.right
sub ecx,r.left
shr ecx,1
add ecx,r.left
mov px,ecx

mov ecx,r.bottom
sub ecx,r.top
shr ecx,1
add ecx,r.top
mov py,ecx

mov edx,px
cmp p.x,edx
jg no_need
fld rotY
fadd CFLT(0.1)
fstp rotY
invoke SetWindowText,hWnd,CADD("add")
jmp next_s
no_need:
fld rotY
fsub CFLT(0.1)
fstp rotY
invoke SetWindowText,hWnd,CADD("Sub")

next_s:

jmp next2
mov ecx,py
cmp p.y,ecx
jg @f
fld rotX
fadd CFLT(0.1)
fstp rotX
jmp next2
@@:
fld rotX
fsub CFLT(0.1)
fstp rotX
next2:

mov ecx,px
.if p.x!=ecx
invoke SetCursorPos,px,p.y
.endif
mov ecx,py
.if p.y!=ecx
invoke SetCursorPos,px,py
.endi .elseif uMsg==WM_MOUSEMOVE
mov eax,lParam
movzx edx,ax
mov MOUSE.x,edx
shr eax,16
movzx edx,ax
mov MOUSE.y,edx


invoke GetWindowRect,hWnd,addr r
invoke ClipCursor,addr r
invoke GetCursorPos,addr p
mov ecx,r.right
sub ecx,r.left
shr ecx,1
add ecx,r.left
mov px,ecx

mov ecx,r.bottom
sub ecx,r.top
shr ecx,1
add ecx,r.top
mov py,ecx

mov edx,px
cmp p.x,edx
jg no_need
fld rotY
fadd CFLT(0.1)
fstp rotY
invoke SetWindowText,hWnd,CADD("add")
jmp next_s
no_need:
fld rotY
fsub CFLT(0.1)
fstp rotY
invoke SetWindowText,hWnd,CADD("Sub")

next_s:

jmp next2
mov ecx,py
cmp p.y,ecx
jg @f
fld rotX
fadd CFLT(0.1)
fstp rotX
jmp next2
@@:
fld rotX
fsub CFLT(0.1)
fstp rotX
next2:

mov ecx,px
.if p.x!=ecx
invoke SetCursorPos,px,p.y
.endif
mov ecx,py
.if p.y!=ecx
invoke SetCursorPos,px,py
.endif
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ramguru

Of course it will give only positive values.
What do you expect :} you even prevent mouse cursor from moving outside client area (if I'm right .. with ClipCursor)
You'll get negative values only when you'll use SetCapture AND u r holding mouse button while moving AND mouse cursor is outside active window area

Farabi

Quote from: ramguru on July 15, 2009, 11:04:40 AM
Of course it will give only positive values.
What do you expect :} you even prevent mouse cursor from moving outside client area (if I'm right .. with ClipCursor)
You'll get negative values only when you'll use SetCapture AND u r holding mouse button while moving AND mouse cursor is outside active window area

No I mean, a less value than the center of the application, I called that a negativ value or a jmp less.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Nevermind, I found the mistake.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"