how to trigger capslock from code in gnuforth on linux host

87 Views Asked by At

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

: caps s" xdotool key Caps_Lock" system ;  

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

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

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.

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 ?

1

There are 1 best solutions below

1
francois P On

For today's need , in fact I can just change the logic of it all from why toupper with 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 )

like calling toupper like

: >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