Incorrect keyboard mapping

Bug #373767 reported by ecishere
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tiemu (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: tiemu

Some keys are mapped incorrectly (ie. arrow keys)

Using kbd_dbg=yes option, some keys are incorrectly defined.
For example, when the left arrow key is pressed output is 'pckey = 71 ()' meaning this is an unrecognised key.
Output should be 'pckey = 71 (PCKEY_LEFT)'
Alphanumeric keys (A-Z,0-9) seem to work, except for 'f' key. Other keys (HOME, PGDN, PGDN, END, arrow, etc.) are incorrectly mapped.

Specifically, pckeys.h in ./src/gui/calc needs to be modified, or another fix.

This behavior appeared since 8.10 and occurs in current release, 9.04

Revision history for this message
Mathias Weyland (launchpad-weyland) wrote :

This is because of the way tiemu handles key press and releases. The mapping for hardware keycodes is hardcoded in src/gui/calc/pckeys.h. Unfortunately, this mapping may differ. That's why certain keys are not working. Furthermore, on my swiss german keyboard, y and z is swapped. Unfortunately, there is no easy solution for this. However, I came up with the following fix:

1.) Use keyvalues instead of hardware keycodes
2.) Add more mappings for instance for the decimal point and the comma

My changes are available in my PPA at https://launchpad.net/~launchpad-weyland/+archive/ppa

To solve the mapping problem, it would only be necessary to implement 1.) in theory. However, I found it extremely annoying not to be able to enter parenthesis, decimal points, pipes etc. with my keyboard. That's why I also implemented 2.). Unfortunately, some important characters like + and * are mapped on top of the numbers on my keyboard and have to be used together with the shift key. This interfers with the way how the calculators handle that key, that's why I disabled the right shift key. Thus, I can use the left shift key for capital letters and the right one for the operators. I also mapped the "second" button to the super ("windows") key because the menu key seems to be used for the context menu.

My changes are based on the current tiemu version 3. Version 2 in ubuntu is seriously outdated and should be replaced anyway (see LP 221332). The PPA may be of use to anyone who needs proper keyboard mappings and for those who may want to adopt my changes. However, the patch needs a cleanup! First, It's going to break any build except for linux, and second, some variables have to be renamed (hardware_keycode is just misleading if we're not dealing with keycodes anymore) and some more mappings have to be added. I'm only using OS 2 for TI-89, so I don't know whether I introduced any bugs for other ROMs. I'm willing to improve the patch if some maintainers decide they want to adopt it, but I have not done so yet because it's working good enough for me.

regards

Matt

Revision history for this message
launchpadmember (lpuser1138) wrote :

The above post is fairly old by now, and as a result I was wondering if any one had any updates as to the progress of this unfortunate problem with tiemu on Ubuntu.

For my own issues with tiemu I need to know the correct key mappings for TiEMU v3.02, using a Ti89 titanium ROM, inside Ubuntu 11.04.

Generally:
Could you please provide some more detail on how you were able to fix the key mappings?

Specifically:
It would help if you could provide an example of some important lines in your keymap file so that I might get some idea of how to solve the problem on my end. Also, any examples of
1.) How you found the hardware key codes for your keybord.
2.) How you found what those key codes were being interpreted as inside TiEMU
3.) ...and how you got TiEMU to recognize the key codes correctly.
...would be a huge help and might go a long way to helping others figure out how to create a solution for there own particular OS / distro / TiEmu version etc.

P.S. If your still around, is your ppa still active, would it solve my issues as described earlier in this post?

Thanks.
Hope someone is still around to answer this one.

Revision history for this message
launchpadmember (lpuser1138) wrote :

Update:
Mathias Weyland's ppa isn't responding. I've tried several servers both in the US and through proxies in other countries and can not get a connection to Weyland's ppa at the moment.

If this ppa is no longer active can someone else please step in and help shed some light on how Weyland might have figured out how to fix the keymap from scratch.

I've read through the documentation, but either the documentation doesn't say anything about what a hardware keycode looks like in tiemu format, or if tiemu even needs a special format for a keycode, or how to find a keycode, or any examples of how to map a "hardware keycode" in tiemu's keymap file, or any alternate methods of mapping keys for tiemu besides the ones mentioned in the keymap file etc. or I just havent found where it says any of that stuff, in any of the documentation yet.

If you know any of the answers please feel free to share them.
Thanks.

Revision history for this message
Mathias Weyland (launchpad-weyland) wrote :
Download full text (4.7 KiB)

Hello

Yes I am still around and you probably got lucky because I need this fix for a class I am teaching once a year and I am currently preparing that class. I have not touched the tiemu part yet, though.

It has to be said that this fix is not complete at all, it is more of a hack to allow me to use some keys during said class. It should be fairly easy to add additional mappings to suit your needs, though.

In general, this diff may help you to see what I did:

https://launchpad.net/~launchpad-weyland/+archive/ppa/+files/tiemu_3.02-1ubuntu2ppa1.diff.gz

I just realised that this patch contains more stuff than it should, so here is a brief walkthrough of what I did:

1. Define keynames with their appropriate pckey number. This is done in tiemu-3.02/src/gui/calc/pckeys.h. Apparently, I am making use of gdkkeysyms.h definitions here. I don't quite remember why I did this but I don't see any reason why this is critical, so it was probably bare convenience or something.

Example:
#define PCKEY_PERIOD GDK_period
#define PCKEY_PIPE GDK_bar
#define PCKEY_EQUALS GDK_equal

2. Assign strings to these definitions. This is done in tiemu-3.02/src/gui/calc/keynames.c.

Example:
    { PCKEY_PERIOD, "PCKEY_PERIOD" },
    { PCKEY_PIPE, "PCKEY_PIPE" },
    { PCKEY_EQUALS, "PCKEY_EQUALS" },

3. Map these strings to the appropriate ti key. This is done in tiemu-3.02/skins/ti89.map.

Example:
PCKEY_PERIOD:TIKEY_PERIOD
PCKEY_PIPE:TIKEY_PIPE
PCKEY_EQUALS:TIKEY_EQUALS

4. Because I used the gdk definitions above, I have to add the proper translation in tiemu-3.02/src/gui/calc/keyboard.c:

 - return hwkey_to_tikey(event->hardware_keycode, !0) ? TRUE : FALSE;
+ {
+ if(!hwkey_to_tikey(event->keyval, !0))
+ {
+ guint newkeyval;
+ GdkKeymap *keymap = gdk_keymap_get_default();
+ gdk_keymap_translate_keyboard_state(
+ keymap, event->hardware_keycode, 0, event->group,
+ &newkeyval,NULL,NULL,NULL);
+ return hwkey_to_tikey(newkeyval, !0) ? TRUE : FALSE;
+ }
+ return TRUE;
+ }

[...]

- return hwkey_to_tikey(event->hardware_keycode, 0) ? TRUE : FALSE;
+ if(!hwkey_to_tikey(event->keyval, 0))
+ {
+ guint newkeyval;
+ GdkKeymap *keymap = gdk_keymap_get_default();
+ gdk_keymap_translate_keyboard_state(
+ keymap, event->hardware_keycode, 0, event->group,
+ &newkeyval,NULL,NULL,NULL);
+ return hwkey_to_tikey(newkeyval, 0) ? TRUE : FALSE;
+ }
+ return TRUE;

(the information in the patch shows where this has to be put. To be honest it looks quite messy and I am not even sure that I knew what I was doing, so I guess I will have to revise this anyway. I remember that I did this the night before the first time I had to teach the class and time was not exactly the resource I had at hands.)

One additional note: Both the left and the right shift keys are mapped to the TI89 shift key by default. I did not like this and removed the binding of the right shift key. This allows me to use the TI89 shift using my left shift key and pass through capital letters using a combination with the right shift ...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.