Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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  
  Hybrid Input Abstraction Layer (HIAL)  (Read 2847 times)
0 Members and 1 Guest are viewing this topic.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Posted 2004-12-06 22:16:43 »

Hi,

I have created an input abstraction API.

It provides interfaces to hardware to remove dependancies on any one input API (currently AWT and LWJGL implementations are provided out of the box).  It also allows input to be converted from one processing style to another (hence the "hybrid").  For example, you can use LWJGL-like keyboard state array query polling with AWT.

The time penalty for using this API as opposed to AWT or LWJGL directly is near zero (this is due to all critical methods being O(1) complexity and with zero garbage generation)*.

I created it for two reasons.  Firstly is to provide an abstraction layer from the hardware devices.  I need this now that Xith3D supports LWJGL, and it also future proofs my code as I may again wish to switch input API's.  The second is to provide handy processing of keyboard inputs with the concept of "sticky" keys.  Prior to developing HIAL, I used a custom solution (which I previously wrote an article about).  HIAL provides this concept and expands it to alternative input processing (like key state arrays) which are faster again.

As a result of some tireless hours spent documenting: The API even has complete javadocs!

You can read more about it, look at examples, view the javadoc and download the code here:  http://input.jtank.net.

I have released it under a BSD-like license.

Regards,

Will.


* Conditions apply, one method does not follow this rule (but you don't have to use it).

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #1 - Posted 2004-12-07 09:49:37 »

Hm, could be made a JXInput driver Smiley

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

JGO Coder


Projects: 2


Fire at will


« Reply #2 - Posted 2004-12-07 10:17:11 »

and vice versa.  I have yet to add joystick support to HIAL but it is on the list.

May I make a suggestion?  
It would be good if you liked to: http://www.hardcode.de/us/index.html from here: http://sourceforge.net/projects/drts .  I followed the sourceforge link in your sig but couldn't find any info on JXInput (I had to google in the end).

I take it you can access DirectInput controllers though JXInput, is that correct?

Will.

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

Junior Member




Come get some


« Reply #3 - Posted 2004-12-07 10:17:58 »

Great. I'll look into it. Do you have to keep track of the mouse button state yourself as there seems to be no methods for asking the current state when for example getting a newX() event?  Huh

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #4 - Posted 2004-12-07 10:39:30 »

Not in the listener interface itself there isn't, but you can use the pre-fabricated MouseListner implementing MouseMotionAccumulator  which does keep track of the X and Y values.

Will.

Offline phazer

Junior Member




Come get some


« Reply #5 - Posted 2004-12-07 10:53:01 »

Quote
Not in the listener interface itself there isn't, but you can use the pre-fabricated MouseListner implementing MouseMotionAccumulator  which does keep track of the X and Y values.

Will.


Oh, missed that one. So, if I'm interested in state and notification I should create a listener that extends MouseMotionAccumulator? Will that not result in keeping unnecessary duplicated states around?

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2004-12-07 23:31:47 »

You have two options:

a) extend MouseMotionAccumulator, and override the events you need to (make sure you remember to call the super method if you still want MMA to process the event).

b) create your own listener, and add it to the device.  The device will send events to both listeners.  The overhead for doing this is minimal (these are O(1) methods we are talking about).


Cheers,

Will.

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #7 - Posted 2004-12-08 05:01:00 »

Quote
and vice versa.  I have yet to add joystick support to HIAL but it is on the list.

May I make a suggestion?  
It would be good if you liked to: http://www.hardcode.de/us/index.html from here: http://sourceforge.net/projects/drts .  I followed the sourceforge link in your sig but couldn't find any info on JXInput (I had to google in the end).


Yeah .... DRTS needs a page of its own anyway. I fooled around with some CMS where an own JXInput section could belong, but without success to far. Volunteers?

Quote

I take it you can access DirectInput controllers though JXInput, is that correct?


Correct. Thus JXInput has parts on the same level as HIAL and other parts that are much more high-level (e.g. simulating joystick axes with keys or mouse, treating mouse or keyboard like joystick buttons and so on, providing event vs. polling etc...

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

Junior Member




Come get some


« Reply #8 - Posted 2004-12-08 05:22:18 »

Quote

b) create your own listener, and add it to the device.  The device will send events to both listeners.  The overhead for doing this is minimal (these are O(1) methods we are talking about).


But if I add two listeners do you guarantee in which order they are called? The MMA listener must be called before my other listener, otherwise I can't trust the state it reports.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #9 - Posted 2004-12-08 05:38:26 »

It isn't documented as such, but it can be.

Currently all Devices use a common abstract class for the broadcasting which uses an ArrayList.  The listeners are called in the order they were added.

Will.

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

Junior Member




Come get some


« Reply #10 - Posted 2004-12-08 06:48:21 »

An easier alternative would be to store the state in the MouseDevice. What is the reason for not doing that?

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #11 - Posted 2004-12-08 07:35:24 »

The devices should not store any public data -- they send events to listeners which do.

What exactly do you need? I am a little unclear.

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #12 - Posted 2004-12-08 07:57:24 »

Quote


Yeah .... DRTS needs a page of its own anyway. I fooled around with some CMS where an own JXInput section could belong, but without success to far. Volunteers?


Good luck with the Volunteers.  I tried that for xith3d -- everyone was happy to complain but nobody wanted to help.  I guess most of us are programmers not web developers.

I do recommend tikiwiki though, I use it for Xith3D and Odejava and it's pretty good.

Quote

Correct. Thus JXInput has parts on the same level as HIAL and other parts that are much more high-level (e.g. simulating joystick axes with keys or mouse, treating mouse or keyboard like joystick buttons and so on, providing event vs. polling etc...


thanks for the info.

Will.

Offline phazer

Junior Member




Come get some


« Reply #13 - Posted 2004-12-08 09:17:51 »

It's I who is a bit unclear.  Smiley

Basicly what I need is to get the mouse position when a button is pressed or released, and the mouse button state when the mouse is moved (for dragging). I think this is very common. For example in AWT you get a MouseEvent which contains all this information. In your case maybe you don't want to create a mouse event, you could keep the info in the MouseDevice class instead (getX(), getY(), isButtonDown() etc.), similar to the LWJGL Mouse class.

Just a suggestion. I could create my own wrapper for your library that does this, but maybe it would be better if it was included in your library.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #14 - Posted 2004-12-09 02:23:16 »

Using MouseMotionAccumulator you can:

1  
2  
3  
boolean getButtonState(int)
int getX()
int getY()


EDIT:  This data is stored in the implementation of the listener.  The Devices should not expose any data at all.  One may only call "update()" on a device, that is all.  The device should handle the rest and notice the listeners of all events.  It is up to the Listener implementations to handle use cases such as yours.

I notice in the docs it says "Button presses are ignored by this MouseListener".  This is out of date, it does now.

Will.

Offline Mithrandir

Senior Member




Cut from being on the bleeding edge too long


« Reply #15 - Posted 2004-12-15 14:41:51 »

You'll want to be very careful about JXInput. It has a license that is incompatible with open source licenses. We had JXInput capabilities in Xj3D for a couple of years but never publically shipped it because of this reason. The maintainer was not interested in changing the license either.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #16 - Posted 2004-12-15 22:08:18 »

Has it changed since then?  From the look of this page:  http://sourceforge.net/projects/drts it is BSD licensed.

Will.

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.

TehJavaDev (12 views)
2014-08-28 18:26:30

CopyableCougar4 (24 views)
2014-08-22 19:31:30

atombrot (37 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (29 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (28 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!