You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(23) |
Dec
(26) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(2) |
Feb
(7) |
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(7) |
Sep
(8) |
Oct
(5) |
Nov
(11) |
Dec
(2) |
| 2008 |
Jan
(8) |
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
| 2009 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(16) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2010 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <mla...@us...> - 2006-12-27 08:38:26
|
Revision: 220
http://svn.sourceforge.net/g15tools/?rev=220&view=rev
Author: mlampard
Date: 2006-12-27 00:38:19 -0800 (Wed, 27 Dec 2006)
Log Message:
-----------
add g15 device struct to simplify adding newly available devices. add capabilities function to allow apps to retrieve data on available features of connected device.
Modified Paths:
--------------
trunk/libg15/debian/changelog
trunk/libg15/libg15.c
trunk/libg15/libg15.h
Modified: trunk/libg15/debian/changelog
===================================================================
--- trunk/libg15/debian/changelog 2006-12-19 20:55:27 UTC (rev 219)
+++ trunk/libg15/debian/changelog 2006-12-27 08:38:19 UTC (rev 220)
@@ -1,3 +1,20 @@
+libg15 (1.2.0) edgy; urgency=low
+ * Add debugging function to enable/disable extra output
+ * All debugging output is now prefixed with libg15 to aid localising
+ problems.
+ * debugging function now also controls libusb debugging output.
+ * Try to claim usb interface up to 10 times before failing
+ * Slow down initialisation, to allow keyboard to come out of usb
+ auto-suspend on newer kernels.
+ * Attempt to combat ENOSPC by slowing down writes to the lcd if ENOSPC is
+ received. Unless that error occurs at least once, transfers are sent as normal.
+ * Add function to change keyboard backlight (independant of lcd backlight).
+ * Add re-initialising function, which will attempt to reconnect a keyboard
+ that was previously removed and replugged.
+ * libg15 now uses pthread mutexes to force sequential access to the bus via
+ libusb. Control message URBs are no longer being lost if sent by a different
+ thread in the middle of a screen transfer etc.
+
libg15 (1.1.1-1) edgy; urgency=low
* Add basic support for the G11 keyboard
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-19 20:55:27 UTC (rev 219)
+++ trunk/libg15/libg15.c 2006-12-27 08:38:19 UTC (rev 220)
@@ -28,11 +28,27 @@
static int libg15_debugging_enabled = 0;
static int enospc_slowdown = 0;
+static int found_devicetype = -1;
+
static pthread_mutex_t libusb_mutex;
+/* to add a new device, simply create a new DEVICE() in this list */
+/* Fields are: "Name",VendorID,ProductID,Capabilities */
+const libg15_devices_t g15_devices[] = {
+ DEVICE("Logitech G15",0x46d,0xc222,G15_LCD|G15_KEYS),
+ DEVICE("Logitech G11",0x46d,0xc225,G15_KEYS),
+ DEVICE(NULL,0,0,0)
+};
+int g15DeviceCapabilities() {
+ if(found_devicetype>-1)
+ return g15_devices[found_devicetype].caps;
+ else
+ return -1;
+}
+
/* enable or disable debugging */
-void libg15Debug(int option ) {
+void libg15Debug(int option) {
libg15_debugging_enabled = option;
usb_set_debug(option);
@@ -69,8 +85,7 @@
return G15_NO_ERROR;
}
-
-static usb_dev_handle * findAndOpenG15()
+static usb_dev_handle * findAndOpenDevice(libg15_devices_t handled_device)
{
struct usb_bus *bus = 0;
struct usb_device *dev = 0;
@@ -79,15 +94,13 @@
{
for (dev = bus->devices; dev; dev = dev->next)
{
-
- if ((dev->descriptor.idVendor == 0x046d && dev->descriptor.idProduct == 0x0c222) //G15
- ||(dev->descriptor.idVendor == 0x046d && dev->descriptor.idProduct == 0x0c225)) //G11 keyboard
+ if ((dev->descriptor.idVendor == handled_device.vendorid && dev->descriptor.idProduct == handled_device.productid))
{
int ret=0;
char name_buffer[65535];
name_buffer[0] = 0;
usb_dev_handle *devh = 0;
- g15_log(stderr,"Found %s, trying to open it\n",dev->descriptor.idProduct == 0x0c222?"G15":"G11");
+ g15_log(stderr,"Found %s, trying to open it\n",handled_device.name);
devh = usb_open(dev);
if (!devh)
@@ -125,7 +138,6 @@
}
}
-
#endif
usleep(50*1000);
@@ -156,10 +168,25 @@
}
}
}
- g15_log(stderr, "Error, keyboard not found, is it plugged in?\n");
return 0;
}
+
+static usb_dev_handle * findAndOpenG15() {
+ int i;
+ for (i=0; g15_devices[i].name !=NULL ;i++){
+ g15_log(stderr,"Trying to find %s\n",g15_devices[i].name);
+ if(keyboard_device = findAndOpenDevice(g15_devices[i])){
+ found_devicetype = i;
+ break;
+ }
+ else
+ g15_log(stderr,"%s not found\n",g15_devices[i].name);
+ }
+ return keyboard_device;
+}
+
+
int re_initLibG15()
{
@@ -281,6 +308,9 @@
unsigned char lcd_buffer[G15_BUFFER_LEN];
memset(lcd_buffer,0,G15_BUFFER_LEN);
dumpPixmapIntoLCDFormat(lcd_buffer, data);
+
+ if(!(g15_devices[found_devicetype].caps & G15_LCD))
+ return 0;
/* the keyboard needs this magic byte */
lcd_buffer[0] = 0x03;
Modified: trunk/libg15/libg15.h
===================================================================
--- trunk/libg15/libg15.h 2006-12-19 20:55:27 UTC (rev 219)
+++ trunk/libg15/libg15.h 2006-12-27 08:38:19 UTC (rev 220)
@@ -24,6 +24,25 @@
{
#endif
+#define G15_LCD 1
+#define G15_KEYS 2
+
+typedef struct libg15_devices_t libg15_devices_t;
+
+struct libg15_devices_t {
+ const char *name; // name - can be anything, only used for informational purposes
+ unsigned int vendorid;
+ unsigned int productid;
+ unsigned int caps; // capability bitfield - G15_LCD|G15_KEYS;
+};
+
+#define DEVICE(name, vendorid, productid, caps) { \
+ name, \
+ vendorid, \
+ productid, \
+ caps \
+}
+
/* allow for api changes */
#define LIBG15_VERSION 1200
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-12-19 20:55:33
|
Revision: 219
http://svn.sourceforge.net/g15tools/?rev=219&view=rev
Author: aneurysm9
Date: 2006-12-19 12:55:27 -0800 (Tue, 19 Dec 2006)
Log Message:
-----------
Fix FIFO handling with flex
Modified Paths:
--------------
trunk/g15composer/g15composer.c
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-12-18 01:31:17 UTC (rev 218)
+++ trunk/g15composer/g15composer.c 2006-12-19 20:55:27 UTC (rev 219)
@@ -58,6 +58,7 @@
struct parserData *param = (struct parserData *) arg;
extern short g15c_logo_data[6880];
int tmpfd, errno;
+ FILE *fifo;
param->leaving = 0;
@@ -117,11 +118,14 @@
param->buflist = new_bufList ();
}
- if ((yyset_in (fopen (param->fifo_filename, "r"), param->scanner)) == 0)
+ fifo = fopen (param->fifo_filename, "r");
+ if (fifo == NULL)
{
perror (param->fifo_filename);
param->leaving = 1;
}
+ else
+ yyset_in (fifo, param->scanner);
int result = 0;
while ((param->leaving == 0) && (param->threads->leaving == 0))
@@ -130,12 +134,15 @@
fclose (yyget_in (param->scanner));
if ((param->leaving == 0) && (param->threads->leaving == 0))
{
- if ((yyset_in (fopen (param->fifo_filename, "r"), param->scanner))
- == 0)
+ fifo = fopen (param->fifo_filename, "r");
+ if (fifo == NULL)
{
perror (param->fifo_filename);
param->leaving = 1;
}
+ else
+ yyset_in (fifo, param->scanner);
+
if (param->background == 1)
continue;
if (!param->canvas->mode_cache)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-18 01:31:17
|
Revision: 218
http://svn.sourceforge.net/g15tools/?rev=218&view=rev
Author: mlampard
Date: 2006-12-17 17:31:17 -0800 (Sun, 17 Dec 2006)
Log Message:
-----------
prepare for 1.2 release.
Modified Paths:
--------------
trunk/libg15/ChangeLog
trunk/libg15/Makefile.am
trunk/libg15/configure.in
trunk/libg15/rpm/libg15.spec
Modified: trunk/libg15/ChangeLog
===================================================================
--- trunk/libg15/ChangeLog 2006-12-17 11:11:00 UTC (rev 217)
+++ trunk/libg15/ChangeLog 2006-12-18 01:31:17 UTC (rev 218)
@@ -11,7 +11,7 @@
* revert all bulk transfers - bulk transfers are illegal for low-speed
devices, and cause -22 (EINVAL) warnings on new kernels.
* pass most errors to the client app.
-SVN
+1.2.0
* Add debugging function to enable/disable extra output
* All debugging output is now prefixed with libg15 to aid localising
problems.
Modified: trunk/libg15/Makefile.am
===================================================================
--- trunk/libg15/Makefile.am 2006-12-17 11:11:00 UTC (rev 217)
+++ trunk/libg15/Makefile.am 2006-12-18 01:31:17 UTC (rev 218)
@@ -8,3 +8,10 @@
dist-hook:
rm -rf `find $(distdir)/debian -name .svn`
rm -rf `find $(distdir)/rpm -name .svn`
+
+dist-rpm: dist-bzip2
+ rpmbuild -ts $(distdir).tar.bz2
+
+dist-archives:
+ $(MAKE) dist-bzip2
+ $(MAKE) dist-rpm
Modified: trunk/libg15/configure.in
===================================================================
--- trunk/libg15/configure.in 2006-12-17 11:11:00 UTC (rev 217)
+++ trunk/libg15/configure.in 2006-12-18 01:31:17 UTC (rev 218)
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT(libg15, 1.1.1, mla...@us...)
+AC_INIT(libg15, 1.2.0, mla...@us...)
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE()
Modified: trunk/libg15/rpm/libg15.spec
===================================================================
--- trunk/libg15/rpm/libg15.spec 2006-12-17 11:11:00 UTC (rev 217)
+++ trunk/libg15/rpm/libg15.spec 2006-12-18 01:31:17 UTC (rev 218)
@@ -3,11 +3,11 @@
%define prefix /usr
Summary: library to control logitech G15 keyboards
Name: libg15
-Version: 1.1.1
+Version: 1.2.0
Release: 1
Copyright: GPL
Group: Applications/System
-Source: http://prdownloads.sourceforge.net/g15tools/libg15-1.1.1.tar.bz2
+Source: http://prdownloads.sourceforge.net/g15tools/libg15-1.2.0.tar.bz2
URL: http://sourceforge.net/projects/g15tools
Distribution: Linux
Vendor: NONE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-17 11:10:59
|
Revision: 217
http://svn.sourceforge.net/g15tools/?rev=217&view=rev
Author: mlampard
Date: 2006-12-17 03:11:00 -0800 (Sun, 17 Dec 2006)
Log Message:
-----------
update changelog
Modified Paths:
--------------
trunk/libg15/ChangeLog
Modified: trunk/libg15/ChangeLog
===================================================================
--- trunk/libg15/ChangeLog 2006-12-17 10:51:31 UTC (rev 216)
+++ trunk/libg15/ChangeLog 2006-12-17 11:11:00 UTC (rev 217)
@@ -15,9 +15,15 @@
* Add debugging function to enable/disable extra output
* All debugging output is now prefixed with libg15 to aid localising
problems.
+* debugging function now also controls libusb debugging output.
* Try to claim usb interface up to 10 times before failing
* Slow down initialisation, to allow keyboard to come out of usb
auto-suspend on newer kernels.
* Attempt to combat ENOSPC by slowing down writes to the lcd if ENOSPC is received.
Unless that error occurs at least once, transfers are sent as normal.
* Add function to change keyboard backlight (independant of lcd backlight).
+* Add re-initialising function, which will attempt to reconnect a keyboard
+ that was previously removed and replugged.
+* libg15 now uses pthread mutexes to force sequential access to the bus via libusb.
+ Control message URBs are no longer being lost if sent by a different
+ thread in the middle of a screen transfer etc.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-17 10:51:33
|
Revision: 216
http://svn.sourceforge.net/g15tools/?rev=216&view=rev
Author: mlampard
Date: 2006-12-17 02:51:31 -0800 (Sun, 17 Dec 2006)
Log Message:
-----------
make all libusb access threadsafe
Modified Paths:
--------------
trunk/libg15/libg15.c
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-17 08:09:13 UTC (rev 215)
+++ trunk/libg15/libg15.c 2006-12-17 10:51:31 UTC (rev 216)
@@ -16,6 +16,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <pthread.h>
#include "libg15.h"
#include <stdio.h>
#include <stdarg.h>
@@ -27,6 +28,9 @@
static int libg15_debugging_enabled = 0;
static int enospc_slowdown = 0;
+static pthread_mutex_t libusb_mutex;
+
+
/* enable or disable debugging */
void libg15Debug(int option ) {
@@ -186,8 +190,10 @@
keyboard_device = findAndOpenG15();
if (!keyboard_device)
return G15_ERROR_OPENING_USB_DEVICE;
-
- return retval;
+
+ pthread_mutex_init(&libusb_mutex, NULL);
+
+ return retval;
}
/* reset the keyboard, returning it to a known state */
@@ -201,6 +207,7 @@
usleep(50*1000);
usb_close(keyboard_device);
keyboard_device=0;
+ pthread_mutex_destroy(&libusb_mutex);
return retval;
}
return -1;
@@ -257,7 +264,9 @@
break;
case -EPIPE: /* endpoint is stalled */
g15_log(stderr,"usb error: %s EPIPE! clearing...\n",prefix);
+ pthread_mutex_lock(&libusb_mutex);
usb_clear_halt(keyboard_device, 0x81);
+ pthread_mutex_unlock(&libusb_mutex);
break;
default: /* timed out */
g15_log(stderr,"Unknown usb error: %s !! (err is %i)\n",prefix,ret);
@@ -281,6 +290,7 @@
I'm not sure how successful this will be in combatting ENOSPC, but we'll give it try in the real-world. */
if(enospc_slowdown != 0){
+ pthread_mutex_lock(&libusb_mutex);
for(transfercount = 0;transfercount<=31;transfercount++){
ret = usb_interrupt_write(keyboard_device, 2, (char*)lcd_buffer+(32*transfercount), 32, 1000);
if (ret != 32)
@@ -290,9 +300,12 @@
}
usleep(100);
}
+ pthread_mutex_unlock(&libusb_mutex);
}else{
/* transfer entire buffer in one hit */
+ pthread_mutex_lock(&libusb_mutex);
ret = usb_interrupt_write(keyboard_device, 2, (char*)lcd_buffer, G15_BUFFER_LEN, 1000);
+ pthread_mutex_unlock(&libusb_mutex);
if (ret != G15_BUFFER_LEN)
{
handle_usb_errors ("LCDPixmap Write",ret);
@@ -306,6 +319,7 @@
int setLCDContrast(unsigned int level)
{
+ int retval = 0;
unsigned char usb_data[] = { 2, 32, 129, 0 };
switch(level)
@@ -319,19 +333,26 @@
default:
usb_data[3] = 18;
}
-
- return usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)usb_data, 4, 10000);
+ pthread_mutex_lock(&libusb_mutex);
+ retval = usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)usb_data, 4, 10000);
+ pthread_mutex_unlock(&libusb_mutex);
+ return retval;
}
int setLEDs(unsigned int leds)
{
+ int retval = 0;
unsigned char m_led_buf[4] = { 2, 4, 0, 0 };
m_led_buf[2] = ~(unsigned char)leds;
- return usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)m_led_buf, 4, 10000);
+ pthread_mutex_lock(&libusb_mutex);
+ retval = usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)m_led_buf, 4, 10000);
+ pthread_mutex_unlock(&libusb_mutex);
+ return retval;
}
int setLCDBrightness(unsigned int level)
{
+ int retval = 0;
unsigned char usb_data[] = { 2, 2, 0, 0 };
switch(level)
@@ -345,13 +366,16 @@
default:
usb_data[2] = 0x00;
}
-
- return usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)usb_data, 4, 10000);
+ pthread_mutex_lock(&libusb_mutex);
+ retval = usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)usb_data, 4, 10000);
+ pthread_mutex_unlock(&libusb_mutex);
+ return retval;
}
/* set the keyboard backlight. doesnt affect lcd backlight. 0==off,1==medium,2==high */
int setKBBrightness(unsigned int level)
{
+ int retval = 0;
unsigned char usb_data[] = { 2, 1, 0, 0 };
switch(level)
@@ -365,8 +389,10 @@
default:
usb_data[2] = 0x0;
}
-
- return usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)usb_data, 4, 10000);
+ pthread_mutex_lock(&libusb_mutex);
+ retval = usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)usb_data, 4, 10000);
+ pthread_mutex_unlock(&libusb_mutex);
+ return retval;
}
static unsigned char g15KeyToLogitechKeyCode(int key)
@@ -476,7 +502,11 @@
int getPressedKeys(unsigned int *pressed_keys, unsigned int timeout)
{
unsigned char buffer[9];
- int ret = usb_interrupt_read(keyboard_device, 0x81, (char*)buffer, 9, timeout);
+ int ret = 0;
+ pthread_mutex_lock(&libusb_mutex);
+ ret = usb_interrupt_read(keyboard_device, 0x81, (char*)buffer, 9, timeout);
+ pthread_mutex_unlock(&libusb_mutex);
+
if (ret == 9)
{
if (buffer[0] == 1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-17 08:09:13
|
Revision: 215
http://svn.sourceforge.net/g15tools/?rev=215&view=rev
Author: mlampard
Date: 2006-12-17 00:09:13 -0800 (Sun, 17 Dec 2006)
Log Message:
-----------
add setKBBrightness() to change keyboard backlight
Modified Paths:
--------------
trunk/libg15/ChangeLog
trunk/libg15/libg15.c
trunk/libg15/libg15.h
Modified: trunk/libg15/ChangeLog
===================================================================
--- trunk/libg15/ChangeLog 2006-12-16 14:14:59 UTC (rev 214)
+++ trunk/libg15/ChangeLog 2006-12-17 08:09:13 UTC (rev 215)
@@ -20,3 +20,4 @@
auto-suspend on newer kernels.
* Attempt to combat ENOSPC by slowing down writes to the lcd if ENOSPC is received.
Unless that error occurs at least once, transfers are sent as normal.
+* Add function to change keyboard backlight (independant of lcd backlight).
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-16 14:14:59 UTC (rev 214)
+++ trunk/libg15/libg15.c 2006-12-17 08:09:13 UTC (rev 215)
@@ -349,6 +349,26 @@
return usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)usb_data, 4, 10000);
}
+/* set the keyboard backlight. doesnt affect lcd backlight. 0==off,1==medium,2==high */
+int setKBBrightness(unsigned int level)
+{
+ unsigned char usb_data[] = { 2, 1, 0, 0 };
+
+ switch(level)
+ {
+ case 1 :
+ usb_data[2] = 0x1;
+ break;
+ case 2 :
+ usb_data[2] = 0x2;
+ break;
+ default:
+ usb_data[2] = 0x0;
+ }
+
+ return usb_control_msg(keyboard_device, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 9, 0x302, 0, (char*)usb_data, 4, 10000);
+}
+
static unsigned char g15KeyToLogitechKeyCode(int key)
{
// first 12 G keys produce F1 - F12, thats 0x3a + key
Modified: trunk/libg15/libg15.h
===================================================================
--- trunk/libg15/libg15.h 2006-12-16 14:14:59 UTC (rev 214)
+++ trunk/libg15/libg15.h 2006-12-17 08:09:13 UTC (rev 215)
@@ -122,7 +122,8 @@
int setLCDContrast(unsigned int level);
int setLEDs(unsigned int leds);
int setLCDBrightness(unsigned int level);
-
+ int setKBBrightness(unsigned int level);
+
/* Please be warned
* the g15 sends two different usb msgs for each key press
* but only one of these two is used here. Since we do not want to wait
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-16 14:14:59
|
Revision: 214
http://svn.sourceforge.net/g15tools/?rev=214&view=rev
Author: mlampard
Date: 2006-12-16 06:14:59 -0800 (Sat, 16 Dec 2006)
Log Message:
-----------
add reinitialising function to re-enable the keyboard if it was unplugged. works here but needs testing.
Modified Paths:
--------------
trunk/libg15/libg15.c
trunk/libg15/libg15.h
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-16 11:37:17 UTC (rev 213)
+++ trunk/libg15/libg15.c 2006-12-16 14:14:59 UTC (rev 214)
@@ -46,7 +46,7 @@
}
return 0;
}
-
+
static int initLibUsb()
{
usb_init();
@@ -58,10 +58,10 @@
if (!usb_find_busses())
return G15_ERROR_OPENING_USB_DEVICE;
-
+
if (!usb_find_devices())
return G15_ERROR_OPENING_USB_DEVICE;
-
+
return G15_NO_ERROR;
}
@@ -156,6 +156,26 @@
return 0;
}
+int re_initLibG15()
+{
+
+ usb_init();
+
+ /**
+ * usb_find_busses and usb_find_devices both report the number of devices
+ * / busses added / removed since the last call. since this is the first
+ * call we have to return values != 0 or else we didnt find anything */
+
+ if (!usb_find_devices())
+ return G15_ERROR_OPENING_USB_DEVICE;
+
+ keyboard_device = findAndOpenG15();
+ if (!keyboard_device)
+ return G15_ERROR_OPENING_USB_DEVICE;
+
+ return G15_NO_ERROR;
+}
+
int initLibG15()
{
int retval = G15_NO_ERROR;
@@ -179,6 +199,8 @@
usleep(50*1000);
retval = usb_reset(keyboard_device);
usleep(50*1000);
+ usb_close(keyboard_device);
+ keyboard_device=0;
return retval;
}
return -1;
Modified: trunk/libg15/libg15.h
===================================================================
--- trunk/libg15/libg15.h 2006-12-16 11:37:17 UTC (rev 213)
+++ trunk/libg15/libg15.h 2006-12-16 14:14:59 UTC (rev 214)
@@ -111,6 +111,9 @@
/* this one return G15_NO_ERROR on success, something
* else otherwise (for instance G15_ERROR_OPENING_USB_DEVICE */
int initLibG15();
+ /* re-initialise a previously unplugged keyboard ie ENODEV was returned at some point */
+ int re_initLibG15();
+
int exitLibG15();
/* enable or disable debugging */
void libg15Debug(int option);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-16 11:38:06
|
Revision: 213
http://svn.sourceforge.net/g15tools/?rev=213&view=rev
Author: mlampard
Date: 2006-12-16 03:37:17 -0800 (Sat, 16 Dec 2006)
Log Message:
-----------
set usb debug level along with ours
Modified Paths:
--------------
trunk/libg15/libg15.c
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-16 09:42:42 UTC (rev 212)
+++ trunk/libg15/libg15.c 2006-12-16 11:37:17 UTC (rev 213)
@@ -31,7 +31,7 @@
void libg15Debug(int option ) {
libg15_debugging_enabled = option;
-
+ usb_set_debug(option);
}
/* debugging wrapper */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-16 09:42:42
|
Revision: 212
http://svn.sourceforge.net/g15tools/?rev=212&view=rev
Author: mlampard
Date: 2006-12-16 01:42:42 -0800 (Sat, 16 Dec 2006)
Log Message:
-----------
attempt to workaround the ENOSPC error by breaking lcd transfers up into 32byte chunks if ENOSPC is received at least once. Otherwise transfers are sent as normal.
Modified Paths:
--------------
trunk/libg15/ChangeLog
trunk/libg15/libg15.c
Modified: trunk/libg15/ChangeLog
===================================================================
--- trunk/libg15/ChangeLog 2006-12-16 05:44:02 UTC (rev 211)
+++ trunk/libg15/ChangeLog 2006-12-16 09:42:42 UTC (rev 212)
@@ -2,17 +2,21 @@
* Initial Release
1.0.1
* Change transfer type from interrupt to bulk for keypresses, which resolves
-problems for some people
+ problems for some people
1.1.0
* Add header define to allow for api version changes
* Add exitLibG15() to reset the device back to factory defaults on library exit.
1.1.1
* Add basic support for the G11 keyboard
* revert all bulk transfers - bulk transfers are illegal for low-speed
-devices, and cause -22 (EINVAL) warnings on new kernels.
+ devices, and cause -22 (EINVAL) warnings on new kernels.
* pass most errors to the client app.
SVN
* Add debugging function to enable/disable extra output
* All debugging output is now prefixed with libg15 to aid localising
-problems.
+ problems.
* Try to claim usb interface up to 10 times before failing
+* Slow down initialisation, to allow keyboard to come out of usb
+ auto-suspend on newer kernels.
+* Attempt to combat ENOSPC by slowing down writes to the lcd if ENOSPC is received.
+ Unless that error occurs at least once, transfers are sent as normal.
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-16 05:44:02 UTC (rev 211)
+++ trunk/libg15/libg15.c 2006-12-16 09:42:42 UTC (rev 212)
@@ -25,6 +25,7 @@
static usb_dev_handle *keyboard_device = 0;
static int libg15_debugging_enabled = 0;
+static int enospc_slowdown = 0;
/* enable or disable debugging */
void libg15Debug(int option ) {
@@ -64,6 +65,7 @@
return G15_NO_ERROR;
}
+
static usb_dev_handle * findAndOpenG15()
{
struct usb_bus *bus = 0;
@@ -90,7 +92,7 @@
g15_log(stderr, "Perhaps you dont have enough permissions to access it\n");
return 0;
}
-
+
usleep(50*1000);
/* libusb functions ending in _np are not portable between OS's
@@ -145,6 +147,7 @@
}
usleep(1000*1000); // FIXME. I should find a way of polling the status to ensure the endpoint has woken up, rather than just waiting for a second
g15_log(stderr,"Done opening the keyboard\n");
+
return devh;
}
}
@@ -219,6 +222,9 @@
return G15_ERROR_READING_USB_DEVICE; /* backward-compatibility */
break;
case -ENOSPC: /* the we dont have enough bandwidth, apparently.. something has to give here.. */
+ g15_log(stderr,"usb error: ENOSPC.. reducing speed\n");
+ enospc_slowdown = 1;
+ break;
case -ENODEV: /* the device went away - we probably should attempt to reattach */
case -ENXIO: /* host controller bug */
case -EINVAL: /* invalid request */
@@ -240,20 +246,39 @@
int writePixmapToLCD(unsigned char const *data)
{
int ret = 0;
+ int transfercount=0;
unsigned char lcd_buffer[G15_BUFFER_LEN];
memset(lcd_buffer,0,G15_BUFFER_LEN);
dumpPixmapIntoLCDFormat(lcd_buffer, data);
/* the keyboard needs this magic byte */
lcd_buffer[0] = 0x03;
+ /* in an attempt to reduce peak bus utilisation, we break the transfer into 32 byte chunks and sleep a bit in between.
+ It shouldnt make much difference, but then again, the g15 shouldnt be flooding the bus enough to cause ENOSPC, yet
+ apparently does on some machines...
+ I'm not sure how successful this will be in combatting ENOSPC, but we'll give it try in the real-world. */
- ret = usb_interrupt_write(keyboard_device, 2, (char*)lcd_buffer, G15_BUFFER_LEN, 10000);
- if (ret != G15_BUFFER_LEN)
- {
- handle_usb_errors ("LCDPixmap Write",ret);
- return G15_ERROR_WRITING_PIXMAP;
+ if(enospc_slowdown != 0){
+ for(transfercount = 0;transfercount<=31;transfercount++){
+ ret = usb_interrupt_write(keyboard_device, 2, (char*)lcd_buffer+(32*transfercount), 32, 1000);
+ if (ret != 32)
+ {
+ handle_usb_errors ("LCDPixmap Slow Write",ret);
+ return G15_ERROR_WRITING_PIXMAP;
+ }
+ usleep(100);
+ }
+ }else{
+ /* transfer entire buffer in one hit */
+ ret = usb_interrupt_write(keyboard_device, 2, (char*)lcd_buffer, G15_BUFFER_LEN, 1000);
+ if (ret != G15_BUFFER_LEN)
+ {
+ handle_usb_errors ("LCDPixmap Write",ret);
+ return G15_ERROR_WRITING_PIXMAP;
+ }
+ usleep(100);
}
-
+
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-16 05:44:02
|
Revision: 211
http://svn.sourceforge.net/g15tools/?rev=211&view=rev
Author: mlampard
Date: 2006-12-15 21:44:02 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
slow down the initialisation phase, and delay exiting the init function, to allow the keyboard to fully wakeup after being suspended before the client app starts transferring data.
Modified Paths:
--------------
trunk/libg15/libg15.c
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-16 04:14:24 UTC (rev 210)
+++ trunk/libg15/libg15.c 2006-12-16 05:44:02 UTC (rev 211)
@@ -91,7 +91,7 @@
return 0;
}
- usleep(25*1000);
+ usleep(50*1000);
/* libusb functions ending in _np are not portable between OS's
* Non-linux users will need some way to detach the HID driver from
@@ -119,8 +119,10 @@
}
}
- g15_log(stderr,"Previously attached driver was: %s\n",name_buffer);
+
#endif
+ usleep(50*1000);
+
ret = usb_set_configuration(devh, 1);
if (ret)
{
@@ -128,20 +130,20 @@
return 0;
}
- usleep(25*1000);
+ usleep(50*1000);
while((ret = usb_claim_interface(devh,0)) && retries <10) {
- usleep(25*1000);
+ usleep(50*1000);
retries++;
g15_log(stderr,"Trying to claim interface\n");
}
-
+
if (ret)
{
g15_log(stderr,"Error claiming interface, good day cruel world\n");
return 0;
}
- usleep(25*1000);
+ usleep(1000*1000); // FIXME. I should find a way of polling the status to ensure the endpoint has woken up, rather than just waiting for a second
g15_log(stderr,"Done opening the keyboard\n");
return devh;
}
@@ -171,7 +173,9 @@
int retval = G15_NO_ERROR;
if (keyboard_device){
retval = usb_release_interface (keyboard_device, 0);
+ usleep(50*1000);
retval = usb_reset(keyboard_device);
+ usleep(50*1000);
return retval;
}
return -1;
@@ -221,14 +225,14 @@
case -EAGAIN: /* try again */
case -EFBIG: /* too many frames to handle */
case -EMSGSIZE: /* msgsize is invalid */
- g15_log(stderr,"libg15 error: %s (%i)\n",prefix,ret);
+ g15_log(stderr,"usb error: %s (%i)\n",prefix,ret);
break;
case -EPIPE: /* endpoint is stalled */
- g15_log(stderr,"libg15 error: %s EPIPE! clearing...\n",prefix);
+ g15_log(stderr,"usb error: %s EPIPE! clearing...\n",prefix);
usb_clear_halt(keyboard_device, 0x81);
break;
default: /* timed out */
- g15_log(stderr,"Unknown error: %s !! (err is %i)\n",prefix,ret);
+ g15_log(stderr,"Unknown usb error: %s !! (err is %i)\n",prefix,ret);
}
return ret;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-16 04:14:24
|
Revision: 210
http://svn.sourceforge.net/g15tools/?rev=210&view=rev
Author: mlampard
Date: 2006-12-15 20:14:24 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
add function to enable debugging programmatically. Output the type of keyboard found when debugging is enabled, and prefix all debug output with libg15
Modified Paths:
--------------
trunk/libg15/ChangeLog
trunk/libg15/libg15.c
trunk/libg15/libg15.h
Modified: trunk/libg15/ChangeLog
===================================================================
--- trunk/libg15/ChangeLog 2006-12-15 10:22:36 UTC (rev 209)
+++ trunk/libg15/ChangeLog 2006-12-16 04:14:24 UTC (rev 210)
@@ -11,4 +11,8 @@
* revert all bulk transfers - bulk transfers are illegal for low-speed
devices, and cause -22 (EINVAL) warnings on new kernels.
* pass most errors to the client app.
-
+SVN
+* Add debugging function to enable/disable extra output
+* All debugging output is now prefixed with libg15 to aid localising
+problems.
+* Try to claim usb interface up to 10 times before failing
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-15 10:22:36 UTC (rev 209)
+++ trunk/libg15/libg15.c 2006-12-16 04:14:24 UTC (rev 210)
@@ -22,17 +22,27 @@
#include <usb.h>
#include <string.h>
#include <errno.h>
+
static usb_dev_handle *keyboard_device = 0;
-//#define DEBUG
+static int libg15_debugging_enabled = 0;
+
+/* enable or disable debugging */
+void libg15Debug(int option ) {
+
+ libg15_debugging_enabled = option;
+
+}
+
/* debugging wrapper */
-int g15_log (FILE *fd, const char *fmt, ...) {
+static int g15_log (FILE *fd, const char *fmt, ...) {
-#ifdef DEBUG
- va_list argp;
- va_start (argp, fmt);
+ if (libg15_debugging_enabled){
+ fprintf(fd,"libg15: ");
+ va_list argp;
+ va_start (argp, fmt);
vfprintf(fd,fmt,argp);
- va_end (argp);
-#endif
+ va_end (argp);
+ }
return 0;
}
@@ -58,6 +68,7 @@
{
struct usb_bus *bus = 0;
struct usb_device *dev = 0;
+ int retries=0;
for (bus = usb_busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
@@ -70,10 +81,9 @@
char name_buffer[65535];
name_buffer[0] = 0;
usb_dev_handle *devh = 0;
- g15_log(stderr,"Found g15, trying to open it\n");
+ g15_log(stderr,"Found %s, trying to open it\n",dev->descriptor.idProduct == 0x0c222?"G15":"G11");
+
devh = usb_open(dev);
-
-
if (!devh)
{
g15_log(stderr, "Error, could not open the keyboard\n");
@@ -81,7 +91,6 @@
return 0;
}
-
usleep(25*1000);
/* libusb functions ending in _np are not portable between OS's
@@ -96,12 +105,12 @@
thanks to RobEngle for pointing this out */
if (!ret && name_buffer[0])
{
- printf("Trying to detach drive currentl attached: \"%s\"\n",name_buffer);
+ g15_log(stderr,"Trying to detach driver currently attached: \"%s\"\n",name_buffer);
ret = usb_detach_kernel_driver_np(devh, 0);
if (!ret)
{
- printf("Success, detached the driver\n");
+ g15_log(stderr,"Success, detached the driver\n");
}
else
{
@@ -110,7 +119,7 @@
}
}
- g15_log(stderr,"Debug: %s\n",name_buffer);
+ g15_log(stderr,"Previously attached driver was: %s\n",name_buffer);
#endif
ret = usb_set_configuration(devh, 1);
if (ret)
@@ -121,7 +130,11 @@
usleep(25*1000);
- ret = usb_claim_interface(devh,0);
+ while((ret = usb_claim_interface(devh,0)) && retries <10) {
+ usleep(25*1000);
+ retries++;
+ g15_log(stderr,"Trying to claim interface\n");
+ }
if (ret)
{
@@ -195,6 +208,7 @@
}
}
}
+
int handle_usb_errors(const char *prefix, int ret) {
switch (ret){
case -ETIMEDOUT:
@@ -271,8 +285,12 @@
switch(level)
{
- case 1 : usb_data[2] = 0x10; break;
- case 2 : usb_data[2] = 0x20; break;
+ case 1 :
+ usb_data[2] = 0x10;
+ break;
+ case 2 :
+ usb_data[2] = 0x20;
+ break;
default:
usb_data[2] = 0x00;
}
Modified: trunk/libg15/libg15.h
===================================================================
--- trunk/libg15/libg15.h 2006-12-15 10:22:36 UTC (rev 209)
+++ trunk/libg15/libg15.h 2006-12-16 04:14:24 UTC (rev 210)
@@ -25,7 +25,7 @@
#endif
/* allow for api changes */
-#define LIBG15_VERSION 1100
+#define LIBG15_VERSION 1200
enum
{
@@ -112,7 +112,9 @@
* else otherwise (for instance G15_ERROR_OPENING_USB_DEVICE */
int initLibG15();
int exitLibG15();
-
+ /* enable or disable debugging */
+ void libg15Debug(int option);
+
int writePixmapToLCD(unsigned char const *data);
int setLCDContrast(unsigned int level);
int setLEDs(unsigned int leds);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-12-15 10:22:35
|
Revision: 209
http://svn.sourceforge.net/g15tools/?rev=209&view=rev
Author: aneurysm9
Date: 2006-12-15 02:22:36 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
Prep for 1.1.1 release
Modified Paths:
--------------
trunk/libg15/ChangeLog
trunk/libg15/configure.in
trunk/libg15/debian/changelog
trunk/libg15/rpm/libg15.spec
Modified: trunk/libg15/ChangeLog
===================================================================
--- trunk/libg15/ChangeLog 2006-12-15 09:28:55 UTC (rev 208)
+++ trunk/libg15/ChangeLog 2006-12-15 10:22:36 UTC (rev 209)
@@ -6,7 +6,7 @@
1.1.0
* Add header define to allow for api version changes
* Add exitLibG15() to reset the device back to factory defaults on library exit.
-SVN
+1.1.1
* Add basic support for the G11 keyboard
* revert all bulk transfers - bulk transfers are illegal for low-speed
devices, and cause -22 (EINVAL) warnings on new kernels.
Modified: trunk/libg15/configure.in
===================================================================
--- trunk/libg15/configure.in 2006-12-15 09:28:55 UTC (rev 208)
+++ trunk/libg15/configure.in 2006-12-15 10:22:36 UTC (rev 209)
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT(libg15, 1.1.0, mla...@us...)
+AC_INIT(libg15, 1.1.1, mla...@us...)
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE()
Modified: trunk/libg15/debian/changelog
===================================================================
--- trunk/libg15/debian/changelog 2006-12-15 09:28:55 UTC (rev 208)
+++ trunk/libg15/debian/changelog 2006-12-15 10:22:36 UTC (rev 209)
@@ -1,3 +1,12 @@
+libg15 (1.1.1-1) edgy; urgency=low
+
+ * Add basic support for the G11 keyboard
+ * revert all bulk transfers - bulk transfers are illegal for low-speed
+ devices, and cause -22 (EINVAL) warnings on new kernels.
+ * pass most errors to the client app.
+
+ -- Anthony J. Mirabella <mir...@gm...> Fri, 15 Dec 2006 05:17:49 -0500
+
libg15 (1.0-1) breezy; urgency=low
* Initial release
Modified: trunk/libg15/rpm/libg15.spec
===================================================================
--- trunk/libg15/rpm/libg15.spec 2006-12-15 09:28:55 UTC (rev 208)
+++ trunk/libg15/rpm/libg15.spec 2006-12-15 10:22:36 UTC (rev 209)
@@ -3,11 +3,11 @@
%define prefix /usr
Summary: library to control logitech G15 keyboards
Name: libg15
-Version: 1.0
+Version: 1.1.1
Release: 1
Copyright: GPL
Group: Applications/System
-Source: http://prdownloads.sourceforge.net/g15tools/libg15-1.0.tar.bz2
+Source: http://prdownloads.sourceforge.net/g15tools/libg15-1.1.1.tar.bz2
URL: http://sourceforge.net/projects/g15tools
Distribution: Linux
Vendor: NONE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2006-12-15 09:28:55
|
Revision: 208
http://svn.sourceforge.net/g15tools/?rev=208&view=rev
Author: mlampard
Date: 2006-12-15 01:28:55 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
update changelog, pass most errors back to the client app.
Modified Paths:
--------------
trunk/libg15/ChangeLog
trunk/libg15/Makefile.am
trunk/libg15/libg15.c
Modified: trunk/libg15/ChangeLog
===================================================================
--- trunk/libg15/ChangeLog 2006-12-12 18:43:57 UTC (rev 207)
+++ trunk/libg15/ChangeLog 2006-12-15 09:28:55 UTC (rev 208)
@@ -6,4 +6,9 @@
1.1.0
* Add header define to allow for api version changes
* Add exitLibG15() to reset the device back to factory defaults on library exit.
+SVN
+* Add basic support for the G11 keyboard
+* revert all bulk transfers - bulk transfers are illegal for low-speed
+devices, and cause -22 (EINVAL) warnings on new kernels.
+* pass most errors to the client app.
Modified: trunk/libg15/Makefile.am
===================================================================
--- trunk/libg15/Makefile.am 2006-12-12 18:43:57 UTC (rev 207)
+++ trunk/libg15/Makefile.am 2006-12-15 09:28:55 UTC (rev 208)
@@ -7,3 +7,4 @@
dist-hook:
rm -rf `find $(distdir)/debian -name .svn`
+ rm -rf `find $(distdir)/rpm -name .svn`
Modified: trunk/libg15/libg15.c
===================================================================
--- trunk/libg15/libg15.c 2006-12-12 18:43:57 UTC (rev 207)
+++ trunk/libg15/libg15.c 2006-12-15 09:28:55 UTC (rev 208)
@@ -21,9 +21,9 @@
#include <stdarg.h>
#include <usb.h>
#include <string.h>
-
+#include <errno.h>
static usb_dev_handle *keyboard_device = 0;
-/* #define DEBUG */
+//#define DEBUG
/* debugging wrapper */
int g15_log (FILE *fd, const char *fmt, ...) {
@@ -195,6 +195,29 @@
}
}
}
+int handle_usb_errors(const char *prefix, int ret) {
+ switch (ret){
+ case -ETIMEDOUT:
+ return G15_ERROR_READING_USB_DEVICE; /* backward-compatibility */
+ break;
+ case -ENOSPC: /* the we dont have enough bandwidth, apparently.. something has to give here.. */
+ case -ENODEV: /* the device went away - we probably should attempt to reattach */
+ case -ENXIO: /* host controller bug */
+ case -EINVAL: /* invalid request */
+ case -EAGAIN: /* try again */
+ case -EFBIG: /* too many frames to handle */
+ case -EMSGSIZE: /* msgsize is invalid */
+ g15_log(stderr,"libg15 error: %s (%i)\n",prefix,ret);
+ break;
+ case -EPIPE: /* endpoint is stalled */
+ g15_log(stderr,"libg15 error: %s EPIPE! clearing...\n",prefix);
+ usb_clear_halt(keyboard_device, 0x81);
+ break;
+ default: /* timed out */
+ g15_log(stderr,"Unknown error: %s !! (err is %i)\n",prefix,ret);
+ }
+ return ret;
+}
int writePixmapToLCD(unsigned char const *data)
{
@@ -205,13 +228,14 @@
/* the keyboard needs this magic byte */
lcd_buffer[0] = 0x03;
-
+
ret = usb_interrupt_write(keyboard_device, 2, (char*)lcd_buffer, G15_BUFFER_LEN, 10000);
if (ret != G15_BUFFER_LEN)
{
- g15_log(stderr, "Error writing pixmap to lcd, return value is %d instead of %d\n",ret,G15_BUFFER_LEN);
+ handle_usb_errors ("LCDPixmap Write",ret);
return G15_ERROR_WRITING_PIXMAP;
}
+
return 0;
}
@@ -363,7 +387,6 @@
int getPressedKeys(unsigned int *pressed_keys, unsigned int timeout)
{
unsigned char buffer[9];
-
int ret = usb_interrupt_read(keyboard_device, 0x81, (char*)buffer, 9, timeout);
if (ret == 9)
{
@@ -374,11 +397,5 @@
return G15_NO_ERROR;
}
- else
- {
- //printf("Return val is %d\n",ret);
- }
-
- return G15_ERROR_READING_USB_DEVICE;
-
+ return handle_usb_errors("Keyboard Read", ret); /* allow the app to deal with errors */
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-12-12 18:44:12
|
Revision: 207
http://svn.sourceforge.net/g15tools/?rev=207&view=rev
Author: aneurysm9
Date: 2006-12-12 10:43:57 -0800 (Tue, 12 Dec 2006)
Log Message:
-----------
Update amarok examples and add album info
Modified Paths:
--------------
trunk/g15composer/examples/amarok-g15-dcop_cli.pl
trunk/g15composer/examples/amarok-g15-perl.pl
Modified: trunk/g15composer/examples/amarok-g15-dcop_cli.pl
===================================================================
--- trunk/g15composer/examples/amarok-g15-dcop_cli.pl 2006-12-04 07:54:32 UTC (rev 206)
+++ trunk/g15composer/examples/amarok-g15-dcop_cli.pl 2006-12-12 18:43:57 UTC (rev 207)
@@ -13,6 +13,8 @@
chomp $tmpStatus;
my $status : shared = ( $tmpStatus > 1 ) ? 1 : 0;
+$SIG{TERM} = \&bye;
+
open(CPIPE, ">>$controlPipe");
print CPIPE "SN \"$pipe\"\n";
close(CPIPE);
@@ -27,6 +29,8 @@
print PIPE "MC 1\n";
}
+&stoppedScreen();
+
while($status == 0) {
$tmpStatus = `dcop amarok player status`;
$status = ( $tmpStatus > 1 ) ? 1 : 0;
@@ -50,8 +54,6 @@
&initScreen();
-$SIG{TERM} = \&bye;
-
my $progressThread = threads->create(\&progress);
$progressThread->detach();
@@ -95,9 +97,11 @@
$status = 1;
initScreen();
} elsif ( /pause/ ) {
- $status = 0;
+ $status = 2;
} else {
$status = 0;
+ stoppedScreen();
+ stoppedScreen();
}
} elsif( /volumeChange/ ){
m/: (\d+)/;
@@ -116,29 +120,53 @@
print PIPE "MP 2\n";
}
+sub stoppedScreen {
+ print PIPE "MC 0\n";
+ print PIPE "PC 0\n";
+ print PIPE "DR 0 0 159 43 1 1\n";
+ print PIPE "DR 3 22 157 40 0 1\n";
+ print PIPE "PB 3 22 157 24 0\n";
+ print PIPE "FP 0 15 0 10 0 1 \"Playback Stopped\"\n";
+ print PIPE "MC 1\n";
+}
+
sub initScreen {
print PIPE "PC 0\n";
print PIPE "DR 0 0 159 43 1 1\n";
print PIPE "DR 3 22 157 40 0 1\n";
print PIPE "PB 3 22 157 24 0\n";
- print PIPE "FP 0 15 0 0 0 1 \"$artist\"\n";
- print PIPE "FP 0 9 0 15 0 1 \"$title\"\n";
- print PIPE "DB 3 27 157 35 2 $trackCurSecs $trackTotalSecs 3\n";
- print PIPE "TO 0 35 0 1 \" $trackCurTime / $trackTotalTime \"\n";
+ print PIPE "MX 1\n";
+ print PIPE "FP 0 15 0 0 1 1 \"$artist\"\n";
+ print PIPE "FP 0 8 0 13 1 1 \"$album\"\n";
+ print PIPE "FP 0 7 0 23 1 1 \"$title\"\n";
+ print PIPE "DB 5 30 155 38 1 $trackCurSecs $trackTotalSecs 1\n";
+ print PIPE "TO 0 32 0 1 \"$trackCurTime / $trackTotalTime\"\n";
+ print PIPE "MX 0\n";
+ print PIPE "DL 5 29 5 39 1\n";
+ print PIPE "PS 5 29 0\n";
+ print PIPE "PS 5 39 0\n";
print PIPE "MC 1\n";
}
sub progress {
while(1) {
- if($status > 0) {
+ if($status == 1) {
$trackCurSecs = `dcop amarok player trackCurrentTime`;
$trackCurTime = `dcop amarok player currentTime`;
chomp $trackCurSecs;
chomp $trackCurTime;
- print PIPE "PB 5 27 155 35 0 1 1\n";
- print PIPE "DB 3 27 157 35 2 $trackCurSecs $trackTotalSecs 3\n";
- print PIPE "TO 0 35 0 1 \" $trackCurTime / $trackTotalTime \"\n";
+ print PIPE "PB 5 29 155 40 0 1 1\n";
+ print PIPE "MX 1\n";
+ print PIPE "DB 5 30 155 38 1 $trackCurSecs $trackTotalSecs 1\n";
+ print PIPE "TO 0 32 0 1 \"$trackCurTime / $trackTotalTime\"\n";
+ print PIPE "MX 0\n";
+ print PIPE "PB 5 29 5 39 1\n";
+ print PIPE "PS 5 29 0\n";
+ print PIPE "PS 5 39 0\n";
print PIPE "MC 1\n";
+ } elsif($status == 0) {
+ stoppedScreen();
+ $status = 2;
} elsif($status == -1) {
return;
}
Modified: trunk/g15composer/examples/amarok-g15-perl.pl
===================================================================
--- trunk/g15composer/examples/amarok-g15-perl.pl 2006-12-04 07:54:32 UTC (rev 206)
+++ trunk/g15composer/examples/amarok-g15-perl.pl 2006-12-12 18:43:57 UTC (rev 207)
@@ -13,6 +13,8 @@
my $vol : shared = $player->getVolume;
my $status : shared = ( $player->status() > 1 ) ? 1 : 0;
+$SIG{TERM} = \&bye;
+
open(CPIPE, ">>$controlPipe");
print CPIPE "SN \"$pipe\"\n";
close(CPIPE);
@@ -25,9 +27,10 @@
print PIPE "PC 0\n";
print PIPE "TO 0 10 2 1 \"Volume\"\n";
print PIPE "DB 3 27 157 35 2 $vol 100 3\n";
- print PIPE "MC 1\n";
}
+&stoppedScreen();
+
while($status == 0) {
$status = ( $player->status() > 1 ) ? 1 : 0;
sleep 1;
@@ -43,8 +46,6 @@
&initScreen();
-$SIG{TERM} = \&bye;
-
my $progressThread = threads->create(\&progress);
$progressThread->detach();
@@ -74,9 +75,11 @@
$status = 1;
initScreen();
} elsif ( /pause/ ) {
- $status = 0;
+ $status = 2;
} else {
$status = 0;
+ stoppedScreen();
+ stoppedScreen();
}
} elsif( /volumeChange/ ){
m/: (\d+)/;
@@ -95,27 +98,51 @@
print PIPE "MP 2\n";
}
+sub stoppedScreen {
+ print PIPE "MC 0\n";
+ print PIPE "PC 0\n";
+ print PIPE "DR 0 0 159 43 1 1\n";
+ print PIPE "DR 3 22 157 40 0 1\n";
+ print PIPE "PB 3 22 157 24 0\n";
+ print PIPE "FP 0 15 0 10 0 1 \"Playback Stopped\"\n";
+ print PIPE "MC 1\n";
+}
+
sub initScreen {
print PIPE "PC 0\n";
print PIPE "DR 0 0 159 43 1 1\n";
print PIPE "DR 3 22 157 40 0 1\n";
- print PIPE "PB 3 22 157 24 0 1 1\n";
- print PIPE "FP 0 15 0 0 0 1 \"$artist\"\n";
- print PIPE "FP 0 9 0 15 0 1 \"$title\"\n";
- print PIPE "DB 3 27 157 35 2 $trackCurSecs $trackTotalSecs 3\n";
- print PIPE "TO 0 35 0 1 \" $trackCurTime / $trackTotalTime \"\n";
+ print PIPE "PB 3 22 157 24 0\n";
+ print PIPE "MX 1\n";
+ print PIPE "FP 0 15 0 0 1 1 \"$artist\"\n";
+ print PIPE "FP 0 8 0 13 1 1 \"$album\"\n";
+ print PIPE "FP 0 7 0 23 1 1 \"$title\"\n";
+ print PIPE "DB 5 30 155 38 1 $trackCurSecs $trackTotalSecs 1\n";
+ print PIPE "TO 0 32 0 1 \"$trackCurTime / $trackTotalTime\"\n";
+ print PIPE "MX 0\n";
+ print PIPE "DL 5 29 5 39 1\n";
+ print PIPE "PS 5 29 0\n";
+ print PIPE "PS 5 39 0\n";
print PIPE "MC 1\n";
}
sub progress {
while(1) {
- if($status > 0) {
+ if($status == 1) {
$trackCurSecs = $player->trackCurrentTime;
$trackCurTime = $player->currentTime;
- print PIPE "PB 5 27 155 35 0 1 1\n";
- print PIPE "DB 3 27 157 35 2 $trackCurSecs $trackTotalSecs 3\n";
- print PIPE "TO 0 35 0 1 \" $trackCurTime / $trackTotalTime \"\n";
+ print PIPE "PB 5 29 155 40 0 1 1\n";
+ print PIPE "MX 1\n";
+ print PIPE "DB 5 30 155 38 1 $trackCurSecs $trackTotalSecs 1\n";
+ print PIPE "TO 0 32 0 1 \"$trackCurTime / $trackTotalTime\"\n";
+ print PIPE "MX 0\n";
+ print PIPE "PB 5 29 5 39 1\n";
+ print PIPE "PS 5 29 0\n";
+ print PIPE "PS 5 39 0\n";
print PIPE "MC 1\n";
+ } elsif($status == 0) {
+ stoppedScreen();
+ $status = 2;
} elsif($status == -1) {
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-12-04 07:54:34
|
Revision: 206
http://svn.sourceforge.net/g15tools/?rev=206&view=rev
Author: aneurysm9
Date: 2006-12-03 23:54:32 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
Don't skip threads->first_thread
Modified Paths:
--------------
trunk/g15composer/g15composer.c
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-12-04 07:32:30 UTC (rev 205)
+++ trunk/g15composer/g15composer.c 2006-12-04 07:54:32 UTC (rev 206)
@@ -247,7 +247,7 @@
thread_list->leaving = 1;
- struct threadItem *tmp_thread = thread_list->first_thread->next;
+ struct threadItem *tmp_thread = thread_list->first_thread;
struct threadItem *next_thread;
while (tmp_thread != NULL)
{
@@ -397,14 +397,18 @@
{
pthread_mutex_lock (&data->threads->mutex);
- struct threadItem *old = data->threads->first_thread->next;
+ struct threadItem *old = data->threads->first_thread;
struct threadItem *prev = data->threads->first_thread;
while (old != NULL)
{
if (old->thread == data->thread)
{
- prev->next = old->next;
+ if (prev != data->threads->first_thread)
+ prev->next = old->next;
+ else
+ data->threads->first_thread = old->next;
+
old->data = NULL;
old->next = NULL;
free (old);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-12-04 07:32:30
|
Revision: 205
http://svn.sourceforge.net/g15tools/?rev=205&view=rev
Author: aneurysm9
Date: 2006-12-03 23:32:30 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
Delete threads from the threadList when they are no longer used
Modified Paths:
--------------
trunk/g15composer/g15composer.c
trunk/g15composer/g15composer.h
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-12-04 03:53:24 UTC (rev 204)
+++ trunk/g15composer/g15composer.c 2006-12-04 07:32:30 UTC (rev 205)
@@ -156,6 +156,8 @@
if (strncmp (param->fifo_filename, "/var/run/", 9))
unlink (param->fifo_filename);
+ del_thread (param);
+
free (param);
pthread_exit (NULL);
@@ -249,12 +251,11 @@
struct threadItem *next_thread;
while (tmp_thread != NULL)
{
+ next_thread = tmp_thread->next;
FILE *to_close = fopen (tmp_thread->data->fifo_filename, "w");
fprintf (to_close, "SC\n");
pthread_join (tmp_thread->thread, NULL);
- next_thread = tmp_thread->next;
fclose (to_close);
- free (tmp_thread);
tmp_thread = next_thread;
}
}
@@ -392,6 +393,32 @@
}
void
+del_thread (struct parserData *data)
+{
+ pthread_mutex_lock (&data->threads->mutex);
+
+ struct threadItem *old = data->threads->first_thread->next;
+ struct threadItem *prev = data->threads->first_thread;
+
+ while (old != NULL)
+ {
+ if (old->thread == data->thread)
+ {
+ prev->next = old->next;
+ old->data = NULL;
+ old->next = NULL;
+ free (old);
+ break;
+ }
+
+ prev = old;
+ old = old->next;
+ }
+
+ pthread_mutex_unlock (&data->threads->mutex);
+}
+
+void
updateScreen (g15canvas * canvas, int g15screen_fd, int force)
{
if (force || !canvas->mode_cache)
Modified: trunk/g15composer/g15composer.h
===================================================================
--- trunk/g15composer/g15composer.h 2006-12-04 03:53:24 UTC (rev 204)
+++ trunk/g15composer/g15composer.h 2006-12-04 07:32:30 UTC (rev 205)
@@ -96,6 +96,7 @@
int add_buf (struct bufList *bufList, int id, char *buffer, int width, int height);
struct threadList * new_threadList ();
void add_thread (struct parserData *data);
+void del_thread (struct parserData *data);
void updateScreen (g15canvas *canvas, int g15screen_fd, int force);
int getDispCol (int len, int size, int type);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-12-04 03:53:26
|
Revision: 204
http://svn.sourceforge.net/g15tools/?rev=204&view=rev
Author: aneurysm9
Date: 2006-12-03 19:53:24 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
Track threads to enable proper cleanup on exit
Modified Paths:
--------------
trunk/g15composer/g15composer.c
trunk/g15composer/g15composer.h
trunk/g15composer/g15composer.y
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-12-01 01:46:25 UTC (rev 203)
+++ trunk/g15composer/g15composer.c 2006-12-04 03:53:24 UTC (rev 204)
@@ -124,11 +124,11 @@
}
int result = 0;
- while (param->leaving == 0)
+ while ((param->leaving == 0) && (param->threads->leaving == 0))
{
result = yyparse (param);
fclose (yyget_in (param->scanner));
- if (param->leaving == 0)
+ if ((param->leaving == 0) && (param->threads->leaving == 0))
{
if ((yyset_in (fopen (param->fifo_filename, "r"), param->scanner))
== 0)
@@ -237,8 +237,26 @@
seteuid (nobody->pw_uid);
}
+ struct threadList *thread_list = new_threadList ();
+ param->threads = thread_list;
pthread_create (¶m->thread, NULL, threadEntry, (void *) param);
+ add_thread (param);
pthread_join (param->thread, NULL);
+
+ thread_list->leaving = 1;
+
+ struct threadItem *tmp_thread = thread_list->first_thread->next;
+ struct threadItem *next_thread;
+ while (tmp_thread != NULL)
+ {
+ FILE *to_close = fopen (tmp_thread->data->fifo_filename, "w");
+ fprintf (to_close, "SC\n");
+ pthread_join (tmp_thread->thread, NULL);
+ next_thread = tmp_thread->next;
+ fclose (to_close);
+ free (tmp_thread);
+ tmp_thread = next_thread;
+ }
}
else
{
@@ -335,6 +353,44 @@
return 0;
}
+struct threadList *
+new_threadList ()
+{
+ struct threadList *new;
+ new = (struct threadList *) malloc (sizeof (struct threadList));
+ if (new == NULL)
+ return NULL;
+
+ new->first_thread = NULL;
+ new->last_thread = NULL;
+ new->leaving = 0;
+ pthread_mutex_init (&new->mutex, NULL);
+
+ return new;
+}
+
+void
+add_thread (struct parserData *data)
+{
+ pthread_mutex_lock (&data->threads->mutex);
+
+ struct threadItem *new;
+ new = (struct threadItem *) malloc (sizeof (struct threadItem));
+ if (new == NULL)
+ return;
+ new->thread = data->thread;
+ new->data = data;
+ new->next = NULL;
+
+ if (data->threads->first_thread == NULL)
+ data->threads->first_thread = new;
+ else
+ data->threads->last_thread->next = new;
+ data->threads->last_thread = new;
+
+ pthread_mutex_unlock (&data->threads->mutex);
+}
+
void
updateScreen (g15canvas * canvas, int g15screen_fd, int force)
{
Modified: trunk/g15composer/g15composer.h
===================================================================
--- trunk/g15composer/g15composer.h 2006-12-01 01:46:25 UTC (rev 203)
+++ trunk/g15composer/g15composer.h 2006-12-04 03:53:24 UTC (rev 204)
@@ -52,6 +52,24 @@
struct bufItem *next;
};
+struct threadList;
+struct threadItem;
+
+struct threadList
+{
+ struct threadItem *first_thread;
+ struct threadItem *last_thread;
+ pthread_mutex_t mutex;
+ int leaving;
+};
+
+struct threadItem
+{
+ pthread_t thread;
+ struct parserData *data;
+ struct threadItem *next;
+};
+
struct parserData
{
int background;
@@ -64,13 +82,11 @@
int leaving;
void *scanner;
pthread_t thread;
+ struct threadList *threads;
struct bufList *buflist;
struct bufItem *bufitem;
};
-typedef struct strList *List;
-typedef struct strItem *String;
-
int yyerror (char *err);
void printUsage ();
void *threadEntry (void *arg);
@@ -78,6 +94,8 @@
void add_string (struct strList *strList, char *string);
struct bufList * new_bufList ();
int add_buf (struct bufList *bufList, int id, char *buffer, int width, int height);
+struct threadList * new_threadList ();
+void add_thread (struct parserData *data);
void updateScreen (g15canvas *canvas, int g15screen_fd, int force);
int getDispCol (int len, int size, int type);
Modified: trunk/g15composer/g15composer.y
===================================================================
--- trunk/g15composer/g15composer.y 2006-12-01 01:46:25 UTC (rev 203)
+++ trunk/g15composer/g15composer.y 2006-12-04 03:53:24 UTC (rev 204)
@@ -655,10 +655,11 @@
{
struct parserData *newParam = (struct parserData *) malloc (sizeof (struct parserData));
newParam->background = 0;
+ newParam->threads = ((struct parserData *)param)->threads;
newParam->fifo_filename = strdup ($2);
pthread_create (&newParam->thread, NULL, threadEntry, (void *) newParam);
- pthread_detach (newParam->thread);
+ add_thread (newParam);
free ($2);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-12-01 01:46:25
|
Revision: 203
http://svn.sourceforge.net/g15tools/?rev=203&view=rev
Author: aneurysm9
Date: 2006-11-30 17:46:25 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
update usage and man page to reflect -u option
Modified Paths:
--------------
trunk/g15composer/doc/g15composer.1
trunk/g15composer/g15composer.c
Modified: trunk/g15composer/doc/g15composer.1
===================================================================
--- trunk/g15composer/doc/g15composer.1 2006-12-01 01:28:46 UTC (rev 202)
+++ trunk/g15composer/doc/g15composer.1 2006-12-01 01:46:25 UTC (rev 203)
@@ -14,6 +14,13 @@
.P
.HP
\-b Start without a display to listen for new screen commands.
+.P
+.HP
+\-u
+.I username
+.br
+Change effective UID to that of
+.I username
.SH "BASIC USAGE"
nohup ./g15composer /path/to/pipe &
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-12-01 01:28:46 UTC (rev 202)
+++ trunk/g15composer/g15composer.c 2006-12-01 01:46:25 UTC (rev 203)
@@ -47,7 +47,7 @@
void
printUsage ()
{
- fprintf (stdout, "Usage: g15composer [-b] /path/to/fifo\n");
+ fprintf (stdout, "Usage: g15composer [-b] [-u username] /path/to/fifo\n");
fprintf (stdout, " cat instructions > /path/to/fifo\n\n");
fprintf (stdout, "Display composer for the Logitech G15 LCD\n");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-12-01 01:28:46
|
Revision: 202
http://svn.sourceforge.net/g15tools/?rev=202&view=rev
Author: aneurysm9
Date: 2006-11-30 17:28:46 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
indent and cleanup code
Modified Paths:
--------------
trunk/g15composer/g15composer.c
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-11-30 21:59:56 UTC (rev 201)
+++ trunk/g15composer/g15composer.c 2006-12-01 01:28:46 UTC (rev 202)
@@ -37,11 +37,11 @@
#include "config.h"
#endif
-int
-yyerror (char *err)
+int
+yyerror (char *err)
{
- fprintf (stderr, "Error: %s\n",err);
- return (0);
+ fprintf (stderr, "Error: %s\n", err);
+ return (0);
}
void
@@ -52,321 +52,339 @@
fprintf (stdout, "Display composer for the Logitech G15 LCD\n");
}
-void
-*threadEntry (void *arg)
+void *
+threadEntry (void *arg)
{
- struct parserData *param = (struct parserData *)arg;
- extern short g15c_logo_data[6880];
- int tmpfd, errno;
+ struct parserData *param = (struct parserData *) arg;
+ extern short g15c_logo_data[6880];
+ int tmpfd, errno;
- param->leaving = 0;
+ param->leaving = 0;
- mode_t mode = S_IRUSR | S_IWUSR | S_IWGRP;
- tmpfd = open (param->fifo_filename, O_WRONLY | O_NDELAY);
- if (tmpfd == -1 && errno == ENOENT)
- {
- if (mkfifo (param->fifo_filename, mode))
- {
- fprintf (stderr, "Error: Could not create FIFO %s, aborting.\n", param->fifo_filename);
- free (param);
- close (tmpfd);
- pthread_exit (NULL);
- }
- chmod (param->fifo_filename, mode);
- }
- else if (tmpfd == -1 && errno != ENXIO)
- {
- fprintf (stderr, "Error: Unable to access %s, aborting.\n", param->fifo_filename);
- free (param);
- close (tmpfd);
- pthread_exit (NULL);
- }
- else if (tmpfd > 0)
- {
- fprintf (stderr, "Error: No usable FIFO %s, aborting.\n", param->fifo_filename);
- free (param);
- close (tmpfd);
- pthread_exit (NULL);
- }
+ mode_t mode = S_IRUSR | S_IWUSR | S_IWGRP;
+ tmpfd = open (param->fifo_filename, O_WRONLY | O_NDELAY);
+ /* Create fifo if it does not exist */
+ if (tmpfd == -1 && errno == ENOENT)
+ {
+ if (mkfifo (param->fifo_filename, mode))
+ {
+ fprintf (stderr, "Error: Could not create FIFO %s, aborting.\n",
+ param->fifo_filename);
+ free (param);
+ close (tmpfd);
+ pthread_exit (NULL);
+ }
+ chmod (param->fifo_filename, mode);
+ }
+ /* Exit if unable to access fifo */
+ else if (tmpfd == -1 && errno != ENXIO)
+ {
+ fprintf (stderr, "Error: Unable to access %s, aborting.\n",
+ param->fifo_filename);
+ free (param);
+ close (tmpfd);
+ pthread_exit (NULL);
+ }
+ /* Exit if fifo is regular file or fifo being read */
+ else if (tmpfd > 0)
+ {
+ fprintf (stderr, "Error: No usable FIFO %s, aborting.\n",
+ param->fifo_filename);
+ free (param);
+ close (tmpfd);
+ pthread_exit (NULL);
+ }
- close (tmpfd);
+ close (tmpfd);
- yylex_init (¶m->scanner);
+ yylex_init (¶m->scanner);
- if (!param->background)
- {
- param->canvas = (g15canvas *) malloc (sizeof (g15canvas));
- param->g15screen_fd = 0;
- if ((param->g15screen_fd = new_g15_screen (G15_G15RBUF)) < 0)
- {
- fprintf (stderr, "Sorry, can't connect to g15daemon\n");
- param->leaving = 1;
- }
- g15r_initCanvas (param->canvas);
- param->canvas->mode_reverse = 1;
- g15r_pixelOverlay (param->canvas, 0, 0, 160, 43, g15c_logo_data);
- param->canvas->mode_reverse = 0;
- updateScreen (param->canvas, param->g15screen_fd, 1);
- g15r_clearScreen (param->canvas, G15_COLOR_WHITE);
- param->buflist = new_bufList ();
- }
+ if (!param->background)
+ {
+ param->canvas = (g15canvas *) malloc (sizeof (g15canvas));
+ param->g15screen_fd = 0;
+ if ((param->g15screen_fd = new_g15_screen (G15_G15RBUF)) < 0)
+ {
+ fprintf (stderr, "Sorry, can't connect to g15daemon\n");
+ param->leaving = 1;
+ }
+ g15r_initCanvas (param->canvas);
+ param->canvas->mode_reverse = 1;
+ g15r_pixelOverlay (param->canvas, 0, 0, 160, 43, g15c_logo_data);
+ param->canvas->mode_reverse = 0;
+ updateScreen (param->canvas, param->g15screen_fd, 1);
+ g15r_clearScreen (param->canvas, G15_COLOR_WHITE);
+ param->buflist = new_bufList ();
+ }
- if ((yyset_in (fopen(param->fifo_filename, "r"), param->scanner)) == 0)
- {
- perror (param->fifo_filename);
- param->leaving = 1;
- }
+ if ((yyset_in (fopen (param->fifo_filename, "r"), param->scanner)) == 0)
+ {
+ perror (param->fifo_filename);
+ param->leaving = 1;
+ }
- int result = 0;
- while (param->leaving == 0)
- {
- result = yyparse(param);
- fclose (yyget_in(param->scanner));
- if (param->leaving == 0)
- {
- if ((yyset_in(fopen (param->fifo_filename,"r"), param->scanner)) == 0)
- {
- perror (param->fifo_filename);
- param->leaving = 1;
- }
- if (param->background == 1)
- continue;
- if (!param->canvas->mode_cache)
- g15r_clearScreen (param->canvas, G15_COLOR_WHITE);
- }
- }
+ int result = 0;
+ while (param->leaving == 0)
+ {
+ result = yyparse (param);
+ fclose (yyget_in (param->scanner));
+ if (param->leaving == 0)
+ {
+ if ((yyset_in (fopen (param->fifo_filename, "r"), param->scanner))
+ == 0)
+ {
+ perror (param->fifo_filename);
+ param->leaving = 1;
+ }
+ if (param->background == 1)
+ continue;
+ if (!param->canvas->mode_cache)
+ g15r_clearScreen (param->canvas, G15_COLOR_WHITE);
+ }
+ }
- if (!param->background)
- {
- if (param->g15screen_fd)
- g15_close_screen (param->g15screen_fd);
- if (param->canvas != NULL)
- free (param->canvas);
- }
+ if (!param->background)
+ {
+ if (param->g15screen_fd)
+ g15_close_screen (param->g15screen_fd);
+ if (param->canvas != NULL)
+ free (param->canvas);
+ }
- yylex_destroy (param->scanner);
+ yylex_destroy (param->scanner);
- if (strncmp(param->fifo_filename, "/var/run/", 9))
- unlink (param->fifo_filename);
+ if (strncmp (param->fifo_filename, "/var/run/", 9))
+ unlink (param->fifo_filename);
- free (param);
-
- pthread_exit(NULL);
+ free (param);
+
+ pthread_exit (NULL);
}
-int
+int
main (int argc, char *argv[])
{
- struct parserData *param = (struct parserData *) malloc (sizeof (struct parserData));
- param->background = 0;
- param->fifo_filename = NULL;
+ struct parserData *param =
+ (struct parserData *) malloc (sizeof (struct parserData));
+ param->background = 0;
+ param->fifo_filename = NULL;
- unsigned char user[256];
+ unsigned char user[256];
- int i = 1;
- for (i = 1; (i < argc && param->fifo_filename == NULL); ++i)
- {
- if (!strcmp (argv[i],"-h") || !strcmp (argv[i],"--help"))
- {
- printUsage ();
- return 0;
- }
- else if (!strcmp (argv[i],"-b"))
- {
- param->background = 1;
- }
- else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--user"))
- {
- if(argv[i+1]!=NULL)
- {
- strncpy((char*)user,argv[i+1],128);
- i++;
- }
- }
- else
- {
- param->fifo_filename = argv[i];
- }
- }
-
- if (param->fifo_filename != NULL)
- {
- char *dirc, *dname;
- dirc = strdup (param->fifo_filename);
- dname = dirname (dirc);
+ int i = 1;
+ for (i = 1; (i < argc && param->fifo_filename == NULL); ++i)
+ {
+ if (!strcmp (argv[i], "-h") || !strcmp (argv[i], "--help"))
+ {
+ printUsage ();
+ return 0;
+ }
+ else if (!strcmp (argv[i], "-b"))
+ {
+ param->background = 1;
+ }
+ else if (!strcmp (argv[i], "-u") || !strcmp (argv[i], "--user"))
+ {
+ if (argv[i + 1] != NULL)
+ {
+ strncpy ((char *) user, argv[i + 1], 128);
+ i++;
+ }
+ }
+ else
+ {
+ param->fifo_filename = argv[i];
+ }
+ }
- if (strncmp (dname, "/", 1))
- {
- char *bname, cwd[256];
- bname = strdup (param->fifo_filename);
- getcwd (cwd, 256);
- sprintf (param->fifo_filename, "%s/%s", cwd, bname);
- }
+ if (param->fifo_filename != NULL)
+ {
+ char *dirc, *dname;
+ dirc = strdup (param->fifo_filename);
+ dname = dirname (dirc);
- int tmpfd = open ("/var/run/g15composer", O_WRONLY | O_NDELAY);
- if (tmpfd > 0)
- {
- FILE *control = fdopen (tmpfd, "w");
- fprintf (control, "SN \"%s\"\n", param->fifo_filename);
- fclose (control);
- close (tmpfd);
- return 0;
- }
+ if (strncmp (dname, "/", 1))
+ {
+ char *bname, cwd[256];
+ bname = strdup (param->fifo_filename);
+ getcwd (cwd, 256);
+ sprintf (param->fifo_filename, "%s/%s", cwd, bname);
+ }
- struct passwd *nobody;
+ int tmpfd = open ("/var/run/g15composer", O_WRONLY | O_NDELAY);
+ if (tmpfd > 0)
+ {
+ FILE *control = fdopen (tmpfd, "w");
+ fprintf (control, "SN \"%s\"\n", param->fifo_filename);
+ fclose (control);
+ close (tmpfd);
+ return 0;
+ }
- if (strlen ((char *)user) == 0)
- nobody = getpwnam("nobody");
- else
- nobody = getpwnam((char *)user);
+ struct passwd *nobody;
- if (nobody == NULL)
- nobody = getpwuid(geteuid());
+ if (strlen ((char *) user) == 0)
+ nobody = getpwnam ("nobody");
+ else
+ nobody = getpwnam ((char *) user);
- if(nobody!=NULL)
- {
- setegid(nobody->pw_gid);
- seteuid(nobody->pw_uid);
- }
+ if (nobody == NULL)
+ nobody = getpwuid (geteuid ());
- pthread_create (¶m->thread, NULL, threadEntry, (void *) param);
- pthread_join (param->thread, NULL);
- }
- else
- {
- fprintf (stderr, "Please provide a FIFO filename to read from.\n");
- return -1;
- }
-
- return 0;
+ if (nobody != NULL)
+ {
+ setegid (nobody->pw_gid);
+ seteuid (nobody->pw_uid);
+ }
+
+ pthread_create (¶m->thread, NULL, threadEntry, (void *) param);
+ pthread_join (param->thread, NULL);
+ }
+ else
+ {
+ fprintf (stderr, "Please provide a FIFO filename to read from.\n");
+ return -1;
+ }
+
+ return 0;
}
-struct strList *
+struct strList *
new_strList ()
{
- struct strList *new;
- new = (struct strList *) malloc (sizeof (struct strList));
- if (new == NULL)
- return NULL;
- new->first_string = 0;
- new->last_string = 0;
+ struct strList *new;
+ new = (struct strList *) malloc (sizeof (struct strList));
+ if (new == NULL)
+ return NULL;
+ new->first_string = NULL;
+ new->last_string = NULL;
- return new;
+ return new;
}
-void
+void
add_string (struct strList *list, char *string)
{
- struct strItem *new;
- new = (struct strItem *) malloc (sizeof (struct strItem));
- if (new == NULL)
- return;
- new->string = strdup(string);
- new->next_string = NULL;
+ struct strItem *new;
+ new = (struct strItem *) malloc (sizeof (struct strItem));
+ if (new == NULL)
+ return;
+ new->string = strdup (string);
+ new->next_string = NULL;
- if (list->first_string == 0)
- list->first_string = new;
- else
- list->last_string->next_string = new;
- list->last_string = new;
- free (string);
+ if (list->first_string == NULL)
+ list->first_string = new;
+ else
+ list->last_string->next_string = new;
+ list->last_string = new;
+ free (string);
}
struct bufList *
new_bufList ()
{
- struct bufList *new;
- new = (struct bufList *) malloc (sizeof (struct bufList));
- if (new == NULL)
- return NULL;
- new->first_buf = 0;
- new->last_buf = 0;
+ struct bufList *new;
+ new = (struct bufList *) malloc (sizeof (struct bufList));
+ if (new == NULL)
+ return NULL;
+ new->first_buf = NULL;
+ new->last_buf = NULL;
- return new;
+ return new;
}
int
add_buf (struct bufList *bufList, int id, char *buffer, int width, int height)
{
- struct bufItem *new;
- struct bufItem *tmp;
-
- tmp = bufList->first_buf;
+ struct bufItem *new = NULL;
+ struct bufItem *tmp;
- while (tmp != 0)
- {
- if (tmp->id == id)
- return 1;
- tmp = tmp->next;
- }
+ tmp = bufList->first_buf;
- new = (struct bufItem *) malloc (sizeof (struct bufItem));
- if (new == NULL)
- return -1;
- new->buffer = buffer;
- new->id = id;
- new->width = width;
- new->height = height;
- new->next = NULL;
+ while (tmp != NULL)
+ {
+ if (tmp->id == id)
+ {
+ new = tmp;
+ free (new->buffer);
+ }
+ tmp = tmp->next;
+ }
- if (bufList->first_buf == 0)
- bufList->first_buf = new;
- else
- bufList->last_buf->next = new;
+ /* Allocate new if we didn't match by id */
+ if (new == NULL)
+ new = (struct bufItem *) malloc (sizeof (struct bufItem));
- bufList->last_buf = new;
+ /* Exit if new still == NULL */
+ if (new == NULL)
+ return -1;
- return 0;
+ new->buffer = buffer;
+ new->id = id;
+ new->width = width;
+ new->height = height;
+ new->next = NULL;
+
+ if (bufList->first_buf == NULL)
+ bufList->first_buf = new;
+ else
+ bufList->last_buf->next = new;
+
+ bufList->last_buf = new;
+
+ return 0;
}
void
-updateScreen (g15canvas *canvas, int g15screen_fd, int force)
+updateScreen (g15canvas * canvas, int g15screen_fd, int force)
{
- if (force || !canvas->mode_cache)
- g15_send (g15screen_fd, (char *) canvas->buffer, 1048);
+ if (force || !canvas->mode_cache)
+ g15_send (g15screen_fd, (char *) canvas->buffer, G15_BUFFER_LEN);
}
int
getDispCol (int len, int size, int type)
{
- int dispcol = 0;
+ #define TEXT_CENTER 1
+ #define TEXT_RIGHT 2
+ #define WIDTH_SMALL 4
+ #define WIDTH_MED 5
+ #define WIDTH_LARGE 8
- switch (size)
- {
- case 0:
- {
- if (type == 1)
- dispcol = (80 - ((len * 4) / 2));
- else if (type == 2)
- dispcol = (160 - (len * 4));
- break;
- }
- case 1:
- {
- if (type == 1)
- dispcol = (80 - ((len * 5) / 2));
- else if (type == 2)
- dispcol = (160 - (len * 5));
- break;
- }
- case 2:
- {
- if (type == 1)
- dispcol = (80 - ((len * 8) / 2));
- else if (type == 2)
- dispcol = (160 - (len * 8));
- break;
- }
- default:
- {
- dispcol = 0;
- break;
- }
- }
-
- if (dispcol < 0)
- dispcol = 0;
+ int dispcol = 0;
- return dispcol;
+ switch (size)
+ {
+ case G15_TEXT_SMALL:
+ {
+ if (type == TEXT_CENTER)
+ dispcol = ((G15_LCD_WIDTH / 2) - ((len * WIDTH_SMALL) / 2));
+ else if (type == TEXT_RIGHT)
+ dispcol = (G15_LCD_WIDTH - (len * WIDTH_SMALL));
+ break;
+ }
+ case G15_TEXT_MED:
+ {
+ if (type == TEXT_CENTER)
+ dispcol = ((G15_LCD_WIDTH / 2) - ((len * WIDTH_MED) / 2));
+ else if (type == TEXT_RIGHT)
+ dispcol = (G15_LCD_WIDTH - (len * WIDTH_MED));
+ break;
+ }
+ case G15_TEXT_LARGE:
+ {
+ if (type == TEXT_CENTER)
+ dispcol = ((G15_LCD_WIDTH / 2) - ((len * WIDTH_LARGE) / 2));
+ else if (type == TEXT_RIGHT)
+ dispcol = (G15_LCD_WIDTH - (len * WIDTH_LARGE));
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (dispcol < 0)
+ dispcol = 0;
+
+ return dispcol;
}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-11-30 21:59:56
|
Revision: 201
http://svn.sourceforge.net/g15tools/?rev=201&view=rev
Author: aneurysm9
Date: 2006-11-30 13:59:56 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
handle relative paths with subdirs
Modified Paths:
--------------
trunk/g15composer/g15composer.c
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-11-30 21:50:36 UTC (rev 200)
+++ trunk/g15composer/g15composer.c 2006-11-30 21:59:56 UTC (rev 201)
@@ -195,11 +195,10 @@
dirc = strdup (param->fifo_filename);
dname = dirname (dirc);
- if (!strcmp (dname, "."))
+ if (strncmp (dname, "/", 1))
{
- char *basec, *bname, cwd[256];
- basec = strdup (param->fifo_filename);
- bname = basename (basec);
+ char *bname, cwd[256];
+ bname = strdup (param->fifo_filename);
getcwd (cwd, 256);
sprintf (param->fifo_filename, "%s/%s", cwd, bname);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-11-30 21:50:36
|
Revision: 200
http://svn.sourceforge.net/g15tools/?rev=200&view=rev
Author: aneurysm9
Date: 2006-11-30 13:50:36 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
Convert relative to absolute paths for fifo_filename
If g15composer is listening on /var/run/g15composer, ask it to create a new screen rather than having second open instance
Modified Paths:
--------------
trunk/g15composer/g15composer.c
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-11-30 03:10:47 UTC (rev 199)
+++ trunk/g15composer/g15composer.c 2006-11-30 21:50:36 UTC (rev 200)
@@ -25,6 +25,7 @@
#include <errno.h>
#include <pwd.h>
#include <fcntl.h>
+#include <libgen.h>
#include <libg15.h>
#include <libg15render.h>
#include <g15daemon_client.h>
@@ -190,6 +191,29 @@
if (param->fifo_filename != NULL)
{
+ char *dirc, *dname;
+ dirc = strdup (param->fifo_filename);
+ dname = dirname (dirc);
+
+ if (!strcmp (dname, "."))
+ {
+ char *basec, *bname, cwd[256];
+ basec = strdup (param->fifo_filename);
+ bname = basename (basec);
+ getcwd (cwd, 256);
+ sprintf (param->fifo_filename, "%s/%s", cwd, bname);
+ }
+
+ int tmpfd = open ("/var/run/g15composer", O_WRONLY | O_NDELAY);
+ if (tmpfd > 0)
+ {
+ FILE *control = fdopen (tmpfd, "w");
+ fprintf (control, "SN \"%s\"\n", param->fifo_filename);
+ fclose (control);
+ close (tmpfd);
+ return 0;
+ }
+
struct passwd *nobody;
if (strlen ((char *)user) == 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-11-30 02:28:07
|
Revision: 198
http://svn.sourceforge.net/g15tools/?rev=198&view=rev
Author: aneurysm9
Date: 2006-11-29 18:28:03 -0800 (Wed, 29 Nov 2006)
Log Message:
-----------
update ChangeLog and configure.in for 3.1 release
Modified Paths:
--------------
trunk/g15composer/ChangeLog
trunk/g15composer/configure.in
Modified: trunk/g15composer/ChangeLog
===================================================================
--- trunk/g15composer/ChangeLog 2006-11-30 02:15:40 UTC (rev 197)
+++ trunk/g15composer/ChangeLog 2006-11-30 02:28:03 UTC (rev 198)
@@ -1,3 +1,8 @@
+3.1
+* Add support for new WBMP and bignum routines in libg15render-1.2
+* Improve FIFO handling to recover dangling FIFOs
+* Add -u/--user command line option to change effective UID/GID
+
3.0
* Reimplement g15composer using flex and bison
* Text may now be right justified with the TO command
Modified: trunk/g15composer/configure.in
===================================================================
--- trunk/g15composer/configure.in 2006-11-30 02:15:40 UTC (rev 197)
+++ trunk/g15composer/configure.in 2006-11-30 02:28:03 UTC (rev 198)
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT(G15Composer, 3.0, mir...@gm...)
+AC_INIT(G15Composer, 3.1, mir...@gm...)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE()
AC_CONFIG_SRCDIR([g15composer.h])
@@ -35,7 +35,7 @@
# Checks for libraries.
AC_CHECK_LIB([g15daemon_client], [g15_send], ,AC_MSG_ERROR(["libg15daemon_client not found. please install it"]))
-AC_CHECK_LIB([g15render], [g15r_initCanvas], ,AC_MSG_ERROR(["libg15render not found. please install it"]))
+AC_CHECK_LIB([g15render], [g15r_loadWbmpToBuf], ,AC_MSG_ERROR([">=libg15render-1.2 not found. please install it"]))
AC_CHECK_LIB([pthread], [pthread_create], ,AC_MSG_ERROR(["lpthread not found. please install it"]))
# Checks for header files.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-11-30 02:15:40
|
Revision: 197
http://svn.sourceforge.net/g15tools/?rev=197&view=rev
Author: aneurysm9
Date: 2006-11-29 18:15:40 -0800 (Wed, 29 Nov 2006)
Log Message:
-----------
Improve FIFO handling to recover dangling FIFOs
Add -u/--user command line option to change EUID/EGID
Modified Paths:
--------------
trunk/g15composer/g15composer.c
trunk/g15composer/g15composer.h
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-11-28 23:30:37 UTC (rev 196)
+++ trunk/g15composer/g15composer.c 2006-11-30 02:15:40 UTC (rev 197)
@@ -22,6 +22,9 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <pthread.h>
+#include <errno.h>
+#include <pwd.h>
+#include <fcntl.h>
#include <libg15.h>
#include <libg15render.h>
#include <g15daemon_client.h>
@@ -53,21 +56,40 @@
{
struct parserData *param = (struct parserData *)arg;
extern short g15c_logo_data[6880];
+ int tmpfd, errno;
param->leaving = 0;
- param->keepFifo = 0;
- mode_t mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH;
- if (mkfifo (param->fifo_filename, mode))
- {
- fprintf (stderr, "Error: Could not create FIFO %s, aborting.\n", param->fifo_filename);
- param->leaving = 1;
- param->keepFifo = 1;
+ mode_t mode = S_IRUSR | S_IWUSR | S_IWGRP;
+ tmpfd = open (param->fifo_filename, O_WRONLY | O_NDELAY);
+ if (tmpfd == -1 && errno == ENOENT)
+ {
+ if (mkfifo (param->fifo_filename, mode))
+ {
+ fprintf (stderr, "Error: Could not create FIFO %s, aborting.\n", param->fifo_filename);
+ free (param);
+ close (tmpfd);
+ pthread_exit (NULL);
+ }
+ chmod (param->fifo_filename, mode);
+ }
+ else if (tmpfd == -1 && errno != ENXIO)
+ {
+ fprintf (stderr, "Error: Unable to access %s, aborting.\n", param->fifo_filename);
free (param);
+ close (tmpfd);
pthread_exit (NULL);
}
- chmod (param->fifo_filename, mode);
+ else if (tmpfd > 0)
+ {
+ fprintf (stderr, "Error: No usable FIFO %s, aborting.\n", param->fifo_filename);
+ free (param);
+ close (tmpfd);
+ pthread_exit (NULL);
+ }
+ close (tmpfd);
+
yylex_init (¶m->scanner);
if (!param->background)
@@ -123,7 +145,7 @@
yylex_destroy (param->scanner);
- if (param->keepFifo == 0)
+ if (strncmp(param->fifo_filename, "/var/run/", 9))
unlink (param->fifo_filename);
free (param);
@@ -138,6 +160,8 @@
param->background = 0;
param->fifo_filename = NULL;
+ unsigned char user[256];
+
int i = 1;
for (i = 1; (i < argc && param->fifo_filename == NULL); ++i)
{
@@ -150,6 +174,14 @@
{
param->background = 1;
}
+ else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--user"))
+ {
+ if(argv[i+1]!=NULL)
+ {
+ strncpy((char*)user,argv[i+1],128);
+ i++;
+ }
+ }
else
{
param->fifo_filename = argv[i];
@@ -158,9 +190,32 @@
if (param->fifo_filename != NULL)
{
+ struct passwd *nobody;
+
+ if (strlen ((char *)user) == 0)
+ nobody = getpwnam("nobody");
+ else
+ nobody = getpwnam((char *)user);
+
+ if (nobody == NULL)
+ nobody = getpwuid(geteuid());
+
+ if(nobody!=NULL)
+ {
+ setegid(nobody->pw_gid);
+ seteuid(nobody->pw_uid);
+ }
+
pthread_create (¶m->thread, NULL, threadEntry, (void *) param);
pthread_join (param->thread, NULL);
}
+ else
+ {
+ fprintf (stderr, "Please provide a FIFO filename to read from.\n");
+ return -1;
+ }
+
+ return 0;
}
struct strList *
Modified: trunk/g15composer/g15composer.h
===================================================================
--- trunk/g15composer/g15composer.h 2006-11-28 23:30:37 UTC (rev 196)
+++ trunk/g15composer/g15composer.h 2006-11-30 02:15:40 UTC (rev 197)
@@ -62,7 +62,6 @@
char *fifo_filename;
int mkey_state;
int leaving;
- int keepFifo;
void *scanner;
pthread_t thread;
struct bufList *buflist;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-11-28 23:30:38
|
Revision: 196
http://svn.sourceforge.net/g15tools/?rev=196&view=rev
Author: aneurysm9
Date: 2006-11-28 15:30:37 -0800 (Tue, 28 Nov 2006)
Log Message:
-----------
Add WBMPLOAD, DRAWICON, and DRAWSPRITE commands
Modified Paths:
--------------
trunk/g15composer/README
trunk/g15composer/doc/g15composer.1
trunk/g15composer/g15composer.c
trunk/g15composer/g15composer.h
trunk/g15composer/g15composer.y
Modified: trunk/g15composer/README
===================================================================
--- trunk/g15composer/README 2006-11-28 23:07:58 UTC (rev 195)
+++ trunk/g15composer/README 2006-11-28 23:30:37 UTC (rev 196)
@@ -82,12 +82,22 @@
DN X1 Y1 X2 Y2 C N
Draws a big number N in the area bounded by (X1,Y2) and (X2,Y2) using color C
+DI B X Y
+ Draws a WBMP icon from buffer B at (X,Y)
+
+DS B X Y W H OX OY
+ Draws a WBMP sprite from buffer B at (X,Y) with size WxH
+ Sprite is drawn from buffer offset by (OX,OY)
+
*** WBMP Commands:
WS "/path/to/image"
Loads a WBMP image from /path/to/image and displays it on the screen
Image must be 160x43 as it is loaded directly into the LCD buffer
+WL B "/path/to/image"
+ Loads a WBMP image from /path/to/image into buffer number B
+
*** Mode Commands:
MC 0|1
Modified: trunk/g15composer/doc/g15composer.1
===================================================================
--- trunk/g15composer/doc/g15composer.1 2006-11-28 23:07:58 UTC (rev 195)
+++ trunk/g15composer/doc/g15composer.1 2006-11-28 23:30:37 UTC (rev 196)
@@ -91,11 +91,21 @@
DN X1 Y1 X2 Y2 C N
Draws a big number N in the area bounded by (X1,Y2) and (X2,Y2) using color C
+DI B X Y
+ Draws a WBMP icon from buffer B at (X,Y)
+
+DS B X Y W H OX OY
+ Draws a WBMP sprite from buffer B at (X,Y) with size WxH
+ Sprite is drawn from buffer offset by (OX,OY)
+
*** WBMP Commands:
WS "/path/to/image"
Loads a WBMP image from /path/to/image and displays it on the screen
Image must be 160x43 as it is loaded directly into the LCD buffer
+
+WL B "/path/to/image"
+ Loads a WBMP image from /path/to/image into buffer number B
*** Mode Commands:
Modified: trunk/g15composer/g15composer.c
===================================================================
--- trunk/g15composer/g15composer.c 2006-11-28 23:07:58 UTC (rev 195)
+++ trunk/g15composer/g15composer.c 2006-11-28 23:30:37 UTC (rev 196)
@@ -85,6 +85,7 @@
param->canvas->mode_reverse = 0;
updateScreen (param->canvas, param->g15screen_fd, 1);
g15r_clearScreen (param->canvas, G15_COLOR_WHITE);
+ param->buflist = new_bufList ();
}
if ((yyset_in (fopen(param->fifo_filename, "r"), param->scanner)) == 0)
@@ -167,6 +168,8 @@
{
struct strList *new;
new = (struct strList *) malloc (sizeof (struct strList));
+ if (new == NULL)
+ return NULL;
new->first_string = 0;
new->last_string = 0;
@@ -178,6 +181,8 @@
{
struct strItem *new;
new = (struct strItem *) malloc (sizeof (struct strItem));
+ if (new == NULL)
+ return;
new->string = strdup(string);
new->next_string = NULL;
@@ -189,6 +194,53 @@
free (string);
}
+struct bufList *
+new_bufList ()
+{
+ struct bufList *new;
+ new = (struct bufList *) malloc (sizeof (struct bufList));
+ if (new == NULL)
+ return NULL;
+ new->first_buf = 0;
+ new->last_buf = 0;
+
+ return new;
+}
+
+int
+add_buf (struct bufList *bufList, int id, char *buffer, int width, int height)
+{
+ struct bufItem *new;
+ struct bufItem *tmp;
+
+ tmp = bufList->first_buf;
+
+ while (tmp != 0)
+ {
+ if (tmp->id == id)
+ return 1;
+ tmp = tmp->next;
+ }
+
+ new = (struct bufItem *) malloc (sizeof (struct bufItem));
+ if (new == NULL)
+ return -1;
+ new->buffer = buffer;
+ new->id = id;
+ new->width = width;
+ new->height = height;
+ new->next = NULL;
+
+ if (bufList->first_buf == 0)
+ bufList->first_buf = new;
+ else
+ bufList->last_buf->next = new;
+
+ bufList->last_buf = new;
+
+ return 0;
+}
+
void
updateScreen (g15canvas *canvas, int g15screen_fd, int force)
{
Modified: trunk/g15composer/g15composer.h
===================================================================
--- trunk/g15composer/g15composer.h 2006-11-28 23:07:58 UTC (rev 195)
+++ trunk/g15composer/g15composer.h 2006-11-28 23:30:37 UTC (rev 196)
@@ -34,6 +34,24 @@
struct strItem *next_string;
};
+struct bufList;
+struct bufItem;
+
+struct bufList
+{
+ struct bufItem *first_buf;
+ struct bufItem *last_buf;
+};
+
+struct bufItem
+{
+ char *buffer;
+ int id;
+ int width;
+ int height;
+ struct bufItem *next;
+};
+
struct parserData
{
int background;
@@ -47,6 +65,8 @@
int keepFifo;
void *scanner;
pthread_t thread;
+ struct bufList *buflist;
+ struct bufItem *bufitem;
};
typedef struct strList *List;
@@ -57,6 +77,8 @@
void *threadEntry (void *arg);
struct strList * new_strList ();
void add_string (struct strList *strList, char *string);
+struct bufList * new_bufList ();
+int add_buf (struct bufList *bufList, int id, char *buffer, int width, int height);
void updateScreen (g15canvas *canvas, int g15screen_fd, int force);
int getDispCol (int len, int size, int type);
Modified: trunk/g15composer/g15composer.y
===================================================================
--- trunk/g15composer/g15composer.y 2006-11-28 23:07:58 UTC (rev 195)
+++ trunk/g15composer/g15composer.y 2006-11-28 23:30:37 UTC (rev 196)
@@ -272,6 +272,42 @@
}
|
+
+ T_DRAWICON T_NUMBER T_NUMBER T_NUMBER T_NEWLINE
+ {
+ if (((struct parserData *)param)->background == 1)
+ return (0);
+
+ struct bufItem *buf = ((struct parserData *)param)->buflist->first_buf;
+
+ while ((buf->id != $2) && (buf != NULL))
+ buf = buf->next;
+
+ if (buf == NULL)
+ return (-1);
+
+ g15r_drawIcon (((struct parserData *)param)->canvas, buf->buffer, $3, $4, buf->width, buf->height);
+ }
+
+ |
+
+ T_DRAWSPRITE T_NUMBER T_NUMBER T_NUMBER T_NUMBER T_NUMBER T_NUMBER T_NUMBER T_NEWLINE
+ {
+ if (((struct parserData *)param)->background == 1)
+ return (0);
+
+ struct bufItem *buf = ((struct parserData *)param)->buflist->first_buf;
+
+ while ((buf->id != $2) && (buf != NULL))
+ buf = buf->next;
+
+ if (buf == NULL)
+ return (-1);
+
+ g15r_drawSprite (((struct parserData *)param)->canvas, buf->buffer, $3, $4, $5, $6, $7, $8, buf->width);
+ }
+
+ |
nt_drawcircle
|
nt_drawrbox
@@ -339,7 +375,22 @@
if (((struct parserData *)param)->background == 1)
return (0);
g15r_loadWbmpSplash (((struct parserData *)param)->canvas, $2);
+ free ($2);
}
+
+ |
+
+ T_WBMPLOAD T_NUMBER nt_string T_NEWLINE
+ {
+ if (((struct parserData *)param)->background == 1)
+ return (0);
+ int width = 0;
+ int height = 0;
+
+ char *buffer = g15r_loadWbmpToBuf ($3, &width, &height);
+ int ret = add_buf (((struct parserData *)param)->buflist, $2, buffer, width, height);
+ free ($3);
+ }
;
nt_mode_command:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ane...@us...> - 2006-11-28 23:07:59
|
Revision: 195
http://svn.sourceforge.net/g15tools/?rev=195&view=rev
Author: aneurysm9
Date: 2006-11-28 15:07:58 -0800 (Tue, 28 Nov 2006)
Log Message:
-----------
have g15r_loadWbmpToBuf() create buffer so we don't need to know size beforehand
Modified Paths:
--------------
trunk/libg15render/libg15render.h
trunk/libg15render/pixel.c
trunk/testlibg15render/testlibg15render.cpp
Modified: trunk/libg15render/libg15render.h
===================================================================
--- trunk/libg15render/libg15render.h 2006-11-28 21:58:48 UTC (rev 194)
+++ trunk/libg15render/libg15render.h 2006-11-28 23:07:58 UTC (rev 195)
@@ -78,7 +78,7 @@
/** \brief Draw a sprite to the screen from a wbmp buffer*/
void g15r_drawSprite(g15canvas *canvas, char *buf, int my_x, int my_y, int width, int height, int start_x, int start_y, int total_width);
/** \brief Load a wbmp file into a buffer*/
-int g15r_loadWbmpToBuf(char *buf, char *filename, int *img_width, int *img_height, int maxlen);
+char *g15r_loadWbmpToBuf(char *filename, int *img_width, int *img_height);
/** \brief Draw a large number*/
void g15r_drawBigNum (g15canvas * canvas, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int color, int num);
Modified: trunk/libg15render/pixel.c
===================================================================
--- trunk/libg15render/pixel.c 2006-11-28 21:58:48 UTC (rev 194)
+++ trunk/libg15render/pixel.c 2006-11-28 23:07:58 UTC (rev 195)
@@ -384,14 +384,15 @@
int
g15r_loadWbmpSplash(g15canvas *canvas, char *filename)
{
- int retval;
int width=0, height=0;
+ char *buf;
- retval = g15r_loadWbmpToBuf(canvas->buffer,filename,
- &width,
- &height,
- G15_BUFFER_LEN);
- return retval;
+ buf = g15r_loadWbmpToBuf(filename,
+ &width,
+ &height);
+
+ memcpy (canvas->buffer, buf, G15_BUFFER_LEN);
+ return 0;
}
/**
@@ -456,31 +457,27 @@
}
/**
- * basic wbmp loader - loads wbmp into pre-prepared buf.
+ * basic wbmp loader - loads a wbmp image into a buffer.
*
- * \param buf A pointer to the buffer into which the wbmp will be loaded.
* \param filename A string holding the path to the wbmp to be loaded.
* \param img_width A pointer to an int that will hold the image width on return.
* \param img_height A pointer to an int that will hold the image height on return.
- * \param maxlen The maximum number of bytes that should be read from filename.
*/
-int
-g15r_loadWbmpToBuf(char *buf, char *filename, int *img_width, int *img_height, int maxlen)
+char *
+g15r_loadWbmpToBuf(char *filename, int *img_width, int *img_height)
{
int wbmp_fd;
int retval;
int x,y,val;
+ char *buf;
unsigned int buflen,header=4;
unsigned char headerbytes[5];
unsigned int pixel_offset = 0;
unsigned int byte_offset, bit_offset;
- if(maxlen<5 || buf == NULL)
- return -1;
-
wbmp_fd=open(filename,O_RDONLY);
if(!wbmp_fd){
- return -1;
+ return NULL;
}
retval=read(wbmp_fd,headerbytes,5);
@@ -493,8 +490,6 @@
} else {
*img_width = headerbytes[2];
*img_height = headerbytes[3];
- header = 4;
- buf[0]=headerbytes[4];
}
int byte_width = *img_width / 8;
@@ -502,10 +497,16 @@
byte_width++;
buflen = byte_width * (*img_height);
- if(buflen<maxlen)
- retval=read(wbmp_fd,buf+(5-header),buflen);
- else
- retval = -1;
+
+ buf = (char *)malloc (buflen);
+ if (buf == NULL)
+ return NULL;
+
+ if (header == 4)
+ buf[0]=headerbytes[4];
+
+ retval=read(wbmp_fd,buf+(5-header),buflen);
+
close(wbmp_fd);
}
@@ -525,7 +526,7 @@
buf[byte_offset] = buf[byte_offset] & ~(1 << bit_offset);
}
- return retval;
+ return buf;
}
/**
Modified: trunk/testlibg15render/testlibg15render.cpp
===================================================================
--- trunk/testlibg15render/testlibg15render.cpp 2006-11-28 21:58:48 UTC (rev 194)
+++ trunk/testlibg15render/testlibg15render.cpp 2006-11-28 23:07:58 UTC (rev 195)
@@ -154,9 +154,8 @@
sleep (3);
g15r_clearScreen (canvas, 0);
- char *buf = (char *)malloc (G15_BUFFER_LEN);
int width, height;
- g15r_loadWbmpToBuf (buf, "./splash.wbmp", &width, &height, G15_BUFFER_LEN);
+ char *buf = g15r_loadWbmpToBuf ("./splash.wbmp", &width, &height);
g15r_drawSprite (canvas, buf, 30, 10, 43, 20, 30, 10, width);
g15r_drawSprite (canvas, buf, 10, 20, 15, 20, 10, 20, width);
g15r_drawSprite (canvas, buf, 100, 20, 25, 20, 100, 20, width);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|