Пример #1
0
static int specialpressed (void)
{
	return ispressed (specialkeycode ());
}
Пример #2
0
void my_kbd_handler (int keyboard, int scancode, int newstate)
{
	int code = 0;
	int scancode_new;
	static int swapperdrive = 0;

	if (scancode == specialkeycode ())
		return;

	if (scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ())
		code = AKS_QUIT;

	scancode_new = scancode;
	if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode))
		scancode = 0;
	// GUI must be always available
	if (scancode_new == DIK_F12 && currprefs.win32_guikey < 0)
		scancode = scancode_new;
	if (scancode_new == currprefs.win32_guikey && scancode_new != DIK_F12)
		scancode = scancode_new;
	
	//write_log (L"keyboard = %d scancode = 0x%02x state = %d\n", keyboard, scancode, newstate );

	if (newstate == 0 && code == 0) {
		switch (scancode)
		{
			case DIK_SYSRQ:
			screenshot (specialpressed () ? 1 : 0, 1);
			break;
		}
	}


	if (newstate && code == 0) {

		if (scancode == DIK_F12 || scancode == currprefs.win32_guikey) {
			if (ctrlpressed ()) {
				code = AKS_TOGGLEDEFAULTSCREEN;
			} else if (shiftpressed () || specialpressed ()) {
				if (isfullscreen() <= 0) {
					disablecapture ();
					code = AKS_ENTERDEBUGGER;
				}
			} else {
				code = AKS_ENTERGUI;
			}
		}

		switch (scancode)
		{
		case DIK_F1:
		case DIK_F2:
		case DIK_F3:
		case DIK_F4:
			if (specialpressed ()) {
				if (ctrlpressed ()) {
				} else {
					if (shiftpressed ())
						code = AKS_EFLOPPY0 + (scancode - DIK_F1);
					else
						code = AKS_FLOPPY0 + (scancode - DIK_F1);
				}
			}
			break;
		case DIK_F5:
#if 0
			{
				disk_prevnext (0, -1);
				return;
				//crap++;
				//write_log (L"%d\n", crap);
			}
#endif
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_STATESAVEDIALOG;
				else
					code = AKS_STATERESTOREDIALOG;
			}
			break;
		case DIK_1:
		case DIK_2:
		case DIK_3:
		case DIK_4:
		case DIK_5:
		case DIK_6:
		case DIK_7:
		case DIK_8:
		case DIK_9:
		case DIK_0:
			if (specialpressed ()) {
				int num = scancode - DIK_1;
				if (shiftpressed ())
					num += 10;
				if (ctrlpressed ()) {
					swapperdrive = num;
					if (swapperdrive > 3)
						swapperdrive = 0;
				} else {
					int i;
					for (i = 0; i < 4; i++) {
						if (!_tcscmp (currprefs.floppyslots[i].df, currprefs.dfxlist[num]))
							changed_prefs.floppyslots[i].df[0] = 0;
					}
					_tcscpy (changed_prefs.floppyslots[swapperdrive].df, currprefs.dfxlist[num]);
					config_changed = 1;
				}
			}
			break;
		case DIK_NUMPAD0:
		case DIK_NUMPAD1:
		case DIK_NUMPAD2:
		case DIK_NUMPAD3:
		case DIK_NUMPAD4:
		case DIK_NUMPAD5:
		case DIK_NUMPAD6:
		case DIK_NUMPAD7:
		case DIK_NUMPAD8:
		case DIK_NUMPAD9:
		case DIK_NUMPADPERIOD:
			if (specialpressed ()) {
				int i = 0, v = -1;
				while (np[i] >= 0) {
					v = np[i + 1];
					if (np[i] == scancode)
						break;
					i += 2;
				}
				if (v >= 0)
					code = AKS_STATESAVEQUICK + v * 2 + ((shiftpressed () || ctrlpressed ()) ? 0 : 1);
			}
			break;
		case DIK_PAUSE:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_IRQ7;
				else
					code = AKS_WARP;
			} else {
				code = AKS_PAUSE;
			}
			break;
		case DIK_SCROLL:
			code = AKS_INHIBITSCREEN;
			break;
		case DIK_NUMPADMINUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_DECREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLDOWN;
				else
					code = AKS_VOLDOWN;
			}
			break;
		case DIK_NUMPADPLUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_INCREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLUP;
				else
					code = AKS_VOLUP;
			}
			break;
		case DIK_NUMPADSTAR:
			if (specialpressed ()) {
				if (ctrlpressed ())
					code = AKS_MVOLMUTE;
				else
					code = AKS_VOLMUTE;
			}
			break;
		case DIK_NUMPADSLASH:
			if (specialpressed ())
				code = AKS_STATEREWIND;
			break;
		}
	}

	if (code) {
		inputdevice_add_inputcode (code, 1);
		return;
	}

	scancode = scancode_new;
	if (!specialpressed () && newstate) {
		if (scancode == DIK_CAPITAL) {
			host_capslockstate = host_capslockstate ? 0 : 1;
			capslockstate = host_capslockstate;
		}
		if (scancode == DIK_NUMLOCK) {
			host_numlockstate = host_numlockstate ? 0 : 1;
			capslockstate = host_numlockstate;
		}
		if (scancode == DIK_SCROLL) {
			host_scrolllockstate = host_scrolllockstate ? 0 : 1;
			capslockstate = host_scrolllockstate;
		}
	}
	if (specialpressed ())
		return;

	inputdevice_translatekeycode (keyboard, scancode, newstate);
}
Пример #3
0
bool my_kbd_handler (int keyboard, int scancode, int newstate)
{
	int code = 0;
	int scancode_new;
	bool amode = currprefs.input_keyboard_type == 0;
	bool special = false;
	static int swapperdrive = 0;

#if 0
	if (scancode == specialkeycode ()) {
		inputdevice_checkqualifierkeycode (keyboard, scancode, newstate);
		return;
	}
#endif
#if 0
	if (scancode == DIK_F1) {
		if (newstate) {
			extern int paska;
			paska++;
		}
		return;
	}
	if (scancode == DIK_F2) {
		if (newstate) {
			extern int paska;
			paska--;
		}
		return;
	}
#endif

	if (amode && scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ())
		code = AKS_QUIT;

	if (scancode == DIK_F9 && specialpressed ()) {
		if (newstate)
			toggle_rtg (-1);
		return true;
	}

	scancode_new = scancode;
	if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode))
		scancode = 0;
	
	if (newstate) {
		int defaultguikey = amode ? DIK_F12 : DIK_NUMLOCK;
		if (currprefs.win32_guikey >= 0x100) {
			if (scancode_new == DIK_F12)
				return true;
		} else if (currprefs.win32_guikey >= 0) {
			if (scancode_new == defaultguikey && currprefs.win32_guikey != scancode_new) {
				scancode = 0;
				if (specialpressed () && ctrlpressed() && shiftpressed() && altpressed ())
					inputdevice_add_inputcode (AKS_ENTERGUI, 1);
			} else if (scancode_new == currprefs.win32_guikey ) {
				inputdevice_add_inputcode (AKS_ENTERGUI, 1);
				scancode = 0;
			}
		} else if (!specialpressed () && !ctrlpressed() && !shiftpressed() && !altpressed () && scancode_new == defaultguikey) {
			inputdevice_add_inputcode (AKS_ENTERGUI, 1);
			scancode = 0;
		}
	}

	//write_log (_T("keyboard = %d scancode = 0x%02x state = %d\n"), keyboard, scancode, newstate );

	if (newstate && code == 0 && amode) {

		switch (scancode)
		{
#if 0
		case DIK_F1:
		case DIK_F2:
		case DIK_F3:
		case DIK_F4:
			if (specialpressed ()) {
				if (ctrlpressed ()) {
				} else {
					if (shiftpressed ())
						code = AKS_EFLOPPY0 + (scancode - DIK_F1);
					else
						code = AKS_FLOPPY0 + (scancode - DIK_F1);
				}
			}
			special = true;
			break;
		case DIK_F5:
#if 0
			{
				disk_prevnext (0, -1);
				return;
				//crap++;
				//write_log (_T("%d\n"), crap);
			}
#endif
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_STATESAVEDIALOG;
				else
					code = AKS_STATERESTOREDIALOG;
			}
			special = true;
			break;
#endif

		case DIK_1:
		case DIK_2:
		case DIK_3:
		case DIK_4:
		case DIK_5:
		case DIK_6:
		case DIK_7:
		case DIK_8:
		case DIK_9:
		case DIK_0:
			if (specialpressed ()) {
				int num = scancode - DIK_1;
				if (shiftpressed ())
					num += 10;
				if (ctrlpressed ()) {
					swapperdrive = num;
					if (swapperdrive > 3)
						swapperdrive = 0;
				} else {
					int i;
					for (i = 0; i < 4; i++) {
						if (!_tcscmp (currprefs.floppyslots[i].df, currprefs.dfxlist[num]))
							changed_prefs.floppyslots[i].df[0] = 0;
					}
					_tcscpy (changed_prefs.floppyslots[swapperdrive].df, currprefs.dfxlist[num]);
					set_config_changed ();
				}
				special = true;
			}
			break;
		case DIK_NUMPAD0:
		case DIK_NUMPAD1:
		case DIK_NUMPAD2:
		case DIK_NUMPAD3:
		case DIK_NUMPAD4:
		case DIK_NUMPAD5:
		case DIK_NUMPAD6:
		case DIK_NUMPAD7:
		case DIK_NUMPAD8:
		case DIK_NUMPAD9:
		case DIK_NUMPADPERIOD:
			if (specialpressed ()) {
				int i = 0, v = -1;
				while (np[i] >= 0) {
					v = np[i + 1];
					if (np[i] == scancode)
						break;
					i += 2;
				}
				if (v >= 0)
					code = AKS_STATESAVEQUICK + v * 2 + ((shiftpressed () || ctrlpressed ()) ? 0 : 1);
				special = true;
			}
			break;
#if 0
		case DIK_PAUSE:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_IRQ7;
				else
					code = AKS_WARP;
			} else {
				code = AKS_PAUSE;
			}
			special = true;
			break;
#if 0
		case DIK_SCROLL:
			code = AKS_INHIBITSCREEN;
			break;
#endif
		case DIK_NUMPADMINUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_DECREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLDOWN;
				else
					code = AKS_VOLDOWN;
			}
			special = true;
			break;
		case DIK_NUMPADPLUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_INCREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLUP;
				else
					code = AKS_VOLUP;
			}
			special = true;
			break;
		case DIK_NUMPADSTAR:
			if (specialpressed ()) {
				if (ctrlpressed ())
					code = AKS_MVOLMUTE;
				else
					code = AKS_VOLMUTE;
			}
			special = true;
			break;
		case DIK_NUMPADSLASH:
			if (specialpressed ())
				code = AKS_STATEREWIND;
			special = true;
			break;
#endif
		}
	}

	if (code) {
		inputdevice_add_inputcode (code, 1);
		return true;
	}


	scancode = scancode_new;
	if (!specialpressed () && newstate) {
		if (scancode == DIK_CAPITAL) {
			host_capslockstate = host_capslockstate ? 0 : 1;
			capslockstate = host_capslockstate;
		}
		if (scancode == DIK_NUMLOCK) {
			host_numlockstate = host_numlockstate ? 0 : 1;
			capslockstate = host_numlockstate;
		}
		if (scancode == DIK_SCROLL) {
			host_scrolllockstate = host_scrolllockstate ? 0 : 1;
			capslockstate = host_scrolllockstate;
		}
	}

	if (special) {
		inputdevice_checkqualifierkeycode (keyboard, scancode, newstate);
		return true;
	}

	return inputdevice_translatekeycode (keyboard, scancode, newstate) != 0;
}