Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (778)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
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 2959 times)
0 Members and 1 Guest are viewing this topic.
Offline misterX

Junior Devvie

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

Offline JuddMan

Senior Devvie

Medals: 1

Your Ad Here

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

check out the jinputtester app, which is posted at;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!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline misterX

Junior Devvie

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 Devvie

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.



my favorite OS:
Java 1.5 -> 1.4 converter:
Pages: [1]
  ignore  |  Print  

hadezbladez (353 views)
2018-11-16 13:46:03

hadezbladez (184 views)
2018-11-16 13:41:33

hadezbladez (356 views)
2018-11-16 13:35:35

hadezbladez (86 views)
2018-11-16 13:32:03

EgonOlsen (2179 views)
2018-06-10 19:43:48

EgonOlsen (2221 views)
2018-06-10 19:43:44

EgonOlsen (1379 views)
2018-06-10 19:43:20

DesertCoockie (2012 views)
2018-05-13 18:23:11

nelsongames (1671 views)
2018-04-24 18:15:36

nelsongames (2310 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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‑
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!