|
@@ -203,18 +203,16 @@ LRESULT CALLBACK Framework::WindowProc(HWND hwnd, UINT message, WPARAM wparam, L
|
|
|
case WM_KEYDOWN:
|
|
|
if (1)
|
|
|
{
|
|
|
- TastaturEreignis te = { TE_Press, VirtualZuChar((int)wparam), 0 };
|
|
|
- if (te.taste == T_Alt_Gr)
|
|
|
- TastenStand[T_Strg] = 0;
|
|
|
- TastenStand[te.taste] = 1;
|
|
|
+ TastaturEreignis te = { TE_Press, {0, 0, 0}, 0, 0 };
|
|
|
+ CalculateEnteredString((int)wparam, 0, te);
|
|
|
WFensterA.sendTastaturMessage(hwnd, te);
|
|
|
break;
|
|
|
} // Taste wird gedrückt
|
|
|
case WM_KEYUP:
|
|
|
if (1)
|
|
|
{
|
|
|
- TastaturEreignis te = { TE_Release, VirtualZuChar((int)wparam), 0 };
|
|
|
- TastenStand[te.taste] = 0;
|
|
|
+ TastaturEreignis te = { TE_Release, {0, 0, 0}, 0, 0 };
|
|
|
+ CalculateEnteredString((int)wparam, HIWORD(lparam) & 0xFF, te);
|
|
|
WFensterA.sendTastaturMessage(hwnd, te);
|
|
|
break;
|
|
|
} // Taste wird losgelassen
|
|
@@ -242,146 +240,23 @@ void Framework::StopNachrichtenSchleife(HWND hwnd)
|
|
|
PostMessage(hwnd, WM_MOUSELEAVE, 0, 0);
|
|
|
}
|
|
|
|
|
|
-unsigned char Framework::VirtualZuChar(int Virtual)
|
|
|
+void Framework::CalculateEnteredString(int virtualKeyCode, int scanCode, TastaturEreignis &te)
|
|
|
{
|
|
|
- UINT vk = MapVirtualKey(Virtual, 2);
|
|
|
- if (!vk)
|
|
|
+ memset(te.taste, 0, sizeof(te.taste));
|
|
|
+ te.virtualKey = virtualKeyCode;
|
|
|
+#ifdef WIN32
|
|
|
+ unsigned char keyState[256];
|
|
|
+ memset(keyState, 0, sizeof(keyState));
|
|
|
+ if (GetKeyboardState(keyState))
|
|
|
{
|
|
|
- switch (Virtual)
|
|
|
- {
|
|
|
- case VK_CAPITAL:
|
|
|
- return T_Caps_Lock;
|
|
|
- case VK_SHIFT:
|
|
|
- return T_Shift;
|
|
|
- case VK_CONTROL:
|
|
|
- return T_Strg;
|
|
|
- case VK_F1:
|
|
|
- return T_F1;
|
|
|
- case VK_F2:
|
|
|
- return T_F2;
|
|
|
- case VK_F3:
|
|
|
- return T_F3;
|
|
|
- case VK_F4:
|
|
|
- return T_F4;
|
|
|
- case VK_F5:
|
|
|
- return T_F5;
|
|
|
- case VK_F6:
|
|
|
- return T_F6;
|
|
|
- case VK_F7:
|
|
|
- return T_F7;
|
|
|
- case VK_F8:
|
|
|
- return T_F8;
|
|
|
- case VK_F9:
|
|
|
- return T_F9;
|
|
|
- case VK_F10:
|
|
|
- return T_F10;
|
|
|
- case VK_F11:
|
|
|
- return T_F11;
|
|
|
- case VK_F12:
|
|
|
- return T_F12;
|
|
|
- case VK_PAUSE:
|
|
|
- return T_Pause;
|
|
|
- case VK_SNAPSHOT:
|
|
|
- return T_Druck;
|
|
|
- case VK_INSERT:
|
|
|
- return T_Einfg;
|
|
|
- case VK_DELETE:
|
|
|
- return T_Entf;
|
|
|
- case VK_LEFT:
|
|
|
- return T_Links;
|
|
|
- case VK_UP:
|
|
|
- return T_Oben;
|
|
|
- case VK_RIGHT:
|
|
|
- return T_Rechts;
|
|
|
- case VK_DOWN:
|
|
|
- return T_Unten;
|
|
|
- case VK_MENU:
|
|
|
- return T_Alt_Gr;
|
|
|
- case VK_NUMLOCK:
|
|
|
- return T_Num;
|
|
|
- case VK_HOME:
|
|
|
- return T_Pos1;
|
|
|
- case VK_PRIOR:
|
|
|
- return T_BildO;
|
|
|
- case VK_NEXT:
|
|
|
- return T_BildU;
|
|
|
- case VK_END:
|
|
|
- return T_Ende;
|
|
|
- case VK_TAB:
|
|
|
- return T_Tab;
|
|
|
- case VK_LMENU:
|
|
|
- return T_Alt;
|
|
|
- }
|
|
|
+ unsigned short str[2] = { 0, 0 };
|
|
|
+ int count = ToAscii(virtualKeyCode, scanCode, keyState, str, 0);
|
|
|
+ if (count == 1 && (str[0] & 0xFF) == str[0])
|
|
|
+ te.taste[0] = (unsigned char)str[0];
|
|
|
+ else if (count == 2 && (str[0] & 0xFF) == str[0] && (str[1] & 0xFF) == str[1])
|
|
|
+ te.taste[0] = (unsigned char)str[0], te.taste[1] = (unsigned char)str[1];
|
|
|
}
|
|
|
- if (vk == VK_TAB)
|
|
|
- return T_Tab;
|
|
|
- char ret = (char)(short)LOWORD(vk);
|
|
|
- short SHIFT = GetKeyState(VK_SHIFT);
|
|
|
- short CAPSLOCK = GetKeyState(VK_CAPITAL);
|
|
|
- short ALTGR = TastenStand[T_Alt_Gr];
|
|
|
- if (ALTGR)
|
|
|
- {
|
|
|
- switch (ret)
|
|
|
- {
|
|
|
- case 'q':
|
|
|
- return '@';
|
|
|
- case 'Q':
|
|
|
- return '@';
|
|
|
- case '<':
|
|
|
- return '|';
|
|
|
- case '>':
|
|
|
- return '|';
|
|
|
- case '7':
|
|
|
- return '{';
|
|
|
- case '/':
|
|
|
- return '{';
|
|
|
- case '8':
|
|
|
- return '[';
|
|
|
- case '(':
|
|
|
- return '[';
|
|
|
- case '9':
|
|
|
- return ']';
|
|
|
- case ')':
|
|
|
- return ']';
|
|
|
- case '0':
|
|
|
- return '}';
|
|
|
- case '=':
|
|
|
- return '}';
|
|
|
- case 'ß':
|
|
|
- return '\\';
|
|
|
- case '?':
|
|
|
- return '\\';
|
|
|
- case '+':
|
|
|
- return '~';
|
|
|
- case '*':
|
|
|
- return '~';
|
|
|
- case 'e':
|
|
|
- return '€';
|
|
|
- case 'E':
|
|
|
- return '€';
|
|
|
- case 'm':
|
|
|
- return 'µ';
|
|
|
- case 'M':
|
|
|
- return 'µ';
|
|
|
- case '2':
|
|
|
- return '²';
|
|
|
- case '"':
|
|
|
- return '²';
|
|
|
- case '3':
|
|
|
- return '³';
|
|
|
- case '§':
|
|
|
- return '³';
|
|
|
- }
|
|
|
- }
|
|
|
- SHIFT = HIWORD(SHIFT);
|
|
|
- CAPSLOCK = LOWORD(CAPSLOCK);
|
|
|
- bool up = 0;
|
|
|
- if (SHIFT && !CAPSLOCK)
|
|
|
- up = 1;
|
|
|
- if (CAPSLOCK && !SHIFT)
|
|
|
- up = 1;
|
|
|
- ret = smallOrBig(ret, up);
|
|
|
- return ret;
|
|
|
+#endif // WIN32
|
|
|
}
|
|
|
|
|
|
// Inhalt der WFenster Klasse aus Fenster.h
|
|
@@ -508,16 +383,6 @@ void WFenster::setPosition(int x, int y)
|
|
|
RECT res;
|
|
|
res.left = x, res.top = y, res.right = r.right - r.left, res.bottom = r.bottom - r.top;
|
|
|
AdjustWindowRect(&res, style, 0);
|
|
|
- /* if( res.top < 0 )
|
|
|
- {
|
|
|
- res.bottom -= res.top;
|
|
|
- res.top = 0;
|
|
|
- }
|
|
|
- if( res.left < 0 )
|
|
|
- {
|
|
|
- res.right -= res.left;
|
|
|
- res.left = 0;
|
|
|
- }*/
|
|
|
SetWindowPos(hWnd, 0, res.left, res.top, res.right, res.bottom, 0); // Position ändern
|
|
|
}
|
|
|
|
|
@@ -528,16 +393,6 @@ void WFenster::setSize(Punkt& g)// Fenster Gr
|
|
|
RECT res;
|
|
|
res.left = r.left, res.top = r.top, res.right = g.x, res.bottom = g.y;
|
|
|
AdjustWindowRect(&res, style, 0);
|
|
|
- /* if( res.top < 0 )
|
|
|
- {
|
|
|
- res.bottom -= res.top;
|
|
|
- res.top = 0;
|
|
|
- }
|
|
|
- if( res.left < 0 )
|
|
|
- {
|
|
|
- res.right -= res.left;
|
|
|
- res.left = 0;
|
|
|
- }*/
|
|
|
SetWindowPos(hWnd, 0, res.left, res.top, res.right, res.bottom, 0); // Größe ändern
|
|
|
}
|
|
|
|
|
@@ -548,16 +403,6 @@ void WFenster::setSize(int breite, int h
|
|
|
RECT res;
|
|
|
res.left = r.left, res.top = r.top, res.right = breite, res.bottom = höhe;
|
|
|
AdjustWindowRect(&res, style, 0);
|
|
|
- /* if( res.top < 0 )
|
|
|
- {
|
|
|
- res.bottom -= res.top;
|
|
|
- res.top = 0;
|
|
|
- }
|
|
|
- if( res.left < 0 )
|
|
|
- {
|
|
|
- res.right -= res.left;
|
|
|
- res.left = 0;
|
|
|
- }*/
|
|
|
SetWindowPos(hWnd, 0, res.left, res.top, res.right, res.bottom, 0); // Größe ändern
|
|
|
}
|
|
|
|