Search
Get Started
S
Silk.NET
•
3y ago
ritchie ❤
where do I start in this repo?
where do I start in this repo
?
Silk.NET
Join
A Discord server for the Silk.NET - your one-stop-shop for high-speed .NET multimedia, graphics, and compute. FOSS.
1,747
Members
View on Discord
Was this page helpful?
Yes
No
R
ritchie ❤
where do I start in this repo?
L
Lyris the Kitori
•
2/5/23, 3:31 AM
X11 folder
L
Lyris the Kitori
•
2/5/23, 3:31 AM
you can use QueryKeymap to get the full state
L
Lyris the Kitori
•
2/5/23, 3:32 AM
and the code shows how to get specific keys
L
Lyris the Kitori
•
2/5/23, 3:32 AM
https://github.com/Beyley/NLSKeyset/blob/master/NLSKeyset/X11/XLibB.cs
heres the bindings i wrote which has all the needed stuff
GitHub
NLSKeyset/XLibB.cs at master · Beyley/NLSKeyset
Contribute to Beyley
/NLSKeyset development by creating an account on GitHub
.
R
ritchie ❤
OP
•
2/5/23, 3:32 AM
I want to specifically know when a key is pressed
, and what key was pressed
L
Lyris the Kitori
•
2/5/23, 3:33 AM
in that case you can just set some code on a thread to check every so often the state of the kb
R
ritchie ❤
OP
•
2/5/23, 3:33 AM
I wonder how performent it
'd be to constantly check the keymap with no delay whatsoeever
L
Lyris the Kitori
•
2/5/23, 3:34 AM
itd be a waste of resources
L
Lyris the Kitori
•
2/5/23, 3:34 AM
at
most
you should check 1000 times a second
L
Lyris the Kitori
•
2/5/23, 3:34 AM
and even that is
way
overkill
L
Lyris the Kitori
•
2/5/23, 3:34 AM
125hz is all you need
L
Lyris the Kitori
•
2/5/23, 3:34 AM
(thats what a lot of keyboards use anyway
)
C
chairclr
•
2/5/23, 3:42 AM
itd probably be detrimental to check too fast
R
ritchie ❤
OP
•
2/5/23, 3:45 AM
@baebey slight problem
.
.
.
.
.
R
ritchie ❤
OP
•
2/5/23, 3:45 AM
airflow
.
.
.
.is a command
-line tool
R
ritchie ❤
OP
•
2/5/23, 3:45 AM
there is
, and should be
, no window
L
Lyris the Kitori
•
2/5/23, 3:45 AM
then open a display connection only you dont need a window
R
ritchie ❤
OP
•
2/5/23, 3:46 AM
.
.
.this is your code
, it
's x11keygrabber
, I have no idea how it works
L
Lyris the Kitori
•
2/5/23, 3:47 AM
XOpenDisplay or smthn
L
Lyris the Kitori
•
2/5/23, 3:47 AM
Xlib
.OpenDisplay in those bindings iirc
?
R
ritchie ❤
OP
•
2/5/23, 3:58 AM
when using QueryKeymap
, how do I know how big
should be
L
Lyris the Kitori
•
2/5/23, 3:58 AM
it
's a set size
L
Lyris the Kitori
•
2/5/23, 3:58 AM
32 bytes
R
ritchie ❤
OP
•
2/5/23, 3:58 AM
That
.
.
.doesn
't seem like it
's enough to hold the entire state of a keyboard
.
R
ritchie ❤
OP
•
2/5/23, 3:58 AM
I
'm pretty sure even a TKL has more than 32 keys
L
Lyris the Kitori
•
2/5/23, 3:59 AM
1 bit per key
L
Lyris the Kitori
•
2/5/23, 3:59 AM
32
*8
=256
R
ritchie ❤
OP
•
2/5/23, 3:59 AM
do I interpret it as ASCII then
R
ritchie ❤
OP
•
2/5/23, 3:59 AM
where each bit corresponds to an ASCII character code
L
Lyris the Kitori
•
2/5/23, 3:59 AM
nah
, you do some magic math to check if a certain key is pressed
L
Lyris the Kitori
•
2/5/23, 4:00 AM
https://github.com/Beyley/NLSKeyset/blob/master/NLSKeyset/X11/X11KeyGrabber.cs#L22
GitHub
NLSKeyset/X11KeyGrabber.cs at master · Beyley/NLSKeyset
Contribute to Beyley
/NLSKeyset development by creating an account on GitHub
.
L
Lyris the Kitori
•
2/5/23, 4:00 AM
it
's an X11 keycode
R
ritchie ❤
OP
•
2/5/23, 4:01 AM
and how would I efficiently know if ANY key is pressed
R
ritchie ❤
OP
•
2/5/23, 4:01 AM
because the way this program works
, Delete and Backspace are bad
, any other key is good
, no key being pressed is bad
L
Lyris the Kitori
•
2/5/23, 4:02 AM
if you want to know if any key at all is pressed
, i guess you could iterate 0
-255 which is well fast enough
L
Lyris the Kitori
•
2/5/23, 4:03 AM
it
's simple bitwise math
R
ritchie ❤
OP
•
2/5/23, 4:04 AM
so it
'll return all zeros if nothing
's pressed
?
L
Lyris the Kitori
•
2/5/23, 4:04 AM
iirc yes
R
ritchie ❤
OP
•
2/5/23, 4:22 AM
HOLY SHIT
R
ritchie ❤
OP
•
2/5/23, 4:22 AM
It
's working
!
R
ritchie ❤
OP
•
2/5/23, 4:22 AM
Really
, really badly
!
R
ritchie ❤
OP
•
2/5/23, 4:22 AM
.
.
.pressing one single key gives me
, like
, 30
% more air
R
ritchie ❤
OP
•
2/5/23, 4:23 AM
and the backspace
/delete buttons increase my air instead of decreasing it
R
ritchie ❤
OP
•
2/5/23, 4:29 AM
okay I fixed the one issue where pressing a single key gives you a 3rd of the air meter but I
'm still not sure about the backspace
/delete keys not working
R
ritchie ❤
OP
•
2/5/23, 4:31 AM
@baebey the breakpoint in this screenshot never gets hit D
:
R
ritchie ❤
OP
•
2/5/23, 4:31 AM
R
ritchie ❤
OP
•
2/5/23, 4:31 AM
It thinks the four keycodes are
"constructive
" keypresses
L
Lyris the Kitori
•
2/5/23, 4:31 AM
are you mixing up key syms and key codes
R
ritchie ❤
OP
•
2/5/23, 4:32 AM
I don
't think so
R
ritchie ❤
OP
•
2/5/23, 4:32 AM
these are the variables in question
Next page
returnArr
returnArr