Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  is LinuxJoystickPOV not subclassed from Component.POV? or am I doing this wrong?  (Read 2548 times)
0 Members and 1 Guest are viewing this topic.
Offline fishtoprecords

Senior Newbie





« Posted 2011-02-03 22:46:00 »

I'm a rookie at this. I'm trying to pick up values from the hat of my joystick. So I have code like:

1  
2  
3  
4  
               Component comp = event.getComponent();
                if (comp instanceof Component.POV || comp instanceof LinuxJoystickPOV) {
                    System.out.println(" is hat");
                }

This works, but if the test is jut for the Component.POV, it fails.

 
1  
2  
3  
            if (comp instanceof Component.POV ) {
                    System.out.println(" should still be a hat");
            }


What is the preferred way to check this?

Thanks
pat
Offline endolf

JGO Knight


Medals: 7
Projects: 1


Current project release date: sometime in 3003


« Reply #1 - Posted 2011-02-04 09:47:53 »

Hi

What you need to be doing is getting the identifer for the component instead of checking the class. This should return Component.Identifier.Axis.POV. The other class is just statics for identifying the direction of the hat.

HTH

Endolf

Offline fishtoprecords

Senior Newbie





« Reply #2 - Posted 2011-02-04 21:40:42 »

Thanks for the reply. A code fragment:

1  
2  
3  
4  
5  
                Component comp = event.getComponent();
                String compName = comp.getName();
                Component.Identifier compIdent = comp.getIdentifier();
                String compId = comp.getIdentifier().getName();
                buffer.append(String.format(" %s idt: %s  %s %s", comp, compName, compIdent, compId));

is returning "pov" for all values.

I'm not seeing anything returning the string "Component.Identifier.Axis.POV" or alternatively
"Component$Identifier$Axis$POV"

If I look at the class name of the "comp" it shows LinuxJoystickPOV

While I can just hard coded it to "pov" I would much rather use either a nice class name or a manifest constant from the package.

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

JGO Knight


Medals: 7
Projects: 1


Current project release date: sometime in 3003


« Reply #3 - Posted 2011-02-05 12:26:01 »

What does the controller text test show?

Offline fishtoprecords

Senior Newbie





« Reply #4 - Posted 2011-02-05 16:30:49 »

pov(pov)
Offline endolf

JGO Knight


Medals: 7
Projects: 1


Current project release date: sometime in 3003


« Reply #5 - Posted 2011-02-05 18:04:54 »

Don't use the class names, use the component identifiers. That is what they are there for.

Endolf

Offline fishtoprecords

Senior Newbie





« Reply #6 - Posted 2011-02-05 21:07:36 »

Don't use the class names, use the component identifiers. That is what they are there for.
I think you are missing some subtle things in my code. I get both the class and the identifier
and the debugging code shows all possible returned values.

So what constants in the package contain the value "pov"?
Offline fishtoprecords

Senior Newbie





« Reply #7 - Posted 2011-02-06 03:39:33 »

Looks like the constant I want is available with:

Axis.POV.getName()

or fully qualified:
net.java.games.input.Component.Identifier.Axis.POV.getName()
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.

xsi3rr4x (53 views)
2014-04-15 18:08:23

BurntPizza (51 views)
2014-04-15 03:46:01

UprightPath (65 views)
2014-04-14 17:39:50

UprightPath (48 views)
2014-04-14 17:35:47

Porlus (65 views)
2014-04-14 15:48:38

tom_mai78101 (89 views)
2014-04-10 04:04:31

BurntPizza (149 views)
2014-04-08 23:06:04

tom_mai78101 (245 views)
2014-04-05 13:34:39

trollwarrior1 (203 views)
2014-04-04 12:06:45

CJLetsGame (210 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!