M Martin Beukes Member Licensed User Longtime User Mar 21, 2019 #1 Greetings Peeps, I have a weird issue with a specific piece of equipment. When I receive physical keyboard input the app is not converting it properly, but it works on most devices I have tested with. The code is probably going to make more sense than what I write here. I listen for key inputs in Java Code: Code: public boolean _onKeyDown(int KeyCode, KeyEvent event) { switch (KeyCode) { case 31: { processBA.raiseEvent(null, "control_inputs", event.getUnicodeChar()); return true; } default: { return true; } } And I receive the inputs with this: Code: Sub control_inputs(i As Int) If i = 99999 Then Starter.myInputCase = "u" myKeyTimer.Enabled = True Else 'Log(i) Dim s As String = Chr(i) If Starter.myInputCase = "u" Then s = s.ToUpperCase Starter.myInputCase = "" End If If i <> 1 And i <> 2 Then Starter.myInputToken = Starter.myInputToken & s Else Starter.myInputToken = Starter.myInputToken & i End If End Sub I don't know why the device is not returning the proper ascii characters, I can only think it is some kind of encoding error and I don't know how to check it. Thanks, Martin
Greetings Peeps, I have a weird issue with a specific piece of equipment. When I receive physical keyboard input the app is not converting it properly, but it works on most devices I have tested with. The code is probably going to make more sense than what I write here. I listen for key inputs in Java Code: Code: public boolean _onKeyDown(int KeyCode, KeyEvent event) { switch (KeyCode) { case 31: { processBA.raiseEvent(null, "control_inputs", event.getUnicodeChar()); return true; } default: { return true; } } And I receive the inputs with this: Code: Sub control_inputs(i As Int) If i = 99999 Then Starter.myInputCase = "u" myKeyTimer.Enabled = True Else 'Log(i) Dim s As String = Chr(i) If Starter.myInputCase = "u" Then s = s.ToUpperCase Starter.myInputCase = "" End If If i <> 1 And i <> 2 Then Starter.myInputToken = Starter.myInputToken & s Else Starter.myInputToken = Starter.myInputToken & i End If End Sub I don't know why the device is not returning the proper ascii characters, I can only think it is some kind of encoding error and I don't know how to check it. Thanks, Martin
agraham Expert Licensed User Longtime User Mar 21, 2019 #2 It would help if we knew what "not returning the proper ascii characters" actually meant Upvote 0
M Martin Beukes Member Licensed User Longtime User Mar 21, 2019 #3 I mean 'a' or 'b' or 'c' or 'd' when that button was pressed on the physical keyboard Upvote 0
agraham Expert Licensed User Longtime User Mar 21, 2019 #4 So what happens instead? Without knowing what is happening we cannot even start to guess at a solution. Upvote 0
So what happens instead? Without knowing what is happening we cannot even start to guess at a solution.
Erel B4X founder Staff member Licensed User Longtime User Mar 21, 2019 #5 Why aren't you using Activity_KeyPress? Upvote 0
M Martin Beukes Member Licensed User Longtime User Mar 29, 2019 #6 Hi all, sorry, I have been afk. What is happening at the moment on the device that will be used for production is I am getting Chinese characters. There is no android setting I can see that is wrong (not in Latin). On my phone (and about a dozen devices) it works fine. Erel, i need to capture the keydown. I remember at the time of writing the origional code this was the only way to do what I needed. I will test the activity_keypress and see if it can do what I need. Upvote 0
Hi all, sorry, I have been afk. What is happening at the moment on the device that will be used for production is I am getting Chinese characters. There is no android setting I can see that is wrong (not in Latin). On my phone (and about a dozen devices) it works fine. Erel, i need to capture the keydown. I remember at the time of writing the origional code this was the only way to do what I needed. I will test the activity_keypress and see if it can do what I need.
E emexes Expert Licensed User Longtime User Mar 29, 2019 #7 Martin Beukes said: I mean 'a' or 'b' or 'c' or 'd' when that button was pressed on the physical keyboard Click to expand... The way I'm reading the Java code, you are only responding to keycode 31, and so that key's corresponding Unicode character will be the only character you ever see. What is also mildly suspicious is that the Java routine seems to swallow all keystroke events, rather than passing the unhandled keystrokes down the chain. Although I guess this could be reasonable if the app is a game. Upvote 0
Martin Beukes said: I mean 'a' or 'b' or 'c' or 'd' when that button was pressed on the physical keyboard Click to expand... The way I'm reading the Java code, you are only responding to keycode 31, and so that key's corresponding Unicode character will be the only character you ever see. What is also mildly suspicious is that the Java routine seems to swallow all keystroke events, rather than passing the unhandled keystrokes down the chain. Although I guess this could be reasonable if the app is a game.