#include <config.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <time.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XTest.h>
#include <X11/keysymdef.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <liberregxml/erregapi.h>
#include <libergtk/ergtk.h>
#include <libermanifest/ermanifest.h>
#include "contentListerLog.h"
#include "erbusy.h"
#include "button.h"
#include "erConnect.h"
#include "system.h"
#include "gtkPincodeScreen.h"
#include "control.h"
#include "programManager.h"
#include "stack.h"
#include "powerManager.h"
#include "click.h"
#include "toolbar.h"
#include "gtkDistListWnd.h"
Go to the source code of this file.
Functions | |
static void * | readFromButtons (void *arg) |
static void * | buttonStateMachine (void *arg) |
static int | button_get_timout (void) |
static void | button_handler (int button, gpointer data) |
static void | default_button_handling (int button, gpointer data) |
static void | misc_state_button_handling (int button, gpointer data) |
static void | pincode_state_button_handling (int button, gpointer data) |
static void | langsel_button_handling (int button, gpointer data) |
static gboolean | button_get_flipbar_direction_setting (void) |
static gboolean | button_key_buffering_timeout (gpointer data) |
static gint | button_get_key_buffering_setting (void) |
int | button_init (gpointer data) |
void | button_block_all_keys (gboolean do_block) |
void | button_enable_key_buffering (gboolean enable) |
static gboolean | button_is_enable_key_buffering () |
static regUserSetting_t * | btn_get_user_setting (void) |
void | flipbarDirectionSettingInit () |
void | keybufferingSettingInit () |
Variables | |
static gboolean | g_block_all_keys = FALSE |
static gboolean | g_flipbar_direction = TRUE |
static gint | g_keybuffering_setting = FALSE |
static gboolean | g_enable_key_buffering = TRUE |
static int | g_timeout_handler_id = 0 |
static pthread_cond_t | buttonCond |
static pthread_mutex_t | buttonCondMutex |
static int | protectedButton |
static struct timespec | g_timoutValue |
<File description>=""> Depending on the configure value "enable-command-line-input" the button input will come from the command line (number 1 till 11) or from the actual button driver
Definition in file button.c.
static regUserSetting_t* btn_get_user_setting | ( | void | ) | [static] |
Definition at line 427 of file button.c.
00428 { 00429 return erRegGetUserSetting(); 00430 }
void button_block_all_keys | ( | gboolean | do_block | ) |
Block/unblock all keys
block | - TRUE/FALSE indicates all keys must be blocked/unblocked |
Definition at line 165 of file button.c.
00166 { 00167 g_block_all_keys = do_block; 00168 }
void button_enable_key_buffering | ( | gboolean | enable | ) |
enable/disable key buffering
enable | - TRUE/FALSE indicates enable key buffering |
Definition at line 177 of file button.c.
00178 { 00179 g_enable_key_buffering = enable; 00180 00181 CL_LOGPRINTF("set g_enable_key_buffering =%d", enable); 00182 00183 if (TRUE == enable) 00184 { 00185 if (g_timeout_handler_id != 0) 00186 { 00187 g_source_remove(g_timeout_handler_id); 00188 g_timeout_handler_id = 0; 00189 } 00190 } 00191 else 00192 { 00193 if (g_timeout_handler_id == 0) 00194 { 00195 g_timeout_handler_id = g_timeout_add (KEYBUFFERING_OFF_TIMEOUT, 00196 button_key_buffering_timeout, NULL); 00197 } 00198 } 00199 }
static gboolean button_get_flipbar_direction_setting | ( | void | ) | [static] |
Definition at line 452 of file button.c.
00453 { 00454 regUserSetting_t *theUserSetting = NULL; 00455 gboolean value = TRUE; 00456 00457 theUserSetting = btn_get_user_setting(); 00458 if (theUserSetting) 00459 { 00460 value = theUserSetting->flipbarLeftIsDown; 00461 erRegFreeUserSetting(theUserSetting); 00462 } 00463 else 00464 { 00465 CL_WARNPRINTF("no reader settings"); 00466 } 00467 00468 CL_LOGPRINTF("flipbarDirection %d", value); 00469 return value; 00470 }
static gint button_get_key_buffering_setting | ( | void | ) | [static] |
Definition at line 478 of file button.c.
00479 { 00480 regUserSetting_t *theUserSetting = NULL; 00481 gint value = 0; 00482 00483 theUserSetting = btn_get_user_setting(); 00484 if (theUserSetting) 00485 { 00486 value = theUserSetting->keyBuffering; 00487 erRegFreeUserSetting(theUserSetting); 00488 } 00489 else 00490 { 00491 CL_WARNPRINTF("no reader settings"); 00492 } 00493 00494 CL_LOGPRINTF("keybuffering %d", value); 00495 return value; 00496 }
static int button_get_timout | ( | void | ) | [static] |
Definition at line 432 of file button.c.
00433 { 00434 regUserSetting_t *theUserSetting = NULL; 00435 int value = BUTTON_LONG_PRESS_TIMEOUT; 00436 00437 theUserSetting = btn_get_user_setting(); 00438 if ((theUserSetting) && (theUserSetting->longkeypressTimeout > 0)) 00439 { 00440 value = theUserSetting->longkeypressTimeout; 00441 erRegFreeUserSetting(theUserSetting); 00442 } 00443 else 00444 { 00445 CL_WARNPRINTF("no reader settings"); 00446 } 00447 00448 CL_LOGPRINTF("timout %d", value); 00449 return value; 00450 }
static void button_handler | ( | int | button, | |
gpointer | data | |||
) | [static] |
Definition at line 505 of file button.c.
00506 { 00507 CL_LOGPRINTF("entry: button [0x%04X] state [%d]", button, getListerState()); 00508 00509 // users set "Flipbar right" as default, need to exchange the UP/DOWN button 00510 if (FALSE == g_flipbar_direction) 00511 { 00512 if (PAGETURN_FORWARD == button) 00513 { 00514 button = PAGETURN_BACK; 00515 } 00516 else if (PAGETURN_BACK == button) 00517 { 00518 button = PAGETURN_FORWARD; 00519 } 00520 else if ((PAGETURN_FORWARD | BUTTON_LONG_PRESS) == button) 00521 { 00522 button = (PAGETURN_BACK | BUTTON_LONG_PRESS); 00523 } 00524 else if ((PAGETURN_BACK | BUTTON_LONG_PRESS) == button) 00525 { 00526 button = (PAGETURN_FORWARD | BUTTON_LONG_PRESS); 00527 } 00528 } 00529 00530 // discard key as needed 00531 if (g_block_all_keys && button != (POWER) && button != (POWER | BUTTON_LONG_PRESS)) 00532 { 00533 return; 00534 } 00535 00536 // with key-lock enabled, click only on the first few keys but discard all keys 00537 static int keyclicks_when_locked = MAX_KEYCLICKS_WHEN_LOCKED; 00538 00539 if ( toolbar_is_locked_selected() 00540 && button != (POWER ) 00541 && button != (POWER | BUTTON_LONG_PRESS) ) 00542 { 00543 // sound key-click as needed 00544 if (keyclicks_when_locked > 0) 00545 { 00546 --keyclicks_when_locked; 00547 click_key_discard(); 00548 } 00549 00550 // discard key 00551 return; 00552 } 00553 00554 // If g_keybuffering_setting > 0, all keys are passed to app in focus. 00555 // If g_keybuffering_setting == 0 00556 // - Keyhandling gets blocked i.e thrown away 00557 // - after first key when key handling is unblocked 00558 // - Keyhandling gets unblocked 00559 // - after 1 second timeout 00560 // - at a display update 00561 // - when busy indicator is switched off 00562 if (0 == g_keybuffering_setting) 00563 { 00564 if (FALSE == button_is_enable_key_buffering() ) 00565 { 00566 CL_LOGPRINTF("ingore key =%d\n", button); 00567 click_key_discard(); 00568 return; 00569 } 00570 button_enable_key_buffering(FALSE); 00571 } 00572 00573 00574 // key to be processed: reset key-click counter 00575 keyclicks_when_locked = MAX_KEYCLICKS_WHEN_LOCKED; 00576 00577 // Button has been pressed: go back to full cpu 00578 // power management disabled for now, needs more testing 00579 //power_cpu_full(); 00580 00581 #ifdef ENABLE_LOGGING 00582 // MvdW: Log this key 00583 erlog_event_button(button); 00584 #endif /* ENABLE LOGGING */ 00585 00586 // sound key-click 00587 click_key(); 00588 00589 listerState_t lister_state = getListerState(); 00590 if (lister_state == STATE_NORMAL) 00591 { 00592 if (listerIsErrorScreenVisible()) 00593 { 00594 gdk_threads_enter(); 00595 listerHideErrorScreen(); 00596 gdk_threads_leave(); 00597 } 00598 else 00599 { 00600 default_button_handling(button, data); 00601 } 00602 } 00603 else if (lister_state == STATE_USB_CONNECTED) 00604 { 00605 switch (button) 00606 { 00607 case POWER: 00608 case POWER | BUTTON_LONG_PRESS: 00609 // Powerdown button is the only button that works when connected via USB 00610 gdk_threads_enter(); 00611 ctrl_shutdown(); 00612 gdk_threads_leave(); 00613 break; 00614 00615 default: 00616 ctrl_usbmode_keypress(); 00617 } 00618 } 00619 else if (lister_state == STATE_DOWNLOADMGR) 00620 { 00621 // downloadMgr is launched from pincode screen, user can't press any keys 00622 if (TRUE == ctrl_is_connect_from_pincode()) 00623 { 00624 switch (button) 00625 { 00626 case OVERVIEW: 00627 case OVERVIEW | BUTTON_LONG_PRESS: 00628 case POWER: 00629 case POWER | BUTTON_LONG_PRESS: 00630 CL_LOGPRINTF("OVERVIEW_BUTTON or POWER_BUTTON"); 00631 ctrl_disconnect(connectScrUnchanged); 00632 break; 00633 00634 default: 00635 CL_WARNPRINTF("DownloadMgr state from pincode: buttons disabled"); 00636 erbusy_off(); 00637 } 00638 } 00639 else 00640 { 00641 erbusy_blink(); 00642 00643 switch (button) 00644 { 00645 case OVERVIEW: 00646 case OVERVIEW | BUTTON_LONG_PRESS: 00647 CL_LOGPRINTF("OVERVIEW_BUTTON"); 00648 gdk_threads_enter(); 00649 pm_SendKey(GDK_F5); 00650 gdk_threads_leave(); 00651 break; 00652 00653 case MODE: 00654 case MODE | BUTTON_LONG_PRESS: 00655 case POWER: 00656 case POWER | BUTTON_LONG_PRESS: 00657 CL_LOGPRINTF("MODE_BUTTON or POWER_BUTTON"); 00658 ctrl_disconnect(connectScrMode); 00659 break; 00660 00661 case NEWSPAPER: 00662 case NEWSPAPER | BUTTON_LONG_PRESS: 00663 CL_LOGPRINTF("MY_NEWSPAPERS_BUTTON"); 00664 ctrl_disconnect(connectScrNews); 00665 break; 00666 00667 case BOOKS: 00668 case BOOKS | BUTTON_LONG_PRESS: 00669 CL_LOGPRINTF("MY_BOOKS_BUTTON"); 00670 ctrl_disconnect(connectScrBooks); 00671 break; 00672 00673 case DOCUMENTS: 00674 case DOCUMENTS | BUTTON_LONG_PRESS: 00675 CL_LOGPRINTF("MY_DOCS_BUTTON"); 00676 ctrl_disconnect(connectScrDocs); 00677 break; 00678 00679 case NOTES: 00680 case NOTES | BUTTON_LONG_PRESS: 00681 CL_LOGPRINTF("MY_NOTES_BUTTON"); 00682 ctrl_disconnect(connectScrNotes); 00683 break; 00684 00685 default: 00686 CL_WARNPRINTF("DownloadMgr state: send key to connectionMgr"); 00687 default_button_handling(button, data); 00688 erbusy_off(); 00689 } 00690 } 00691 } 00692 else if (lister_state == STATE_MISC) 00693 { 00694 misc_state_button_handling(button, data); 00695 } 00696 else if (lister_state == STATE_PINCODE) 00697 { 00698 if (listerIsErrorScreenVisible()) 00699 { 00700 gdk_threads_enter(); 00701 listerHideErrorScreen(); 00702 gdk_threads_leave(); 00703 } 00704 else 00705 { 00706 pincode_state_button_handling(button, data); 00707 } 00708 } 00709 else if (lister_state == STATE_LANG_SEL) 00710 { 00711 if (listerIsErrorScreenVisible()) 00712 { 00713 gdk_threads_enter(); 00714 listerHideErrorScreen(); 00715 gdk_threads_leave(); 00716 } 00717 else 00718 { 00719 langsel_button_handling(button, data); 00720 } 00721 } 00722 else 00723 { 00724 CL_ERRORPRINTF("Unexpected lister_state [%d]", lister_state); 00725 } 00726 00727 CL_LOGPRINTF("leave"); 00728 }
int button_init | ( | gpointer | data | ) |
Start up button handling thread
data | value that needs to be passed in the button handling routines |
Definition at line 120 of file button.c.
00121 { 00122 00123 pthread_t theThread; 00124 00125 #ifdef COMMAND_LINE_INPUT 00126 CL_LOGPRINTF("Command line input"); 00127 00128 // Create the thread that will read from the keyboard. 00129 if (pthread_create(&theThread, NULL, readFromNamedPipe, (void *)data) != 0) 00130 { 00131 CL_ERRORPRINTF("Could not create thread"); 00132 return -1; 00133 } 00134 else 00135 { 00136 return 0; 00137 } 00138 #else 00139 CL_LOGPRINTF("Button driver input"); 00140 int timoutValue = button_get_timout(); 00141 g_timoutValue.tv_sec = timoutValue / 1000; 00142 g_timoutValue.tv_nsec = (timoutValue % 1000) * 1000000; 00143 keybufferingSettingInit(); 00144 flipbarDirectionSettingInit(); 00145 protectedButton = -1; 00146 pthread_mutex_init(&buttonCondMutex, NULL); 00147 pthread_cond_init(&buttonCond, NULL); 00148 // Create the thread that will read from the button driver. 00149 if (pthread_create(&theThread, NULL, readFromButtons, (void *)data) != 0) 00150 { 00151 CL_ERRORPRINTF("Could not create thread"); 00152 return -1; 00153 } 00154 if (pthread_create(&theThread, NULL, buttonStateMachine, (void *)data) != 0) 00155 { 00156 CL_ERRORPRINTF("Could not create thread"); 00157 return -1; 00158 } 00159 00160 return 0; 00161 #endif //COMMAND_LINE_INPUT 00162 }
static gboolean button_is_enable_key_buffering | ( | ) | [static] |
static gboolean button_key_buffering_timeout | ( | gpointer | data | ) | [static] |
Definition at line 207 of file button.c.
00208 { 00209 CL_LOGPRINTF("enable key buffering again for timeout"); 00210 button_enable_key_buffering(TRUE); 00211 return TRUE; 00212 }
static void * buttonStateMachine | ( | void * | arg | ) | [static] |
This thread implements the long keypress state machine. The state machine has two states: 0: no button is currently pressed 1: some button is currently pressed. the currently pressed button is stored in int button
in state 0, we wait for a button event to proceed. when a press is received, we go to state 1 in state 1, we do a wait with a timeout of BUTTON_LONG_PRESS_TIMEOUT ms if the wait returns with a timeout, it means the button is still pressed, and we handle it as a long press. if the wait returns because of being signalled, it means a button event has happened. if this is a release, we handle it as a short press.
Definition at line 339 of file button.c.
00340 { 00341 int button; 00342 struct timespec times; 00343 struct timeval timev; 00344 00345 enum 00346 { 00347 buttonReleased, 00348 buttonPressed 00349 } state = buttonReleased; 00350 00351 button = -1; 00352 while (1) 00353 { 00354 CL_LOGPRINTF("smthread: start of loop, state %d", state); 00355 switch (state) 00356 { 00357 case buttonReleased: 00358 pthread_mutex_lock(&buttonCondMutex); 00359 CL_LOGPRINTF("smthread: waiting for press"); 00360 pthread_cond_wait(&buttonCond, &buttonCondMutex); 00361 if (protectedButton == 0xFF) 00362 { 00363 CL_LOGPRINTF("smthread: release in released"); 00364 pthread_mutex_unlock(&buttonCondMutex); 00365 } 00366 else 00367 { 00368 CL_LOGPRINTF("smthread: press in released"); 00369 button = protectedButton; 00370 state = buttonPressed; 00371 pthread_mutex_unlock(&buttonCondMutex); 00372 } 00373 break; 00374 00375 case buttonPressed: 00376 pthread_mutex_lock(&buttonCondMutex); 00377 // get current time, and add BUTTON_LONG_PRESS_TIMEOUT ms 00378 // a timeval -> timespec conversion is needed (nanosec to microsec) 00379 gettimeofday(&timev, NULL); 00380 times.tv_sec = timev.tv_sec + g_timoutValue.tv_sec; 00381 times.tv_nsec = (timev.tv_usec * 1000) + g_timoutValue.tv_nsec; 00382 if (times.tv_nsec >= 1000000000) 00383 { 00384 times.tv_nsec -= 1000000000; 00385 times.tv_sec += 1; 00386 } 00387 CL_LOGPRINTF("smthread: timed waiting for release"); 00388 if (pthread_cond_timedwait(&buttonCond, &buttonCondMutex, ×) == ETIMEDOUT) 00389 { 00390 CL_LOGPRINTF("smthread: timeout in pressed"); 00391 pthread_mutex_unlock(&buttonCondMutex); 00392 if (button >= 0 && button < NUM_BUTTONS) 00393 { 00394 CL_LOGPRINTF("smthread: long button handler"); 00395 button_handler(button | BUTTON_LONG_PRESS, arg); // long 00396 } 00397 button = -1; 00398 state = buttonReleased; 00399 } 00400 else 00401 { 00402 if (protectedButton == 0xFF) 00403 { 00404 CL_LOGPRINTF("smthread: release in pressed"); 00405 state = buttonReleased; 00406 pthread_mutex_unlock(&buttonCondMutex); 00407 if (button >= 0 && button < NUM_BUTTONS) 00408 { 00409 CL_LOGPRINTF("smthread: short button handler"); 00410 button_handler(button, arg); // short 00411 } 00412 button = -1; 00413 } 00414 else 00415 { 00416 CL_LOGPRINTF("smthread: press in pressed"); 00417 button = protectedButton; 00418 pthread_mutex_unlock(&buttonCondMutex); 00419 } 00420 } 00421 break; 00422 } 00423 } 00424 pthread_exit(NULL); 00425 }
static void default_button_handling | ( | int | button, | |
gpointer | data | |||
) | [static] |
Definition at line 730 of file button.c.
00731 { 00732 CL_LOGPRINTF("entry: button [0x%04X]", button); 00733 00734 erbusy_blink(); 00735 00736 switch (button) 00737 { 00738 case NEWSPAPER: 00739 case NEWSPAPER | BUTTON_LONG_PRESS: 00740 CL_LOGPRINTF("MY_NEWSPAPERS_BUTTON"); 00741 gdk_threads_enter(); 00742 ctrl_contentType_button_clicked(st_ContentTypeNews); 00743 gdk_threads_leave(); 00744 break; 00745 00746 case BOOKS: 00747 case BOOKS | BUTTON_LONG_PRESS: 00748 CL_LOGPRINTF("MY_BOOKS_BUTTON"); 00749 gdk_threads_enter(); 00750 ctrl_contentType_button_clicked(st_ContentTypeBooks); 00751 gdk_threads_leave(); 00752 break; 00753 00754 case DOCUMENTS: 00755 case DOCUMENTS | BUTTON_LONG_PRESS: 00756 CL_LOGPRINTF("MY_DOCS_BUTTON"); 00757 gdk_threads_enter(); 00758 ctrl_contentType_button_clicked(st_ContentTypeDocs); 00759 gdk_threads_leave(); 00760 break; 00761 00762 case NOTES: 00763 case NOTES | BUTTON_LONG_PRESS: 00764 CL_LOGPRINTF("MY_NOTES_BUTTON"); 00765 gdk_threads_enter(); 00766 ctrl_contentType_button_clicked(st_ContentTypeNotes); 00767 gdk_threads_leave(); 00768 break; 00769 00770 case MODE: 00771 CL_LOGPRINTF("MODE_BUTTON"); 00772 gdk_threads_enter(); 00773 ctrl_mode_button_clicked(); 00774 gdk_threads_leave(); 00775 break; 00776 00777 case MODE | BUTTON_LONG_PRESS: 00778 CL_LOGPRINTF("MODE_BUTTON LONG"); 00779 gdk_threads_enter(); 00780 ctrl_mode_button_long_clicked(); 00781 gdk_threads_leave(); 00782 break; 00783 00784 case PAGETURN_FORWARD: 00785 CL_LOGPRINTF("PAGETURN_FORWARD"); 00786 gdk_threads_enter(); 00787 pm_SendKey(GDK_Page_Down); 00788 gdk_threads_leave(); 00789 break; 00790 00791 case PAGETURN_FORWARD | BUTTON_LONG_PRESS: 00792 CL_LOGPRINTF("PAGETURN_FORWARD LONG"); 00793 gdk_threads_enter(); 00794 pm_SendKey(GDK_F1); 00795 gdk_threads_leave(); 00796 break; 00797 00798 case PAGETURN_BACK: 00799 CL_LOGPRINTF("PAGETURN_BACK"); 00800 gdk_threads_enter(); 00801 pm_SendKey(GDK_Page_Up); 00802 gdk_threads_leave(); 00803 break; 00804 00805 case PAGETURN_BACK | BUTTON_LONG_PRESS: 00806 CL_LOGPRINTF("PAGETURN_BACK LONG"); 00807 gdk_threads_enter(); 00808 pm_SendKey(GDK_F2); 00809 gdk_threads_leave(); 00810 break; 00811 00812 case OVERVIEW: 00813 CL_LOGPRINTF("OVERVIEW_BUTTON"); 00814 gdk_threads_enter(); 00815 pm_SendKey(GDK_F5); 00816 gdk_threads_leave(); 00817 break; 00818 00819 case OVERVIEW | BUTTON_LONG_PRESS: 00820 CL_LOGPRINTF("OVERVIEW_BUTTON LONG"); 00821 gdk_threads_enter(); 00822 pm_SendKey(GDK_Home); 00823 gdk_threads_leave(); 00824 break; 00825 00826 case NAVIGATE_3: 00827 CL_LOGPRINTF("NEXT_LINK_BUTTON"); 00828 gdk_threads_enter(); 00829 pm_SendKey(GDK_Down); 00830 gdk_threads_leave(); 00831 break; 00832 00833 case NAVIGATE_3 | BUTTON_LONG_PRESS: 00834 CL_LOGPRINTF("NEXT_LINK_BUTTON LONG"); 00835 gdk_threads_enter(); 00836 pm_SendKey(GDK_F3); 00837 gdk_threads_leave(); 00838 break; 00839 00840 case NAVIGATE_1: 00841 CL_LOGPRINTF("PREVIOUS_LINK_BUTTON"); 00842 gdk_threads_enter(); 00843 pm_SendKey(GDK_Up); 00844 gdk_threads_leave(); 00845 break; 00846 00847 case NAVIGATE_1 | BUTTON_LONG_PRESS: 00848 CL_LOGPRINTF("PREVIOUS_LINK_BUTTON LONG"); 00849 gdk_threads_enter(); 00850 pm_SendKey(GDK_F4); 00851 gdk_threads_leave(); 00852 break; 00853 00854 case NAVIGATE_2: 00855 CL_LOGPRINTF("CONFIRM_BUTTON"); 00856 gdk_threads_enter(); 00857 pm_SendKey(GDK_Return); 00858 gdk_threads_leave(); 00859 break; 00860 00861 case NAVIGATE_2 | BUTTON_LONG_PRESS: 00862 CL_LOGPRINTF("CONFIRM_BUTTON LONG"); 00863 gdk_threads_enter(); 00864 pm_SendKey(GDK_F6); 00865 gdk_threads_leave(); 00866 break; 00867 00868 case CONNECT: 00869 CL_LOGPRINTF("CONNECT_BUTTON"); 00870 gdk_threads_enter(); 00871 ctrl_display_download_history(); 00872 gdk_threads_leave(); 00873 break; 00874 00875 case CONNECT | BUTTON_LONG_PRESS: 00876 CL_LOGPRINTF("CONNECT_BUTTON LONG"); 00877 gdk_threads_enter(); 00878 ctrl_connect_button_clicked(); 00879 gdk_threads_leave(); 00880 break; 00881 00882 case POWER: 00883 case POWER | BUTTON_LONG_PRESS: 00884 gdk_threads_enter(); 00885 ctrl_shutdown(); 00886 gdk_threads_leave(); 00887 break; 00888 00889 default: 00890 CL_ERRORPRINTF("unknown value %d", button); 00891 erbusy_off(); 00892 } 00893 }
void flipbarDirectionSettingInit | ( | ) |
read the value of flipbar direction from er_registry.txt
Definition at line 472 of file button.c.
00473 { 00474 // get the value of flipbar direction from the user settings 00475 g_flipbar_direction = button_get_flipbar_direction_setting(); 00476 }
void keybufferingSettingInit | ( | ) |
read the value of key buffering from er_registry.txt
Definition at line 498 of file button.c.
00499 { 00500 // get the value of key buffering from the user settings 00501 g_keybuffering_setting = button_get_key_buffering_setting(); 00502 }
static void langsel_button_handling | ( | int | button, | |
gpointer | data | |||
) | [static] |
Definition at line 999 of file button.c.
01000 { 01001 CL_LOGPRINTF("entry: button [0x%04X]", button); 01002 01003 erbusy_blink(); 01004 01005 switch (button) 01006 { 01007 case OVERVIEW: 01008 case OVERVIEW | BUTTON_LONG_PRESS: 01009 case NAVIGATE_3: 01010 case NAVIGATE_3 | BUTTON_LONG_PRESS: 01011 case NAVIGATE_1: 01012 case NAVIGATE_1 | BUTTON_LONG_PRESS: 01013 case NAVIGATE_2: 01014 case NAVIGATE_2 | BUTTON_LONG_PRESS: 01015 case POWER: 01016 case POWER | BUTTON_LONG_PRESS: 01017 default_button_handling(button, data); 01018 break; 01019 default: 01020 CL_ERRORPRINTF("unknown value %d", button); 01021 erbusy_off(); 01022 break; 01023 } 01024 }
static void misc_state_button_handling | ( | int | button, | |
gpointer | data | |||
) | [static] |
Definition at line 896 of file button.c.
00897 { 00898 CL_LOGPRINTF("entry"); 00899 00900 int i; 00901 00902 erbusy_blink(); 00903 00904 switch (button) 00905 { 00906 case OVERVIEW: 00907 case OVERVIEW | BUTTON_LONG_PRESS: 00908 gdk_threads_enter(); 00909 ctrl_hide_misc_screen(); 00910 gdk_threads_leave(); 00911 break; 00912 00913 case MODE: 00914 case MODE | BUTTON_LONG_PRESS: 00915 case NEWSPAPER: 00916 case NEWSPAPER | BUTTON_LONG_PRESS: 00917 case BOOKS: 00918 case BOOKS | BUTTON_LONG_PRESS: 00919 case DOCUMENTS: 00920 case DOCUMENTS | BUTTON_LONG_PRESS: 00921 case NOTES: 00922 case NOTES | BUTTON_LONG_PRESS: 00923 case POWER: 00924 case POWER | BUTTON_LONG_PRESS: 00925 default_button_handling(button, data); 00926 break; 00927 00928 case PAGETURN_FORWARD: 00929 case PAGETURN_FORWARD | BUTTON_LONG_PRESS: 00930 gdk_threads_enter(); 00931 if (dist_list_wnd_is_visible()) 00932 { 00933 i = (button & BUTTON_LONG_PRESS) ? 5 : 1; 00934 dist_list_wnd_page_forward(i); 00935 } 00936 else 00937 { 00938 CL_WARNPRINTF("misc state: buttons disabled"); 00939 erbusy_off(); 00940 } 00941 gdk_threads_leave(); 00942 break; 00943 00944 case PAGETURN_BACK: 00945 case PAGETURN_BACK | BUTTON_LONG_PRESS: 00946 gdk_threads_enter(); 00947 if (dist_list_wnd_is_visible()) 00948 { 00949 i = (button & BUTTON_LONG_PRESS) ? 5 : 1; 00950 dist_list_wnd_page_back(i); 00951 } 00952 else 00953 { 00954 CL_WARNPRINTF("misc state: buttons disabled"); 00955 erbusy_off(); 00956 } 00957 gdk_threads_leave(); 00958 break; 00959 00960 default: 00961 CL_WARNPRINTF("misc state: buttons disabled"); 00962 erbusy_off(); 00963 } 00964 }
static void pincode_state_button_handling | ( | int | button, | |
gpointer | data | |||
) | [static] |
Definition at line 966 of file button.c.
00967 { 00968 erbusy_blink(); 00969 00970 switch (button) 00971 { 00972 case OVERVIEW: 00973 CL_LOGPRINTF("OVERVIEW_BUTTON"); 00974 gdk_threads_enter(); 00975 ctrl_pincode_overview_button_clicked(); 00976 gdk_threads_leave(); 00977 break; 00978 00979 case CONNECT | BUTTON_LONG_PRESS: 00980 CL_LOGPRINTF("CONNECT_BUTTON LONG"); 00981 gdk_threads_enter(); 00982 ctrl_pincode_connect_button_clicked(); 00983 gdk_threads_leave(); 00984 break; 00985 00986 case POWER: 00987 case POWER | BUTTON_LONG_PRESS: 00988 gdk_threads_enter(); 00989 ctrl_shutdown(); 00990 gdk_threads_leave(); 00991 break; 00992 00993 default: 00994 CL_WARNPRINTF("Pincode state: buttons(%d) disabled", button); 00995 ctrl_pincode_button_clicked(); 00996 } 00997 }
static void * readFromButtons | ( | void * | arg | ) | [static] |
This thread will do a blocking read until a button is pressed or released; store the button in protectedButton; signal the buttonStateMachine thread
Definition at line 258 of file button.c.
00259 { 00260 int status; 00261 int button_device; 00262 int ret; 00263 00264 button_device = open("/dev/buttons", O_RDWR); 00265 if (button_device == -1) 00266 { 00267 CL_ERRORPRINTF("Error opening buttondriver."); 00268 exit(-1); 00269 } 00270 00271 // Disable the activity led 00272 ioctl(button_device, BUTTON_IOCTL_WRITE_ACTIVITY_LED, 0); 00273 00274 // Scan keycode and detect status change 00275 int button; 00276 int button_old = 0xff; 00277 while (1) 00278 { 00279 usleep(100 * 1000L); 00280 ret = ioctl(button_device, BUTTON_IOCTL_GET_STATUS, &status); 00281 if (ret) 00282 { 00283 CL_ERRORPRINTF("ioctl returned 0x%x", ret); 00284 } 00285 else 00286 { 00287 button = GETBUTTON(status); 00288 if (button != button_old) 00289 { 00290 // Button has changed 00291 CL_LOGPRINTF("Button changed: new 0x%04X, old 0x%04X", button, button_old); 00292 button_old = button; 00293 pthread_mutex_lock(&buttonCondMutex); 00294 protectedButton = button; 00295 00296 /* Check if a button was pressed or released */ 00297 if (protectedButton == 0xff) 00298 { 00299 CL_LOGPRINTF("ioctlthread: Button released"); 00300 if (ret) 00301 { 00302 CL_ERRORPRINTF("ioctl returned 0x%x", ret); 00303 } 00304 } 00305 else if (protectedButton >= 0 && protectedButton < NUM_BUTTONS) 00306 { 00307 CL_LOGPRINTF 00308 ("ioctlthread: Button pressed: %d, Pen detect: %s", 00309 protectedButton, GETPENDETECT(status) ? "Yes" : "No"); 00310 if (ret) 00311 { 00312 CL_ERRORPRINTF("ioctl returned 0x%x", ret); 00313 } 00314 } 00315 else 00316 { 00317 CL_LOGPRINTF("ioctlthread: button weirdness"); 00318 } 00319 pthread_cond_signal(&buttonCond); 00320 pthread_mutex_unlock(&buttonCondMutex); 00321 } 00322 } 00323 } 00324 pthread_exit(NULL); 00325 }
pthread_cond_t buttonCond [static] |
pthread_mutex_t buttonCondMutex [static] |
gboolean g_block_all_keys = FALSE [static] |
gboolean g_enable_key_buffering = TRUE [static] |
gboolean g_flipbar_direction = TRUE [static] |
gint g_keybuffering_setting = FALSE [static] |
int g_timeout_handler_id = 0 [static] |
struct timespec g_timoutValue [static] |
int protectedButton [static] |