user-input

Uinput virtual device is detected as physical keyboard on android

三世轮回 提交于 2019-12-19 11:35:02
问题 I've created a simple native library in C that allows the user to create a device using uinput module. The code seems to work, but there's a problem: my virtual device is detected as physical keyboard and, when I need to write some text, the soft keyboard doesn't appear since android detects a real keyboard connected. How to set this device virtual? If i don't set the keybits it is not detected as a physical keyboard, but I need the keys enabled. #include <string.h> #include <jni.h> #include

Haskell printing strings stdout

丶灬走出姿态 提交于 2019-12-19 10:47:10
问题 I need to print the elements in a powerset. Right now my code's output is this: "a" "ab" "b" "x" "xy" "xyz" "xz" "y" "yz" "z" However, I need the output to not have quotation marks, like this: a ab b x xy xyz xz y yz z This is what I have. How do I fix it do to get the right output? import Data.List powerset = foldr (\x acc -> acc ++ map (x:) acc) [[]] main = do numCases <- getLine repl $ (read numCases :: Int) repl num = do if(num == 0) then return () else do size <- getLine input <- getLine

php - how to validate a regular expression itself?

穿精又带淫゛_ 提交于 2019-12-19 07:49:08
问题 I need to validate user input that might be a regular expression for filtering fields in his/her own application, how can I check the validity of that regex? 回答1: Pass it into a dummy call to preg_match() , and see if it returns false (indicating an error)? Note:: Depending on where you intend this application to be run, I would question the decision to allow users to do this. You could be setting yourself up for a denial-of-service attack; all a malicious user needs to do is provide an

Why my textbox TextChanged event gets fired after I enter “only” one character in my text box?

醉酒当歌 提交于 2019-12-19 07:48:23
问题 private void NameVal_TextChanged(object sender, EventArgs e) { String text = NameVal.Text; } As soon as I enter the first letter of my Name this program gets executed . How do I make the program wait until I finish entering the whole string for the field (such as Name ex: James) is entered. 回答1: If you want to determine when the user has finished typing, you can catch the leave event instead - this is fired when the focus is lost on that text box - ie the user clicks outside of the textbox:

waiting for user input in separate thread

让人想犯罪 __ 提交于 2019-12-19 07:35:15
问题 I am trying to accomplish a way to spawn a thread that waits for user input; if no input is entered within 10 seconds, I want the script to kill off the spawned thread and continue processing. I've got a way to get the input back from the thread if text is entered but I have no way to let the timeout kill off the newly spawned thread. In the example below is the closest I have come. I tell the newly created thread that it is a daemon and it will exit when the main script exits. The issue that

waiting for user input in separate thread

人走茶凉 提交于 2019-12-19 07:35:01
问题 I am trying to accomplish a way to spawn a thread that waits for user input; if no input is entered within 10 seconds, I want the script to kill off the spawned thread and continue processing. I've got a way to get the input back from the thread if text is entered but I have no way to let the timeout kill off the newly spawned thread. In the example below is the closest I have come. I tell the newly created thread that it is a daemon and it will exit when the main script exits. The issue that

Running C scripts with terminal instead of Xcode

让人想犯罪 __ 提交于 2019-12-19 04:52:05
问题 Currently I am developing a couple of C programs on my mac using Xcode. There however is 1 problem. My study requires me to use some sort of input field through the coding. So for instance if the users wants to run the program 10 times or wants the program to create 10 answers. I am using "atoi(argv[1])" just to get the input from the user. This is exactly the problem. As soon as I run the program it just starts to bug, which is normal I quess because he is waiting for the input and not

How to allow multiple inputs from user using R?

◇◆丶佛笑我妖孽 提交于 2019-12-19 03:24:38
问题 For example, if I need that the user specifies the number of rows and columns of a matrix: PROMPT: Number of rows?: USER INPUT: [a number] I need that R 'waits' for the input. Then save [a number] into a variable v1. Next, PROMPT: Number of columns?: USER INPUT: [another number] Also save [another number] into a variable v2. At the end, I will have two variables (v1, v2) that will be used in the rest of the code. "readline" only works for one input at a time. I can't run the two lines

How to make string input in Assembly language?

北慕城南 提交于 2019-12-18 13:26:49
问题 Please, does anybody know how to code string input in assembly language? I'm using int 21 to display and input characters. 回答1: You can use function 0Ah to read buffered input. Given a string buffer in ds:dx it reads a string of up to length 255. The buffer layout is: Byte 0 String length (0-255) Byte 1 Bytes read (0-255, filled by DOS on return) Bytes 2-..Length+2 (The character string including newline as read by DOS). An example of a small COM file that reads a string and then echos it

How to save user input into a variable in html and js

扶醉桌前 提交于 2019-12-18 10:46:20
问题 i am making a game and at the start it asks for your name. I want this name to be saved as varible. i have this html code: <form id="form" onsubmit="return false;"> <input style=position:absolute;top:80%;left:5%;width:40%; type="text" id="userInput"> <input style=position:absolute;top:50%;left:5%;width:40%; type="submit" onclick="name()"> </form> and this is javascript part: function name() { var input = document.getElementById("userInput"); alert(input); } 回答1: It doesn't work because name