xenstore_write_dom0_driver("command", buff);
}
-static void dom0_driver_key_switch_1(void)
-{
- dom0_driver_key_switch(1);
-}
-
static void dom0_driver_read_secure(int ascii)
{
int write_sz;
if (!vga_passthrough)
return 0;
- if (mouse.state == -1)
+ if (mouse.state == -1)
{
DEBUG("No state grab the device\n");
dom0_gr_devices(1, DOM0_KEYBOARD);
binds[1] = KEY_1 + i;
dom0_driver_handler->add_binding(binds, dom0_driver_switch, (void*)(i + 1));
}
+
+ binds[0] = KEY_LEFTCTRL;
+ binds[1] = KEY_LEFTALT;
+ binds[2] = KEY_BACKSPACE;
+ binds[3] = -1;
+ dom0_driver_handler->add_binding(binds, dom0_driver_detect_secure_auth, NULL);
}
void dom0_driver_init(const char *position)
char *controller_paths[HID_LINUX_MAX_DEV];
int mouse_button_state;
int key_status[256];
+ void (*secure_key)(int ascii);
} hid_linux_driver;
struct hid_linux_binding
kbd_put_keycode(keycode & 0x7f);
}
-void hid_linux_reset_keyboard(void)
-{
- int i = 0;
- for (i = 0; i < 256; i++)
- if (hid_linux_driver.key_status[i])
- {
- hid_linux_key_inject(0, i);
- hid_linux_driver.key_status[i] = 0;
- }
-}
static void hid_linux_key_event(int code, uint32_t keycode)
{
hid_linux_key_inject(code, keycode);
}
-void hid_linux_secure_keyboard(void (*cb)(int ascii))
-{
-}
-
-static void hid_linux_redirect_fds(int *fd, IOHandler *cb)
-{
- assert(fd != NULL);
-
- while (*fd != -1)
- {
- qemu_set_fd_handler(*fd, cb, NULL, fd);
- fd++;
- }
-}
-
static void hid_linux_read(void *opaque)
{
struct input_event event[5];
}
}
+void hid_linux_reset_keyboard(void)
+{
+ int i = 0;
+
+ for (i = 0; i < 256; i++)
+ if (hid_linux_driver.key_status[i])
+ {
+ hid_linux_key_inject(0, i);
+ hid_linux_driver.key_status[i] = 0;
+ }
+}
+
+
+
+static void hid_linux_redirect_fds(int *fd, IOHandler *cb)
+{
+ assert(fd != NULL);
+
+ while (*fd != -1)
+ {
+ qemu_set_fd_handler(*fd, cb, NULL, fd);
+ fd++;
+ }
+}
+
+static void hid_linux_secure_read(void *opaque)
+{
+ struct input_event event[5];
+ int i = 0;
+ int read_sz = 0;
+ int fd = *(int *)opaque;
+
+ assert(hid_linux_driver.secure_key);
+
+ read_sz = read(fd, event, sizeof (event));
+ for (i = 0; i < read_sz / (sizeof (struct input_event)); i++)
+ if (event[i].type == EV_KEY && event[i].code < BTN_MOUSE &&
+ event[i].value > 0)
+ hid_linux_driver.secure_key(keycode2ascii(event[i].code));
+}
+
+
+void hid_linux_secure_keyboard(void (*cb)(int ascii))
+{
+ hid_linux_driver.secure_key = cb;
+ if (cb)
+ hid_linux_redirect_fds(hid_linux_driver.keyboard_fds,
+ hid_linux_secure_read);
+ else
+ hid_linux_redirect_fds(hid_linux_driver.keyboard_fds,
+ hid_linux_read);
+}
+
static int hid_linux_grab_devices(int grab, int *fd)
{
int rc = 0;
+ int try = 10;
assert(fd != NULL && *fd != -1);
for (; *fd != -1; fd++)
{
- if ((rc = ioctl(*fd, EVIOCGRAB, grab)) == -1)
+ while (try--)
{
- char *er;
- er = strerror(errno);
- DEBUG("ioctl(%d, EVOCGRAB) failed, %s\n", *fd, er);
- return 0;
+ if ((rc = ioctl(*fd, EVIOCGRAB, grab)) == -1)
+ {
+ char *er;
+ er = strerror(errno);
+ DEBUG("ioctl(%d, EVOCGRAB) failed, %s\n", *fd, er);
+ return 0;
+ }
+ else
+ break;
}
+ assert(try);
DEBUG("ioctl(%d, EVOCGRAB) succed\n", *fd);