Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (427)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
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  
  Game Controller Input  (Read 4706 times)
0 Members and 1 Guest are viewing this topic.
Offline NexusOne

Junior Member




Java games rock!


« Posted 2003-12-30 15:17:50 »

If I attach a controller, say a gamecube or ps2 controller, to my computer through some sort of attachment how can I read input from it for my (jogl) game?
Offline kevglass

JGO Kernel


Medals: 85
Projects: 22


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2003-12-30 15:26:45 »

See JInput Smiley

Although I'm not sure how a gamecube or ps2 controller will function. My gamepad (Logitech Wingman) works happily through JInput.

Kev

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #2 - Posted 2003-12-30 17:00:47 »

Don't forget JXInput. Whatever shows up as a DirectInput-device will be usable.

And - with JXInput you can code with virtual or auxiluary devices so that your game works when the control is NOT available.

Look at FlyingGuns as an example, where you can use joystick, mouse or keyboard .... even simulatniously ... same code....

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2003-12-31 21:48:39 »

So to plug my own project, and for completeness.

All of the above is also true for JInput.  You do virtual control devices by writing plug-ins.

JInput is currently ported to Win32, OSX and Linux.  On Win32 it supports DirectInput devices as well as the Win32 plug-in also calls DirectInput.   The linux and OSX developers can tell you the details of those plug-ins.

JInput is part of the 3 current "core" APIs that the sun Game Technology Group is supporting.  (JOGL, JOAL, JInput).   Having said that, there are cetainly other API sets out there that work fine if they meet your needs better (LWJGL, JXInput, JavaJoystick, etc)




Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline NexusOne

Junior Member




Java games rock!


« Reply #4 - Posted 2004-01-01 00:06:09 »

thanks  Cool
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #5 - Posted 2006-10-23 08:24:54 »

What I meant is that JXInput supports high-level structures that allow e.g. to have an 'Axis' (like a joysticks x-, y- or z-axis) only by using 'Button's (e.g. from a joystick again or a keyboard. Like this one:


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
     JXKeyboardInputDevice kd = JXInputManager.createKeyboardDevice( comp );

    Button left = kd.createButton( KeyEvent.VK_LEFT );
    Button right = kd.createButton( KeyEvent.VK_RIGHT );
               
    JXVirtualInputDevice vd = JXInputManager.createVirtualDevice();
    VirtualAxis vaileron = vd.createAxis( Axis.ID_X );
       
     vaileron.setButtons( right, left );
     vaileron.setTimeFor0To1( 1000 );
     vaileron.setTimeFor1To0( 500 );
     vaileron.setName( "Aileron" );


Or something that allows for 'overlaying' axes and 'or'-ing buttons:

1  
2  
    Axis aileron = new LatestChangedValueAxis( vaileron, mouseaileron );
    Button trigger = new OrButton( joysticktrigger, mousetrigger );


FlyingGuns shows user extensions (that I may mave to JXInput). E.g. a 'MouseDevice'
that creates x/y axes from mouse movements.


HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #6 - Posted 2006-10-23 13:20:41 »

JInput unders Linux will expose any joysticks and / or event devices. That means almost anything with a USB interface. My scanner shows up there with 3 buttons, which in theory, I could use in a game for input Smiley. LWJGL, and by extention JME use/can use JInput under the covers.

Endolf

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #7 - Posted 2006-10-23 14:31:49 »

Smiley

I had a problem with JXInput crashing on certain machines. It turned out it was some USB keyboard device enumerating 665  buttons!!
This caused a buffer overflow in my code (shame on me  Embarrassed )

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
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 (78 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (221 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!