HRESULT CKeyMgr::Init(HINSTANCE _hInst, HWND _hWnd) { FAILED_CHECK_MSG(DirectInput8Create( _hInst , DIRECTINPUT_VERSION , IID_IDirectInput8 , (void**)&m_pInput , NULL), L"다이렉트 인풋 생성 실패"); FAILED_CHECK_MSG(InitKeyBoard(_hWnd), L"키보드 생성 실패"); FAILED_CHECK_MSG(InitMouse(_hWnd), L"마우스 생성 실패"); return S_OK; }
void main(void) { u16 id; InitUart(); InitKeyBoard(); //*********************************** // Prints("adfasdfadsfasf"); // LightUpLed(LED1); // TurnOffLed(LED2); Prints("\nGetting chip ID..."); D12ReadID(&id); PrintShortIntHex(id); Prints(",over\n"); USBConnect(); //************************************ while(1); }
Keyboard::Keyboard(QWidget *parent, bool num) : QMainWindow(parent), ui(new Ui::Keyboard) { ui->setupUi(this); Flag_InputMode = LETTER; //输入格式变量 Flag_Mid_Mode = LETTER; //输入格式中转变量 m_MouseDown = false; //鼠标事件初始化 m_Page =0; m_Page_A =0;//初始化总页数和当前页码 k_letter[0]=0; k_letter[1]=0; k_letter[2]=0; k_letter[3]=0; k_letter[4]=0; k_letter[5]=0; k_letter[6]=0; k_letter_index=0; m_Display[0] = ui->hz_1; m_Display[1] = ui->hz_2; m_Display[2] = ui->hz_3; m_Display[3] = ui->hz_4; m_Display[4] = ui->hz_5; m_Display[5] = ui->hz_6; m_Display[6] = ui->hz_7; m_Display[7] = ui->hz_8; m_Display[8] = ui->hz_9; m_Display[9] = ui->hz_10;//汉字1-10的定义,将其统一放在一个数组中,方便后续代码。 m_letter_a_z[0]=ui->pushButton_a; m_letter_a_z[1]=ui->pushButton_b; m_letter_a_z[2]=ui->pushButton_c; m_letter_a_z[3]=ui->pushButton_d; m_letter_a_z[4]=ui->pushButton_e; m_letter_a_z[5]=ui->pushButton_f; m_letter_a_z[6]=ui->pushButton_g; m_letter_a_z[7]=ui->pushButton_h; m_letter_a_z[8]=ui->pushButton_i; m_letter_a_z[9]=ui->pushButton_j; m_letter_a_z[10]=ui->pushButton_k; m_letter_a_z[11]=ui->pushButton_l; m_letter_a_z[12]=ui->pushButton_m; m_letter_a_z[13]=ui->pushButton_n; m_letter_a_z[14]=ui->pushButton_o; m_letter_a_z[15]=ui->pushButton_p; m_letter_a_z[16]=ui->pushButton_q; m_letter_a_z[17]=ui->pushButton_r; m_letter_a_z[18]=ui->pushButton_s; m_letter_a_z[19]=ui->pushButton_t; m_letter_a_z[20]=ui->pushButton_u; m_letter_a_z[21]=ui->pushButton_v; m_letter_a_z[22]=ui->pushButton_w; m_letter_a_z[23]=ui->pushButton_x; m_letter_a_z[24]=ui->pushButton_y; m_letter_a_z[25]=ui->pushButton_z; setWindowFlags(Qt::Tool|Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint);/*窗口风格设置,这里是去除标题栏即蓝色部分*/ if(num) { Flag_InputMode = NUMBER; //输入格式变量 Flag_Mid_Mode = NUMBER; //输入格式中转变量 KeyBoardStartMode(NUMBER); ui->pushButton_en_ch->setEnabled(false); ui->pushButton_cap->setEnabled(false); } else { Flag_InputMode = LETTER; //输入格式变量 Flag_Mid_Mode = LETTER; //输入格式中转变量 KeyBoardStartMode(LETTER); //HANZI ui->pushButton_en_ch->setEnabled(true); ui->pushButton_cap->setEnabled(true); } QString srf; QFile file(FILE_ZI_KU);//打开FILE_ZI_KU文件 if (file.open(QFile::ReadOnly)) { while (true) { char buf[1024] = {0}; qint64 Len = file.readLine(buf, sizeof(buf));//读取文件一行 if (Len <= 0) break; //判断是否读取成功,失败即跳出 srf += QString(buf);//将读取的字符流添加到srf中 } } m_srf = srf.split("\r\n"); //用QString的split函数将字库文件划分成一段一段,每个拼音对应一段字库 InitKeyBoard(); }