Skip to contentSkip to conversation

Fn + [KEYS] question

DISCUSSION Xiangfu Liu 2 participants 13 messages Sep 16, 2009 – Sep 18, 2009 HID

lore
Share & tools
lore
#0 lore raw

Hi

I know in the IBM laptop, you use Fn + F1 to do something. I want [Fn + U = 7] in my device.
when you press Fn + U in the terminal it will display '7'.

I look into the keyboard.c file.
but don't know which function is handle the Fn key?

there is [1] in the keyboard.h file. I don't know
which Fn key belong. is it KT_SHIFT???

thanks for any advice.

[1] -------------
#define KT_LATIN 0 /* we depend on this being zero */
#define KT_LETTER 11 /* symbol that can be acted upon by CapsLock */
#define KT_FN 1
#define KT_SPEC 2
#define KT_PAD 3
#define KT_DEAD 4
#define KT_CONS 5
#define KT_CUR 6
#define KT_SHIFT 7
#define KT_META 8
#define KT_ASCII 9
#define KT_LOCK 10
#define KT_SLOCK 12
#define KT_DEAD2 13
#define KT_BRL 14

Signature · 3 lines
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com
#1 lore raw
Quoted 7 lines · Xiangfu Liu

Hi

I know in the IBM laptop, you use Fn + F1 to do something. I want [Fn + U = 7] in my device.
when you press Fn + U in the terminal it will display '7'.

Quoted 6 lines

I look into the keyboard.c file.
but don't know which function is handle the Fn key?

there is [1] in the keyboard.h file. I don't know
which Fn key belong. is it KT_SHIFT???

Fn in laptops usually handled by firmware (OS does not see the scancode for Fn at all). In your driver you will probably have to handle it manually and adjust which keycode you emit (KEY_Y or KEY_7) depending on whether Fn is active or not. I'd recommend not hardcoding KEY_* but actually "shift" to different part of driver keymap so userspace could change the keycodes if it wishes to do so.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 15 lines · Dmitry Torokhov
Quoted 7 lines · Xiangfu Liu

Hi

I know in the IBM laptop, you use Fn + F1 to do something. I want [Fn + U = 7] in my device.
when you press Fn + U in the terminal it will display '7'.

Quoted 6 lines

I look into the keyboard.c file.
but don't know which function is handle the Fn key?

there is [1] in the keyboard.h file. I don't know
which Fn key belong. is it KT_SHIFT???

Quoted 6 lines

Fn in laptops usually handled by firmware (OS does not see the scancode for Fn at all). In your driver you will probably have to handle it manually and adjust which keycode you emit (KEY_Y or KEY_7) depending on whether Fn is active or not. I'd recommend not hardcoding KEY_* but actually "shift" to different part of driver keymap so userspace could change the keycodes if it wishes to do so.

Hi Dmitry
thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

thanks for help.

[1] http://downloads.qi-hardware.com/hardware/mechanical/ben/2009_08_26/keyboard_problem_2.JPG

Quoted 1 line
Signature · 3 lines
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com
#3 lore raw
Quoted 27 lines · Xiangfu Liu
Quoted 15 lines · Dmitry Torokhov
Quoted 7 lines · Xiangfu Liu

Hi

I know in the IBM laptop, you use Fn + F1 to do something. I want [Fn + U = 7] in my device.
when you press Fn + U in the terminal it will display '7'.

Quoted 6 lines

I look into the keyboard.c file.
but don't know which function is handle the Fn key?

there is [1] in the keyboard.h file. I don't know
which Fn key belong. is it KT_SHIFT???

Quoted 6 lines

Fn in laptops usually handled by firmware (OS does not see the scancode for Fn at all). In your driver you will probably have to handle it manually and adjust which keycode you emit (KEY_Y or KEY_7) depending on whether Fn is active or not. I'd recommend not hardcoding KEY_* but actually "shift" to different part of driver keymap so userspace could change the keycodes if it wishes to do so.

Hi Dmitry
thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

Quoted 9 lines

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

Signature · 1 line
Dmitry
#4 lore raw

Hi Dmitry

Quoted 8 lines
Quoted 8 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

Quoted 9 lines
Quoted 5 lines

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Signature · 3 lines
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com
#5 lore raw
Quoted 15 lines · Xiangfu Liu

Hi Dmitry

Quoted 13 lines
Quoted 13 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Quoted 9 lines
Quoted 3 lines

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Hi Dmitry I found this[1] in the 'man keymaps', three are 9 modifiers. but the in defkaymap.map, there is alwasy like:

control keycode 53 = Delete

there is no ctrll in the defkeymap.map.
how to implement this?
ShiftL + u = U
ShiflR + u = 7

thansk for help

[1]
Which of the actions bound to a given key is taken when it is pressed depends on what modifiers are in effect at
that moment. The keyboard driver supports 9 modifiers. These modifiers are labeled (completely arbitrarily) Shift, AltGr, Control, Alt, ShiftL, ShiftR, CtrlL, CtrlR and CapsShift. Each of these modifiers has an associated weight of power of two according to the following table:

modifier weight

Shift 1
AltGr 2
Control 4
Alt 8
ShiftL 16
ShiftR 32
CtrlL 64
CtrlR 128
CapsShift 256

Signature · 3 lines
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com
#6 lore raw
Quoted 28 lines · Xiangfu Liu
Quoted 15 lines · Xiangfu Liu

Hi Dmitry

Quoted 13 lines
Quoted 13 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Quoted 9 lines
Quoted 3 lines

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Hi Dmitry I found this[1] in the 'man keymaps', three are 9 modifiers. but the in defkaymap.map, there is alwasy like:

Quoted 8 lines

control keycode 53 = Delete

there is no ctrll in the defkeymap.map.
how to implement this?

ShiftL + u = U
ShiflR + u = 7

The same as with AltGr you need to do

keycode XX = CtrlR

and then

keycode YY = u
shift keycode YY = U
ctrlr keycode YY = seven

Let me know if this works.

Signature · 1 line
Dmitry
#7 lore raw
Quoted 39 lines · Dmitry Torokhov
Quoted 27 lines · Xiangfu Liu
Quoted 15 lines · Xiangfu Liu

Hi Dmitry

Quoted 13 lines
Quoted 13 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Quoted 8 lines
Quoted 3 lines

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Hi Dmitry I found this[1] in the 'man keymaps', three are 9 modifiers. but the in defkaymap.map, there is alwasy like:

Quoted 8 lines

control keycode 53 = Delete

there is no ctrll in the defkeymap.map.
how to implement this?

ShiftL + u = U
ShiflR + u = 7

The same as with AltGr you need to do

Quoted 7 lines

keycode XX = CtrlR

and then

keycode YY = u
shift keycode YY = U
ctrlr keycode YY = seven

Hi Dmitry
thanks for the reply. I test this, it's not work.
----------

$ loadkeys -m defkeymap.map > defkeymap.c && rm defkeymap.o
loadkeys: defkeymap.map:71: adding map 64 violates explicit keymaps line

I look into the keyboard.c, in the kbd_keycode function seems this "keysym = key_map[keycode];" make the CtrlL and CtrlR map to the Ctrl. so I change the keyboard.c[1] code like:

1. when press CtrlR pass, change back the Ctrl to CtrlR.
2. in the k_shift function set a sign [shift_right] to 1
3. change the CtrlR to Ctrl in k_shift funtion. other code will only know the Ctrl. not the CtrlR.
4. when press "u" and [shift_right] is true change the keysym to "1" others are same.

_I think the code is not good. so if someone have any idea._ _just let me know._

thanks.

[1]
-----------------------
@@ -800,7 +805,15 @@ static void k_shift(struct vc_data *vc, unsigned char value, char up_flag)

                        clr_vc_kbd_led(kbd, VC_CAPSLOCK);
        }

+ if (value == KVAL(K_CTRLR)) {
+ shift_right = 1;
+ value = KVAL(K_CTRL);
+ }
+

        if (up_flag) {

+ shift_right = 0;
/*
* handle the case that two shift or control
* keys are depressed simultaneously
@@ -1284,6 +1297,20 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)

        if (raw_mode && type != KT_SPEC && type != KT_SHIFT)
                return;

+ if (keysym == 61461 && shift_right == 1)//61461 is CtrlR + U
+ keysym = 61489; //61489 is "1"
+ if (keysym == 61449 && shift_right == 1)
+ keysym = 61490;
+ if (keysym == 64367 && shift_right == 1)
+ keysym = 61491;
+
+ if (keycode == KEY_RIGHTCTRL)
+ keysym += 5;

//KEY_CTRL = 2
//KEY_RIGHTCTRL = 7 form the keyboard.h file

        (*k_handler[type])(vc, keysym & 0xff, !down);
 
        param.ledstate = kbd->ledflagstate;
Quoted 3 lines

Let me know if this works.

Signature · 3 lines
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com
#8 lore raw
Quoted 48 lines · Xiangfu Liu
Quoted 39 lines · Dmitry Torokhov
Quoted 28 lines · Xiangfu Liu
Quoted 16 lines · Xiangfu Liu

Hi Dmitry

Quoted 14 lines
Quoted 13 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Quoted 7 lines
Quoted 2 lines

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Hi Dmitry I found this[1] in the 'man keymaps', three are 9 modifiers. but the in defkaymap.map, there is alwasy like:

Quoted 7 lines

control keycode 53 = Delete

there is no ctrll in the defkeymap.map.
how to implement this?

ShiftL + u = U
ShiflR + u = 7

The same as with AltGr you need to do

Quoted 7 lines

keycode XX = CtrlR

and then

keycode YY = u
shift keycode YY = U
ctrlr keycode YY = seven

Quoted 5 lines

Hi Dmitry
thanks for the reply. I test this, it's not work.
----------

$ loadkeys -m defkeymap.map > defkeymap.c && rm defkeymap.o
loadkeys: defkeymap.map:71: adding map 64 violates explicit keymaps line

You need to fix this ^^^^ first.

Signature · 1 line
Dmitry
#9 lore raw
Quoted 44 lines · Dmitry Torokhov
Quoted 43 lines · Xiangfu Liu
Quoted 42 lines · Dmitry Torokhov
Quoted 25 lines · Xiangfu Liu
Quoted 15 lines · Xiangfu Liu

Hi Dmitry

Quoted 13 lines
Quoted 13 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Quoted 6 lines
Quoted 2 lines

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Hi Dmitry I found this[1] in the 'man keymaps', three are 9 modifiers. but the in defkaymap.map, there is alwasy like:

Quoted 7 lines

control keycode 53 = Delete

there is no ctrll in the defkeymap.map.
how to implement this?

ShiftL + u = U
ShiflR + u = 7

The same as with AltGr you need to do

keycode XX = CtrlR

and then

keycode YY = u
shift keycode YY = U
ctrlr keycode YY = seven

Quoted 8 lines
Quoted 5 lines

Hi Dmitry
thanks for the reply. I test this, it's not work.
----------

$ loadkeys -m defkeymap.map > defkeymap.c && rm defkeymap.o
loadkeys: defkeymap.map:71: adding map 64 violates explicit keymaps line

You need to fix this ^^^^ first.

the line 71 is the "ctrlr ....", so I think the defkeymap.map not support the "ctrlr".

Signature · 3 lines
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com
#10 lore raw
Quoted 51 lines · Xiangfu Liu
Quoted 50 lines · Dmitry Torokhov
Quoted 48 lines · Xiangfu Liu
Quoted 35 lines · Dmitry Torokhov
Quoted 25 lines · Xiangfu Liu
Quoted 15 lines · Xiangfu Liu

Hi Dmitry

Quoted 13 lines
Quoted 13 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Quoted 6 lines
Quoted 2 lines

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Hi Dmitry I found this[1] in the 'man keymaps', three are 9 modifiers. but the in defkaymap.map, there is alwasy like:

Quoted 7 lines

control keycode 53 = Delete

there is no ctrll in the defkeymap.map.
how to implement this?

ShiftL + u = U
ShiflR + u = 7

The same as with AltGr you need to do

Quoted 7 lines

keycode XX = CtrlR

and then

keycode YY = u
shift keycode YY = U
ctrlr keycode YY = seven

Hi Dmitry
thanks for the reply. I test this, it's not work.
----------

$ loadkeys -m defkeymap.map > defkeymap.c && rm defkeymap.o
loadkeys: defkeymap.map:71: adding map 64 violates explicit keymaps line
Quoted 5 lines
Quoted 2 lines

You need to fix this ^^^^ first.

the line 71 is the "ctrlr ....", so I think the defkeymap.map not support the "ctrlr".

Please look at the very beginning of the file where there is "keymaps" statement - you need to enable keymap 64.

Signature · 1 line
Dmitry
#11 lore raw
Quoted 51 lines · Dmitry Torokhov
Quoted 50 lines · Xiangfu Liu
Quoted 49 lines · Dmitry Torokhov
Quoted 48 lines · Xiangfu Liu
Quoted 35 lines · Dmitry Torokhov
Quoted 25 lines · Xiangfu Liu
Quoted 15 lines · Xiangfu Liu

Hi Dmitry

Quoted 13 lines
Quoted 13 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Quoted 6 lines
Quoted 2 lines

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Hi Dmitry I found this[1] in the 'man keymaps', three are 9 modifiers. but the in defkaymap.map, there is alwasy like:

Quoted 7 lines

control keycode 53 = Delete

there is no ctrll in the defkeymap.map.
how to implement this?

ShiftL + u = U
ShiflR + u = 7

The same as with AltGr you need to do

Quoted 7 lines

keycode XX = CtrlR

and then

keycode YY = u
shift keycode YY = U
ctrlr keycode YY = seven

Hi Dmitry
thanks for the reply. I test this, it's not work.
----------

$ loadkeys -m defkeymap.map > defkeymap.c && rm defkeymap.o
loadkeys: defkeymap.map:71: adding map 64 violates explicit keymaps line
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

You need to fix this ^^^^ first.

the line 71 is the "ctrlr ....", so I think the defkeymap.map not support the "ctrlr".

Please look at the very beginning of the file where there is "keymaps" statement - you need to enable keymap 64.

Hi Dmitry.
very thanks. it's work now.
I need work hard in learn English :-)

Signature · 3 lines
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com
#12 lore raw
Quoted 58 lines · Xiangfu Liu
Quoted 57 lines · Dmitry Torokhov
Quoted 55 lines · Xiangfu Liu
Quoted 44 lines · Dmitry Torokhov
Quoted 43 lines · Xiangfu Liu
Quoted 42 lines · Dmitry Torokhov
Quoted 25 lines · Xiangfu Liu
Quoted 15 lines · Xiangfu Liu

Hi Dmitry

Quoted 13 lines
Quoted 13 lines

thanks for the reply.
see [1], I change the [Red arrow] key to [ALTGR] then I can easy change the defkeymap.map. make all the red keys work.

but for the [Blue Fn] key. I don't know how to make it work in keymap? there is [SHIFT] [CONTROL] [SHIFT] [ALTGR] four modifier keys. all used. so I can not may the [Fn] to those four modifier keys.

can I make the leftAlt and rightAlt generate different keys? like:
LeftAlt + 'U' = Alt + 'U'
RightAlt + 'U' = '7'

Quoted 6 lines
Quoted 2 lines

Keyboard driver supports 9 modifiers total, you should be able use one of these for your numeric buttons.

oh. can you give me some tips on the other modifiers. how to define them?
can I just change the defkeymap.map file?
or I must change the source code?

Hi Dmitry I found this[1] in the 'man keymaps', three are 9 modifiers. but the in defkaymap.map, there is alwasy like:

Quoted 7 lines

control keycode 53 = Delete

there is no ctrll in the defkeymap.map.
how to implement this?

ShiftL + u = U
ShiflR + u = 7

The same as with AltGr you need to do

keycode XX = CtrlR

and then

keycode YY = u
shift keycode YY = U
ctrlr keycode YY = seven

Quoted 7 lines
Quoted 5 lines

Hi Dmitry
thanks for the reply. I test this, it's not work.
----------

$ loadkeys -m defkeymap.map > defkeymap.c && rm defkeymap.o
loadkeys: defkeymap.map:71: adding map 64 violates explicit keymaps line

You need to fix this ^^^^ first.

the line 71 is the "ctrlr ....", so I think the defkeymap.map not support the "ctrlr".

Quoted 5 lines
Quoted 3 lines

Please look at the very beginning of the file where there is "keymaps" statement - you need to enable keymap 64.

Hi Dmitry.
very thanks. it's work now.

Great! I am glad to hear you were able to work this out.

Signature · 1 line
Dmitry