|
From: <mla...@us...> - 2008-01-21 10:40:18
|
Revision: 438
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=438&view=rev
Author: mlampard
Date: 2008-01-21 02:40:18 -0800 (Mon, 21 Jan 2008)
Log Message:
-----------
g15daemon 1.9x: add screen capture ability (M1+M3 == screen dump to /tmp/g15daemon-sc-X.pbm).
Modified Paths:
--------------
trunk/g15daemon-wip/ChangeLog
trunk/g15daemon-wip/g15daemon/g15daemon.h
trunk/g15daemon-wip/g15daemon/main.c
trunk/g15daemon-wip/g15daemon/utility_funcs.c
Modified: trunk/g15daemon-wip/ChangeLog
===================================================================
--- trunk/g15daemon-wip/ChangeLog 2008-01-21 01:32:40 UTC (rev 437)
+++ trunk/g15daemon-wip/ChangeLog 2008-01-21 10:40:18 UTC (rev 438)
@@ -155,3 +155,6 @@
client-switch. Used by G15Macro if available.
- Debug: Add segfault handler to libg15daemon_client to aid debugging
clients.
+- Feature: Add screendump ability. Pressing M1+M3 simultaneously will write
+ a pbm format image of the currently displayed screen to
+ /tmp/g15daemon-sc-?.pbm, where ? is an incremental number.
Modified: trunk/g15daemon-wip/g15daemon/g15daemon.h
===================================================================
--- trunk/g15daemon-wip/g15daemon/g15daemon.h 2008-01-21 01:32:40 UTC (rev 437)
+++ trunk/g15daemon-wip/g15daemon/g15daemon.h 2008-01-21 10:40:18 UTC (rev 438)
@@ -227,6 +227,8 @@
void g15daemon_init_refresh();
void g15daemon_quit_refresh();
int uf_write_buf_to_g15(lcd_t *lcd);
+/* write a pbm format file 'filename' with image contained in 'buf' */
+int uf_screendump_pbm(unsigned char *buf,char *filename);
int uf_read_keypresses(unsigned int *keypresses, unsigned int timeout);
/* return the pid of a running copy of g15daemon, else -1 */
int uf_return_running();
Modified: trunk/g15daemon-wip/g15daemon/main.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/main.c 2008-01-21 01:32:40 UTC (rev 437)
+++ trunk/g15daemon-wip/g15daemon/main.c 2008-01-21 10:40:18 UTC (rev 438)
@@ -95,6 +95,14 @@
displaying->backlight_state++;
displaying->backlight_state %= 3; // limit to 0-2 inclusive
}
+ if(value & G15_KEY_M1 && value & G15_KEY_M3) {
+ static int scr_num=0;
+ char filename[128];
+ lcd_t *displaying = lcd->masterlist->current->lcd;
+ sprintf(filename,"/tmp/g15daemon-sc-%i.pbm",scr_num);
+ uf_screendump_pbm(displaying->buf,filename);
+ scr_num++;
+ }
free(newevent);
}else{
/* hacky attempt to double-time the use of L1, if the key is pressed less than half a second, it cycles the screens. If held for longer, the key is sent to the application for use instead */
Modified: trunk/g15daemon-wip/g15daemon/utility_funcs.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/utility_funcs.c 2008-01-21 01:32:40 UTC (rev 437)
+++ trunk/g15daemon-wip/g15daemon/utility_funcs.c 2008-01-21 10:40:18 UTC (rev 438)
@@ -44,6 +44,7 @@
#include "g15daemon.h"
#include <libg15.h>
#include <stdarg.h>
+#include <libg15render.h>
extern unsigned int g15daemon_debug;
extern volatile int leaving;
@@ -659,3 +660,24 @@
return 0;
}
+int uf_screendump_pbm(unsigned char *buffer,char *filename) {
+ FILE *f;
+ int x,y;
+ #define WIDTH 40
+ g15canvas *canvas=g15daemon_xmalloc(sizeof(g15canvas));
+ memcpy(canvas->buffer,buffer,LCD_BUFSIZE);
+ f = fopen(filename,"w+");
+ fprintf(f,"P1\n160 43\n");
+ fprintf(f,"# G15 screendump - %s\n\n",filename);
+ for(y=0;y<43;y++)
+ for(x=0;x<160;x++) {
+ fprintf(f,"%i",g15r_getPixel(canvas,x,y));
+ if(x%WIDTH==WIDTH-1)
+ fprintf(f,"\n");
+ }
+
+ fclose(f);
+ free(canvas);
+ return 0;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|