Added server message in bottom-right corner of active screen.
Will display short text if a rotation key is pressed.
This commit is contained in:
+27
-5
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "shared/sockets.h"
|
||||
#include "shared/report.h"
|
||||
#include "shared/configfile.h"
|
||||
|
||||
#include "drivers.h"
|
||||
|
||||
@@ -28,14 +29,15 @@
|
||||
#include "menuscreens.h"
|
||||
|
||||
#include "input.h"
|
||||
#include "render.h" /* For server_msg* */
|
||||
|
||||
|
||||
LinkedList * keylist;
|
||||
char * toggle_rotate_key = "Enter";
|
||||
char * prev_screen_key = "Left";
|
||||
char * next_screen_key = "Right";
|
||||
char * scroll_up_key = "Up";
|
||||
char * scroll_down_key = "Down";
|
||||
char * toggle_rotate_key;
|
||||
char * prev_screen_key;
|
||||
char * next_screen_key;
|
||||
char * scroll_up_key;
|
||||
char * scroll_down_key;
|
||||
|
||||
/* Local functions */
|
||||
int server_input (int key);
|
||||
@@ -49,6 +51,13 @@ int input_init()
|
||||
|
||||
keylist = LL_new();
|
||||
|
||||
/* Get rotate/scroll keys from config file */
|
||||
toggle_rotate_key = strdup (config_get_string ("server", "ToggleRotateKey", 0, "Enter"));
|
||||
prev_screen_key = strdup (config_get_string ("server", "PrevScreenKey", 0, "Left"));
|
||||
next_screen_key = strdup (config_get_string ("server", "NextScreenKey", 0, "Right"));
|
||||
scroll_up_key = strdup (config_get_string ("server", "ScrollUpKey", 0, "Up"));
|
||||
scroll_down_key = strdup (config_get_string ("server", "ScrollDownKey", 0, "Down"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -62,6 +71,12 @@ int input_shutdown()
|
||||
|
||||
free (keylist);
|
||||
|
||||
free (toggle_rotate_key);
|
||||
free (prev_screen_key);
|
||||
free (next_screen_key);
|
||||
free (scroll_up_key);
|
||||
free (scroll_down_key);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -134,12 +149,19 @@ input_internal_key (char * key)
|
||||
/* Keys are for scrolling or rotating */
|
||||
if( strcmp(key,toggle_rotate_key) == 0 ) {
|
||||
autorotate = !autorotate;
|
||||
if( autorotate ) {
|
||||
server_msg( "Rotate", 4 );
|
||||
} else {
|
||||
server_msg( "Hold", 4 );
|
||||
}
|
||||
}
|
||||
else if( strcmp(key,prev_screen_key) == 0 ) {
|
||||
screenlist_goto_prev ();
|
||||
server_msg( "Prev", 4 );
|
||||
}
|
||||
else if( strcmp(key,next_screen_key) == 0 ) {
|
||||
screenlist_goto_next ();
|
||||
server_msg( "Next", 4 );
|
||||
}
|
||||
else if( strcmp(key,scroll_up_key) == 0 ) {
|
||||
}
|
||||
|
||||
+38
-8
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "shared/report.h"
|
||||
#include "shared/LL.h"
|
||||
@@ -38,8 +39,6 @@
|
||||
#include "widget.h"
|
||||
#include "render.h"
|
||||
|
||||
int metronome = 0; /* This counter will be increased at every rendering */
|
||||
|
||||
int heartbeat = HEARTBEAT_OPEN;
|
||||
int heartbeat_fallback = HEARTBEAT_ON; /* If no heartbeat setting has been set at all */
|
||||
int backlight = BACKLIGHT_OPEN;
|
||||
@@ -47,6 +46,8 @@ int backlight_fallback = BACKLIGHT_ON; /* If no backlight setting has been set a
|
||||
int backlight_brightness = 255;
|
||||
int backlight_off_brightness = 0;
|
||||
int output_state = 0;
|
||||
char * server_msg_text;
|
||||
int server_msg_expire = 0;
|
||||
|
||||
static int reset;
|
||||
|
||||
@@ -122,8 +123,6 @@ render_screen (Screen * s, long int timer)
|
||||
/* Set the cursor */
|
||||
drivers_cursor (s->cursor_x, s->cursor_y, s->cursor);
|
||||
|
||||
/*debug(RPT_DEBUG, "%s done", __FUNCTION__); */
|
||||
|
||||
if (heartbeat != HEARTBEAT_OPEN) {
|
||||
tmp_state = heartbeat;
|
||||
} else if (s->client && s->client->heartbeat != HEARTBEAT_OPEN) {
|
||||
@@ -135,11 +134,19 @@ render_screen (Screen * s, long int timer)
|
||||
}
|
||||
drivers_heartbeat(tmp_state);
|
||||
|
||||
/* If there is an server message that is not expired, display it */
|
||||
if( server_msg_expire > 0 ) {
|
||||
drivers_string( display_props->width - strlen(server_msg_text) + 1,
|
||||
display_props->height, server_msg_text );
|
||||
server_msg_expire --;
|
||||
if( server_msg_expire == 0 ) {
|
||||
free( server_msg_text );
|
||||
}
|
||||
}
|
||||
|
||||
/* flush display out, frame and all... */
|
||||
drivers_flush ();
|
||||
|
||||
/*debug(RPT_DEBUG, "%s: %8x, %i", __FUNCTION__, s, timer); */
|
||||
|
||||
debug(RPT_DEBUG, "==== END RENDERING ====" );
|
||||
return 0;
|
||||
|
||||
@@ -205,8 +212,6 @@ render_frame (LinkedList * list,
|
||||
if (!list)
|
||||
return -1;
|
||||
|
||||
/*debug(RPT_DEBUG, "%s: %8x, %i", __FUNCTION__, frame, timer); */
|
||||
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
w = (Widget *) LL_Get (list);
|
||||
@@ -481,3 +486,28 @@ render_frame (LinkedList * list,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
server_msg( const char * text, int expire )
|
||||
{
|
||||
debug( RPT_DEBUG, "%s( text=\"%.40s\", expire=%d )", __FUNCTION__, text, expire );
|
||||
|
||||
if( strlen(text) > 15 || expire <= 0 ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Still a message active ? */
|
||||
|
||||
if( server_msg_expire > 0 ) {
|
||||
free( server_msg_text );
|
||||
}
|
||||
|
||||
/* Store new message */
|
||||
server_msg_text = malloc( strlen(text) + 3 );
|
||||
strcpy( server_msg_text, "| " );
|
||||
strcat( server_msg_text, text );
|
||||
|
||||
server_msg_expire = expire;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,12 @@ extern int backlight;
|
||||
extern int backlight_brightness;
|
||||
extern int backlight_off_brightness;
|
||||
extern int output_state;
|
||||
|
||||
int render_screen (Screen * s, long int timer);
|
||||
/* Renders the given screen. */
|
||||
|
||||
int server_msg( const char * text, int expire );
|
||||
/* Displays a short message in a corner. Message must be shorter
|
||||
* than 16 chars. */
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user