Mouse Driver Problems
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Here's what I do:Lprogster wrote:One last question though...
The unsigned char array stores the 3 bytes from the mouse. If I'm right, bute 0 is x, byte 1 is y and byte 2 is status. I'm not quite sure how to interpret them though.
Say I have 2 variables that store the cursors x and y positions. Why doesn't this work:
I hope I'm being coherent enough.Code: Select all
void anim ( ) { MOUSEDATA q; int x = 160 , y = 100; // Center of the screen for ( ; ; ) { GetMouseData ( &q ); x += sign ( q.xmove ); // How should this interpret the data? y += sign ( q.ymove ); pix ( x , y , 15 ); } }
Anyhow - thank you for the code,
Lster
Code: Select all
// gets and returns the mouse data
// note: all data seems to come in back-to-front. don't ask me why
void GetMouseData( MOUSEDATA* data )
{
if( readable )
{
data->xmove = bytes[0];
data->ymove = bytes[1];
data->MouseStatus.status = bytes[2];
readable = 0;
}
}
Now, to interpret this, you just have to do some simple math:
Code: Select all
x += ( q.xmove * 1 );
y += ( q.ymove * -1 );
If you do a dump of the xmove and ymove values you'll see why the above works.
Edit: the mouse co-ords send properly in QEMU, but few other commands work. You can assume if it works in Bochs it'll work on bare hardware though, as my PS2 driver works properly.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Don't. Bochs is just an emulator with its own flaws. Code running on bochs is not guaranteed to run on real PCs. Even if you are able to run something on all virtual machines and emulators, it isn't a guarantuee for success on real hardware. However, by that time it has become rather likely.pcmattman wrote:You can assume if it works in Bochs it'll work on bare hardware though
isn't there a saying like 'assumption is the mother of all fuckups'. I tend to live by this rule. If you have to assume something... don't and make it explicit. This will save you a lot of troubles later on..
my 2ct
my 2ct
Author of COBOS
It seems that you enable irq's but don't use them. Which can be bad.., considering the mouse needs some to time (order milli seconds) to reply. If i look at your read mouse function it returns the value obtained from port 0x60 whether it is updated or not and thus returns immediatly (order of microseconds). In short the outcome of your driver is to be expected.
So to fix the issue you have to enable interrupts with an interrupt handler to store the data into a buffer or you will have to adapt the mouseread to polling mode with a check if new data is available (status port 0x64 i guess).
regards
So to fix the issue you have to enable interrupts with an interrupt handler to store the data into a buffer or you will have to adapt the mouseread to polling mode with a check if new data is available (status port 0x64 i guess).
regards
Author of COBOS