- bugfixes for display != MatrixOrb LCD
- changes the meaning of output_state
+ it's now a bitfield where evry bit corresponds to
one output
- protocol change
output on|off|value
where on = all outputs on
off = all outputs off
value = output on for all 1 bits
- changes the behavior for key presses
Keypresses are now deliverd to _all_ clients (not only
the one with the active screen)
reason: I have an client which is only active a few seconds after
an keypress
- changes the protocol so that a response is sent for every
command
reason: the client needs to communicate with the server with a
minimal latency
113 lines
2.2 KiB
C
113 lines
2.2 KiB
C
/*
|
|
|
|
input.c
|
|
|
|
Handles keypad (and other?) input from the user.
|
|
|
|
Currently, the keys are as follows:
|
|
|
|
Context Key Function
|
|
------- --- --------
|
|
Normal "normal" context is handled in this source file.
|
|
A Pause/Continue
|
|
B Back(Go to previous screen)
|
|
C Forward(Go to next screen)
|
|
D Open main menu
|
|
E-Z Sent to client, if any; ignored otherwise
|
|
|
|
(menu keys are not handled here, but in the menu code)
|
|
Menu
|
|
A Enter/select
|
|
B Up/Left
|
|
C Down/Right
|
|
D Exit/Cancel
|
|
E-Z Ignored
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
#include "../shared/sockets.h"
|
|
#include "../shared/debug.h"
|
|
|
|
#include "drivers/lcd.h"
|
|
|
|
#include "client_data.h"
|
|
#include "clients.h"
|
|
#include "screen.h"
|
|
#include "screenlist.h"
|
|
#include "menus.h"
|
|
|
|
#include "input.h"
|
|
|
|
int server_input (int key);
|
|
|
|
// FIXME! The server tends to crash when "E" is pressed.. (?!)
|
|
// (but only when the joystick driver is the last one on the list...)
|
|
|
|
// Checks for keypad input, and dispatches it
|
|
int
|
|
handle_input ()
|
|
{
|
|
char str[256];
|
|
int key;
|
|
screen *s;
|
|
client *c;
|
|
|
|
key = lcd.getkey ();
|
|
|
|
if (!key)
|
|
return 0;
|
|
|
|
debug ("handle_input(%c)\n", (char) key);
|
|
|
|
if (key) {
|
|
/* s = screenlist_current (); */
|
|
c = (client *)LL_GetFirst(clients);
|
|
while(c) {
|
|
// TODO: Interpret and translate keys!
|
|
// If the client should have this keypress...
|
|
// Send keypress to client
|
|
// TODO: Implement client "acceptable key" lists
|
|
sprintf(str, "key %c\n", key);
|
|
sock_send_string(c->sock, str);
|
|
c = (client *)LL_GetNext(clients);
|
|
}
|
|
server_input (key);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
server_input (int key)
|
|
{
|
|
debug ("server_input(%c)\n", (char) key);
|
|
|
|
switch (key) {
|
|
case 'A':
|
|
if (screenlist_action == SCR_HOLD)
|
|
screenlist_action = 0;
|
|
else
|
|
screenlist_action = SCR_HOLD;
|
|
break;
|
|
case 'B':
|
|
screenlist_action = SCR_BACK;
|
|
screenlist_prev ();
|
|
break;
|
|
case 'C':
|
|
screenlist_action = SCR_SKIP;
|
|
screenlist_next ();
|
|
break;
|
|
case 'D':
|
|
debug ("got the menu key!\n");
|
|
server_menu ();
|
|
break;
|
|
default:
|
|
debug ("server_input: Invalid key \"%c\" (%i)\n", (char) key, key);
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|