flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > Mouse events?

Author
Thread Post new topic Reply to topic
jason



Joined: 30 Nov 2003
Posts: 8
Location: germany
jason
I currently try to write a mouse event system for an application.
Has anyone experiences with mouse events yet? Is the mouse change event implemented by the OS and currently working?

I know, You have to set an extra bit to tell the OS to receive mouse change events. I have done this already.
But it don't seem to work, because I get no event notification from the OS on mouse change inside the "WaitForEvents" [syscall 10] loop with this (missing the exact access code in the documentations) ...

So the other variant would be to call "GetMousePosition" [syscall 37] each time needed, but I think it would be much better to receive an event by the OS to be informed, when anything with the mouse has changed...

I could not find an example app, which demonstrates the mouse change event, all seems to be sys-button event based...

Can anyone help?
Post 01 Dec 2003, 17:17
View user's profile Send private message Reply with quote
Mike Hibbett



Joined: 02 Sep 2003
Posts: 88
Location: UK
Mike Hibbett
there are several examples - icon.asm would be a good start. this is the program that displays the icons on the desktop, and takes action when the mouse is clicked over the icon. also Iconedit, the source for which is zipped up using mhc.

Several games - connect4, minesweeper, memory also use mouse events.

Cheers,

Mike
Post 01 Dec 2003, 17:44
View user's profile Send private message AIM Address Reply with quote
Den



Joined: 27 Nov 2003
Posts: 16
Location: Canada
Den
Hi,

I'm reading EXAMPLE2.ASM (and DIALOGS1.INC) right now and it contains some mouse event handling (eg. clicking on menu or dialog box). It's written unclearly in my opinion but it may help.

Den
Post 01 Dec 2003, 18:17
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
jason



Joined: 30 Nov 2003
Posts: 8
Location: germany
jason
Thank You all.
This is nice by You.

But the problem with all this examples is definitively, that You have to check the mouse manually each time the event loop is called -> tends to overhead.
As far as I can see, all those examples use this mechanism...

This is not performance saving and also generally not very clever.

Because the mouse event should be raised merely, if the mouse has in fact changed its state. This is much more efficient for some reasons. Also an application should process only mouse events inside its window (in general).

The documentation describes a bit flag for receiving mouse change events in [syscall 40] "WantedEvents" by the application.
My question is, whether this is implemented completely by the OS yet. If so, I would see an example of this, because the documentation don't resolve the return codes clearly.

Else I have to do that "alternative way". But for some reasons, I would prefer the first more logical way. So we can save unnecessary mouse checking million times while applications are running ...

Imagine, You have 10 applications running at same time and all those applications check up the mouse positions all the time for the entire screen, even if the mouse state has not changed....
Somehow stupid, I think.

The only way to handle it intelligent, is to be informed by the OS, if a mouse state has changed. Fortunately this is prepared already by the API, but obviously not working yet... ?

jason
Post 01 Dec 2003, 18:39
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 222
Ville
Add this to the beginning of the program.

START:

mov eax,40
mov ebx,100111b
int 0x40

And the code below to event loop.

cmp eax,6
je read_mouse

So this is executed at every mouse-event.

read_mouse:

mov eax,37
mov ebx,0
int 0x40
...
jmp still
Post 01 Dec 2003, 20:30
View user's profile Send private message Reply with quote
jason



Joined: 30 Nov 2003
Posts: 8
Location: germany
jason
Thank You Ville.

This is exactly, what I have done already, but it didn't work. So perhaps this is an other error anywhere inside my code. I will check it now...

But there is nevertheless a thing missing with that:

[sys_call 37] with ebx=2 returnes the mouse buttons, right?

What are the exact return codes for pressing mouse buttons (i.e. left button, right button and eventually others) ?
I cannot find it in the "documentations".

Thank You very much again.
Post 02 Dec 2003, 14:37
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 222
Ville
> [sys_call 37] with ebx=2 returnes the mouse buttons, right?
> What are the exact return codes for pressing mouse buttons (i.e. left
> button, right button and eventually others) ?

Thats right, the return values are 0=no buttons pressed, 1=left, 2=right, 3=both left and right.
Post 02 Dec 2003, 15:15
View user's profile Send private message Reply with quote
KiteMaster



Joined: 01 Aug 2003
Posts: 18
Location: Austria
KiteMaster
is there also a suport for middle button and mousewheel?
Post 02 Dec 2003, 16:56
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 222
Ville
> is there also a suport for middle button and mousewheel ?

Currently no, since I dont have the possibility to try those protocols. Feel free to implement.
Post 02 Dec 2003, 17:33
View user's profile Send private message Reply with quote
jason



Joined: 30 Nov 2003
Posts: 8
Location: germany
jason
Thank You thousand times, Ville.
I got it working now.
Post 02 Dec 2003, 18:26
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.