|
From: <mla...@us...> - 2006-11-21 16:13:38
|
Revision: 189
http://svn.sourceforge.net/g15daemon/?rev=189&view=rev
Author: mlampard
Date: 2006-11-21 08:13:35 -0800 (Tue, 21 Nov 2006)
Log Message:
-----------
add mutexs around all libg15 access, and improve keyboard handling
Modified Paths:
--------------
trunk/g15daemon-wip/g15daemon/main.c
Modified: trunk/g15daemon-wip/g15daemon/main.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/main.c 2006-11-21 16:10:15 UTC (rev 188)
+++ trunk/g15daemon-wip/g15daemon/main.c 2006-11-21 16:13:35 UTC (rev 189)
@@ -155,17 +155,26 @@
unsigned int keypresses = 0;
int retval = 0;
-
while (!leaving) {
pthread_mutex_lock(&g15lib_mutex);
retval = getPressedKeys(&keypresses, 40);
pthread_mutex_unlock(&g15lib_mutex);
+ /* every 2nd packet contains the codes we want.. immediately try again */
+ while (retval == G15_ERROR_TRY_AGAIN){
+ pthread_mutex_lock(&g15lib_mutex);
+ retval = getPressedKeys(&keypresses, 40);
+ pthread_mutex_unlock(&g15lib_mutex);
+ }
+
if(retval == G15_NO_ERROR){
g15daemon_send_event(masterlist->current->lcd,
- G15_EVENT_KEYPRESS, keypresses);
+ G15_EVENT_KEYPRESS, keypresses);
}
+ if(retval == G15_ERROR_READING_USB_DEVICE){
+ //g15daemon_log(LOG_WARNING,"Error reading the keyboard");
+ }
g15daemon_msleep(10);
}
@@ -205,9 +214,11 @@
}
if(displaying->state_changed ){
+ pthread_mutex_lock(&g15lib_mutex);
setLCDContrast(displaying->contrast_state);
setLEDs(displaying->mkey_state);
setLCDBrightness(displaying->backlight_state);
+ pthread_mutex_unlock(&g15lib_mutex);
displaying->state_changed = 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|