gpt4 book ai didi

how to trigger capslock from code in gnuforth on linux host(如何在linux主机上从gnuforth中的代码触发capslock)

转载 作者:bug小助手 更新时间:2023-10-28 11:45:02 24 4
gpt4 key购买 nike



how to trigger caps lock from code in gnu-forth ?
currently as a temporary solution I use

如何从GNU-FORDS中的代码触发大写锁定?目前作为临时解决方案,我使用


: caps s" xdotool key Caps_Lock" system ;  

I'm looking for either a full gforth code solution either a abi-code assembly solution

我正在寻找一个完整的gforth代码解决方案或一个abi代码汇编解决方案


I also tried many solutions around external nasm code but xdotool is available, so I preferred using it.

我还尝试了许多关于外部NASM代码的解决方案,但xdotool是可用的,所以我更喜欢使用它。


I tried many thing around https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/386-Assembler.html#g_t386-Assembler documentation without result until now.

我尝试了很多关于https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/386-Assembler.html#g_t386-Assembler文档的东西,直到现在都没有结果。


like

喜欢


abi-code toto                                                                                                                                                                                                                                 
0x3A .b al mov
0x02 .b ah mov
0x80 int
ret
end-code

and so on ... without results

以此类推。没有结果


I near solution I think I also tryied to work around asm code below 
; Open /dev/port for I/O operations
mov eax, 5 ; syscall number for sys_open
mov ebx, dev_port ; pointer to the filename "/dev/port"
mov ecx, 2 ; O_RDWR mode
int 0x80 ; Call the kernel

; Enable Caps Lock by sending the scancode to the keyboard controller
mov dx, 0x60 ; Port 0x60 is the keyboard controller data port
mov al, [capslock_scancode]
out dx, al

so how to trigger ON caps-lock from the gnuforth code ?

那么如何从GNOUFORTS代码触发大写锁定呢?


更多回答

Basically, this question isn't about Forth, but about Linux and a windowing system API (I would suggest to add the corresponding tags). See also: Simulate keypress in a Linux C console application, How to simulate a key press in C++ for Linux.

基本上,这个问题不是关于Forth,而是关于Linux和一个窗口系统API(我建议添加相应的标签)。另请参阅:在Linux C控制台应用程序中模拟按键,如何在C++for Linux中模拟按键。

no its is forth oriented // i really not want an external solution but o forth one like insider asm abi-code or a pure forth one // the fact about linux is only the platform nothing to see about C solutions and so on this is out of interest at all here (and optionally stackoverflow disallow enough tags to add more) // using external c or binary is already how I cheat the need as wrote in the first lines of the post

不,ITS是面向FORTH的//我真的不想要外部的解决方案,而是像Insider ASM ABI-code或纯FORT那样的解决方案//关于Linux的事实只是一个平台,没有关于C解决方案的任何东西,等等,这里根本不感兴趣(还可以选择Stackoverflow,不允许添加更多的标记)//使用外部的c或二进制已经是我欺骗需求的方式,正如我在文章的第一行中所写的那样

There isn't really a good solution to this as the terminal abstract does not have knowledge about the caps lock key and thus cannot toggle it.

没有真正好的解决方案,因为终端摘要不知道Caps Lock键,因此无法切换它。

Linux is the kernel, but multiple user-interface software packages can run on top of it. For example the X Window system (typically the x.org implementation), or Wayland, or a text console terminal (with the kernel's own terminal emulation instead of xterm), or full-screen console applications like with SDL which I think get keyboard input via evdev or something like that, not a "terminal".

Linux是内核,但可以在其上运行多个用户界面软件包。例如,X Window System(通常是x.org实现),或Wayland,或文本控制台终端(具有内核自己的终端仿真,而不是xTerm),或者像SDL这样的全屏控制台应用程序,我认为它通过evdev或类似的东西获得键盘输入,而不是“终端”。

Also, unless the system hardware happens to be using a PS/2 keyboard (not USB), an out instruction to port 0x60 isn't going to affect anything, even with iopl or ioperm to make it not segfault, or doing it via /dev/port.

此外,除非系统硬件恰好使用PS/2键盘(而不是USB),否则发送到端口0x60的OUT指令不会产生任何影响,即使使用iopl或iperm来使其不分段错误,或者通过/dev/port来执行。

优秀答案推荐

For today's need , in fact I can just change the logic of it all from why toupper with accept

对于今天的需要,事实上我可以改变它的逻辑,从为什么Toupper与Accept


'toupper' ( c1 -- c2 ) gforth-0.2 "toupper"
'accept' ( c-addr +n1 -- +n2 ) core "accept"

so I needed a capslock trigger but a better solution is to force convertion making a intermediary word to apply toupper over a ( addr len -- addr len )

所以我需要一个胶囊锁触发器,但更好的解决方案是强制转换,使中间字在(addr len--addr len)上应用Toupper


like calling toupper like

就像这样叫Toupper


: >UPPER  ( addr len -- addr len)
2DUP bounds do
I C@ TOUPPER I C! \ convert each char in loop
loop ; \ over the whole string

so I can use

这样我就可以用


pad dup 16 $INPUT >UPPER  

without need to modify the capslock state neither the tty setup

在不需要修改封装锁定状态的情况下,


therefore I am still interested in capslock trigger for future potential needs

因此,我仍然对用于未来潜在需求的胶囊锁触发器感兴趣


更多回答

This post does not answer to the initial question and is not related to it at all. If you want to share this answer, it's better to create a corresponding question and post this answer to it.

这篇文章没有回答最初的问题,也完全与之无关。如果你想分享这个答案,最好是创建一个相应的问题并将这个答案发布到它上面。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com