Esempio n. 1
0
//키보드로부터 입력받은 데이터를 가공하는 함수(raw_keydata_q -> user_keydata_q)
static DWORD KbdpTranslatorThread(PVOID StartContext)
{
	KBD_KEY_DATA key_data;
	BYTE raw_key, indicator, key_family;

	while(1) {

		if(!KbdpPopRawKeyData(&(m_KbdData.raw_keydata_q), &raw_key)){
			HalTaskSwitch();
			continue;
		}

		if(raw_key & 0x80) {
			if(raw_key == 0xaa || raw_key == 0xb6)
				m_KbdData.shift_key_pressed = FALSE;
			else if(raw_key == 0xb8)
				m_KbdData.alt_key_pressed = FALSE;
			else if(raw_key == 0x9d)
				m_KbdData.ctrl_key_pressed = FALSE;
			continue;
		}

		if(raw_key == 0x45) {
			indicator = KBD_LED_NUMLOCK;
			goto $reset;
		} else if (raw_key == 0x3a) {
			indicator = KBD_LED_CAPSLOCK;
			goto $reset;
		} else if(raw_key == 0x46) {
			indicator = KBD_LED_SCROLLLOCK;
$reset:
			if(m_KbdData.indicator_status & indicator) {
				m_KbdData.indicator_status &= (~indicator);
			} else {
				m_KbdData.indicator_status |= indicator;
			}
			KbdpResetIndicator();
			continue;
		}

		if(raw_key == 0x2a || raw_key == 0x36) {
			m_KbdData.shift_key_pressed = TRUE;
		} else if(raw_key == 0x1d) {
			m_KbdData.ctrl_key_pressed = TRUE;
		} else if(raw_key == 0x38) {
			m_KbdData.alt_key_pressed = TRUE;
		}

		key_family = KBD_ASCII_ORG;
		key_family |= (m_KbdData.shift_key_pressed ? KBD_ASCII_WITH_SHIFT : 0);
		key_family |= (m_KbdData.indicator_status&KBD_LED_CAPSLOCK ? KBD_ASCII_WITH_CAPSLOCK : 0);

		key_data.type = KBD_KTYPE_GENERAL;
		key_data.key = m_AsciiCode[key_family][raw_key];
		KbdpPushUserKeyData(&(m_KbdData.user_keydata_q), &key_data);
	}

	return 0;
}
Esempio n. 2
0
BOOL KbdInitializeDriver(VOID)
{
	memset(&m_KbdData, 0, sizeof(m_KbdData));

	m_KbdData.indicator_status = KBD_LED_NUMLOCK;

	KbdpResetIndicator();

	if(!PsCreateProcess(&m_ProcessHandle))
		return FALSE;

	if(!PsCreateThread(&m_TranslatorThreadHandle,m_ProcessHandle, KbdpTranslatorThread, NULL, DEFAULT_STACK_SIZE, FALSE))
		return FALSE;
	PsSetThreadStatus(m_TranslatorThreadHandle, THREAD_STATUS_READY);
$reset:
	return TRUE;

}
Esempio n. 3
0
/**********************************************************************************************************
 *                                             GLOBAL FUNTIONS                                            *
 **********************************************************************************************************/
BOOL KbdInitializeDriver(VOID)
{
	memset(&m_KbdData, 0, sizeof(m_KbdData));

	/* initial indicator LEDs */
	m_KbdData.indicator_status = KBD_LED_NUMLOCK;
	KbdpResetIndicator();

	/* create keyboard process */
	if(!PsCreateProcess(&m_ProcessHandle)) 
		return FALSE;

	/* create a thread doing translation of raw_key_data 2 user_key_data */
	if(!PsCreateThread(&m_TranslatorThreadHandle, m_ProcessHandle, KbdpTranslatorThread, NULL, DEFAULT_STACK_SIZE, FALSE)) 
		return FALSE;
	PsSetThreadStatus(m_TranslatorThreadHandle, THREAD_STATUS_READY); /* i'm ready! */

	return TRUE;
}
Esempio n. 4
0
/*
								* LED ASSOCIATED KEYs *
45-c5 : num-lock
3a-ba : capslock
46-c6 : scroll-lock

								* MAIN KEYs (LEFT-SIDED AREA) *
2a-aa : left-shift
36-b6 : right-shift
1d-9d : left-ctrl
e0-1d-e0-9d : right-ctrl
38-b8 : left-alt
e0-38-e0-b8 : right-alt

1c-9c : enter
e-8e : back-space
f-8f : tab

e0-71-e0-f1 : chinese
e0-5c-e0-dc : right-windows-key
e0-72 : kor/eng

1-81 : esc

3b-bb : f1
3c-bc : f2
3d-bd : f3
3e-be : f4
3f-bf : f5
40-c0 : f6
41-c1 : f7
42-c2 : f8
43-c3 : f9
44-c4 : f10
57-d7 : f11
58-d8 : f12

								* MIDDLE SIDE *
e0-2a-e0-37-e0-b7-e0-aa : print screen
e1-1d-45-e1-9d-c5 : pause

e0-2a-e0-52-e0-d2-e0-aa : insert
e0-2a-e0-47-e0-c7-e0-aa : home
e0-2a-e0-49-e0-c9-e0-aa : page up
e0-2a-e0-53-e0-d3-e0-aa : delete
e0-2a-e0-4f-e0-cf-e0-aa : end
e0-2a-e0-51-e0-d1-e0-aa : page down

e0-2a-e0-48-e0-c8-e0-aa : up arrow
e0-2a-e0-50-e0-d0-e0-aa : down arrow
e0-2a-e0-4b-e0-cb-e0-aa : left arrow
e0-2a-e0-4d-e0-cd-e0-aa : right arrow

								* NUM PAD *
e0-35-e0-b5 : /
37-b7 : *
4a-ca : -
4e-ce : +
e0-1c-e0-9c : enter
53-d3 : . (or Del)
52-d2 : 0 (or Ins)
4f-cf : 1
50-d0 : 2
51-d1 : 3
4b-cb : 4
4c-cc : 5
4d-cd : 6
47-c7 : 7
48-c8 : 8
c9-49 : 9

e0-21-e0-a1 : calculator
e0-18-e0-98 : X'fer
*/
static DWORD KbdpTranslatorThread(PVOID StartContext)
{
	KBD_KEY_DATA key_data;
	BYTE raw_key, indicator, key_family;

	while(1) {
		if(!KbdpPopRawKeyData(&(m_KbdData.raw_keydata_q), &raw_key)) {
			HalTaskSwitch(); /* if there is no remained job to do, then call task-swithing task in order to run other taks. */
			continue;
		}

		/* is this special key or function key started with '0xe0'? */
		/* do something */

		/* dont process such "break key" */
		if(raw_key & 0x80) {
			if(raw_key == 0xaa || raw_key == 0xb6) /* shift key breaked */
				m_KbdData.shift_key_pressed = FALSE;
			else if(raw_key == 0xb8) /* alt key breaked */
				m_KbdData.alt_key_pressed = FALSE;
			else if(raw_key == 0x9d) /* alt key breaked */
				m_KbdData.ctrl_key_pressed = FALSE;
			continue;
		}

		/* RESET INDICATORs */
		if(raw_key == 0x45) { /* num lock */
			indicator = KBD_LED_NUMLOCK;
			goto $reset_indicator;
		} else if(raw_key == 0x3a) { /* capslock */
			indicator = KBD_LED_CAPSLOCK;
			goto $reset_indicator;
		} else if(raw_key == 0x46) { /* scroll lock */
			indicator = KBD_LED_SCROLLLOCK;
$reset_indicator:
			if(m_KbdData.indicator_status & indicator) {
				m_KbdData.indicator_status &= (~indicator);
			} else {
				m_KbdData.indicator_status |= indicator;
			}
			KbdpResetIndicator();
			continue;
		}

		/* SHIFT, ALT, CTRL */
		if(raw_key == 0x2a || raw_key == 0x36) { /* shift */
			m_KbdData.shift_key_pressed = TRUE;		continue;
		} else if(raw_key == 0x1d) {
			m_KbdData.ctrl_key_pressed = TRUE;		continue;
		} else if(raw_key == 0x38) {
			m_KbdData.alt_key_pressed = TRUE;		continue;
		}

		/* GENERAL KEYs */
		key_family  = KBD_ASCII_ORG;
		key_family |= (m_KbdData.shift_key_pressed ? KBD_ASCII_WITH_SHIFT : 0);
		key_family |= (m_KbdData.indicator_status&KBD_LED_CAPSLOCK ? KBD_ASCII_WITH_CAPSLOCK : 0);

		key_data.type = KBD_KTYPE_GENERAL;
		key_data.key  = m_AsciiCode[key_family][raw_key];
		KbdpPushUserKeyData(&(m_KbdData.user_keydata_q), &key_data);
	}

	return 0;
}