Commit 5738e33f authored by dscho's avatar dscho

VisualNaCro: add sendascii

parent a5baf57b
...@@ -717,6 +717,47 @@ bool_t sendkey(resource_t res,keysym_t keysym,bool_t keydown) ...@@ -717,6 +717,47 @@ bool_t sendkey(resource_t res,keysym_t keysym,bool_t keydown)
return SendKeyEvent(r->client,keysym,keydown); return SendKeyEvent(r->client,keysym,keydown);
} }
bool_t sendascii(resource_t res,const char *string)
{
timeout_t delay = 0.1;
private_resource_t* r=get_resource(res);
int i;
if(r==NULL)
return 0;
while (*string) {
int keysym = *string;
int need_shift = 0;
if (keysym >= 8 && keysym < ' ')
keysym += 0xff00;
else if (keysym >= 'A' && keysym <= 'Z')
need_shift = 1;
else if (keysym > '~') {
fprintf(stderr, "String contains non-ASCII "
"character 0x%02x\n", *string);
return FALSE;
}
if (need_shift) {
if (!SendKeyEvent(r->client,0xffe1,1))
return FALSE;
waitforinput(r,delay);
}
for (i = 1; i >= 0; i--) {
if (!SendKeyEvent(r->client,keysym,i))
return FALSE;
waitforinput(r,delay);
}
if (need_shift) {
if (!SendKeyEvent(r->client,0xffe1,0))
return FALSE;
waitforinput(r,delay);
}
string++;
}
return TRUE;
}
bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons) bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons)
{ {
private_resource_t* r=get_resource(res); private_resource_t* r=get_resource(res);
......
...@@ -94,6 +94,7 @@ const char *gettext_server(resource_t res); ...@@ -94,6 +94,7 @@ const char *gettext_server(resource_t res);
/* send events to the server */ /* send events to the server */
bool_t sendkey(resource_t res,keysym_t keysym,bool_t keydown); bool_t sendkey(resource_t res,keysym_t keysym,bool_t keydown);
bool_t sendascii(resource_t res,const char *string);
bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons); bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons);
bool_t sendtext(resource_t res, const char *string); bool_t sendtext(resource_t res, const char *string);
bool_t sendtext_to_server(resource_t res, const char *string); bool_t sendtext_to_server(resource_t res, const char *string);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment