Ctrl button

This commit is contained in:
Michael Jumper 2011-08-21 23:24:40 -07:00
parent 7b09948842
commit e7607b1e9b
3 changed files with 19 additions and 1 deletions

View File

@ -65,6 +65,8 @@ typedef struct ssh_guac_client_data {
char password[1024]; char password[1024];
int password_length; int password_length;
int mod_ctrl;
} ssh_guac_client_data; } ssh_guac_client_data;
int ssh_guac_client_auth(guac_client* client, const char* password); int ssh_guac_client_auth(guac_client* client, const char* password);

View File

@ -114,6 +114,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* Init client data */ /* Init client data */
client->data = client_data; client->data = client_data;
client_data->term = term; client_data->term = term;
client_data->mod_ctrl = 0;
/* Send name and dimensions */ /* Send name and dimensions */
guac_send_name(io, "SSH TEST"); guac_send_name(io, "SSH TEST");

View File

@ -113,13 +113,28 @@ int ssh_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data; ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data;
/* Track modifiers */
if (keysym == 0xFFE3) {
client_data->mod_ctrl = pressed;
}
/* If key pressed */ /* If key pressed */
if (pressed) { else if (pressed) {
/* If simple ASCII key */ /* If simple ASCII key */
if (keysym >= 0x00 && keysym <= 0xFF) { if (keysym >= 0x00 && keysym <= 0xFF) {
char data = (char) keysym; char data = (char) keysym;
/* Handle Ctrl modifier */
if (client_data->mod_ctrl) {
if (keysym >= 'A' && keysym <= 'Z')
data = (char) (keysym - 'A' + 1);
else if (keysym >= 'a' && keysym <= 'z')
data = (char) (keysym - 'a' + 1);
}
return channel_write(client_data->term_channel, &data, 1); return channel_write(client_data->term_channel, &data, 1);
} }
else { else {