basic question: programming a device

Hi,

I am programming a platform-independent (Linux/Windows) application using C++ and some graphics libraries.  I will be using a trackball for the user to be able to interact with my application.  Motion of the trackball will manipulate the image onscreen in some way..

So right now I have a mouse with a trackball on it, but will soon be purchasing simply a panel-mount industrial trackball.

What is the first step I need to take in order to program this device?  Do I need to program a driver?  Or if it comes with a drive or is compatible with the driver I have, then how do I detect this device and get output from it? Do these devices normally come with drivers??

Should I be doing X programming or Win32 programming to do this?  Or can I call  a library in C++ which detects IO?

I think my trackball device will be attached to a serial port, and possibly a USB

Thank you!

(Also if you have any suggestions on books/sites taht I should look into - that would be great..)
lost_bits1110Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brettmjohnsonCommented:
Most trackballs are supported out-of-the box as a pointing device under Windows and Linux.
If the OS vendor doesn't support that particular brand, the device manufacturer will usually
provide a driver.  From the OS driver perspective, a trackball is simply a mouse.  So you
are unlikely required to write the device driver yourself.

If you want write a platform independent app, don't write directly to Win32 or X window APIs.
Confine you library calls to the ANSI, POSIX, and STL interfaces and use a platform independent
GUI framework such as Qt.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lost_bits1110Author Commented:
Thank you,

What do you mean by 'supported out of the box'..

So do you mean that if I used just POSIX calls for instance, then my program would still work under both Linux and Windows..? I will be using FLTK probably as my GUI framework..

Then if I understand correctly, using the GUI framework serves the purpose of continuosly detecting for events, and using either ANSI, STL etc.. is for opening the serial port, detecting that the device is there, and retrieving data from it?  

How does the device driver come into play in all of this

Thank you

0
brettmjohnsonCommented:
> What do you mean by 'supported out of the box'..
I mean most major OS's ship with drivers for commonly used pointing devices.

> So do you mean that if I used just POSIX calls for instance, then my program would still work under both Linux and Windows..?
Yes, Microsoft makes Windows NT/2000/XP/2003 POSIX compliant in order to sell to the US government.

> I will be using FLTK probably as my GUI framework..
I've never used it, so I can't comment.

> Then if I understand correctly, using the GUI framework serves the purpose of continuosly detecting for events, ...
Yes

> and using either ANSI, STL etc.. is for opening the serial port, detecting that the device is there, and retrieving data from it?
Yes.  Use fopen() for opening the device, ioctl() or fcntl() to query device type, and fread() et al to read data.

> How does the device driver come into play in all of this?
Device drivers map physical devices (including disk drives, keyboards, mice, etc) into the abstract filesystem
namespace, and abstract the interface to conform to character or block i/o devices .  So you can open/read/write
files, terminals, pipes, shared memory, sockets, etc. using the standard library routines.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.