Mouse question

Hello all,

I am currently involved in writing an application for qnxrtp but I have one
problem The problem is I need to know upon startup of the program (or at
any time for that matter) if there is a mouse connected to the PS2 mouse
port. It is a C/C++ app and I just cannot find any way to do this. Any
help is appreciated.

Thank you

Chris

Chris Haidvogel wrote:

Hello all,

I am currently involved in writing an application for qnxrtp but I have one
problem The problem is I need to know upon startup of the program (or at
any time for that matter) if there is a mouse connected to the PS2 mouse
port. It is a C/C++ app and I just cannot find any way to do this. Any
help is appreciated.

I think you want PtQuerySystemInfo() - it’s in the on-line docs.

Rennie

I am sorry I should have been more clear about this. It is not a Photon
application. It is a command line application with a self written graphics
driver. I need something low level to say if there is a mouse attached.
Sorry for the lack of information.

Chris

“Rennie Allen” <rallen@csical.com> wrote in message
news:3C9B830F.6040108@csical.com

Chris Haidvogel wrote:

Hello all,

I am currently involved in writing an application for qnxrtp but I have
one
problem The problem is I need to know upon startup of the program (or
at
any time for that matter) if there is a mouse connected to the PS2 mouse
port. It is a C/C++ app and I just cannot find any way to do this. Any
help is appreciated.


I think you want PtQuerySystemInfo() - it’s in the on-line docs.

Rennie

Chris Haidvogel wrote:

I am sorry I should have been more clear about this. It is not a Photon
application. It is a command line application with a self written graphics
driver. I need something low level to say if there is a mouse attached.
Sorry for the lack of information.

Ahhh, OK, assuming you’re on a PC platform, then finding out whether
there is a PS/2 mouse attached is extremely easy. Simply map the BIOS
data area and check the “PS2 Mouse Present” bit, that the BIOS sets when
it detects a mouse.

The offset of the byte that contains the bit is 0x10. The “PS2 Mouse
Present” is the third bit (i.e. mask 0x04).

If you’re not on a PC platform then you will most likely have to query
the mouse yourself.

Hope this helps

Rennie

Thank you very much. I have just one more request: you wouldn’t happen to
know of any resources that I could that I would be able to see how to map
the BIOS and what not? How about any sample code showing the mapping of the
BIOS and all that? Also, what do you mean by PC platform? I am not clear
on this. I would appreciate any help.

Thanks (again),
Chris

“Rennie Allen” <rallen@csical.com> wrote in message
news:3C9B988F.6020101@csical.com

Chris Haidvogel wrote:

I am sorry I should have been more clear about this. It is not a Photon
application. It is a command line application with a self written
graphics
driver. I need something low level to say if there is a mouse attached.
Sorry for the lack of information.

Ahhh, OK, assuming you’re on a PC platform, then finding out whether
there is a PS/2 mouse attached is extremely easy. Simply map the BIOS
data area and check the “PS2 Mouse Present” bit, that the BIOS sets when
it detects a mouse.

The offset of the byte that contains the bit is 0x10. The “PS2 Mouse
Present” is the third bit (i.e. mask 0x04).

If you’re not on a PC platform then you will most likely have to query
the mouse yourself.

Hope this helps

Rennie

Chris Haidvogel wrote:

Thank you very much. I have just one more request: you wouldn’t happen to
know of any resources that I could that I would be able to see how to map
the BIOS and what not?

http://www.bioscentral.com/misc/bda.htm

and the qnx online docs…

How about any sample code showing the mapping of the
BIOS and all that?


#include <stdio.h>
#include <sys/mman.h>
#include <stdlib.h>

main()
{
unsigned short *ptr;

ptr = mmap_device_memory( 0, sizeof(*ptr),
PROT_READ|PROT_WRITE|PROT_NOCACHE, 0, 0x410);
if ( ptr == MAP_FAILED ) {
perror( “mmap_device_memory for physical address 0x410
failed” );
exit( EXIT_FAILURE );
}

if(*ptr & 0x04) {
printf(“PS2 Mouse installed\n”);
} else {
printf(“No PS2 Mouse installed\n”);
}
}

Also, what do you mean by PC platform?

PC == x86 based personal computer, as opposed to a x86 based computer of
your own design. The above code will only work on an x86 PC.

Rennie

Hi Rennie…

How do you know all of these things? :slight_smile: Experience? :slight_smile:)

You are an asset to this news group. I am sure many of us appreciate
yours (and Mario’s, Igor’s and other’s…) input. Thanks.

Miguel.


Rennie Allen wrote:

Chris Haidvogel wrote:

Thank you very much. I have just one more request: you wouldn’t happen to
know of any resources that I could that I would be able to see how to map
the BIOS and what not?

http://www.bioscentral.com/misc/bda.htm

and the qnx online docs…

How about any sample code showing the mapping of the
BIOS and all that?


#include <stdio.h
#include <sys/mman.h
#include <stdlib.h

main()
{
unsigned short *ptr;

ptr = mmap_device_memory( 0, sizeof(*ptr),
PROT_READ|PROT_WRITE|PROT_NOCACHE, 0, 0x410);
if ( ptr == MAP_FAILED ) {
perror( “mmap_device_memory for physical address 0x410
failed” );
exit( EXIT_FAILURE );
}

if(*ptr & 0x04) {
printf(“PS2 Mouse installed\n”);
} else {
printf(“No PS2 Mouse installed\n”);
}
}

Also, what do you mean by PC platform?

PC == x86 based personal computer, as opposed to a x86 based computer of
your own design. The above code will only work on an x86 PC.

Rennie

my opinions are mine, only mine, solely mine, and they are not related
in any possible way to the institution(s) in which I study and work.

Miguel Simon
Research Engineer
School of Aerospace and Mechanical Engineering
University of Oklahoma
http://www.amerobotics.ou.edu/
http://www.saic.com

Miguel Simon wrote:

Hi Rennie…

How do you know all of these things? > :slight_smile: > Experience? > :slight_smile:> )

More likely age. I’m old enough to remember ancient artifacts like PC
bioses and PS/2 mice in these days of flash based ipl’s and USB-2 :slight_smile:


You are an asset to this news group. I am sure many of us appreciate
yours (and Mario’s, Igor’s and other’s…) input. Thanks.

Glad if I can help.