New Mois keymap

Wasabi

27-10-2008 19:50:46

Hi sorry if exsist a topic like this but i don't found it

now my problem I have a Germen Keybord but the Mois only support englisch key bords an i have allredy changet the keycodes in the ois


//ALPHA NUMMERIC
KC_A = 0x1C, // A
KC_B = 0x32, // B
KC_C = 0x21, // C
KC_D = 0x23, // D
KC_E = 0x24, // E
KC_F = 0x2B, // F
KC_G = 0x34, // G
KC_H = 0x33, // H
KC_I = 0x43, // I
KC_J = 0x3B, // J
KC_K = 0x42, // K
KC_L = 0x4B, // L
KC_M = 0x3A, // M
KC_N = 0x31, // N
KC_O = 0x44, // O
KC_P = 0x4D, // P
KC_Q = 0x15, // Q
KC_R = 0x2D, // R
KC_S = 0x1B, // S
KC_T = 0x2C, // T
KC_U = 0x3C, // U
KC_V = 0x2A, // V
KC_W = 0x1D, // W
KC_X = 0x22, // X
KC_Y = 0x35, // Y
KC_Z = 0x1A, // Z
//NUMMERIC
KC_0 = 0x45, // 0
KC_1 = 0x16, // 1
KC_2 = 0x1E, // 2
KC_3 = 0x26, // 3
KC_4 = 0x25, // 4
KC_5 = 0x2E, // 5
KC_6 = 0x36, // 6
KC_7 = 0x3D, // 7
KC_8 = 0x3E, // 8
KC_9 = 0x46, // 9
//NUMPAD
KC_NUMLOCK = 0x77, // NUMLOCK
KC_NUMPAD0 = 0x70, // 0
KC_NUMPAD1 = 0x69, // 1
KC_NUMPAD2 = 0x72, // 2
KC_NUMPAD3 = 0x7A, // 3
KC_NUMPAD4 = 0x6B, // 4
KC_NUMPAD5 = 0x73, // 5
KC_NUMPAD6 = 0x74, // 6
KC_NUMPAD7 = 0x6c, // 7
KC_NUMPAD8 = 0x75, // 8
KC_NUMPAD9 = 0x7D, // 9
KC_DECIMAL = 0x71, // .
KC_NUM_EN = 0x5A, // ENTER
KC_ADD = 0x79, // +
KC_SUBTRACT = 0x7B, // -
KC_NUM_TIM = 0x7C, // *
KC_DIVIDE = 0x4A, // /
// F
KC_F1 = 0x05, //F1
KC_F2 = 0x06, //F2
KC_F3 = 0x04, //F3
KC_F4 = 0x0C, //F4
KC_F5 = 0x03, //F5
KC_F6 = 0x0B, //F6
KC_F7 = 0x83, //F7
KC_F8 = 0x0A, //F8
KC_F9 = 0x01, //F9
KC_F10 = 0x09, //F10
KC_F11 = 0x78, //F11
KC_F12 = 0x07, //F12
// OTHR KEYS
KC_ESCAPE = 0x76, //ESCAPE
KC_TAB = 0x0D, //TABULATOR
KC_BACK = 0x66, //BACKSPACE
KC_SPAC = 0x29, //SPACE
KC_CAPS = 0x58, //CAPSLOCK
KC_LSHIFT = 0x12, //LEFT SHIFT
KC_LCONTROL = 0x14, //LEFT CTRL
KC_RCONTROL = 0x14, //LEFT CTRL
KC_LMENU = 0x1F, //LEFT WINDOWS
KC_ALT = 0x11, //LEFT ALT
KC_RSHIFT = 0x59, //RIGHT SHIFT
KC_RMENU = 0x27, //RIGHT WINDOWS
KC_ENTER = 0x5A, //ENTER


but if i would like start the wraper projekt it throw out a error

and now my questen can me anyone help with the wrapper?
or can me any one give a workabel germankeybord mois wrapper?

thans for any help

Wasi

ps: i know my English are very terribel

Beauty

29-10-2008 12:18:46

Nice that you want to make MOIS usable for German keyboards :)
If the code is ready / working I would add it to the wiki.

With the problem itself I can't help you.
If after one week comes no answer, you can Bekas. He is the author of MOIS and a real professional. (but he has only less time)

smiley80

10-12-2008 16:31:44

It seems that Keyboard.GetAsString returns the localized version, e.g. instead of ';' it returns 'ö'.

Unfortunately, it's sometimes a bit too verbose ('ZIRKUMFLEX' and '1 (ZEHNERTASTATUR)') and I don't know a way to get the correct symbol if a modifier key is pressed (without hardcoding every possible combination for every possible keyboard layout).

Beauty

10-12-2008 18:08:42

I think this is a question for a forum of C# specialists.
But english ones I don't know. Look out for it ...

smiley80

11-12-2008 07:13:43

I couldn't find a managed way, so:

namespace Helper
{
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

public static class Keyboard
{
public static string GetPressedKey()
{
string s = string.Empty;

foreach (int i in Enum.GetValues(typeof(Keys)))
{
if (GetAsyncKeyState(i) == -32767)
{
string c = ConvertVKToUnicode(i);
s += c;
}
}

return s;
}

[DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int key);

[DllImport("user32.dll")]
private static extern int MapVirtualKeyW(int code, int mapType);

[DllImport("user32.dll")]
private static extern bool GetKeyboardState(byte[] keyState);

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern int ToUnicode(
int virtKey,
int scanCode,
byte[] keyState,
StringBuilder buff,
int buffs,
uint flags);

private static string ConvertVKToUnicode(int vk)
{
byte[] keyState = new byte[256];
GetKeyboardState(keyState);

int sca = MapVirtualKeyW(vk, 0);
if (sca != 0)
{
StringBuilder sb = new StringBuilder();

int rc = ToUnicode(vk, sca, keyState, sb, sb.Capacity, 0);

if (rc == 1)
{
return sb.ToString();
}
}

return string.Empty;
}
}
}


inspired by: http://blogs.msdn.com/michkap/archive/2 ... 58674.aspx

Beauty

29-12-2009 16:59:07

I'm not shure how to use the last code.
Is it needed for compiling MOIS or is it needed to include it to the target application?
I never used MOIS, so I don't know much about.
But I want to discuss it, because it could be helpful for other users and want to add the information to the wiki.

By the way - what happens with MOIS when a German push a German key (e.g. Ä or ß)?
Does the application get the Char of the "english" keyboard?

The linked code seems to be useful. It uses the current system settings to create a Char from the key number.
But the author writes, it doesn't work e.g. for capital letters. What is the output for capital inputs? Just the small letter? Or 2 inputs (shift + small letter)?
Maybe somewhere is an improved code, based on the source in the blog.
Maybe there is a solution in the OIS forum.

This key mapping problem is related to many users (with non english keyboard). So I suppose there can still be a good solution.

smiley80

29-12-2009 18:17:45

The code doesn't use Mois.
If a key is pressed, you just call Keyboard.GetPressedKey() and it returns the key combination as string.
Works for modifier + key combinations (e.g. shift + letter, shift + number, altgr + whatever), but it doesn't work for dead keys (e.g. 'Zirkumflex' on a German keyboard).

By the way - what happens with MOIS when a German push a German key (e.g. Ä or ß)?
For ä, you'll get the keycode 'KC_APOSTROPHE', which get's translated back correctly when you use it in Mois.Keyboard.GetAsString(). However, this doesn't work for combinations.