Enlightenment CVS committal Author : raster Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_fb Modified Files: Tag: SPLIT Ecore_Fb.h ecore_fb.c Log Message: vt switching... fb (and evas) mdouels support vt switching... if you run ecore_fb stuff form the console... it plays "nice" with the mosue device etc. now i don't know if it works runing it from somehting that isnt a console... i need to work on that next... :) =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_fb/Attic/Ecore_Fb.h,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -3 -r1.1.2.7 -r1.1.2.8 --- Ecore_Fb.h 20 Feb 2003 06:56:40 -0000 1.1.2.7 +++ Ecore_Fb.h 27 Feb 2003 07:05:54 -0000 1.1.2.8 @@ -80,6 +80,9 @@ double ecore_fb_light_sensor_get(void); +void ecore_fb_callback_gain_set(void (*func) (void *data), void *data); +void ecore_fb_callback_lose_set(void (*func) (void *data), void *data); + #ifdef __cplusplus } #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_fb/Attic/ecore_fb.c,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -3 -r1.1.2.9 -r1.1.2.10 --- ecore_fb.c 27 Feb 2003 01:58:13 -0000 1.1.2.9 +++ ecore_fb.c 27 Feb 2003 07:05:54 -0000 1.1.2.10 @@ -14,6 +14,7 @@ #include <linux/vt.h> #include <linux/fb.h> #include <sys/ioctl.h> +#include <signal.h> typedef struct _Ecore_Fb_Ts_Event Ecore_Fb_Ts_Event; typedef struct _Ecore_Fb_Ts_Calibrate Ecore_Fb_Ts_Calibrate; @@ -81,15 +82,18 @@ static void _ecore_fb_event_free_key_down(void *ev, void *data); static void _ecore_fb_event_free_key_up(void *ev, void *data); static void _ecore_fb_event_free_generic(void *ev, void *data); - +static int _ecore_fb_signal_usr_handler(int type, void *ev, void *data); +static void _ecore_fb_vt_switch(int vt); + int ECORE_FB_EVENT_KEY_DOWN = 0; int ECORE_FB_EVENT_KEY_UP = 0; int ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = 0; int ECORE_FB_EVENT_MOUSE_BUTTON_UP = 0; int ECORE_FB_EVENT_MOUSE_MOVE = 0; -Ecore_Fd_Handler *_ecore_fb_ts_fd_handler_handle = NULL; -Ecore_Fd_Handler *_ecore_fb_kbd_fd_handler_handle = NULL; +static Ecore_Event_Handler *_ecore_fb_user_handler = NULL; +static Ecore_Fd_Handler *_ecore_fb_ts_fd_handler_handle = NULL; +static Ecore_Fd_Handler *_ecore_fb_kbd_fd_handler_handle = NULL; static int _ecore_fb_init_count = 0; static int _ecore_fb_ts_fd = 0; static int _ecore_fb_ps2_fd = 0; @@ -104,6 +108,15 @@ static int _ecore_fb_tty_prev_mode = 0; static int _ecore_fb_tty_prev_kd_mode = 0; static struct termios _ecore_fb_tty_prev_tio_mode; +static struct vt_mode _ecore_fb_vt_prev_mode; +static int _ecore_fb_current_vt = 0; +static int _ecore_fb_ctrl = 0; +static int _ecore_fb_alt = 0; + +static void (*_ecore_fb_func_fb_lost) (void *data) = NULL; +static void *_ecore_fb_func_fb_lost_data = NULL; +static void (*_ecore_fb_func_fb_gain) (void *data) = NULL; +static void *_ecore_fb_func_fb_gain_data = NULL; static double _ecore_fb_double_click_time = 0.25; @@ -410,16 +423,31 @@ if (_ecore_fb_tty_fd >= 0) { struct termios tio; - + struct vt_mode new_vtmode; + struct vt_stat vts; + tcgetattr(_ecore_fb_tty_fd, &_ecore_fb_tty_prev_tio_mode); ioctl(_ecore_fb_tty_fd, KDGETMODE, &_ecore_fb_tty_prev_kd_mode); ioctl(_ecore_fb_tty_fd, KDGKBMODE, &_ecore_fb_tty_prev_mode); + ioctl(_ecore_fb_tty_fd, VT_GETMODE, &_ecore_fb_vt_prev_mode); + if (ioctl(_ecore_fb_tty_fd, VT_GETSTATE, &vts) < 0) + { + /* HACK - need to better handle this if not on a vt */ + _ecore_fb_current_vt = 1; + } + else + _ecore_fb_current_vt = vts.v_active; tio.c_iflag = tio.c_oflag = tio.c_cflag = tio.c_lflag = 0; tio.c_cc[VTIME] = 0; tio.c_cc[VMIN] = 1; + new_vtmode.mode = VT_PROCESS; + new_vtmode.waitv = 0; + new_vtmode.relsig = SIGUSR1; + new_vtmode.acqsig = SIGUSR2; tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &tio); ioctl(_ecore_fb_tty_fd, KDSETMODE, KD_GRAPHICS); ioctl(_ecore_fb_tty_fd, KDSKBMODE, K_MEDIUMRAW); + ioctl(_ecore_fb_tty_fd, VT_SETMODE, &new_vtmode); } if (_ecore_fb_kbd_fd <= 0) _ecore_fb_kbd_fd = _ecore_fb_tty_fd; if (_ecore_fb_kbd_fd >= 0) @@ -457,6 +485,9 @@ } _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h); + _ecore_fb_user_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, + _ecore_fb_signal_usr_handler, + NULL); return _ecore_fb_init_count; } @@ -482,6 +513,7 @@ tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); ioctl(_ecore_fb_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); ioctl(_ecore_fb_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); + ioctl(_ecore_fb_tty_fd, VT_SETMODE, &_ecore_fb_vt_prev_mode); close(_ecore_fb_tty_fd); if (_ecore_fb_tty_fd == _ecore_fb_kbd_fd) _ecore_fb_kbd_fd = 0; } @@ -492,12 +524,17 @@ ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle); if (_ecore_fb_kbd_fd_handler_handle) ecore_main_fd_handler_del(_ecore_fb_kbd_fd_handler_handle); + if (_ecore_fb_user_handler) + ecore_event_handler_del(_ecore_fb_user_handler); _ecore_fb_ts_fd = 0; _ecore_fb_kbd_fd = 0; _ecore_fb_tty_fd = 0; _ecore_fb_ps2_fd = 0; _ecore_fb_ts_fd_handler_handle = NULL; _ecore_fb_kbd_fd_handler_handle = NULL; + _ecore_fb_user_handler = NULL; + _ecore_fb_ctrl = 0; + _ecore_fb_alt = 0; return _ecore_fb_init_count; } @@ -729,6 +766,20 @@ return (double)fl.brightness / 255.0; } +void +ecore_fb_callback_gain_set(void (*func) (void *data), void *data) +{ + _ecore_fb_func_fb_gain = func; + _ecore_fb_func_fb_gain_data = data; +} + +void +ecore_fb_callback_lose_set(void (*func) (void *data), void *data) +{ + _ecore_fb_func_fb_lost = func; + _ecore_fb_func_fb_lost_data = data; +} + static void _ecore_fb_size_get(int *w, int *h) { @@ -859,6 +910,7 @@ if (buf & 0x80) { /* DOWN */ + int vt_switch = -1; Ecore_Fb_Event_Key_Down *e; e = calloc(1, sizeof(Ecore_Fb_Event_Key_Down)); @@ -873,6 +925,30 @@ goto retry; } ecore_event_add(ECORE_FB_EVENT_KEY_DOWN, e, _ecore_fb_event_free_key_down, NULL); + if (!strcmp(e->keyname, "Control_L")) + _ecore_fb_ctrl++; + if (!strcmp(e->keyname, "Control_R")) + _ecore_fb_ctrl++; + else if (!strcmp(e->keyname, "Alt_L")) + _ecore_fb_alt++; + else if (!strcmp(e->keyname, "Alt_R")) + _ecore_fb_alt++; + else if (!strcmp(e->keyname, "F1")) vt_switch = 0; + else if (!strcmp(e->keyname, "F2")) vt_switch = 1; + else if (!strcmp(e->keyname, "F3")) vt_switch = 2; + else if (!strcmp(e->keyname, "F4")) vt_switch = 3; + else if (!strcmp(e->keyname, "F5")) vt_switch = 4; + else if (!strcmp(e->keyname, "F6")) vt_switch = 5; + else if (!strcmp(e->keyname, "F7")) vt_switch = 6; + else if (!strcmp(e->keyname, "F8")) vt_switch = 7; + else if (!strcmp(e->keyname, "F9")) vt_switch = 8; + else if (!strcmp(e->keyname, "F10")) vt_switch = 9; + else if (!strcmp(e->keyname, "F11")) vt_switch = 10; + else if (!strcmp(e->keyname, "F12")) vt_switch = 11; + if (_ecore_fb_ctrl > 2) _ecore_fb_ctrl = 2; + if (_ecore_fb_alt > 2) _ecore_fb_alt = 2; + if (vt_switch >= 0) + _ecore_fb_vt_switch(vt_switch); } else { @@ -891,6 +967,16 @@ goto retry; } ecore_event_add(ECORE_FB_EVENT_KEY_UP, e, _ecore_fb_event_free_key_up, NULL); + if (!strcmp(e->keyname, "Control_L")) + _ecore_fb_ctrl--; + if (!strcmp(e->keyname, "Control_R")) + _ecore_fb_ctrl--; + else if (!strcmp(e->keyname, "Alt_L")) + _ecore_fb_alt--; + else if (!strcmp(e->keyname, "Alt_R")) + _ecore_fb_alt--; + if (_ecore_fb_ctrl < 0) _ecore_fb_ctrl = 0; + if (_ecore_fb_alt < 0) _ecore_fb_alt = 0; } retry: } @@ -1029,4 +1115,99 @@ _ecore_fb_event_free_generic(void *ev, void *data) { free(ev); +} + +static int +_ecore_fb_signal_usr_handler(int type, void *ev, void *data) +{ + Ecore_Event_Signal_User *e; + + e = (Ecore_Event_Signal_User *)ev; + if (e->number == 1) + { + /* release */ + if (_ecore_fb_func_fb_lost) + _ecore_fb_func_fb_lost(_ecore_fb_func_fb_lost_data); + if (_ecore_fb_ps2_fd > 0) close(_ecore_fb_ps2_fd); + if (_ecore_fb_ts_fd >= 0) close(_ecore_fb_ts_fd); + if (_ecore_fb_ts_fd_handler_handle) + ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle); + _ecore_fb_ps2_fd = 0; + _ecore_fb_ts_fd = 0; + _ecore_fb_ts_fd_handler_handle = NULL; + ioctl(_ecore_fb_tty_fd, VT_RELDISP, 1); + } + else if (e->number == 2) + { + int prev_flags; + + /* gain */ + if (_ecore_fb_func_fb_gain) + _ecore_fb_func_fb_gain(_ecore_fb_func_fb_gain_data); + _ecore_fb_ts_fd = open("/dev/touchscreen/0", O_RDONLY); + if (_ecore_fb_ts_fd >= 0) + { + prev_flags = fcntl(_ecore_fb_ts_fd, F_GETFL); + fcntl(_ecore_fb_ts_fd, F_SETFL, prev_flags | O_NONBLOCK); + _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ts_fd, + ECORE_FD_READ, + _ecore_fb_ts_fd_handler, NULL, + NULL, NULL); + if (!_ecore_fb_ts_fd_handler_handle) + { + close(_ecore_fb_ts_fd); + } + } + if (_ecore_fb_ts_fd < 0) + { + _ecore_fb_ps2_fd = open("/dev/psaux", O_RDWR); + if (_ecore_fb_ps2_fd >= 0) + { + prev_flags = fcntl(_ecore_fb_ps2_fd, F_GETFL); + fcntl(_ecore_fb_ps2_fd, F_SETFL, prev_flags | O_NONBLOCK); + _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ps2_fd, + ECORE_FD_READ, + _ecore_fb_ps2_fd_handler, NULL, + NULL, NULL); + if (!_ecore_fb_ts_fd_handler_handle) + { + close(_ecore_fb_ps2_fd); + } + } + } + if (_ecore_fb_tty_fd != 0) + { + struct termios tio; + struct vt_mode new_vtmode; + + tio.c_iflag = tio.c_oflag = tio.c_cflag = tio.c_lflag = 0; + tio.c_cc[VTIME] = 0; + tio.c_cc[VMIN] = 1; + new_vtmode.mode = VT_PROCESS; + new_vtmode.waitv = 0; + new_vtmode.relsig = SIGUSR1; + new_vtmode.acqsig = SIGUSR2; + tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &tio); + ioctl(_ecore_fb_tty_fd, KDSETMODE, KD_GRAPHICS); + ioctl(_ecore_fb_tty_fd, KDSKBMODE, K_MEDIUMRAW); + ioctl(_ecore_fb_tty_fd, VT_SETMODE, &new_vtmode); + } + } + return 1; +} + +static void +_ecore_fb_vt_switch(int vt) +{ + vt++; + if (_ecore_fb_tty_fd != 0) + { + if (vt != _ecore_fb_current_vt) + { + tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); + ioctl(_ecore_fb_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); + ioctl(_ecore_fb_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); + } + } + ioctl(_ecore_fb_tty_fd, VT_ACTIVATE, vt); } ------------------------------------------------------- This SF.net email is sponsored by: Scholarships for Techies! Can't afford IT training? All 2003 ictp students receive scholarships. Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more. www.ictp.com/training/sourceforge.asp _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs