handling mouse and keyboard events in the GUI service
- distantvoices
- Member
Member - Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
handling mouse and keyboard events in the GUI service
Post by distantvoices »
Just thinking about this: In the micro kernel environment, there are many possibilities to *pipe* data in a very quick manner hither and tither.
Now, I wanna redo my GUI service-Video Driver cooperation. It is awfully slow at the moment and in no case suitable for any environment. Why: because I have shied away too long from mapping the frame buffer memory into the gui service adress space.
In this scheme of things, the video driver wouldn't have to do anymore anything with drawing. Instead, it just would expose the frame buffer as a device for further use.
Now, another thing arises from there: drawing the mouse and handling the events. Till now, I am doing the mouse drawing and window moving in the video driver. I don't think this is good, because this way, the video driver hogs the cpu for quite some time.
I am thinking about stuffing mouse and keyboard events in form of packets into a kind of serial queue the gui service registers in kernel land. a thread of the gui service shall then pick up one packet after an other and perform the requested action.
What do you think about this? Is it rubbish?
Stay safe.
BlueillusionOS iso image
- Pype.Clicker
- Member
Member - Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:handling mouse and keyboard events in the GUI service
Post by Pype.Clicker »
the GUI service would be responsible for reading those FIFOs (it could get notified of data presence by the kernel), perform further decoding like translating the mouse packet into some X,Y + buttons events and the keyboard packet into some unicode character or a 'special keystroke', inspect the 'current window' preference and events masks, and if needed, send the datum to the responsible GUI client ...
If i had to do it myself, i would rather have the 'video' driver as a shareable component that can be 'imported' in the GUI service. For instance, the video driver may have hardware cursor feature which is only supposed to be used by the GUI service, but it may occur that another video driver has no such support, so it only exports a software rendering library instead...
Once the driver has been 'imported' by a client, though, no other client can connect to it, and such an 'import' is only achievable when the driver has no client ...
- Xardfir
Re:handling mouse and keyboard events in the GUI service
Post by Xardfir »
On one hand a well defined API allows applications to access all gui services under gui control, but lacks flexibility and as you've pointed out speed.
On the other, simply whacking up a linear section of memory as a virtual screen gives all sorts of flexibility but at the price of everything being done in software.
Discarding (most) hardware acceleration for the moment, the only thing a video driver should be concerned with is, "here is a bunch of windows draw them".
For standard 2D windows you're stuck with slowness. Apart from a bit of block move acceleration, don't expect anything more from any video card.
For 3D windows, these can be drawn using hardware acceleration by feeding the display list generated by your vector engine to the video driver. The driver then calls the hardware accelerator to draw the triangles, textures etc. at full speed.
If you're stuck with software rendering then it should be done before reaching the video driver. Then all output can be done by 2D objects (lines make triangles, flood or pattern fill triangles).
Separating your graphics into a pipeline like this can speed up your graphics (2D and 3D) just like pipelining in the 486 made it four times faster than a 386 at the same clock speed (I don't guarantee that kind of increase though!). Pipelining can also be veiwed as micro-kernel versus monolithinc. Splitting the problems into components should prove useful and make life less complicsated..
Many good books are available (Andrew LaMoth's 3D game programming series is recommeded, make sure it's DOS based though - it's easier to port). Although you might not be writing games, the principles are developed here for fast graphics pipelines in software.
As for messaging, the mouse cursor is just a small transparent window - where is goes on the screen is of no business to applications. Update it with information received from the mouse and then send the data onto the appropriate application.
Then draw the mouse as a normal window, or if you can access the hardware cursor, use that (I'm not sure how you can animate it or do fancy happy user stuff though.)
Anyway - I'd recommend removing it from the video driver into it's own little interrupt handler (small, neat and single minded - get mouse packet, update mouse cursor location, pass on mouse packet, IRET).
As for the shareable component bit - the more components the better. By limiting the things the driver can actually do, you should be able to make it 'upgradeable on the fly'.
(Stop component, export start of display list, copy new pointers to new driver, import start of display list, restart new service).
Nothing more annoying than "Reboot system, for driver to take effect" Errrrr <:(.
Messaging: following on from above, the only message the video driver should receive is a list of windows and their starting addresses. You can do window sorting and Z-buffering before sending to the video driver. Anything that hasn't been updated can be removed from the sorted list reducing the work of your video driver even further. Application windows can exist in the 'plane' (in the video cards memory) or across the 'plane' (stored in main memory).
In the plane is faster because you can get the viseo card to do it, but there is never enough video memory for all windows. (Especially for textures).
Messaging from applications to the GUI/S is a totally different proposition but I hope my suggestions can help you get some more speed.
- distantvoices
- Member
Member - Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:handling mouse and keyboard events in the GUI service
Post by distantvoices »
What about exposing a frame buffer device to the gui service and having the gui service doing all the drawing onto the frame buffer directly?
Further, what about informing the gui service about a mouse event via a signal sent by the mouse driver? The according signal handler would then kick off the mouse handling in the gui service which fetches mouse packets and does what it has to do?
Things to think about...
STay safe, and thanks!
BlueillusionOS iso image
- Pype.Clicker
- Member
Member - Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:handling mouse and keyboard events in the GUI service
Post by Pype.Clicker »
That way, you would prevent yourself from using any acceleration beyond the simple framebuffer.beyond infinity wrote: First, thanks for the suggestions! :-)) Appreciating them!
What about exposing a frame buffer device to the gui service and having the gui service doing all the drawing onto the frame buffer directly?
What i would use as 'video driver interface' would be:
Code: Select all
interface VideoDriver {
class VideoArea {
VideoArea(initial_size, combine_method);
Memory getBuffer(); // ask for memory we can draw in
void commitBuffer(); // tell the driver we're done drawing
void resize(new_size);
}
VideoArea makeArea(initial_size, combine_method, initial_position);
moveArea(VideoArea, new_position);
removeArea(VideoArea);
setOrder(VideoArea, z_order);
}
However, i must admit that i don't have a clear proposal for "redrawing of the exposed regions" with this scheme... and keeping a buffer of everything 'hidden' by other areas is usually not a valid option ...
When you say "the gui service fetches mouse packet", are you thinking about "the gui service fetches bytes from port 0x60" or "the gui service get the pre-decoded mouse information from a software fifo" ?Further, what about informing the gui service about a mouse event via a signal sent by the mouse driver? The according signal handler would then kick off the mouse handling in the gui service which fetches mouse packets and does what it has to do?
Kicking the GUI service through some signal is of course an interresting thing to do. Letting it get the raw things from the raw hardware wouldn't (imho)
- Tim
Re:handling mouse and keyboard events in the GUI service
Post by Tim »
- distantvoices
- Member
Member - Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:handling mouse and keyboard events in the GUI service
Post by distantvoices »
ad framebuffer: It's because of the micro kernel design: at the moment I have the gui service draw the screen contents into a buffer and after drawing 's finished inform the video driver about screen data to be fetched.
The video driver copies the data into the frame buffer.
Sure, on a pc with a decent graphics adapter and a decent processor, it works rather well. But it's annoying and complicated design and a hell to debug.
@tim: that's a good Idea: having a dedicated thread listening for mouse movements.
stay safe
BlueillusionOS iso image
- Pype.Clicker
- Member
Member - Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:handling mouse and keyboard events in the GUI service
Post by Pype.Clicker »
- BI lazy
Re:handling mouse and keyboard events in the GUI service
Post by BI lazy »
Re:handling mouse and keyboard events in the GUI service
Programs only get the inputs they should get, and they get all inputs that occur during the time the focus is set to them. The user environment is configurable, and you can of course define environments for a certain user. This results in a number of "events" that can happen, and each event can be coupled by the user program to the "default action", that is, redirection to the GUI service, redirection to the input service, or it can do SomethingCompletelyDifferent(tm), such as interpreting keyboard make/breaks as game input, for controls etc.
I hope this makes the environment more configurable, especially since all input that ends up at the user level has been parsed through the user settings, so you can make a virtual mouse or virtual keyboard from whatever you do have. External applications can also send input to the currently-focussed application, so you can make an onscreen keyboard, and automate tasks using that kind of input.
I'm considering adding logging of input streams, so you can make a "demo" of the programs function using that input stream as actions, possibly together with what you add as comment.
- Pype.Clicker
- Member
Member - Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:handling mouse and keyboard events in the GUI service
Post by Pype.Clicker »
what was rolling in /dev/brain is that it makes no sense to say 'everything is a file' if sometimes you can seek a file and sometimes you cannot...
The unix approach says 'fifos, character devices, sockets are files ... they just cannot do everything a 'regular' file can!' while OOP programming would prefer 'fifos, character devices, sockets and files are all X ... but files can do more than what X can ...'
Re:handling mouse and keyboard events in the GUI service
Or, put directer, UNIX doesn't work according to "Make it as simple as it can be, but no simpler - Einstein". The dude was right.Pype.Clicker wrote: what was rolling in /dev/brain is that it makes no sense to say 'everything is a file' if sometimes you can seek a file and sometimes you cannot...
And if you model them as such in your c++ environment, as opposed to the current STL template idea (I think it models it the same, not sure), you'll have a more powerful OS.The unix approach says 'fifos, character devices, sockets are files ... they just cannot do everything a 'regular' file can!' while OOP programming would prefer 'fifos, character devices, sockets and files are all X ... but files can do more than what X can ...'
PS: in some cases, I'd rather get event messages telling me something has happened. Input is one such things, it just makes no sense to have a pipe of inputs where a key being hit is an _event_, not an _input stream_.
Same for listening sockets, you don't block a thread on it actively, you let the app tell you it wants to "open that port for listening", and you then deliver messages to its inbox telling it that "there is a connection request from x.x.x.x:y to z.z.z.z@a, at time b", so you can reply as you should. Of course, it's even better if there's a default way to do popup threads, but my head is still munching the ideas around that. I'm now thinking about a handle_t defer(&function, ...) where the deferred function is executed at SOME time in the future, after which a signal is sent to that handle. If something is listening at the handle, it's awaken at the time of completion, so you can do more than one thing at once, without thread sync problems... Point is, how the **** do I write down that defer function without compiler warnings?
- distantvoices
- Member
Member - Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:handling mouse and keyboard events in the GUI service
Post by distantvoices »
Gonna think about this. Just want to have an acceptable way of abstraction for them. To open the mouse device and then read from it seems quite straight to me, but I might be in err.
BlueillusionOS iso image
- Pype.Clicker
- Member
Member - Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:handling mouse and keyboard events in the GUI service
Post by Pype.Clicker »
I would be tempted to trybeyond infinity wrote: You recommend then, that I introduce an additional interface to fifos/sockets/pipes/mouse-kbd-inputstreams?
Code: Select all
class File implements rStream, wStream{
void seekReader(position);
void seekWriter(position);
// other methods about attributes, and other things.
}
interface rStream {
read();
int howManyBytesReadSinceConstruction();
}
interface wStream {
write();
int howManyBytesWrittenSinceConstruction();
}
And of course
Code: Select all
class mouseQueue implements rStream {
void reset();
/* transmit a signal to the writer to tell him we're lost and
*we'd like him to return to a 'valid' state, and block until it
*acknowledged that signal
*/
}
- Tim
Re:handling mouse and keyboard events in the GUI service
Post by Tim »