Ejemplo n.º 1
0
DWORD CHotkey::_HotkeyThread(LPVOID lpParam)
{
	MSG msg;
	HACCEL hAccelTable;

	hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_ANEMONE));

	InstallHook();
	LoadKeyMap();

	// 기본 메시지 루프입니다.
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	return (int)msg.wParam;
}
Ejemplo n.º 2
0
// AVS
// completelly rewrited to support new conceptions
int TMapLoader::Load(const char * filename, const char * szActiveEmul) {
	char buf[256];
	int bufLen;
	
	ifstream inpfile(filename);
	KeyTrans.DeleteAllDefs();
	Charmap.init();
	
	// it is an array for store [...] ... [end ...] parts from file
	stringArray SA(0,0,sizeof(string));
	int AllOk = 0;
	
	while ( inpfile ) {
		
		getline(inpfile, buf, 255);
		bufLen = strlen(buf);
		if ( !bufLen ) continue;
		
		if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
			// is a part splitter [...]
			string temps(buf);
			
			if (!normalizeSplitter(temps)) {
				printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
				AllOk = 0;
				break;
			};
			// if a comment
			if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
#ifdef KEYDEBUG
				printit(temps.c_str());
#endif
				if ( !getLongComment(inpfile, buf, sizeof(buf)) ) {
					printm(0, FALSE, MSG_KEYUNEXPEOF);
					break;
				};
#ifdef KEYDEBUG
				printit("\r          \r");
#endif
				continue;
			};
			
			
			string back = temps;
			// prepare line for make it as [end ...]
			// and check it
			if ( strnicmp(back.c_str(), "[global]", 8) == 0 ) {} // do nothing
			else if ( strnicmp(back.c_str(), "[keymap", 7) == 0 ) {
				// DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
#ifndef __BORLANDC__
				back.erase(7);
#else
				back.remove(7);
#endif
				back += "]";
			}
			else if ( strnicmp(back.c_str(), "[charmap", 8) == 0 ) {
				// Paul Brannan 6/23/98
#ifndef __BORLANDC__
				back.erase(8);
#else
				back.remove(8);
#endif
				back += "]";
			}
			else if ( strnicmp(back.c_str(), "[config", 7) == 0 ) {
				// Paul Brannan 6/23/98
#ifndef __BORLANDC__
				back.erase(7);
#else
				back.remove(7);
#endif
				back += "]";
			}
			else {
				//        cerr << "Unexpected token " << back << endl;
				printm(0, FALSE, MSG_KEYUNEXPTOK, back.c_str());
				break;
			};
			
			back.insert(1,"END "); // now it looks like [END ...]
#ifdef KEYDEBUG
			printit(temps.c_str());
#endif
			
			int ok = 0;
			// fetch it to temps
			while ( 1 ) {
				getline(inpfile, buf, sizeof(buf));
				bufLen = strlen(buf);
				if ( !bufLen ) break;
				if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
					string t(buf);
					if ( !normalizeSplitter(t) ) break;
					
					if ( stricmp(t.c_str(),back.c_str()) == 0 ) {
						ok = 1;
						break;
					};
					
					// AVS 31.12.97 fix [comment] block inside another block
					if ( stricmp(t.c_str(),"[comment]") == 0 &&
						getLongComment(inpfile, buf, sizeof(buf)) ) continue;
					
					break;
				};
				temps += "\n";
				temps += buf;
			};
			if ( !ok ) {
				//         cerr << "Unexpected end of file or token" << endl;
				printm(0, FALSE, MSG_KEYUNEXP);
				AllOk = 0;
				break;
			};
#ifdef KEYDEBUG
			printit("\r                                                                      \r");
#endif
			AllOk = SA.Add(temps);;
			if ( !AllOk ) break;
		} else {
			//       cerr << "Unexpected line '" << buf << "'\n";
			printm(0, FALSE, MSG_KEYUNEXPLINE, buf);
			AllOk = 0;
			break;
		};
	};
	
	inpfile.close();
	
	if ( !AllOk ) return 0;
	
	// now all file are in SA, comments are stripped
	
	int i = LookForPart(SA, "global", "");
	if ( i == INT_MAX ) {
		//     cerr << "No [GLOBAL] definition!" << endl;
		printm(0, FALSE, MSG_KEYNOGLOBAL);
		return 0;
	};
	if ( !LoadGlobal(SA[i]) ) {
		return 0;
	};
	
	// look for need configuration
	i = LookForPart(SA, "config", szActiveEmul);
	if ( i == INT_MAX ) {
		//     cerr << "No [CONFIG " << szActiveEmul << "]\n";
		printm(0, FALSE, MSG_KEYNOCONFIG, szActiveEmul);
		return 0;
	};
	//  cerr << "use configuration: " << szActiveEmul << endl;
	printm(0, FALSE, MSG_KEYUSECONFIG, szActiveEmul);
	BOOL hadKeys = FALSE;
	
	string config = SA[i];
	// parse it
	while ( config.length() ) {
		buf[0] = 0;
		getline(config,buf,sizeof(buf));
		bufLen = strlen(buf);
		if ( !bufLen || (buf[0] == '[' && buf[bufLen-1] == ']') ) continue;
		if ( strnicmp(buf,"keymap",6) == 0 ) {
			string orig(buf);
			printit("\t"); printit(buf); printit("\n");
			char * mapdef = strtok(buf,":");
			char * switchKey = strtok(NULL,"\n");
			
			if ( !KeyTrans.mapArray.IsEmpty() && switchKey == NULL ) {
				//            cerr << "no switch Key for '" << mapdef
				//                 << "'" << endl;
				printm(0, FALSE, MSG_KEYNOSWKEY, mapdef);
				break;
			};
			if ( KeyTrans.mapArray.IsEmpty() ) {
				if ( switchKey != NULL ) { // create default keymap
					//               cerr << "You cannot define switch key for default keymap -> ignored"
					//                    << endl;
					printm(0, FALSE, MSG_KEYCANNOTDEF);
				};
				TKeyDef empty;
				KeyTrans.mapArray.Add(KeyMap(string(mapdef)));
				KeyTrans.switchMap(empty); // set it as current keymap
				KeyTrans.mainKeyMap = KeyTrans.currentKeyMap;
			}
			else {
				string keydef(switchKey);
				keydef += " !*!*!*"; // just for check
				WORD vk_code;
				DWORD control;
				switchKey = ParseKeyDef(keydef.c_str(),vk_code,control);
				if ( switchKey != NULL ) {
					TKeyDef swi(NULL,control,vk_code);
					if ( KeyTrans.switchMap(swi) > 0 ) {
						//                  cerr << "Duplicate switching key\n";
						printm(0, FALSE, MSG_KEYDUPSWKEY);
						break;
					};
					KeyTrans.mapArray.Add(KeyMap(swi, orig));
					KeyTrans.switchMap(swi); // set it as current keymap
				}
			};
			mapdef+=7; // 'keymap '
			// now load defined keymaps to current
			while ((mapdef != NULL)&&
				(mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
				i = LookForPart(SA,"keymap",mapdef);
				if ( i == INT_MAX ) {
					//               cerr << "Unknown KEYMAP " << mapdef << endl;
					printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
				} else {
					mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
					// so - save pointer!
					hadKeys = LoadKeyMap(SA[i]); // load it
				};
			};
			
		}
		else if ( strnicmp(buf,"charmap",7) == 0 ) {
			printit("\t"); printit(buf); printit("\n");
			char * mapdef = buf + 8;// 'charmap '
			int SuccesLoaded = 0;
			// now load defined charmaps to current
			while ((mapdef != NULL)&&
				(mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
				i = LookForPart(SA,"charmap",mapdef);
				if ( i == INT_MAX ) {
					//               cerr << "Unknown KEYMAP " << mapdef << endl;
					printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
				} else {
					mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
					// so - save pointer!
					if (LoadCharMap(SA[i])) // load it
						SuccesLoaded++;
				};
			};
			if (!SuccesLoaded) {
				//            cerr << "No charmaps loaded\n";
				printm(0, FALSE, MSG_KEYNOCHARMAPS);
				Charmap.init();
			};
			/*         strtok(buf," ");
			
			  char* name = strtok(NULL," ");
			  if ( name == NULL ) {
			  cerr << "No name for CHARMAP" << endl;
			  } else {
			  i = LookForPart(SA,"charmap", name);
			  if ( i == INT_MAX ) {
			  cerr << "Unknown CHARMAP " << name << endl;
			  } else {
			  LoadCharMap(SA[i]);
			  };
			  };
			*/
		}
		else {
			//        cerr << "unexpected token in " << szActiveEmul << endl;
			printm(0, FALSE, MSG_KEYUNEXPTOKIN, szActiveEmul);
		}
	}

	if ( hadKeys) {
		TKeyDef empty;
		KeyTrans.switchMap(empty); // switch to default
		KeyTrans.mainKeyMap = KeyTrans.currentKeyMap; // save it's number
		//     cerr << "There are " << (KeyTrans.mapArray.GetItemsInContainer()) << " maps\n";
		char s[12]; // good enough for a long int (32-bit)
		itoa(KeyTrans.mapArray.GetItemsInContainer(), s, 10);
		printm(0, FALSE, MSG_KEYNUMMAPS, s);
		return 1;
	};
	return 0;
}
Ejemplo n.º 3
0
INT_PTR CALLBACK DlgProcKeyMap(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, int no)
{
	switch(message)
	{
	case WM_INITDIALOG:
		for(int i = 0; i < _countof(KeyMap[no]); i++)
		{
			LoadKeyMap(hDlg, KeyMap[no][i].idd, SectionName[no], KeyMap[no][i].keyName, KeyMap[no][i].defaultValue);
		}
		return TRUE;

	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDC_EDIT_KANA:
		case IDC_EDIT_CONV_CHAR:
		case IDC_EDIT_JLATIN:
		case IDC_EDIT_ASCII:
		case IDC_EDIT_JMODE:
		case IDC_EDIT_ABBREV:
		case IDC_EDIT_AFFIX:
		case IDC_EDIT_NEXT_CAND:
		case IDC_EDIT_PREV_CAND:
		case IDC_EDIT_PURGE_DIC:
		case IDC_EDIT_NEXT_COMP:
		case IDC_EDIT_PREV_COMP:
		case IDC_EDIT_HINT:
		case IDC_EDIT_CONV_POINT:
		case IDC_EDIT_DIRECT:
		case IDC_EDIT_ENTER:
		case IDC_EDIT_CANCEL:
		case IDC_EDIT_BACK:
		case IDC_EDIT_DELETE:
		case IDC_EDIT_VOID:
		case IDC_EDIT_LEFT:
		case IDC_EDIT_UP:
		case IDC_EDIT_RIGHT:
		case IDC_EDIT_DOWN:
		case IDC_EDIT_PASTE:
		case IDC_EDIT_OTHERIME:
		case IDC_EDIT_VIESC:
			switch(HIWORD(wParam))
			{
			case EN_CHANGE:
				PropSheet_Changed(GetParent(hDlg), hDlg);
				return TRUE;
			default:
				break;
			}
			break;
		default:
			break;
		}
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lParam)->code)
		{
		case PSN_APPLY:
			WriterStartSection(pXmlWriter, SectionName[no]);	//Start of SectionKeyMap or SectionVKeyMap

			for(int i = 0; i < _countof(KeyMap[no]); i++)
			{
				SaveKeyMap(hDlg, KeyMap[no][i].idd, KeyMap[no][i].keyName);
			}

			WriterEndSection(pXmlWriter);	//End of SectionKeyMap or SectionVKeyMap

			return TRUE;

		default:
			break;
		}
		break;

	default:
		break;
	}

	return FALSE;
}