Remapping minus key on numeric keyboard - ubuntu-20.04

I'm new to linux and even after after searching for more than an hour and help from my IT friends I didn't find a "name" for minus key on numeric keyboard. I'm searching for something like
key <PAUS> { [ Home ] };
key <INS> { [ End ] };
specifically that first part out of the brackets. I've already tried
key <MNS>, key <MINS>, key <MNUS>
but it broke my keyboard (I ended up with EN keyboard), which I assume means, there's a mistake in the code.
Does anybody know the "name"? Thanks.

Open a terminal and:
xev -event keyboard
Press the minus key on numeric keyboard and see the key code.
On my system I obtain this output:
KeyRelease event, serial 28, synthetic NO, window 0x1c00001,
root 0x31b, subw 0x0, time 1053670, (75,41), root:(1768,207),
state 0x0, keycode 82 (keysym 0xffad, KP_Subtract), same_screen YES,
XLookupString gives 1 bytes: (2d) "-"
XFilterEvent returns: False
The keycode is 82
I see from your tag that you are using Ubuntu 20.04.
You can see that the file /usr/share/X11/xkb/symbols/pc has the line:
keycode 82 = KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract XF86Prev_VMode

Related

how to limit 00 to 99 counter to 60

For a simple starter project I was putting together a 2-7segement display 00 to 99 counter coded on sketch.
//The line below is the array containing all the binary numbers for the digits on a SSD from 0 to 9
const int number[11] = {0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000};
I believe that my solution is either to change this part of the code or add another line, I'm just unsure.
Any advice?
I have tried adding another line to set one of the displays to stop at 6 but it didn't compile with the rest of the code.

How to show keystrokes of dead keys in Visual Studio

In Visual Studio I want to use a character which is composed of a dead key plus another key.
I type this : ` + e -> è
VS takes it as : 96 + 101 -> 232 ( and only shows 232)
or in HEx : 0060 + 0065 -> 00e8 ( and only shows 00e8 )
My problem now is that I want to be able to have access to both input key strokes ( eg 96 / 101 ) not the combined. (232) . How do I do that?
In addition I need to be able to distinguish other dead keys like backspace, linefeed, etc.
You could add a U+FEFF (ZERO WIDTH NO-BREAK SPACE) between the two characters U+0060 and U+0065 this will keep the two characters separate but will also treat the three of them as a unit for line break opperations.

Can't hold down a key with AutoHotkey

I have a simple script that doesn't seem to behave as expected:
^j::
Send, {Down down}
Sleep, 10000
Send, {Down up}
Return
I would like it to hold the down arrow key for 10 seconds, and then release. Instead, it presses the down key once, and breaks the script until reload. What am I doing wrong?
Send documentation says:
When a key is held down via the method above, it does not begin auto-repeating like it would if you were physically holding it down (this is because auto-repeat is a driver/hardware feature).
Use SetKeyDelay and specify the number of repetitions:
SetKeyDelay, 30
Send {Down 333}
333 is approximately 10000/30
Alternatively you can do it in a loop and check for other keys in order to stop sending Down key.
Found a nice workaround, try some script like this (adjust the Mynumber variable to your liking and the Sleep aswell)
a::
Mynumber = 10
While Mynumber > 0
{
Send {Down DOWN}
Sleep 10
Send {Down UP}
Mynumber--
}
According to documentation this should work:
To hold down or release a key: Enclose in braces the name of the key followed by the word Down or Up. For example:
Send {b down}{b up}
Send {TAB down}{TAB up}
Send {Up down} ; Press down the up-arrow key.
Sleep 1000 ; Keep it down for one second.
Send {Up up} ; Release the up-arrow key.
docs about holding down keys: https://www.autohotkey.com/docs/commands/Send.htm

What is the meaning of numbers in inline assemble

Do anyone know what the following code does?
I'm not sure what the 1, 2, 3 is refered and how they are used here. :-(
95 asm volatile("2: wrmsr ; xor %[err],%[err]\n"
96 "1:\n\t"
97 ".section .fixup,\"ax\"\n\t"
98 "3: mov %[fault],%[err] ; jmp 1b\n\t"
99 ".previous\n\t"
100 _ASM_EXTABLE(2b, 3b)
101 : [err] "=a" (err)
102 : "c" (msr), "" (low), "d" (high),
103 [fault] "i" (-EIO)
104 : "memory");
105 return err;​
The code is from Linux: http://lxr.free-electrons.com/source/arch/x86/include/asm/msr.h#L91
I really appreciate it ​if anyone could give me some key word to google it.
Thank you very much in advance!
Those are local labels (numbers followed by a colon).
When they are later referenced, the b (as in jmp 1b) means to refer to the nearest local label of that number going backwards. An f would look for a matching local label later (forwards) in the code.
That code declares an exception table, when an exception occurs executing the wrmsr instruction, the fault handler (usually in arch/<your_CPU_arch>/mm/fault.c) searches the exception table for the corresponding entry, and jumps there.
As you can see, the entry for that exception moves EIO into err, and jumps back to the instruction following the xor (which would clear err in case there was no error).

Imitate pressing keyboard F-keys using a Perl script

Is there a way that I can imitate the pressing of a function key (F1-F12) from a Perl script on Windows 7?
I have a program that requires F7 to be pressed in order to stop it.
I have tried killing the program process, but that doesn't stop the process cleanly.
If you're on Windows, Win32::GuiTest can do what you want. They have several examples of using SendKeys to press function keys.
On Unix the situation is both easier and harder. Function keys are usually mapped in a terminal to send several characters. You can find out what they are using ord and sprintf to get their hex values (easier to work with). Here's an example of "kj" as a simple example, then F1 through F7.
$ perl -wle 'while(<>) { chomp; print join ", ", map { sprintf "%x", ord } split //, $_ }'
kj
6b, 6a
^[OP
1b, 4f, 50
^[OQ
1b, 4f, 51
^[OR
1b, 4f, 52
^[OS
1b, 4f, 53
^[[15~
1b, 5b, 31, 35, 7e
^[[17~
1b, 5b, 31, 37, 7e
^[[18~
1b, 5b, 31, 38, 7e
^[[19~
1b, 5b, 31, 39, 7e
ASCII 1b is the escape character (represented on the terminal by a ^[). 5b is [, and so on. So you can print those strings to the program's input or to the tty. For example, F8 would be "\x{1b}[19~".
Why are F1-F4 different? The VT100 terminal, upon which this is all based, only had four function keys. The later VT220 added the rest.
There's probably a module to take care of this for you, but I can't find it.

Resources