UBKeyboardPalette_win.cpp 2.16 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1 2 3 4 5 6 7 8

#include "UBKeyboardPalette.h"

#include <windows.h>

#include "../core/UBApplication.h"
#include "../gui/UBMainWindow.h"

9 10
#include "core/memcheck.h"

11
void UBKeyboardButton::sendUnicodeSymbol(KEYCODE keycode)
Claudio Valerio's avatar
Claudio Valerio committed
12 13 14 15
{
	INPUT input[2];
	input[0].type = INPUT_KEYBOARD;
	input[0].ki.wVk = 0;
16
    input[0].ki.wScan = keycode.symbol;
Claudio Valerio's avatar
Claudio Valerio committed
17 18 19 20 21 22
	input[0].ki.dwFlags = KEYEVENTF_UNICODE;
	input[0].ki.time = 0;
	input[0].ki.dwExtraInfo = 0;

	input[1].type = INPUT_KEYBOARD;
	input[1].ki.wVk = 0;
23
    input[1].ki.wScan = keycode.symbol;
Claudio Valerio's avatar
Claudio Valerio committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
	input[1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
	input[1].ki.time = 0;
	input[1].ki.dwExtraInfo = 0;

	::SendInput(2, input, sizeof(input[0]));
}

void UBKeyboardButton::sendControlSymbol(int nSymbol)
{
	INPUT input[2];
	input[0].type = INPUT_KEYBOARD;
	input[0].ki.wVk = nSymbol;
	input[0].ki.wScan = 0;
	input[0].ki.dwFlags = 0;
	input[0].ki.time = 0;
	input[0].ki.dwExtraInfo = 0;

	input[1].type = INPUT_KEYBOARD;
	input[1].ki.wVk = nSymbol;
	input[1].ki.wScan = 0;
	input[1].ki.dwFlags = KEYEVENTF_KEYUP;
	input[1].ki.time = 0;
	input[1].ki.dwExtraInfo = 0;

	::SendInput(2, input, sizeof(input[0]));
}

void UBKeyboardPalette::createCtrlButtons()
{
53 54 55 56 57
    int ctrlID = 0;
    ctrlButtons = new UBKeyboardButton*[9];

    ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x08, "backspace");// Backspace
    ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x09, "tab");      // Tab
58
    ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock");    // Shift
59
    ctrlButtons[ctrlID++] = new UBCntrlButton(this, tr("Enter"), 0x0d);    // Enter
60 61
    ctrlButtons[ctrlID++] = new UBShiftButton(this, "shift");    // Shift
    ctrlButtons[ctrlID++] = new UBShiftButton(this, "shift");    // Shift
62 63 64
    ctrlButtons[ctrlID++] = new UBLocaleButton(this);                  // Language Switch 
    ctrlButtons[ctrlID++] = new UBCntrlButton(this, "", 0x20);         // Space
    ctrlButtons[ctrlID++] = new UBLocaleButton(this);                  // Language Switch 
Claudio Valerio's avatar
Claudio Valerio committed
65 66
}

Anatoly Mihalchenko's avatar
Anatoly Mihalchenko committed
67 68 69
void UBKeyboardPalette::checkLayout()
{}

Claudio Valerio's avatar
Claudio Valerio committed
70
void UBKeyboardPalette::onActivated(bool)
Anatoly Mihalchenko's avatar
Anatoly Mihalchenko committed
71 72
{}

Claudio Valerio's avatar
Claudio Valerio committed
73 74 75
void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* )
{}