1 /* Public Domain Curses */
5 RCSID("$Id: pdckbd.c,v 1.62 2008/07/14 04:24:52 wmcbrine Exp $")
7 /*man-start**************************************************************
12 unsigned long PDC_get_input_fd(void);
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};
30 /* Is something ready to be read on the socket ? Must be a key. */
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"));
46 /* return the next available key or mouse event */
50 unsigned long newkey
= 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
));
71 unsigned long PDC_get_input_fd(void)
73 PDC_LOG(("PDC_get_input_fd() - called\n"));
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())
94 int PDC_mouse_set(void)
99 int PDC_modifiers_set(void)