📄 keymap.cpp
字号:
}
} /* end of ResetKeyMemory */
/*****************************************************************************
* FUNCTION
* ReadKeyProfile
* DESCRIPTION
* Reading the skin data from INI file
*
* PARAMETERS
* in_path IN indicates the directory where the INI file resides
* hWnd IN window handle
* RETURNS
* void
* GLOBALS AFFECTED
* nil
*****************************************************************************/
void ReadKeyProfile(char in_path[], HWND hWnd)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
char buffer[512], old_path[512], path[512];
int buffer_size = 512;
HBITMAP img;
BITMAP bmp;
HDC hdc;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
set_global_window_handle(hWnd);
/* save the original working directory */
GetCurrentDirectory(512, old_path);
/* get the complete name for opening the INI file */
SetCurrentDirectory(in_path);
strcpy(path, "./Profile.ini");
/* get layout related date */
GetPrivateProfileString("Layout", "WINDOW_WIDTH", NULL, buffer, buffer_size, path);
device.window_width = atoi(buffer);
GetPrivateProfileString("Layout", "WINDOW_HEIGHT", NULL, buffer, buffer_size, path);
device.window_height = atoi(buffer);
GetPrivateProfileString("Layout", "MAIN_LCD_WIDTH", NULL, buffer, buffer_size, path);
device.main_lcd_width = atoi(buffer);
GetPrivateProfileString("Layout", "MAIN_LCD_HEIGHT", NULL, buffer, buffer_size, path);
device.main_lcd_height = atoi(buffer);
GetPrivateProfileString("Layout", "MAIN_LCD_X", NULL, buffer, buffer_size, path);
device.skin_main_lcd_x = atoi(buffer);
GetPrivateProfileString("Layout", "MAIN_LCD_y", NULL, buffer, buffer_size, path);
device.skin_main_lcd_y = atoi(buffer);
GetPrivateProfileString("Layout", "SUB_LCD_WIDTH", NULL, buffer, buffer_size, path);
device.sub_lcd_width = atoi(buffer);
GetPrivateProfileString("Layout", "SUB_LCD_HEIGHT", NULL, buffer, buffer_size, path);
device.sub_lcd_height = atoi(buffer);
GetPrivateProfileString("Layout", "SUB_LCD_X", NULL, buffer, buffer_size, path);
device.skin_sub_lcd_x = atoi(buffer);
GetPrivateProfileString("Layout", "SUB_LCD_y", NULL, buffer, buffer_size, path);
device.skin_sub_lcd_y = atoi(buffer);
/* this should be calculated with window info, not read from INI file */
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
hdc = GetDC(GetWindowHandle());
/* get coordinates & images */
/* background image */
GetPrivateProfileString("Image", "BACKGROUND", NULL, buffer, buffer_size, path);
if (device.main_bitmap != NULL)
{
DeleteDC(device.main_bitmap);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.main_bitmap = CreateCompatibleDC(hdc);
SelectObject(device.main_bitmap, img);
GetObject(img, sizeof(BITMAP), &bmp);
device.main_bitmap_width = (U16)bmp.bmWidth;
device.main_bitmap_height = (U16)bmp.bmHeight;
/* key 0 */
GetPrivateProfileString("Coordinate", "KEY_0_LEFT", NULL, buffer, buffer_size, path);
KeyZero[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_0_TOP", NULL, buffer, buffer_size, path);
KeyZero[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_0", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_0] != NULL)
{
DeleteDC(device.key_bitmap[KEY_0]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_0] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_0], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeyZero[2] = KeyZero[0] + bmp.bmWidth - 1;
KeyZero[3] = KeyZero[1] + bmp.bmHeight - 1;
/* key 1 */
GetPrivateProfileString("Coordinate", "KEY_1_LEFT", NULL, buffer, buffer_size, path);
KeyOne[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_1_TOP", NULL, buffer, buffer_size, path);
KeyOne[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_1", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_1] != NULL)
{
DeleteDC(device.key_bitmap[KEY_1]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_1] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_1], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeyOne[2] = KeyOne[0] + bmp.bmWidth - 1;
KeyOne[3] = KeyOne[1] + bmp.bmHeight - 1;
/* key 2 */
GetPrivateProfileString("Coordinate", "KEY_2_LEFT", NULL, buffer, buffer_size, path);
KeyTwo[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_2_TOP", NULL, buffer, buffer_size, path);
KeyTwo[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_2", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_2] != NULL)
{
DeleteDC(device.key_bitmap[KEY_2]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_2] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_2], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeyTwo[2] = KeyTwo[0] + bmp.bmWidth - 1;
KeyTwo[3] = KeyTwo[1] + bmp.bmHeight - 1;
/* key 3 */
GetPrivateProfileString("Coordinate", "KEY_3_LEFT", NULL, buffer, buffer_size, path);
KeyThree[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_3_TOP", NULL, buffer, buffer_size, path);
KeyThree[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_3", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_3] != NULL)
{
DeleteDC(device.key_bitmap[KEY_3]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_3] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_3], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeyThree[2] = KeyThree[0] + bmp.bmWidth - 1;
KeyThree[3] = KeyThree[1] + bmp.bmHeight - 1;
/* key 4 */
GetPrivateProfileString("Coordinate", "KEY_4_LEFT", NULL, buffer, buffer_size, path);
KeyFour[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_4_TOP", NULL, buffer, buffer_size, path);
KeyFour[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_4", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_4] != NULL)
{
DeleteDC(device.key_bitmap[KEY_4]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_4] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_4], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeyFour[2] = KeyFour[0] + bmp.bmWidth - 1;
KeyFour[3] = KeyFour[1] + bmp.bmHeight - 1;
/* key 5 */
GetPrivateProfileString("Coordinate", "KEY_5_LEFT", NULL, buffer, buffer_size, path);
KeyFive[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_5_TOP", NULL, buffer, buffer_size, path);
KeyFive[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_5", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_5] != NULL)
{
DeleteDC(device.key_bitmap[KEY_5]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_5] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_5], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeyFive[2] = KeyFive[0] + bmp.bmWidth - 1;
KeyFive[3] = KeyFive[1] + bmp.bmHeight - 1;
/* key 6 */
GetPrivateProfileString("Coordinate", "KEY_6_LEFT", NULL, buffer, buffer_size, path);
KeySix[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_6_TOP", NULL, buffer, buffer_size, path);
KeySix[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_6", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_6] != NULL)
{
DeleteDC(device.key_bitmap[KEY_6]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_6] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_6], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeySix[2] = KeySix[0] + bmp.bmWidth - 1;
KeySix[3] = KeySix[1] + bmp.bmHeight - 1;
/* key 7 */
GetPrivateProfileString("Coordinate", "KEY_7_LEFT", NULL, buffer, buffer_size, path);
KeySeven[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_7_TOP", NULL, buffer, buffer_size, path);
KeySeven[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_7", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_7] != NULL)
{
DeleteDC(device.key_bitmap[KEY_7]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_7] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_7], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeySeven[2] = KeySeven[0] + bmp.bmWidth - 1;
KeySeven[3] = KeySeven[1] + bmp.bmHeight - 1;
/* key 8 */
GetPrivateProfileString("Coordinate", "KEY_8_LEFT", NULL, buffer, buffer_size, path);
KeyEight[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_8_TOP", NULL, buffer, buffer_size, path);
KeyEight[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_8", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_8] != NULL)
{
DeleteDC(device.key_bitmap[KEY_8]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_8] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_8], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeyEight[2] = KeyEight[0] + bmp.bmWidth - 1;
KeyEight[3] = KeyEight[1] + bmp.bmHeight - 1;
/* key 9 */
GetPrivateProfileString("Coordinate", "KEY_9_LEFT", NULL, buffer, buffer_size, path);
KeyNine[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_9_TOP", NULL, buffer, buffer_size, path);
KeyNine[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_9", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_9] != NULL)
{
DeleteDC(device.key_bitmap[KEY_9]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_9] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_9], img);
GetObject(img, sizeof(BITMAP), &bmp);
KeyNine[2] = KeyNine[0] + bmp.bmWidth - 1;
KeyNine[3] = KeyNine[1] + bmp.bmHeight - 1;
/* LSK */
GetPrivateProfileString("Coordinate", "KEY_LSK_LEFT", NULL, buffer, buffer_size, path);
Leftsoftkey[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_LSK_TOP", NULL, buffer, buffer_size, path);
Leftsoftkey[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_LSK", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_LSK] != NULL)
{
DeleteDC(device.key_bitmap[KEY_LSK]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_LSK] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_LSK], img);
GetObject(img, sizeof(BITMAP), &bmp);
Leftsoftkey[2] = Leftsoftkey[0] + bmp.bmWidth - 1;
Leftsoftkey[3] = Leftsoftkey[1] + bmp.bmHeight - 1;
/* RSK */
GetPrivateProfileString("Coordinate", "KEY_RSK_LEFT", NULL, buffer, buffer_size, path);
Rightsoftkey[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_RSK_TOP", NULL, buffer, buffer_size, path);
Rightsoftkey[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_RSK", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_RSK] != NULL)
{
DeleteDC(device.key_bitmap[KEY_RSK]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_RSK] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_RSK], img);
GetObject(img, sizeof(BITMAP), &bmp);
Rightsoftkey[2] = Rightsoftkey[0] + bmp.bmWidth - 1;
Rightsoftkey[3] = Rightsoftkey[1] + bmp.bmHeight - 1;
/* up arrow key */
GetPrivateProfileString("Coordinate", "KEY_UP_ARROW_LEFT", NULL, buffer, buffer_size, path);
UpArrow[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_UP_ARROW_TOP", NULL, buffer, buffer_size, path);
UpArrow[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_UP_ARROW", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_UP_ARROW] != NULL)
{
DeleteDC(device.key_bitmap[KEY_UP_ARROW]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_UP_ARROW] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_UP_ARROW], img);
GetObject(img, sizeof(BITMAP), &bmp);
UpArrow[2] = UpArrow[0] + bmp.bmWidth - 1;
UpArrow[3] = UpArrow[1] + bmp.bmHeight - 1;
/* down arrow key */
GetPrivateProfileString("Coordinate", "KEY_DOWN_ARROW_LEFT", NULL, buffer, buffer_size, path);
DownArrow[0] = atoi(buffer);
GetPrivateProfileString("Coordinate", "KEY_DOWN_ARROW_TOP", NULL, buffer, buffer_size, path);
DownArrow[1] = atoi(buffer);
GetPrivateProfileString("Image", "KEY_DOWN_ARROW", NULL, buffer, buffer_size, path);
if (device.key_bitmap[KEY_DOWN_ARROW] != NULL)
{
DeleteDC(device.key_bitmap[KEY_DOWN_ARROW]);
}
img = (HBITMAP)LoadImage(0, buffer, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
device.key_bitmap[KEY_DOWN_ARROW] = CreateCompatibleDC(hdc);
SelectObject(device.key_bitmap[KEY_DOWN_ARROW], img);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -