Guppy Posted September 7, 2014 Share Posted September 7, 2014 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. Quote 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 More sharing options...
Josh Posted September 7, 2014 Share Posted September 7, 2014 There's probably no real disadvantage to the way you describe above. An out of order key would probably be a pretty rare event. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
DerRidda Posted September 7, 2014 Share Posted September 7, 2014 http://www.leadwerks.com/werkspace/topic/10578-is-there-any-way-to-get-a-keymouse-button-directly-in-lua/ Also want that. 1 Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 9, 2014 Author Share Posted September 9, 2014 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? Quote 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 More sharing options...
Guppy Posted September 9, 2014 Author Share Posted September 9, 2014 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 Quote 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 More sharing options...
Recommended Posts
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.