Comments (6)
Hey! I'm sorry I haven't been able to get back to this. I'm not exactly sure of the right solution here, but I would love to have this solved. Do you see any downsides with adding this? I guess I'm not sure which situations it won't get input.
It's not like we could detect a down and up input both anyway, right?
from rawdraw.
Hi, yes there might be an issue with physical keyboards. I can try asking around if I can borrow a bluetooth keyboard somewhere. Or do you have one?
But I also now realize that in the current code the order in which the two bDown are sent determines whether the keycode was from a unicode conversion or not. When the key doesn't have a unicode equivalent the order of the bDown
is 1 -> 0. If there is a unicode equivalent it is 0 -> 1.
But I do think it's a bit cumbersome to work with that.
With both up and down inputs do you mean with a modifier? I tried a lot of combinations, but it seems to be either
- Shift with bDown 1
- Key with bDown 0
- Key with bDown 1
- Shift with bDown 0
(Hacker Keyboard does this. Same for CTRL + key or pressing for instance tilde directly)
or
- Shift with bDown 1
- Shift with bDown 0
- Key with bDown 0
- Key with bDown 1
(GBoard does this)
BTW I'm currently making a todo / shopping list:
from rawdraw.
I do have a USB keyboard and otg adapter, hut not sure what I'd need to do
from rawdraw.
Can you add this line to CNFGEGLDriver.c:
int unicode = AndroidGetUnicodeChar( code, AMotionEvent_getMetaState( event ) ); // Line 399
printf("PROKTEST: code:%d, unicode:%d, action:%d\n", code, unicode, AKeyEvent_getAction(event));
if( unicode ) // Line 400
I suppose you don't need AndroidDisplayKeyboard(1);
Then with adb logcat | grep PROKTEST
, if you press Shift + a
it might give the shift key and a capital A (like the virtual keyboard) in this case the bDown and modifier isn't actually needed because the unicode that gets sent already has all the information:
(example hacker keyboard)
PROKTEST: code:59, unicode:0, action:0
PROKTEST: code:29, unicode:65, action:0
PROKTEST: code:29, unicode:65, action:1
PROKTEST: code:59, unicode:0, action:1
(example GBoard)
PROKTEST: code:59, unicode:0, action:0
PROKTEST: code:59, unicode:0, action:1
PROKTEST: code:29, unicode:65, action:0
PROKTEST: code:29, unicode:65, action:1
or a lower case a (like Windows and Linux):
PROKTEST: code:59(?) unicode:0, action:1
PROKTEST: code:(??), unicode:97, action:1
PROKTEST: code:(??), unicode:97, action:0
PROKTEST: code:59(?), unicode:0, action:0
And either way, I'll try whether the current method is sufficient and works for what I can test. So it will use a buffer that says to ignore the next keycode/bDown pair.
from rawdraw.
Using a buffer which ignores duplicate keys on Android seems to work all right. But the solution is a bit quirky and I suppose it is what an app is required to do if it wants text entry.
Here is the code I used. NB it uses an ignore_buffer
which can grow, but doesn't shrink. Because it's silly to make it go above what you normally use and even then I can't get it above size 5 in Hacker Keyboard (CTRL + SHIFT + ALT + "4 diamonds" + A) and not above size 1 in GBoard.
void HandleKey(int keycode, int bDown) {
# ifdef ANDROID
static int * ignore_buffer;
static int ignore_buffer_size;
int found = 0;
for (int i=0; i<ignore_buffer_size; i++) {
if (keycode == ignore_buffer[i]) {
ignore_buffer[i] = 0;
found = 1;
break;
}
}
if (! found) {
int assigned = 0;
for (int i=0; i<ignore_buffer_size; i++) {
if (ignore_buffer[i] == 0) {
ignore_buffer[i] = keycode;
assigned = 1;
break;
}
}
if (! assigned) {
ignore_buffer_size++;
ignore_buffer = realloc(ignore_buffer, ignore_buffer_size * sizeof(int));
ignore_buffer[ignore_buffer_size -1] = keycode;
}
} else {
return;
}
if (keycode == 59 && bDown) return; // Ignore shift key
if (keycode == 'C' && bDown) keycode = '\b'; // Backspace
key = keycode;
# else
/* Windows, Linux code */
# endif
}
from rawdraw.
This looks good to me - if you are interested in committing it. One question, though. How is ignore_buffer populated? It looks like it would corrupt the static area. @Procyon3
from rawdraw.
Related Issues (20)
- Black window on some launches for rawdraw.c (.exe) HOT 3
- Port "triangularizer" for rawdraw from wasm HOT 1
- Running on Apple M1 Silicone HOT 3
- CNFGTackPoly() only drawing the outline HOT 10
- warning: implicit declaration of function 'tolower' HOT 2
- Print error message if OpenGL is not available HOT 2
- Vulkan Support HOT 3
- CNFGOGL not drawing polygons correcly HOT 3
- CNFGBlitImage transparency HOT 1
- CNFGBlitImage performance HOT 12
- Removal of box functions breaks colorchord HOT 1
- Windriver, CNFGHandleInput, PeekMessage should use HWND 0. HOT 1
- Test application crashes when compiling with clang
- [Windows] Handling function keys needs information from msg.lParam in CNFGHandleInput() HOT 3
- rawdraw.c unable to close
- iOS, macOS support based on vger HOT 4
- Issue with texture wrapping HOT 8
- CNFGSetupFullscreen() Not Implemented for Windows HOT 1
- Add MINGW64 support to makefile HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rawdraw.