Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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 this possible right now?  (Read 1532 times)
0 Members and 1 Guest are viewing this topic.
Offline misterX

Junior Duke




java forever!


« Posted 2003-09-27 15:35:03 »


Hi guys,

since i've never touched jinput yet and am not so aware about its developpement stage, i'm wondering about few things, and if they're doable right now.

A. Keyboard
---------------
Is it possible to get a sort of "isKeyPressed(int keyCode)" information directly?
(I mean a direct access of course, not a layer which sets a true/false flag on key events.)

B. Mouse
-----------
Is it possible to "block" the cursor completely? or into a given area?
Is it possible to get the dx/dy directly? (i mean, to get it even when the cursor is out of the window or even if the cursor doesn't move at all, when it's blocked or against the border)

If you could give me some sample code, it would even be more appreciated. Well, it's really needed since i've no clue on how it works at all. Tongue

cheers
Offline JuddMan

Senior Duke


Medals: 1


Your Ad Here


« Reply #1 - Posted 2003-09-27 19:49:28 »

check out the jinputtester app, which is posted athttp://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jinput;action=display;num=1064360336

it has source code included.

soon as the mouse bug with directx is sorted out, all of those things will be possible, except mouse blocking (i think)

if you're doing a full-screen app and want to use jinput for mouse input you will have to draw the cursor and track its position yourself, which leaves the blocking up to you. as for windowed apps im not sure, but just yet, i dont think there's a way to lock the mouse so the OS doesnt let you click outside of the window.

AWT lets you get the exact location of the pointer, but leaves problems for eg. FPS games, but for an RTS or mouse based games, if you're already using AWT, it may be more predictable for your users. (mouse will move at same speed in game as it does in OS for instance)
Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2003-09-28 04:31:57 »

(1)  Yes.  It is a polled input library that supprots keyboard.  Hviong said that, the Win32 plug-in currently queues key-strokes but we've had an action item to fix that for awhile now.

(2)  JInput has nothing to do with cursors.  It is purely a  low level inpout device API.  A cursor is an output device.

(3) A mouse is a relative input device, so yes, it returns dx/dy.  It has no idea of "cursor psoition", thats  a highelr level construct that the OS typically layers  ontop.

Again, the one caveat is that the mouse code in the WIn32 plug-in is currently returning "normalized" data which needs to be changed.


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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline misterX

Junior Duke




java forever!


« Reply #3 - Posted 2003-09-28 06:04:53 »

ah, cool! thanks for the infos.  Smiley

btw, could you also give me the few lines needed? it would really save me a lot of time! Tongue
Offline TheBohemian

Junior Duke




Java will rule them all!


« Reply #4 - Posted 2003-09-28 19:21:29 »

The general idea is the following:

setup controller environment:
Controller[] controllers = ControllerEnvironment.getDefaultControllerEnvironment().getControllers();

Now you have to find the controller you want: You can do this by checking Controller.getType():

myController = retrieveMyController(controllers);

Each controller contains an array of axes (may be empty!) and/or subcontrollers (may be empty as well!).

Typically a gamepad with 4 buttons contains 6 axes:
- 2 for the directions
- 4 for the buttons

Access to all axes is made through Controller.getAxes(). You can determine the type of an axis with Axis.getType().

To read current data from the controller you have to poll it with: Controller.poll()
After that you can retrieve the value of each axis using Axis.getPollData()

When the axis is normalized (keyboard, buttons, etc) you get values in the range [-1,1]. Negative values only make sense for directions on a gamepad/joystick. 0.0 generally means unpressed and 1.0 pressed. Values in between can be generated form analog devices (e.g: joystick).

Analog devices usually never have a relased/unpressed state in which they report 0.0. They differ from that in positive AND negative direction by an amount that can be retrieved with Axes.getDeadZone().

Note: Currently the mouse device is implemented differently on the major plattforms Lin/Mac and Win. On Windows the mouse generates normalized delta values when the Linux/MacOS X version is not nomalized.

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
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.

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

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
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!