LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Module programming - keyboard layout (https://www.linuxquestions.org/questions/linux-kernel-70/module-programming-keyboard-layout-4175633482/)

francesco.pileo 07-07-2018 03:28 AM

Module programming - keyboard layout
 
I'm developing a kernel module for didactic purposes, does anyone know a way to get the keyboard layout in use when the module is inserted?

X-LFS-2010 07-07-2018 04:06 PM

# i'm unsure but i need this on debian to get into a "normal mode" so X11 takes essential to operation keystrokes
# i'm unsure how it works
# but if your loading a special module that f's up the keyboard, then use lsmod to see if it's currently loaded?

#!/bin/sh

[ -x /bin/loadkeys ] && {
[ -z "$1" ] && [ -s /etc/console/defkeymap_V1.0.kmap.gz ] && \
/bin/loadkeys -s /etc/console/defkeymap_V1.0.kmap.gz
[ ! -z "$1" ] && [ -s $1 ] && /bin/loadkeys -s $1
}

# make sure debian didn't make console unicode

[ -x /usr/bin/kbd_mode ] && {
/usr/bin/kbd_mode -a
/usr/bin/kbd_mode
}

/bin/true

# KBD_MODE(1) Linux User's Manual KBD_MODE(1)

NAME
kbd_mode - report or set the keyboard mode

SYNOPSIS
kbd_mode [ -auks ]

it comes with "console tools", and the source may show you how it (talks with the kernel)

X-LFS-2010 07-07-2018 04:11 PM

keyboards have been known as a "security item" since the 80's (drivers also chips)

it's not really a toy for teaching. it should be code that is inspected to not allow breaches and operated on "well known chips".

when you add in the factor "they expect it to be internationalized" but want to submit hacked code to do it. it's a disaster to support 2,000 languages.

what i mean is: it's not an introductory topic that hacks should be submitting code changes to - not that your a hack. i'm saying using it as a teaching tool is not a great idea

anyway are you doing this only when another kbd is attacheed? sounds like students could lock their keyboard and maybe damage their computer by forcing a reset

francesco.pileo 07-09-2018 04:26 AM

Quote:

Originally Posted by X-LFS-2010 (Post 5876753)
keyboards have been known as a "security item" since the 80's (drivers also chips)

it's not really a toy for teaching. it should be code that is inspected to not allow breaches and operated on "well known chips".

when you add in the factor "they expect it to be internationalized" but want to submit hacked code to do it. it's a disaster to support 2,000 languages.

what i mean is: it's not an introductory topic that hacks should be submitting code changes to - not that your a hack. i'm saying using it as a teaching tool is not a great idea

anyway are you doing this only when another kbd is attacheed? sounds like students could lock their keyboard and maybe damage their computer by forcing a reset

I'm developing a "malevolent" module that works like a keysniffer. The module works great, but i want to try to translate the keycode to the corresponding key-value, and this depends on the keyboard layout in use.
This module is in the context of an university project, and this is not really dangerous (insmod require super user permissions)


All times are GMT -5. The time now is 07:41 PM.