Comments (4)
The main difference is that CHAR gives you the UNICODE code point of what's printed on the keyboard key (assuming correct keyboard layout settings in the OS), while the KEY events are "virtual key codes" which are independent from any international keyboard layout.
E.g. for text input you would use CHAR events, and for game controls you would use KEY events.
What do you mean with "behaves like text inputs" for KEY events, the key repeat?
If you're just interested in whether a key is currently held down, you need to track that yourself. For example see here in pacman.c:
https://github.com/floooh/pacman.c/blob/090c18849c49fb162c27afb0b959bd9fda885f0c/pacman.c#L770-L800
...eventually there might be a separate header which provides such a polling API on top of input events, but that's quite low on the priority stack.
from sokol.
Thank you for the response. Following the pacman.c example, It worked smoothly. What I meant by behave like text inputs
is a delay after the first key tick If you are holding down the key. Like: a__aaaaaaaaa.
Too bad I have to keep the state of every key I wanted but It is what it is.
Other than that, are there possible SDL/Sokol usage examples out there, If you are aware? I found a lot of examples for OpenGL but the main reason I'm using Sokol is DXD11 and Metal support.
from sokol.
is a delay after the first key tick If you are holding down the key. Like: a__aaaaaaaaa.
Ah right, yeah that might be a bit confusing for "raw" key input, but that's how the underlying operating system events behave. There's a bool key_repeat
field in the event struct which you can use to detect and ignore such followup events if desired:
Line 1413 in 17b399b
Closing this ticket if that's ok :)
from sokol.
PS:
Other than that, are there possible SDL/Sokol usage examples out there,
Not that I know of unfortunately. The sokol-samples have examples for GLFW+GL (https://github.com/floooh/sokol-samples/tree/master/glfw) plus a very simple example for GLFW+Metal (https://github.com/floooh/sokol-samples/blob/master/glfw/metal-glfw.m).
I haven't attempted to use SDL with sokol_gfx.h so far though.
from sokol.
Related Issues (20)
- [webgpu] Bindgroups cache breaks down with init/uninit pattern.
- macOS huge memory usage when window minimized HOT 1
- Questions regarding default GL version HOT 5
- App Window Size on Android HOT 3
- Default value _sg_gl_uniform_t::gl_loc when uniform_desc's name isn't given in sokol_gfx HOT 1
- sokol_gfx.h: wrong define in log related to SOKOL_TRACE_HOOKS HOT 1
- WebGPU TextureView validation error HOT 6
- sokol_fetch on Android
- partial updates to buffers/textures (e.g. offset and size args to glBufferSubData, glTexSubImage) HOT 1
- Right shift is recognized as "invalid key" on Windows. HOT 9
- SAPP_EVENT_CHAR for Space is fired when Ctrl+Space is pressed. HOT 2
- Key events on Linux always use the **first** keyboard layout in the system's keyboard layout list. HOT 1
- Continuous Bind Slots Restriction Unnecessary? HOT 3
- Feature request: Please drop the direct use of int, short, etc in favour of int_least32_t, int_least16_t HOT 9
- attributeless rendering support HOT 2
- WebGL Offscreen rending is broken in Chrome v127 on Mac M1 and MacOS 14.5. HOT 22
- Manage AltGr key combinations in windows backends HOT 2
- windows WM_TOUCH events? HOT 3
- WebGL context lost handling HOT 2
- sokol_gl.h: should not skip rendering completely if a 'FULL' error is encountered.
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 sokol.