I thought about an adaptor too, but wasn't sure if such an adaptor would provide a real serial-port. I am using a specific control line of the serial-port to detect the signal and in order for this to work the adaptor would have to convert and provide the signal. All I really need is an easy way to get a detectable signal in via the USB port and read it with Java. I thought that USB mice are cheap and supported by all computers and since they provide up to three buttons they would be ideal. I guess I have to try such an adaptor.
Thanks

Lars

Dan Streetman wrote:
Yep that is by far the easiest thing to do.

Actually getting mouse events through USB using javax.usb will be much more work. You'll need to kick the existing HID driver off the mouse (so you can't use it as a normal system mouse anymore). Then claim it and start parsing its input reports which are in HID format. The mouse buttons are part of each report. I'm not completely sure, as I haven't checked the HID spec, but I believe that mice are not standardized, as HID devices can generically specify their input format so the mouse manufacturer can just set up the mouse HID Report Descriptor to specify how it will report mouse movement and buttons. So you would either need to write code to specifically parse your device report format, or actually write a HID parser (you don't want to do that). If you have only one mouse (or one type of mouse) then you can just easily figure out what its input report layout is and code directly to that.

But again as Oscar said - getting a USB to RS232 converter is by far the easiest thing to do, assuming this is a small scale personal effort. Converters are super cheap these days; probably less than the mouse you're connecting.

On Thu, Aug 6, 2009 at 10:08 AM, <m...@san.rr.com <mailto:m...@san.rr.com>> wrote:



    I think your best bet is to get one a usb to serial adapter (for
    example: http://sewelldirect.com/usbtoserial.asp)
    This will simply show up as a serial port and you won't have to do
    anything differently than you do now.

    Oscar

    ---- Lars Schnoor <lars.schn...@ifad.dk
    <mailto:lars.schn...@ifad.dk>> wrote:
    > Hi everyone
    > I have a Java application that needs to detect mouse button
    activation.
    > I need some hardware input to my application, currently I access the
    > serial port to detect some button press by reading the control
    lines of
    > the serial port using the RXTXcomm package. More and more modern
    > computers do however come without serial(COM) port so I need to
    switch
    > over to USB.
    > In a graphical Java user interface I can add a MouseListener and get
    > informed when a mouse button is pressed. Basically I need this
    > functionality just without the graphical user interface. All I
    need is
    > button presses, no mouse movement. It would of cause also be
    nice if it
    > would work under both Windows and Linux. Is there an easy way to
    do this?
    > Thanks in advance!
    >
    > Lars
    >
    >
    
------------------------------------------------------------------------------
    > Let Crystal Reports handle the reporting - Free Crystal Reports
    2008 30-Day
    > trial. Simplify your report design, integration and deployment -
    and focus on
    > what you do best, core application coding. Discover what's new with
    > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
    > _______________________________________________
    > javax-usb-devel mailing list
    > javax-usb-devel@lists.sourceforge.net
    <mailto:javax-usb-devel@lists.sourceforge.net>
    > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel


    
------------------------------------------------------------------------------
    Let Crystal Reports handle the reporting - Free Crystal Reports
    2008 30-Day
    trial. Simplify your report design, integration and deployment -
    and focus on
    what you do best, core application coding. Discover what's new with
    Crystal Reports now.  http://p.sf.net/sfu/bobj-july
    _______________________________________________
    javax-usb-devel mailing list
    javax-usb-devel@lists.sourceforge.net
    <mailto:javax-usb-devel@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/javax-usb-devel


------------------------------------------------------------------------

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
------------------------------------------------------------------------

_______________________________________________
javax-usb-devel mailing list
javax-usb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
javax-usb-devel mailing list
javax-usb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to