42,6 → 42,7 |
#include <bool.h> |
|
|
/* GXemul key codes in no-framebuffer mode. */ |
#define GXEMUL_KEY_F1 0x504f1bL |
#define GXEMUL_KEY_F2 0x514f1bL |
#define GXEMUL_KEY_F3 0x524f1bL |
55,7 → 56,10 |
#define GXEMUL_KEY_F11 0x33325d1bL |
#define GXEMUL_KEY_F12 0x34325b1bL |
|
/** Start code of F5-F12 keys. */ |
#define GXEMUL_KEY_F5_F12_START_CODE 0x7e |
|
/* GXemul key codes in framebuffer mode. */ |
#define GXEMUL_FB_KEY_F1 0x504f5b1bL |
#define GXEMUL_FB_KEY_F2 0x514f5b1bL |
#define GXEMUL_FB_KEY_F3 0x524f5b1bL |
103,28 → 107,33 |
|
/** Process data sent when a key is pressed (in no-framebuffer mode). |
* |
* @param keybuffer Buffer of scan codes. |
* @param keybuffer Buffer of pressed key. |
* @param scan_code Scan code. |
* |
* @return Code of the pressed key. |
* @return Always 1. |
*/ |
static int gxemul_process_no_fb(keybuffer_t *keybuffer, int scan_code) |
static int gxemul_kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code) |
{ |
// holds at most 4 latest scan codes |
static unsigned long buf = 0; |
|
static unsigned long buf = 0; |
// number of scan codes in #buf |
static int count = 0; |
|
/* |
// Preserve for detecting scan codes. |
// keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf)); |
// keybuffer_push(keybuffer, to_hex(scan_code&0xf)); |
// keybuffer_push(keybuffer, 'X'); |
// keybuffer_push(keybuffer, 'Y'); |
// return 1; |
keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf)); |
keybuffer_push(keybuffer, to_hex(scan_code&0xf)); |
keybuffer_push(keybuffer, 'X'); |
keybuffer_push(keybuffer, 'Y'); |
return 1; |
*/ |
|
if (scan_code == '\r') |
if (scan_code == '\r') { |
scan_code = '\n'; |
} |
|
if(scan_code == 0x7e) { |
if (scan_code == GXEMUL_KEY_F5_F12_START_CODE) { |
switch (buf) { |
case GXEMUL_KEY_F5: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 5); |
169,6 → 178,7 |
} |
} |
|
// add to buffer |
buf |= ((unsigned long) scan_code)<<(8*(count++)); |
|
if((buf & 0xff) != (GXEMUL_KEY_F1 & 0xff)) { |
177,8 → 187,9 |
return 1; |
} |
|
if (count <= 1) |
if (count <= 1) { |
return 1; |
} |
|
if ((buf & 0xffff) != (GXEMUL_KEY_F1 & 0xffff) |
&& (buf & 0xffff) != (GXEMUL_KEY_F5 & 0xffff) ) { |
189,8 → 200,9 |
return 1; |
} |
|
if (count <= 2) |
if (count <= 2) { |
return 1; |
} |
|
switch (buf) { |
case GXEMUL_KEY_F1: |
222,8 → 234,9 |
return 1; |
} |
|
if (count <= 3) |
if (count <= 3) { |
return 1; |
} |
|
switch (buf) { |
case GXEMUL_KEY_F5: |
243,6 → 256,7 |
buf = count = 0; |
return 1; |
} |
|
return 1; |
} |
|
249,29 → 263,33 |
|
/** Process data sent when a key is pressed (in framebuffer mode). |
* |
* @param keybuffer Buffer of scan codes. |
* @param keybuffer Buffer of pressed keys. |
* @param scan_code Scan code. |
* |
* @return Code of the pressed key. |
* @return Always 1. |
*/ |
static int gxemul_process_fb(keybuffer_t *keybuffer, int scan_code) |
static int gxemul_kbd_process_fb(keybuffer_t *keybuffer, int scan_code) |
{ |
// holds at most 4 latest scan codes |
static unsigned long buf = 0; |
|
// number of scan codes in #buf |
static int count = 0; |
|
/* Please preserve this code (it can be used to determine scancodes) |
|
/* |
// Please preserve this code (it can be used to determine scancodes) |
keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf)); |
keybuffer_push(keybuffer, to_hex(scan_code&0xf)); |
keybuffer_push(keybuffer, ' '); |
keybuffer_push(keybuffer, ' '); |
|
return 1; |
*/ |
|
if (scan_code == '\r') |
if (scan_code == '\r') { |
scan_code = '\n'; |
} |
|
// add to buffer |
buf |= ((unsigned long) scan_code)<<(8*(count++)); |
|
|
281,8 → 299,9 |
return 1; |
} |
|
if (count <= 1) |
if (count <= 1) { |
return 1; |
} |
|
if ((buf & 0xffff) != (GXEMUL_FB_KEY_F1 & 0xffff)) { |
keybuffer_push(keybuffer, buf & 0xff); |
291,10 → 310,10 |
return 1; |
} |
|
if (count <= 2) |
if (count <= 2) { |
return 1; |
} |
|
|
if ((buf & 0xffffff) != (GXEMUL_FB_KEY_F1 & 0xffffff) |
&& (buf & 0xffffff) != (GXEMUL_FB_KEY_F5 & 0xffffff) |
&& (buf & 0xffffff) != (GXEMUL_FB_KEY_F9 & 0xffffff)) { |
306,10 → 325,10 |
return 1; |
} |
|
if ( count <= 3 ) |
if (count <= 3) { |
return 1; |
} |
|
|
switch (buf) { |
case GXEMUL_FB_KEY_F1: |
keybuffer_push(keybuffer,FUNCTION_KEYS | 1 ); |
367,6 → 386,7 |
buf=count=0; |
return 1; |
} |
|
return 1; |
} |
|
383,29 → 403,19 |
|
/** Process data sent when a key is pressed. |
* |
* @param keybuffer Buffer of scan codes. |
* @param keybuffer Buffer of pressed keys. |
* @param call IPC call. |
* |
* @return Code of the pressed key. |
* @return Always 1. |
*/ |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
int scan_code = IPC_GET_ARG2(*call); |
static int esc_count = 0; |
|
if (scan_code == 0x1b) { |
esc_count++; |
if (esc_count == 3) { |
__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE); |
} |
} else { |
esc_count = 0; |
} |
|
if (fb) { |
return gxemul_process_fb(keybuffer, scan_code); |
return gxemul_kbd_process_fb(keybuffer, scan_code); |
} else { |
return gxemul_process_no_fb(keybuffer, scan_code); |
return gxemul_kbd_process_no_fb(keybuffer, scan_code); |
} |
|
} |