Solved

basic question: programming a device

Posted on 2004-10-22
242 Views
Last Modified: 2013-11-15
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..)
0
Question by:lost_bits1110
    3 Comments
     
    LVL 23

    Accepted Solution

    by:
    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
     

    Author Comment

    by:lost_bits1110
    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
     
    LVL 23

    Expert Comment

    by:brettmjohnson
    > 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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
    The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

    931 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now