Add Colemak keyboard definition files
Colemak is unusual in that it doesn't have a Caps Lock key. This means we don't need to generate capslock sections in the keymap file. We add a flag to the keymap file [General] section to indicate these sections are missing. A change is also made to the way the Dvorak keymap file (00010409) is generated, for consistency with Colemak.
This commit is contained in:
@@ -18,7 +18,10 @@ kbgen()
|
||||
desc="$2"
|
||||
os="$3"
|
||||
shift 3
|
||||
setxkbmap "$@"
|
||||
if ! setxkbmap "$@"; then
|
||||
echo "Failed to run setxkbmap $*" >&2
|
||||
return 1
|
||||
fi
|
||||
./xrdp-genkeymap \
|
||||
-c "Description: $desc" \
|
||||
-c "Operating system: $os" \
|
||||
@@ -68,7 +71,8 @@ fi
|
||||
kbgen 0406 "da-DK" "$os" -model pc105 -layout dk
|
||||
kbgen 0407 "de-DE" "$os" -model pc104 -layout de
|
||||
kbgen 0409 "en-US" "$os" -model pc104 -layout us
|
||||
kbgen 10409 "en-US" "$os" -model pc104 -layout dvorak
|
||||
kbgen 10409 "en-US" "$os" -model pc104 -layout us -variant dvorak
|
||||
kbgen 60409 "en-US" "$os" -model pc104 -layout us -variant colemak
|
||||
kbgen 040a "es-ES_tradnl" "$os" -model pc105 -layout es
|
||||
kbgen 040b "fi-FI" "$os" -model pc105 -layout 'fi'
|
||||
kbgen 040c "fr-FR" "$os" -model pc105 -layout fr
|
||||
|
||||
+40
-1
@@ -317,6 +317,34 @@ output_file_section(FILE *outf,
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine is caps-lock is supported. Some layouts (e.g. Colemak) do not
|
||||
* support this key.
|
||||
*
|
||||
* @param dpy X display
|
||||
* @reurn boolean
|
||||
*/
|
||||
static int
|
||||
is_caps_lock_supported(Display *dpy)
|
||||
{
|
||||
char dummy[4];
|
||||
KeySym ks;
|
||||
XKeyPressedEvent e =
|
||||
{
|
||||
.type = KeyPress,
|
||||
.serial = 16,
|
||||
.send_event = True,
|
||||
.display = dpy,
|
||||
.state = 0,
|
||||
.keycode = scancode_to_x11_keycode(SCANCODE_CAPS_KEY),
|
||||
.same_screen = True
|
||||
};
|
||||
|
||||
(void)XLookupString(&e, dummy, sizeof(dummy), &ks, NULL);
|
||||
return (ks == XK_Caps_Lock || ks == XK_Eisu_toggle);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Main
|
||||
@@ -345,6 +373,7 @@ int main(int argc, char **argv)
|
||||
const char *keycode_set = NULL;
|
||||
struct kbd_info *kbd_info = NULL;
|
||||
int status = 1;
|
||||
int caps_lock_supported;
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
if (strrchr(argv[0], '/') != NULL)
|
||||
@@ -418,6 +447,8 @@ int main(int argc, char **argv)
|
||||
goto finish;
|
||||
}
|
||||
|
||||
caps_lock_supported = is_caps_lock_supported(dpy);
|
||||
|
||||
fprintf(outf, "# Created by %s V" PACKAGE_VERSION
|
||||
"\n# Key code set: %s\n",
|
||||
programname, keycode_set);
|
||||
@@ -430,10 +461,18 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
fprintf(outf, "\n[General]\nversion=" KEYMAP_FILE_FORMAT_VERSION "\n");
|
||||
fprintf(outf, "caps_lock_supported=%s\n",
|
||||
(caps_lock_supported) ? "true" : "false");
|
||||
|
||||
for (idx = 0; idx < NUM_STATES; idx++) /* Sections and states */
|
||||
{
|
||||
output_file_section(outf, dpy, sections[idx], states[idx]);
|
||||
int mod_state = states[idx];
|
||||
if (!caps_lock_supported && ((mod_state & 2) != 0))
|
||||
{
|
||||
// Skip this section as it's for caps lock
|
||||
continue;
|
||||
}
|
||||
output_file_section(outf, dpy, sections[idx], mod_state);
|
||||
}
|
||||
|
||||
status = 0; // Successful run
|
||||
|
||||
Reference in New Issue
Block a user