Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (578)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JInput and Custom USB Devices  (Read 1694 times)
0 Members and 1 Guest are viewing this topic.
Offline kmconroy

Junior Newbie





« Posted 2004-06-22 16:18:53 »

Hi everyone!

Pointless Background

I've been using JOGL for the past several months and just love it. I've just started a new project where I'm building some custom hardware that will be USB (HID) compatible that I want to use to control interaction in my application.

This is the first time I've attempted to build custom hardware/drivers/etc so please forgive me if I'm asking the obvious here. There's a venerable RAINFOREST of USB documentation that I've been trying to wade through and make sense of. I'm still very much in the research and design stage as far as software goes and want to make sure that I understand all of the options available to me before I waste several weeks (months?) writing a driver.

Start Reading Here
My question for you guys: does the Collection/Axis structure of a device directly correspond to the HID descriptor for a device?

For example, I wrote a quick recursive app that prints out the structure of my Microsoft USB Optical mouse. I found the following:

Controller: Mouse Mouse
Axises

  •  Controller: Mouse Mouse ball
     Axises [3]
       X-axis (x)
       Y-axis (y)
       Wheel (slider)
     Controller: Mouse Mouse buttons
     Axises [3]
       Button 0 (left)
       Button 1 (right)
       Button 2 (middle)[/tt]


    And the typical mouse HID (abbreviated) looks like this:
    Usage_Page(Generic Desktop)
    Usage (Mouse)
    Collection(Application)
     Usage(Pointer)
       Collection(Physical)
             Usage_Page(Button) // then button 1, 2, 3
             ...
             Usage_Page(Generic Desktop) // then x, y
             ...
       End Collection
    End Collection


    So, let's say that I added another Usage_Page under the "Physical Collection" that reported arbitrary values A, B, and C, would I see those as another Controller with three Axes (A, B, C) under the high level mouse controller?

    Translation:
    Controller: Mouse Mouse
    Axises

    •  Controller: Mouse Mouse ball
       Axises [3]
         X-axis (x)
         Y-axis (y)
         Wheel (slider)
       Controller: Mouse Mouse buttons
       Axises [3]
         Button 0 (left)
         Button 1 (right)
         Button 2 (middle)
       Controller: Mouse Arbitrary values
       Axises [3]
         A (A)
         B (B)
         C (C)[/tt]

      Hope this isn't too basic... just want to make sure that I understand what JInput is doing. If it will recognize my new device as I've specified above (or close to it if I got the controller/axis heirarchy wrong) then that means I just need to worry about the embedded software and don't need to write a host driver... I can just import JInput into my application and keep coding!

      Thanks for your help... you guys are doing great work.

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #1 - Posted 2004-06-23 00:47:55 »

Yes that is the way it is supposed to work.  It seems the USB device vendors are very inconsistent though.  Many of the standard HID usage codes are rarely used, even though they would fit the function of the controller exactly.  For example HID defines usages for a hat switch (thumb operated directional control on the end of a joystick), but you may find that a controller with a hat switch treats it as four unrelated buttons or maybe a single axis with 9 states.  Basically the vendors ruined HID so that you can pretty much ignore the standardization that was attempted and you have  to write custom tables and stuff for each controller.. failing back on the standard stuff for things you don't recognize and hope for the best...   at least that's how it appeared to me when I was last playing with the MAc plugin.

Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #2 - Posted 2004-06-23 07:07:47 »

Hi
 The other thing to note is that the mouse is split up into seperate controllers in JInput, that is not based on the HID info. I'm not sure it would show up as a sub controller. Atleast, thats how windows and linux plugins do it.

Endolf

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kmconroy

Junior Newbie





« Reply #3 - Posted 2004-06-23 10:30:53 »

Quote
The other thing to note is that the mouse is split up into seperate controllers in JInput, that is not based on the HID info. I'm not sure it would show up as a sub controller. Atleast, thats how windows and linux plugins do it.


Just look a peak at the source code. In theory if a custom mouse doesn't register the additional axies/controllers then it seems like it'd be a fairly simple matter of just mucking around with the DirectMouse implementation for Windows to get additional controllers recognized. (Or am I mistaken?)

Is the reason that the mouse self enumerates the Ball and Button controllers due to the fact that many different manufactuers have followed various HID implementations and thus the only way to have a consistent mouse object is to hard code in those controllers?
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #4 - Posted 2004-06-23 11:02:08 »

Hi
 My understanding for what it was originally done, is because the mouse ball is two axis, and grouping them together seems to make sense, ideally a coolie hat on a joystick would be one object too, a subcontroller of the joystick maybe, but for now, the mouse is the only one that actually does it.

Endolf

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

DarkCart (18 views)
2014-10-31 21:44:48

DarkCart (23 views)
2014-10-31 21:43:57

TehJavaDev (40 views)
2014-10-27 03:28:38

TehJavaDev (31 views)
2014-10-27 03:27:51

DarkCart (45 views)
2014-10-26 19:37:11

Luminem (27 views)
2014-10-26 10:17:50

Luminem (31 views)
2014-10-26 10:14:04

theagentd (36 views)
2014-10-25 15:46:29

Longarmx (64 views)
2014-10-17 03:59:02

Norakomi (62 views)
2014-10-16 15:22:06
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!