Пример #1
0
void mod_down(const uint8_t code, const uint8_t action)
{
	switch(action & KEY_ACTION_MASK)
	{
	case ACTION_RAPIDFIRE:
	case ACTION_TAPKEY:
	case ACTION_LOCKABLE:
	case ACTION_NORMAL:
		set_modifier(code);
		break;
	case ACTION_TOGGLE:
		toggle_modifier(code);
		break;
	default:
		break;
	}
}
Пример #2
0
void input_thread(void *args)
{
	int					key=-1;
	int					lastkey;
	INPUT_RECORD		ckey;
	int i;
	DWORD d;
	SHORT s;

	input_thread_running=1;
	while(!terminate) {
		if(kbhit()) {
			lastkey=key;
			key=getch();
			if(key==0 || key == 0xff)
				key|=getch()<<8;
			if(key==1) {
				toggle_modifier(CIO_MOD_ALT);
				if(alt)
					continue;
			}
			if(key==18) {	/* CTRL-R */
				if(lastkey != 18) {
					force_redraw=1;
					continue;
				}
			}
			if(key==26) {	/* CTRL-Z */
				force_redraw=1;
				display_top=!display_top;
				if(lastkey != 26)
					continue;
			}
			if(key==8 || key==9 || key==10 || key==13 || key==27) {
				s=VkKeyScan(key);

				/* No translation */
				if(s==-1)
					continue;

				if(ctrl)
					toggle_modifier(CIO_MOD_CONTROL);
				if(shift)
					toggle_modifier(CIO_MOD_SHIFT);

				frobkey(TRUE, TRUE, MapVirtualKey(s & 0xff, 0), s&0xff, key);
			}
			else if(key < 256) {
				s=VkKeyScan(key);

				/* No translation */
				if(s==-1)
					continue;

				/* Make the mod states match up... */
				/* Wish I had a ^^ operator */
				if(((s & 0x0100) == 0x0100) != (shift != 0))
					toggle_modifier(CIO_MOD_SHIFT);
				if(((s & 0x0200) == 0x0200) != (ctrl != 0))
					toggle_modifier(CIO_MOD_CONTROL);
				/* ALT is handled via CTRL-A, not here */
				/* if(((s & 0x0400) == 0x0400) != (alt != 0))
					toggle_modifier(CIO_MOD_ALT); */

				frobkey(TRUE, TRUE, MapVirtualKey(s & 0xff, 0), s&0xff, key);
			}
			else {
				/* Check if CTRL or ALT are "pressed" */
				for(i=0;keyval[i].Key;i++) {
					if(keyval[i].Key==key)
						break;
					if(keyval[i].Shift==key) {
						/* Release the CTRL key */
						if(ctrl)
							toggle_modifier(CIO_MOD_CONTROL);
						/* Press the SHIFT key */
						if(!shift)
							toggle_modifier(CIO_MOD_SHIFT);
						break;
					}
					if(keyval[i].CTRL==key) {
						/* Release the shift key */
						if(shift)
							toggle_modifier(CIO_MOD_SHIFT);
						/* Press the CTRL key */
						if(!ctrl)
							toggle_modifier(CIO_MOD_CONTROL);
						break;
					}
					if(keyval[i].ALT==key) {
						/* Release the shift key */
						if(shift)
							toggle_modifier(CIO_MOD_SHIFT);
						/* Release the CTRL key */
						if(ctrl)
							toggle_modifier(CIO_MOD_CONTROL);
						/* Press the ALT key */
						if(!alt)
							toggle_modifier(CIO_MOD_ALT);
						break;
					}
				}
				frobkey(TRUE, TRUE, key>>8, MapVirtualKey(key>>8, 1), 0);
			}
			if(alt)
				toggle_modifier(CIO_MOD_ALT);
			if(ctrl)
				toggle_modifier(CIO_MOD_CONTROL);
			if(shift)
				toggle_modifier(CIO_MOD_SHIFT);
		}
		else
			SLEEP(1);
	}