drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / payloads / libpayload / curses / PDCurses / x11 / pdckbd.c
blob2f85ba062da94eede1218204c314c5e5bb3a1029
1 /* Public Domain Curses */
3 #include "pdcx11.h"
5 RCSID("$Id: pdckbd.c,v 1.62 2008/07/14 04:24:52 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: pdckbd
11 Synopsis:
12 unsigned long PDC_get_input_fd(void);
14 Description:
15 PDC_get_input_fd() returns the file descriptor that PDCurses
16 reads its input from. It can be used for select().
18 Portability X/Open BSD SYS V
19 PDC_get_input_fd - - -
21 **man-end****************************************************************/
23 /* check if a key or mouse event is waiting */
25 bool PDC_check_key(void)
27 struct timeval socket_timeout = {0};
28 int s;
30 /* Is something ready to be read on the socket ? Must be a key. */
32 FD_ZERO(&xc_readfds);
33 FD_SET(xc_key_sock, &xc_readfds);
35 if ((s = select(FD_SETSIZE, (FD_SET_CAST)&xc_readfds, NULL,
36 NULL, &socket_timeout)) < 0)
37 XCursesExitCursesProcess(3, "child - exiting from "
38 "PDC_check_key select failed");
40 PDC_LOG(("%s:PDC_check_key() - returning %s\n", XCLOGMSG,
41 s ? "TRUE" : "FALSE"));
43 return !!s;
46 /* return the next available key or mouse event */
48 int PDC_get_key(void)
50 unsigned long newkey = 0;
51 int key = 0;
53 if (XC_read_socket(xc_key_sock, &newkey, sizeof(unsigned long)) < 0)
54 XCursesExitCursesProcess(2, "exiting from PDC_get_key");
56 pdc_key_modifiers = (newkey >> 24) & 0xFF;
57 key = (int)(newkey & 0x00FFFFFF);
59 if (key == KEY_MOUSE && SP->key_code)
61 if (XC_read_socket(xc_key_sock, &pdc_mouse_status,
62 sizeof(MOUSE_STATUS)) < 0)
63 XCursesExitCursesProcess(2, "exiting from PDC_get_key");
66 PDC_LOG(("%s:PDC_get_key() - key %d returned\n", XCLOGMSG, key));
68 return key;
71 unsigned long PDC_get_input_fd(void)
73 PDC_LOG(("PDC_get_input_fd() - called\n"));
75 return xc_key_sock;
78 void PDC_set_keyboard_binary(bool on)
80 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
83 /* discard any pending keyboard or mouse input -- this is the core
84 routine for flushinp() */
86 void PDC_flushinp(void)
88 PDC_LOG(("PDC_flushinp() - called\n"));
90 while (PDC_check_key())
91 PDC_get_key();
94 int PDC_mouse_set(void)
96 return OK;
99 int PDC_modifiers_set(void)
101 return OK;