Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
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  
  JInput question  (Read 2706 times)
0 Members and 1 Guest are viewing this topic.
Offline kuldar

Senior Newbie

« Posted 2008-07-10 10:28:47 »

Hey! Im making a controller config option for my game and I came across a little bug. Program works like this:
If Button is pressed on config screen, it calls for input.update() which polls every device (limited it to keyboard and gamepads) and returns a vector of strings. Now config program reads firstElement of the vector and assigns it as label text.
Anyways, if you pressed lets say "any" key before actually pressing any button and then pressed the button to assign a value, it would assign it as "any" key. Is there a way to clear input buffer or smth? Smiley

Question 2: Is it good to save config as a file and in the main program if any key is pressed it checks if that key's value is assigned to any function? (eg. Player 1 assigned "X" key to attack on his gamepad and if "X" key is pressed in game, it would make him attack?)
Offline kuldar

Senior Newbie

« Reply #1 - Posted 2008-07-15 07:28:50 »

Nice to see that this forum is full of active members.  Undecided
Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

« Reply #2 - Posted 2008-07-16 06:31:28 »

No, there is no way to clear the buffer. If you know you are going to press a key to get past the menu, read the first value and ignore it.

Yes, saving the config is a good idea.

Sorry for going away for a week, I'll try not to take any holiday and inconvenience anyone again :p.


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

Senior Newbie

« Reply #3 - Posted 2008-07-20 16:31:14 »

Ty! Since the subject is jinput question, I'm going to ask another question about it. Smiley
Is it normal if my comp can flip through empty program like this:

class Test
    public static void main(String args[])
        int frames = 0;
        long timer = System.currentTimeMillis();
            if(System.currentTimeMillis() >= timer + 1000)
                System.out.println("fps: " + frames);
                frames = 0;
                timer = System.currentTimeMillis();

-> about 17 million times per second and with input checking for Keyboard and 2x Joysticks(with exclusion of additional hardware like mouse, etc) about 45 000 times/s or does my jinput code blow? Smiley

E: Nevermind after I used randomly colored and positioned QL_QUADS those frames were 585 per update w/o jinput and 550 w/ it.
Pages: [1]
  ignore  |  Print  

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

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

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

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

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

nelsongames (1709 views)
2018-04-24 18:14:32

ivj94 (2533 views)
2018-03-24 14:47:39

ivj94 (1758 views)
2018-03-24 14:46:31

ivj94 (2836 views)
2018-03-24 14:43:53

Solater (971 views)
2018-03-17 05:04:08
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!