Open GoogleCodeExporter opened 9 years ago
Dear Friend
I confirm the behavior (since I don't have time to implement rotation of
joystick
together with the screen).
I will mark this as an improvement new feature for Amora client.
Best regards
Adenilson
Original comment by cavalcan...@gmail.com
on 12 Dec 2007 at 2:34
I made a kind of patch to fix this:
in main.c create a structure like this in the top of the file:
struct
{
int do_capture, screen_rotate,
width, height, flag , times;
} phone_state;
then in main function
phone_state.do_capture = 0;
phone_state.screen_rotate = 0;
phone_state.width = 176;
phone_state.height = 208;
phone_state.flag = 0;
phone_state.times = 0;
now you have a global structure with phone config (global is bad, but it's a
quick
fix :) )
now modify treat_command in order to take these settings, and not static local
settings, you can replace the function by this one:
static int treat_command(char *buffer, int length, int client_socket)
{
int result, tmp;
Imlib_Image image, rescaled;
result = protocol_command(buffer, length);
switch (result) {
case CONN_CLOSE:
phone_state.do_capture = 0;
phone_state.screen_rotate = 1;
phone_state.width = 320;
phone_state.height = 240;
phone_state.flag = 0;
break;
case SERVER_STOP: /* TODO: add server stop code */
break;
case RESOLUTION:
break;
case IMG_FORMAT:
break;
case SCREEN_MODE_ON:
phone_state.do_capture = 1;
break;
case SCREEN_MODE_OFF:
phone_state.do_capture = 0;
break;
case SCREEN_ROTATE:
phone_state.screen_rotate = 1;
break;
case SCREEN_NORMAL:
phone_state.screen_rotate = 0;
break;
case SCREEN_RESOLUTION:
phone_state.flag = 1;
break;
case SCREEN_WIDTH:
break;
case SCREEN_HEIGHT:
break;
case SCREEN_TAKE:
tmp = screen_capture(amora.display, &image);
if (tmp) {
perror("failed screen capture!\n");
result = NONE;
break;
}
tmp = rescale_image(&image, phone_state.width, phone_state.height, &rescaled);
imlib_free_image();
if (tmp) {
perror("failed screen capture!\n");
result = NONE;
break;
}
if (phone_state.screen_rotate) {
tmp = rotate_image(&rescaled);
if (tmp) {
imlib_free_image();
perror("failed screen capture!\n");
result = NONE;
break;
}
}
/* XXX, TODO: we should have a tmp or working dir for
* amora-server created with mkdtemp(3) */
tmp = save_image(&rescaled, "amora-screenshot.png");
imlib_free_image();
if (tmp) {
perror("failed screen capture!\n");
result = NONE;
break;
}
tmp = send_file(client_socket, "amora-screenshot.png");
if (tmp) {
perror("failed screen transfer!\n");
result = NONE;
break;
}
break;
case NONE:
tmp = atoi(buffer);
if (phone_state.flag)
result = SCREEN_RESOLUTION;
if (phone_state.flag && (!phone_state.times)) {
++phone_state.times;
if (tmp > 0)
phone_state.width = tmp;
} else if (phone_state.flag && phone_state.times) {
phone_state.flag = phone_state.times = 0;
if (tmp > 0)
phone_state.height = tmp;
}
}
return result;
}
now, you just have to modify the call to mouse_move and the mouse_move
definition:
- in x11_event.h
replace: int mouse_move(int x, int y, Display *active_display);
by: int mouse_move(int x, int y, Display *active_display, int rotate);
- in x11_event.c
replace: int mouse_move(int x, int y, Display *active_display)
by: int mouse_move(int x, int y, Display *active_display, int rotate)
and then
replace
res = XWarpPointer(active_display,
None, DefaultRootWindow(active_display),
0, 0, 0, 0,
root_x + x, root_y + y);
by
if( ! rotate )
res = XWarpPointer(active_display,
None, DefaultRootWindow(active_display),
0, 0, 0, 0,
root_x + x, root_y + y);
else
res = XWarpPointer(active_display,
None, DefaultRootWindow(active_display),
0, 0, 0, 0,
root_x +y, root_y - x);
- in main.c
in treat_events (around line 347)
replace
result = mouse_move(x_mouse, y_mouse, amora.display);
by
result = mouse_move(x_mouse, y_mouse, amora.display, phone_state.screen_rotate);
Hope it helps you while official changes are made
Original comment by hamstahguru
on 9 Feb 2008 at 1:02
Dear Friend
Thanks a lot for your suggestion. I will take a look on it and report as soon
as possible.
For while, I will ask you 2 things:
a) base your changes over trunk source code version (of course, if its is not
the
case). To checkout the source code, visit this URL (it has information
explaining how
to use svn): http://code.google.com/p/amora/source/checkout
b) If possible, attach your patch in this same issue ticket (so it will make
easier
for me to give it a try). Tip: execute 'svn diff > rotate.patch' it will make
the trick.
I will just comment that if you are planning to keep the state for the
cellphone in a
structure, its required to consider that starting from amora 1.0, the server
side
supports multiple cellphones connected at *same* time.
Best regards
Adenilson
Original comment by cavalcan...@gmail.com
on 9 Feb 2008 at 10:22
Original issue reported on code.google.com by
megs....@gmail.com
on 11 Dec 2007 at 2:47