Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4342 → Rev 4343

/branches/dynload/uspace/srv/kbd/generic/kbd.c
42,13 → 42,16
#include <stdlib.h>
#include <stdio.h>
#include <ipc/ns.h>
#include <async.h>
#include <errno.h>
#include <arch/kbd.h>
#include <libadt/fifo.h>
#include <kbd/kbd.h>
 
#include <kbd.h>
#include <libadt/fifo.h>
#include <key_buffer.h>
#include <async.h>
#include <keys.h>
#include <kbd_port.h>
#include <kbd_ctl.h>
#include <layout.h>
 
#define NAME "kbd"
 
56,31 → 59,51
int phone2cons = -1;
keybuffer_t keybuffer;
 
static void irq_handler(ipc_callid_t iid, ipc_call_t *call)
void kbd_push_scancode(int scancode)
{
int chr;
printf("scancode: 0x%x\n", scancode);
kbd_ctl_parse_scancode(scancode);
}
 
#ifdef MOUSE_ENABLED
if (mouse_arch_process(phone2cons, call))
return;
#endif
kbd_arch_process(&keybuffer, call);
#include <kbd/keycode.h>
void kbd_push_ev(int type, unsigned int key, unsigned int mods)
{
kbd_event_t ev;
 
if (cons_connected && phone2cons != -1) {
/*
* recode to ASCII - one interrupt can produce more than one
* code so result is stored in fifo
*/
while (!keybuffer_empty(&keybuffer)) {
if (!keybuffer_pop(&keybuffer, (int *)&chr))
break;
printf("type: %d\n", type);
printf("mods: 0x%x\n", mods);
printf("keycode: %u\n", key);
 
async_msg_1(phone2cons, KBD_PUSHCHAR, chr);
}
}
ev.type = type;
ev.key = key;
ev.mods = mods;
 
ev.c = layout_parse_ev(&ev);
 
async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c);
}
 
//static void irq_handler(ipc_callid_t iid, ipc_call_t *call)
//{
// kbd_event_t ev;
//
// kbd_arch_process(&keybuffer, call);
//
// if (cons_connected && phone2cons != -1) {
// /*
// * One interrupt can produce more than one event so the result
// * is stored in a FIFO.
// */
// while (!keybuffer_empty(&keybuffer)) {
// if (!keybuffer_pop(&keybuffer, &ev))
// break;
//
// async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key,
// ev.mods, ev.c);
// }
// }
//}
 
static void console_connection(ipc_callid_t iid, ipc_call_t *icall)
{
ipc_callid_t callid;
119,6 → 142,7
}
 
 
 
int main(int argc, char **argv)
{
printf(NAME ": HelenOS Keyboard service\n");
125,8 → 149,8
ipcarg_t phonead;
/* Initialize arch dependent parts */
if (kbd_arch_init())
/* Initialize port driver. */
if (kbd_port_init())
return -1;
/* Initialize key buffer */
133,8 → 157,8
keybuffer_init(&keybuffer);
async_set_client_connection(console_connection);
async_set_interrupt_received(irq_handler);
/* Register service at nameserver */
 
/* Register service at nameserver. */
if (ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, 0, &phonead) != 0)
return -1;
141,7 → 165,7
printf(NAME ": Accepting connections\n");
async_manager();
 
/* Never reached */
/* Not reached. */
return 0;
}