Jump to content

Textinput


Guppy
 Share

Recommended Posts

Is there a way to get raw key presses in Leadwerks?

 

I mean getting an the actuall letter "A" rather than a Leadwerks::Key::A

 

My first naive approach after noticing that window->keyhitstate was 256 long was to simply convert it to ascii;

 

    std::string inputbuffer="";
    for( int i=0; i < 256; i++ ){
	    if (window->keyhitstate[i]){
               [size=3]inputbuffer[/size]+=static_cast<char>(i);
	    }
    }
    window->FlushKeys();

 

However that gets me all keys as uppercase and f1-12 as lower case letters - and even if it worked there is a very high risk of getting inputs out of order

 

I worry that reading the keys manually will either prevent leadwerks input from working or yield no results as leadwerks already emptied the keyboard buffer.

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

As I continue on this today something has changed - keyhitstate and keydownstate will both only ever hold 1 character, holding down for instance shift and a will result in only the last key pressed being set to true.

 

The same is true for holding down multiple characters.

 

 std::string inputBuffer="";
 int c=0;
 for( int i=0; i < 256; i++ ){
		 if (window->keyhitstate[i]){
			 inputBuffer+=static_cast<char>(i);
			 inputBuffer+=" ["+std::to_string(i)+"]";
			 inputBuffer+=",";
			 c++;
		 }
 }
 if ( c > 0 ) {
	 inputBuffer=std::to_string(c)+" characters: "+inputBuffer;
 }
 window->FlushKeys();

 

I figured this was due to the beta code, but even after uninstalling leadwerks and re-installing and rebuilding my project the problem persists.

 

 

So something else is afoot here, but what?

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

To illustrate the problem more clearly than the above ramblings;

 

Holding down shift and hitting h,e,l,l,o

 

results in:

 

H:16

D:16

H:72

D:72

H:69

D:69

H:76

D:76

H:76

D:76

H:79

D:79

 

with this code

 for( int i=0; i < 256; i++ ){
		 if ( window->keyhitstate[i] )
		 std::cerr << "H:" << std::to_string(i) << std::endl;
		 if ( window->keydownstate[i] )
		 std::cerr << "D:" << std::to_string(i) << std::endl;
 }

 

Where each new letter should also have a D:16

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...