Rev 1707 | Rev 1718 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1707 | Rev 1717 | ||
|---|---|---|---|
| Line 238... | Line 238... | ||
| 238 | if (a >= right) |
238 | if (a >= right) |
| 239 | a = right - 1; |
239 | a = right - 1; |
| 240 | return a; |
240 | return a; |
| 241 | } |
241 | } |
| 242 | 242 | ||
| - | 243 | int mouse_x, mouse_y; |
|
| - | 244 | int btn_pressed, btn_x, btn_y; |
|
| - | 245 | ||
| - | 246 | /** Handle mouse move |
|
| - | 247 | * |
|
| - | 248 | * @param dx Delta X of mouse move |
|
| - | 249 | * @param dy Delta Y of mouse move |
|
| - | 250 | */ |
|
| 243 | void gcons_mouse_move(int dx, int dy) |
251 | void gcons_mouse_move(int dx, int dy) |
| 244 | { |
252 | { |
| - | 253 | mouse_x = limit(mouse_x+dx, 0, xres); |
|
| - | 254 | mouse_y = limit(mouse_y+dy, 0, yres); |
|
| - | 255 | ||
| - | 256 | async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); |
|
| - | 257 | } |
|
| - | 258 | ||
| - | 259 | static int gcons_find_conbut(int x, int y) |
|
| - | 260 | { |
|
| - | 261 | int status_start = STATUS_START + (xres-800) / 2;; |
|
| - | 262 | ||
| - | 263 | if (y < STATUS_TOP || y >= STATUS_TOP+STATUS_HEIGHT) |
|
| 245 | static int x = 0; |
264 | return -1; |
| - | 265 | ||
| - | 266 | if (x < status_start) |
|
| - | 267 | return -1; |
|
| - | 268 | ||
| - | 269 | if (x >= status_start + (STATUS_WIDTH+STATUS_SPACE)*CONSOLE_COUNT) |
|
| - | 270 | return -1; |
|
| - | 271 | if (((x - status_start) % (STATUS_WIDTH+STATUS_SPACE)) >= STATUS_WIDTH) |
|
| - | 272 | return -1; |
|
| - | 273 | ||
| - | 274 | return (x-status_start) / (STATUS_WIDTH+STATUS_SPACE); |
|
| - | 275 | } |
|
| - | 276 | ||
| - | 277 | /** Handle mouse click |
|
| - | 278 | * |
|
| - | 279 | * @param state New state (1-pressed, 0-depressed) |
|
| - | 280 | */ |
|
| - | 281 | int gcons_mouse_btn(int state) |
|
| - | 282 | { |
|
| 246 | static int y = 0; |
283 | int conbut; |
| 247 | 284 | ||
| - | 285 | if (state) { |
|
| - | 286 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
|
| - | 287 | if (conbut != -1) { |
|
| - | 288 | btn_pressed = 1; |
|
| - | 289 | btn_x = mouse_x; |
|
| 248 | x = limit(x+dx, 0, xres); |
290 | btn_y = mouse_y; |
| - | 291 | } |
|
| - | 292 | return -1; |
|
| - | 293 | } |
|
| 249 | y = limit(y+dy, 0, yres); |
294 | if (!state && !btn_pressed) |
| - | 295 | return -1; |
|
| - | 296 | btn_pressed = 0; |
|
| 250 | 297 | ||
| - | 298 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
|
| 251 | async_msg_2(fbphone, FB_POINTER_MOVE, x, y); |
299 | if (conbut == gcons_find_conbut(btn_x, btn_y)) |
| - | 300 | return conbut; |
|
| - | 301 | return -1; |
|
| 252 | } |
302 | } |
| 253 | 303 | ||
| 254 | 304 | ||
| 255 | /** Draw a PPM pixmap to framebuffer |
305 | /** Draw a PPM pixmap to framebuffer |
| 256 | * |
306 | * |