contentLister/inc/cursor.h File Reference

content lister - eReader cursor handling More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  coordinates
struct  point_info
struct  transfer_buffer
struct  display_update_info
struct  brush_draw_info_obsolete
struct  brush_draw_info

Defines

#define WAVEFORM_SIZE   (128*1024)
#define FBIO_IOCTL_BASE   'v'
#define FBIO_DISPLAY   _IOW(FBIO_IOCTL_BASE, 1, struct display_update_info)
#define FBIO_ERASE_WHITE   _IOW(FBIO_IOCTL_BASE, 2, struct display_update_info)
#define FBIO_DRAWPIXELS   _IOW(FBIO_IOCTL_BASE, 3, struct transfer_buffer)
#define FBIO_DRAW_BRUSH   _IOW(FBIO_IOCTL_BASE, 4, struct brush_draw_info_obsolete)
#define FBIO_REDRAW   _IOW(FBIO_IOCTL_BASE, 5, struct display_update_info)
#define FBIO_UPLOAD_WAVEFORM   _IOC(_IOC_WRITE, FBIO_IOCTL_BASE, 6, WAVEFORM_SIZE)
#define FBIO_UPLOAD_BRUSH   _IO(FBIO_IOCTL_BASE, 7)
#define FBIO_DRAW_BUBBLE   _IOW(FBIO_IOCTL_BASE, 8, struct brush_draw_info_obsolete)
#define FBIO_DRAW_BRUSH_GENERIC   _IOW(FBIO_IOCTL_BASE, 9, struct brush_draw_info)
#define FBIO_START_PROGRESS_BAR   _IO(FBIO_IOCTL_BASE, 10)
#define WAVEFORM_2BPP_IMAGE   0
#define WAVEFORM_4BPP_IMAGE   1
#define WAVEFORM_DRAW   4
#define WAVEFORM_FAST_BLACK_WHITE   6
#define WAVEFORM_TYPING   9
#define HARDWARE_V3   1
#define ESTIMATED_BOOT_TIME   (39)
#define ESTIMATED_BOOT_JIFFIES   (ESTIMATED_BOOT_TIME * 100)
#define BOOT_PROGRESS_STEPS   (18)
#define BOOT_PROGRESS_START_STEP   (0)
#define PROGRESS_STEP_JIFFIES   (ESTIMATED_BOOT_JIFFIES / (BOOT_PROGRESS_STEPS - BOOT_PROGRESS_START_STEP))
#define BLACK_CURSOR_X   0
#define BLACK_CURSOR_Y   24
#define BLACK_CURSOR_SIZE_X   114
#define BLACK_CURSOR_SIZE_Y   24
#define WHITE_CURSOR_X   0
#define WHITE_CURSOR_Y   0
#define WHITE_CURSOR_SIZE_X   114
#define WHITE_CURSOR_SIZE_Y   24
#define BLACK_BUBBLE_X   102
#define BLACK_BUBBLE_Y   49
#define BLACK_BUBBLE_SIZE_X   7
#define BLACK_BUBBLE_SIZE_Y   7
#define WHITE_BUBBLE_X   21
#define WHITE_BUBBLE_Y   49
#define WHITE_BUBBLE_SIZE_X   7
#define WHITE_BUBBLE_SIZE_Y   7
#define PROGRESS_BLOCK_BWHITE_X   118
#define PROGRESS_BLOCK_BWHITE_Y   22
#define PROGRESS_BLOCK_BWHITE_SIZE_X   19
#define PROGRESS_BLOCK_BWHITE_SIZE_Y   36
#define PROGRESS_BLOCK_WHITE_X   138
#define PROGRESS_BLOCK_WHITE_Y   22
#define PROGRESS_BLOCK_WHITE_SIZE_X   19
#define PROGRESS_BLOCK_WHITE_SIZE_Y   36
#define PROGRESS_BLOCK_BLACK_X   159
#define PROGRESS_BLOCK_BLACK_Y   22
#define PROGRESS_BLOCK_BLACK_SIZE_X   19
#define PROGRESS_BLOCK_BLACK_SIZE_Y   36
#define WHITE_BRUSH_X   1
#define LGRAY_BRUSH_X   28
#define DGRAY_BRUSH_X   55
#define BLACK_BRUSH_X   82
#define BRUSH_Y   49
#define MAX_BRUSH_SIZE   6
#define WHITE   0
#define LIGHT_GRAY   1
#define DARK_GRAY   2
#define BLACK   3
#define PIXELBUFSIZE   25

Typedefs

typedef unsigned short u16

Enumerations

enum  cursor_state_t { e_cursor_hide = 0, e_cursor_show, e_cursor_blink, e_cursor_undefined }

Functions

int cursor_init (ContentLister *theContentLister)
int cursor_set_state (const int pos, const cursor_state_t state)
void cursor_hide_all (void)
void cursor_redraw (void)
void cursor_destroy ()
void start_progress_indicator (void)


Detailed Description

content lister - eReader cursor handling

<File description>="">

Depending on the configure value "cursor-used" the e-reader specific cursor code will be enabled/disabled

Definition in file cursor.h.


Define Documentation

#define BLACK   3

Definition at line 159 of file cursor.h.

#define BLACK_BRUSH_X   82

Definition at line 150 of file cursor.h.

#define BLACK_BUBBLE_SIZE_X   7

Definition at line 123 of file cursor.h.

#define BLACK_BUBBLE_SIZE_Y   7

Definition at line 124 of file cursor.h.

#define BLACK_BUBBLE_X   102

Definition at line 121 of file cursor.h.

#define BLACK_BUBBLE_Y   49

Definition at line 122 of file cursor.h.

#define BLACK_CURSOR_SIZE_X   114

Definition at line 113 of file cursor.h.

#define BLACK_CURSOR_SIZE_Y   24

Definition at line 114 of file cursor.h.

#define BLACK_CURSOR_X   0

Definition at line 111 of file cursor.h.

#define BLACK_CURSOR_Y   24

Definition at line 112 of file cursor.h.

#define BOOT_PROGRESS_START_STEP   (0)

Definition at line 107 of file cursor.h.

#define BOOT_PROGRESS_STEPS   (18)

Definition at line 106 of file cursor.h.

#define BRUSH_Y   49

Definition at line 151 of file cursor.h.

#define DARK_GRAY   2

Definition at line 158 of file cursor.h.

#define DGRAY_BRUSH_X   55

Definition at line 149 of file cursor.h.

#define ESTIMATED_BOOT_JIFFIES   (ESTIMATED_BOOT_TIME * 100)

Definition at line 105 of file cursor.h.

#define ESTIMATED_BOOT_TIME   (39)

Definition at line 104 of file cursor.h.

#define FBIO_DISPLAY   _IOW(FBIO_IOCTL_BASE, 1, struct display_update_info)

Definition at line 81 of file cursor.h.

#define FBIO_DRAW_BRUSH   _IOW(FBIO_IOCTL_BASE, 4, struct brush_draw_info_obsolete)

Definition at line 84 of file cursor.h.

#define FBIO_DRAW_BRUSH_GENERIC   _IOW(FBIO_IOCTL_BASE, 9, struct brush_draw_info)

Definition at line 89 of file cursor.h.

#define FBIO_DRAW_BUBBLE   _IOW(FBIO_IOCTL_BASE, 8, struct brush_draw_info_obsolete)

Definition at line 88 of file cursor.h.

#define FBIO_DRAWPIXELS   _IOW(FBIO_IOCTL_BASE, 3, struct transfer_buffer)

Definition at line 83 of file cursor.h.

#define FBIO_ERASE_WHITE   _IOW(FBIO_IOCTL_BASE, 2, struct display_update_info)

Definition at line 82 of file cursor.h.

#define FBIO_IOCTL_BASE   'v'

Definition at line 80 of file cursor.h.

#define FBIO_REDRAW   _IOW(FBIO_IOCTL_BASE, 5, struct display_update_info)

Definition at line 85 of file cursor.h.

#define FBIO_START_PROGRESS_BAR   _IO(FBIO_IOCTL_BASE, 10)

Definition at line 90 of file cursor.h.

#define FBIO_UPLOAD_BRUSH   _IO(FBIO_IOCTL_BASE, 7)

Definition at line 87 of file cursor.h.

#define FBIO_UPLOAD_WAVEFORM   _IOC(_IOC_WRITE, FBIO_IOCTL_BASE, 6, WAVEFORM_SIZE)

Definition at line 86 of file cursor.h.

#define HARDWARE_V3   1

Definition at line 100 of file cursor.h.

#define LGRAY_BRUSH_X   28

Definition at line 148 of file cursor.h.

#define LIGHT_GRAY   1

Definition at line 157 of file cursor.h.

#define MAX_BRUSH_SIZE   6

Definition at line 153 of file cursor.h.

#define PIXELBUFSIZE   25

Definition at line 161 of file cursor.h.

#define PROGRESS_BLOCK_BLACK_SIZE_X   19

Definition at line 143 of file cursor.h.

#define PROGRESS_BLOCK_BLACK_SIZE_Y   36

Definition at line 144 of file cursor.h.

#define PROGRESS_BLOCK_BLACK_X   159

Definition at line 141 of file cursor.h.

#define PROGRESS_BLOCK_BLACK_Y   22

Definition at line 142 of file cursor.h.

#define PROGRESS_BLOCK_BWHITE_SIZE_X   19

Definition at line 133 of file cursor.h.

#define PROGRESS_BLOCK_BWHITE_SIZE_Y   36

Definition at line 134 of file cursor.h.

#define PROGRESS_BLOCK_BWHITE_X   118

Definition at line 131 of file cursor.h.

#define PROGRESS_BLOCK_BWHITE_Y   22

Definition at line 132 of file cursor.h.

#define PROGRESS_BLOCK_WHITE_SIZE_X   19

Definition at line 138 of file cursor.h.

#define PROGRESS_BLOCK_WHITE_SIZE_Y   36

Definition at line 139 of file cursor.h.

#define PROGRESS_BLOCK_WHITE_X   138

Definition at line 136 of file cursor.h.

#define PROGRESS_BLOCK_WHITE_Y   22

Definition at line 137 of file cursor.h.

#define PROGRESS_STEP_JIFFIES   (ESTIMATED_BOOT_JIFFIES / (BOOT_PROGRESS_STEPS - BOOT_PROGRESS_START_STEP))

Definition at line 108 of file cursor.h.

#define WAVEFORM_2BPP_IMAGE   0

Definition at line 94 of file cursor.h.

#define WAVEFORM_4BPP_IMAGE   1

Definition at line 95 of file cursor.h.

#define WAVEFORM_DRAW   4

Definition at line 96 of file cursor.h.

#define WAVEFORM_FAST_BLACK_WHITE   6

Definition at line 97 of file cursor.h.

#define WAVEFORM_SIZE   (128*1024)

Definition at line 77 of file cursor.h.

#define WAVEFORM_TYPING   9

Definition at line 98 of file cursor.h.

#define WHITE   0

Definition at line 156 of file cursor.h.

#define WHITE_BRUSH_X   1

Definition at line 147 of file cursor.h.

#define WHITE_BUBBLE_SIZE_X   7

Definition at line 128 of file cursor.h.

#define WHITE_BUBBLE_SIZE_Y   7

Definition at line 129 of file cursor.h.

#define WHITE_BUBBLE_X   21

Definition at line 126 of file cursor.h.

#define WHITE_BUBBLE_Y   49

Definition at line 127 of file cursor.h.

#define WHITE_CURSOR_SIZE_X   114

Definition at line 118 of file cursor.h.

#define WHITE_CURSOR_SIZE_Y   24

Definition at line 119 of file cursor.h.

#define WHITE_CURSOR_X   0

Definition at line 116 of file cursor.h.

#define WHITE_CURSOR_Y   0

Definition at line 117 of file cursor.h.


Typedef Documentation

typedef unsigned short u16

Definition at line 35 of file cursor.h.


Enumeration Type Documentation

Enumerator:
e_cursor_hide 
e_cursor_show 
e_cursor_blink 
e_cursor_undefined 

Definition at line 164 of file cursor.h.

00165 {
00166     e_cursor_hide = 0,
00167     e_cursor_show,
00168     e_cursor_blink,
00169     e_cursor_undefined
00170 } cursor_state_t;


Function Documentation

void cursor_destroy (  ) 

Free resources used by cursor

Parameters:
- 
Returns:
-

Definition at line 404 of file cursor.c.

00405 {
00406     close(g_framebuffer_device);
00407 }

void cursor_hide_all ( void   ) 

Hide cursor for all lister items

Parameters:
-- 
Returns:
--

Definition at line 229 of file cursor.c.

00230 {
00231     int                    rc;
00232     int                    pos;
00233     struct brush_draw_info drawinfo;
00234     GtkWidget*             listItem = NULL;
00235 
00236     CL_CURSORPRINTF("entry");
00237 
00238     // stop blink handler
00239     cursor_blink_handler_stop();
00240     g_cursor_num_blinking = 0;
00241     g_cursor_x_pos_blink  = g_cursor_x_pos;
00242 
00243     // hide all cursors (i.e. paint white)
00244     drawinfo.sourcex  = WHITE_CURSOR_X;
00245     drawinfo.sourcey  = WHITE_CURSOR_Y;
00246     drawinfo.sizex    = WHITE_CURSOR_SIZE_X;
00247     drawinfo.sizey    = WHITE_CURSOR_SIZE_Y;
00248     drawinfo.brushlsb = WHITE;
00249     for (pos = 0 ; pos < MAX_ITEMS_ON_ONE_PAGE ; pos++)
00250     {
00251         drawinfo.destx = cursor_info[pos].y_pos;
00252 
00253         cursor_info[pos].state = e_cursor_hide;
00254         
00255         // hide gtk cursor
00256         listItem  = lsGetListerItem(g_contentLister->lister, pos);
00257         gtk_content_list_item_show_cursor(GTK_CONTENT_LIST_ITEM(listItem), FALSE);
00258 
00259         // write the brush/drawing for standard location to framebuffer (in-memory)
00260         drawinfo.desty = SCREEN_WIDTH - g_cursor_x_pos;
00261         if (display_update_get_level() < NO_DISPLAY_UPDATE_LEVEL)
00262         {
00263             CL_CURSORPRINTF("FBIO_DRAW_BRUSH location %dx%d color %d", drawinfo.desty, drawinfo.destx, drawinfo.brushlsb);
00264             rc = ioctl(g_framebuffer_device, FBIO_DRAW_BRUSH_GENERIC, &drawinfo);
00265             if (rc != 0)
00266             {
00267                 CL_ERRORPRINTF("Error drawing brush (err=0x%x)", rc);
00268             }
00269         }
00270         
00271         // write the brush/drawing for alternative location to framebuffer (in-memory)
00272         drawinfo.desty = SCREEN_WIDTH - g_cursor_x_pos_alt;
00273         if (display_update_get_level() < NO_DISPLAY_UPDATE_LEVEL)
00274         {
00275             CL_CURSORPRINTF("FBIO_DRAW_BRUSH location %dx%d color %d", drawinfo.desty, drawinfo.destx, drawinfo.brushlsb);
00276             rc = ioctl(g_framebuffer_device, FBIO_DRAW_BRUSH_GENERIC, &drawinfo);
00277             if (rc != 0)
00278             {
00279                 CL_ERRORPRINTF("Error drawing brush (err=0x%x)", rc);
00280             }
00281         }
00282         g_cursor_needs_update = TRUE;
00283     }
00284 }

Here is the call graph for this function:

int cursor_init ( ContentLister theContentLister  ) 

Load bitmap, open framebuffer_device, init values...

Returns:
0/-1 = ok/failure

Definition at line 89 of file cursor.c.

00090 {
00091     int i;
00092 
00093     g_contentLister = theContentLister;
00094 
00095     // open framebuffer device
00096     g_framebuffer_device = open("/dev/fb0", O_RDWR);
00097     if (g_framebuffer_device == -1)
00098     {
00099         CL_ERRORPRINTF("Error opening framebufferdevice. # mknod /dev/fb0 c 29 0");
00100         return -1;  // -1 = error
00101     }
00102 
00103     // determine X coordinate
00104     g_cursor_x_pos     = CURSOR_X;
00105     g_cursor_x_pos_alt = g_cursor_x_pos - BLACK_CURSOR_SIZE_Y;
00106     if (g_cursor_x_pos_alt < BLACK_CURSOR_SIZE_Y + 3)
00107     {
00108         g_cursor_x_pos_alt = BLACK_CURSOR_SIZE_Y + 3;
00109     }
00110     g_cursor_x_pos_blink = g_cursor_x_pos;
00111 
00112     // determine Y coordinate
00113     for (i = 0 ; i < MAX_ITEMS_ON_ONE_PAGE ; i++)
00114     {
00115         cursor_info[i].y_pos = CURSOR_START_Y + i * CURSOR_STEP;
00116         cursor_info[i].state = e_cursor_hide;
00117     }
00118 
00119     // set waveform parameters
00120     updateinfo.waveform = WAVEFORM_FAST_BLACK_WHITE;
00121     updateinfo.sequence = 0;
00122     
00123     return 0;  // 0 = ok
00124 }

void cursor_redraw ( void   ) 

Redraw cursur, when needed

Parameters:
-- 
Returns:
--

Definition at line 286 of file cursor.c.

00287 {
00288     CL_CURSORPRINTF("entry");
00289 
00290     int  rc;
00291 
00292     if (   g_cursor_needs_update
00293         && display_update_get_level() < NO_DISPLAY_UPDATE_LEVEL )
00294     {
00295         // display the modification on screen
00296         CL_CURSORPRINTF("FBIO_REDRAW waveform %d - sequence %d", updateinfo.waveform, updateinfo.sequence);
00297         rc = ioctl(g_framebuffer_device, FBIO_REDRAW, &updateinfo);
00298         if (rc != 0)
00299         {
00300             CL_ERRORPRINTF("Error sending FBIO_REDRAW: %x", rc);
00301         }
00302         g_cursor_needs_update = FALSE;
00303     }
00304 }

Here is the call graph for this function:

int cursor_set_state ( const int  pos,
const cursor_state_t  state 
)

Show/hide/blink cursor at lister-item position

Parameters:
pos - index of lister item (0 ..)
state - new state of cursor
Returns:
0/-1 = ok/failure

Definition at line 130 of file cursor.c.

00131 {
00132     int retVal = 0;  // 0 = ok
00133 
00134     if (pos == -1)
00135     {
00136         return 0;  // 0 = ok
00137     }
00138     CL_CURSORPRINTF("entry: pos [%d] new_state [%d]", pos, new_state);
00139     g_return_val_if_fail((pos >= 0  &&  pos < MAX_ITEMS_ON_ONE_PAGE), -1);
00140 
00141     int                    rc;
00142     struct brush_draw_info drawinfo;
00143     cursor_state_t         old_state = cursor_info[pos].state;
00144     GtkWidget*             listItem  = lsGetListerItem(g_contentLister->lister, pos);
00145 
00146     if (new_state == e_cursor_hide)
00147     {
00148         gtk_content_list_item_show_cursor(GTK_CONTENT_LIST_ITEM(listItem), FALSE);
00149 
00150         // remove cursor (i.e. paint white)
00151         drawinfo.sourcex  = WHITE_CURSOR_X;
00152         drawinfo.sourcey  = WHITE_CURSOR_Y;
00153         drawinfo.sizex    = WHITE_CURSOR_SIZE_X;
00154         drawinfo.sizey    = WHITE_CURSOR_SIZE_Y;
00155         drawinfo.destx    = cursor_info[pos].y_pos;
00156         drawinfo.desty    = SCREEN_WIDTH - ((old_state == e_cursor_blink) ? g_cursor_x_pos_blink : g_cursor_x_pos);
00157         drawinfo.brushlsb = WHITE;
00158     }
00159     else
00160     {
00161         gtk_content_list_item_show_cursor(GTK_CONTENT_LIST_ITEM(listItem), TRUE);
00162 
00163         // show cursor (black)
00164         drawinfo.sourcex  = BLACK_CURSOR_X;
00165         drawinfo.sourcey  = BLACK_CURSOR_Y;
00166         drawinfo.sizex    = BLACK_CURSOR_SIZE_X;
00167         drawinfo.sizey    = BLACK_CURSOR_SIZE_Y;
00168         drawinfo.destx    = cursor_info[pos].y_pos;
00169         drawinfo.desty    = SCREEN_WIDTH - ((new_state == e_cursor_blink) ? g_cursor_x_pos_blink : g_cursor_x_pos);
00170         drawinfo.brushlsb = BLACK;
00171     }
00172     cursor_info[pos].state = new_state;
00173 
00174     // write the brush/drawing to framebuffer (in-memory)
00175     if (display_update_get_level() < NO_DISPLAY_UPDATE_LEVEL)
00176     {
00177         CL_CURSORPRINTF("FBIO_DRAW_BRUSH location %dx%d color %d", drawinfo.desty, drawinfo.destx, drawinfo.brushlsb);
00178         rc = ioctl(g_framebuffer_device, FBIO_DRAW_BRUSH_GENERIC, &drawinfo);
00179         if (rc != 0)
00180         {
00181             CL_ERRORPRINTF("Error drawing brush (err=0x%x)", rc);
00182             retVal = -1;  // -1 = error
00183         }
00184     }
00185 
00186     // set blinking parameters
00187     //   adjust number of blinking cursors
00188     if (old_state == e_cursor_blink  &&  g_cursor_num_blinking > 0)
00189     {
00190         g_cursor_num_blinking--;
00191     }
00192     if (new_state == e_cursor_blink)
00193     {
00194         g_cursor_num_blinking++;
00195     }
00196     g_cursor_num_blinking = g_cursor_num_blinking;
00197     //   start/stop blink timeout handler
00198     if (g_cursor_num_blinking == 0)
00199     {
00200         if (g_cursor_blink_handler != 0)
00201         {
00202             cursor_blink_handler_stop();
00203             g_cursor_x_pos_blink = g_cursor_x_pos;
00204         }
00205     }
00206     else
00207     {
00208         if (g_cursor_blink_handler == 0)
00209         {
00210             g_cursor_blink_handler = g_timeout_add(800, cursor_blink, NULL);
00211         }
00212     }
00213 
00214     // screen update needed except when blink
00215     if (   (new_state == e_cursor_blink  &&  g_cursor_num_blinking > 1)
00216         || (old_state == e_cursor_blink  &&  g_cursor_num_blinking > 0) )
00217     {
00218         // wait for next blink timer to do screen update
00219     }
00220     else
00221     {
00222         // do screen update now
00223         g_cursor_needs_update = TRUE;
00224     }
00225 
00226     return retVal;
00227 }

Here is the call graph for this function:

void start_progress_indicator ( void   ) 

Start progress indicator (knight rider)

Parameters:
- 
Returns:
-

Definition at line 409 of file cursor.c.

00410 {
00411     int framebuffer_device;
00412 
00413     // start the timer now, the viewer has been launched
00414     if (display_update_get_level() < NO_DISPLAY_UPDATE_LEVEL)
00415     {
00416         framebuffer_device = open("/dev/fb0", O_RDWR);    
00417         if ((ioctl(framebuffer_device, FBIO_START_PROGRESS_BAR)) != 0)
00418         {
00419             CL_ERRORPRINTF("einkfb IOCTL failed");
00420         }
00421         close(framebuffer_device);
00422     }
00423 }

Here is the call graph for this function:


Generated on Sun Dec 14 17:12:47 2008 by  doxygen 1.5.6