Mouse driver not working
Mouse driver not working
[post was deleted]
Last edited by mrosdev on Sun Oct 18, 2020 7:20 am, edited 1 time in total.
-
- Member
- Posts: 797
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: Mouse driver not working
I didn't look at the code and logic closely but one observation is that there is 1 byte available to read per mouse interrupt. You should not be reading 3 bytes at a time the way you are doing it.
Re: Mouse driver not working
Ok.
Last edited by mrosdev on Sun Oct 18, 2020 7:41 am, edited 2 times in total.
Re: Mouse driver not working
As MichaelPetch correctly states, you should only be reading one (1) byte per interrupt. The controller will trigger an interrupt when it has a single byte ready for reading.
Your code must keep track of which byte within the packet is currently being read and update the packet accordingly.
For example, if you have a three byte packet, you start with a PACKET_INDEX of zero. Also, you should have a local (to your interrupt) buffer holding the data, and only sending a fully updated packet to your mouse driver after the last byte has been received.
1) Interrupt Fired
2) Read Byte
3a) if PACKET_INDEX == 0, update button status in local buffer (see note below)
3b) if PACKET_INDEX == 1, update X coord in local buffer
3c) if PACKET_INDEX == 2, update Y coord in local buffer
4) Increment PACKET_INDEX
5) if PACKET_INDEX == 3, send contents of local packet to mouse driver packet, and set PACKET_INDEX to zero
6) exit interrupt
Note: The first byte of the packet sent from the mouse will have a bit indicating that it is the first byte of the packet. You will need to watch for this bit.
Ben
- http://www.fysnet.net/input_and_output_devices.htm
Your code must keep track of which byte within the packet is currently being read and update the packet accordingly.
For example, if you have a three byte packet, you start with a PACKET_INDEX of zero. Also, you should have a local (to your interrupt) buffer holding the data, and only sending a fully updated packet to your mouse driver after the last byte has been received.
1) Interrupt Fired
2) Read Byte
3a) if PACKET_INDEX == 0, update button status in local buffer (see note below)
3b) if PACKET_INDEX == 1, update X coord in local buffer
3c) if PACKET_INDEX == 2, update Y coord in local buffer
4) Increment PACKET_INDEX
5) if PACKET_INDEX == 3, send contents of local packet to mouse driver packet, and set PACKET_INDEX to zero
6) exit interrupt
Note: The first byte of the packet sent from the mouse will have a bit indicating that it is the first byte of the packet. You will need to watch for this bit.
Ben
- http://www.fysnet.net/input_and_output_devices.htm
Re: Mouse driver not working
If you don't know anything about mouse driver programming, why are you trying to fix a mouse driver???HyperCreeck wrote:As I mentioned at the top of the post, the mouse driver was from the basekernel project. I didn't make it and I don't know anything about mouse driver programming.MichaelPetch wrote:You should not be reading 3 bytes at a time the way you are doing it.
Why should we bother to help you if you don't show any interest?
Re: Mouse driver not working
As you have based your OS on someone else's work, I wonder if it would be polite to at least acknowledge that - and provide a link to that original work - in your project. And I'm not sure you can put a copyright notice claiming the copyright for yourself, in code that you didn't write and don't understand.
Re: Mouse driver not working
PeterX, I need mouse driver for making GUI.PeterX wrote:If you don't know anything about mouse driver programming, why are you trying to fix a mouse driver???
Re: Mouse driver not working
Sorry, I forgot to do that. Here's the link to the original basekernel project.iansjack wrote:As you have based your OS on someone else's work, I wonder if it would be polite to at least acknowledge that - and provide a link to that original work - in your project.
Re: Mouse driver not working
OK, that's fine. But how do you expect do fix your mouse driver without learning first how to program a mouse driver? It seems impossible to me.HyperCreeck wrote:PeterX, I need mouse driver for making GUI.PeterX wrote:If you don't know anything about mouse driver programming, why are you trying to fix a mouse driver???
Greetings
Peter
Re: Mouse driver not working
I think you miss my point.
1. You should provide a very prominent acknowledgement in your source code to the work that it is derivative of (if it is derivative rather than just a direct steal). That way anyone looking at it can see the connection.
2. Far more serious. You are claiming copyright on material that is already copyrighted by someone else. For example, your file "bitmap.c" is identical to the original "bitmap.c". The only difference is that you have removed the original copyright notice and inserted your own. That's known as plagiarism.
I haven't been through your code file by file, but I suspect that most of it is identical to the original work. You can't just claim this as your own work - that's immoral, and probably illegal.
You should read the Licence of the original work and ensure that you conform with all the conditions stated in that licence. You have failed to do so.
1. You should provide a very prominent acknowledgement in your source code to the work that it is derivative of (if it is derivative rather than just a direct steal). That way anyone looking at it can see the connection.
2. Far more serious. You are claiming copyright on material that is already copyrighted by someone else. For example, your file "bitmap.c" is identical to the original "bitmap.c". The only difference is that you have removed the original copyright notice and inserted your own. That's known as plagiarism.
I haven't been through your code file by file, but I suspect that most of it is identical to the original work. You can't just claim this as your own work - that's immoral, and probably illegal.
You should read the Licence of the original work and ensure that you conform with all the conditions stated in that licence. You have failed to do so.
Re: Mouse driver not working
@iansjack, I understand what you said, so I deleted that project permanently (Including the repository and documentation). (BTW I changed my name to mrosdev because I like that name).