diff options
Diffstat (limited to 'mousetsr.c')
-rw-r--r-- | mousetsr.c | 57 |
1 files changed, 33 insertions, 24 deletions
@@ -35,6 +35,8 @@ TSRDATA data; +static const char version_string[] = "VBADOS"; + static const uint16_t default_cursor_graphic[] = { 0x3FFF, 0x1FFF, 0x0FFF, 0x07FF, 0x03FF, 0x01FF, 0x00FF, 0x007F, @@ -565,26 +567,19 @@ static uint16_t button_event_mask(int btn, bool released) } /** Calls the application-registered event handler. */ -static void call_event_handler(void (__far *handler)(), uint16_t events, - uint16_t buttons, int16_t x, int16_t y, - int16_t delta_x, int16_t delta_y) -{ -#if TRACE_EVENTS - dprintf("calling event handler events=0x%x buttons=0x%x x=%d y=%d dx=%d dy=%d\n", - events, buttons, x, y, delta_x, delta_y); -#endif - - __asm { - mov ax, [events] - mov bx, [buttons] - mov cx, [x] - mov dx, [y] - mov si, [delta_x] - mov di, [delta_y] - - call dword ptr [handler] - } -} +static void call_event_handler(uint16_t events, uint16_t buttons, + int16_t x, int16_t y, + int16_t delta_x, int16_t delta_y, + void (__far *handler)()); +#pragma aux call_event_handler = \ + "push bp" \ + "mov bp, sp" \ + "push ds" \ + "call dword ptr 0x2[bp]" \ + "pop ds" \ + "pop bp" \ + __parm __caller [ax] [bx] [cx] [dx] [si] [di] [] \ + __modify [es fs gs] /** Process a mouse event internally. * @param buttons currently pressed buttons as a bitfield @@ -727,8 +722,17 @@ static void handle_mouse_event(uint16_t buttons, bool absolute, int x, int y, ch x = snap_to_grid(data.pos.x, data.screen_granularity.x); y = snap_to_grid(data.pos.y, data.screen_granularity.y); - call_event_handler(data.event_handler, events, - buttons, x, y, data.delta.x, data.delta.y); +#if TRACE_EVENTS + dprintf("calling user event handler events=0x%x buttons=0x%x x=%d y=%d dx=%d dy=%d\n", + events, buttons, x, y, data.delta.x, data.delta.y); +#endif + + call_event_handler(events, buttons, x, y, data.delta.x, data.delta.y, + data.event_handler); + +#if TRACE_EVENTS + dputs("return from user event handler"); +#endif } static void handle_ps2_packet(void) @@ -884,8 +888,8 @@ static void ps2_mouse_handler(uint16_t word0, uint16_t word1, uint16_t word2, ui if (data.cur_packet_bytes && ticks >= data.cur_packet_ticks + MAX_PS2_PACKET_DELAY) { // Assume the start of a new packet - dprintf("dropping packet! prev_ticks=%u new_ticks=%u\n", - data.cur_packet_ticks, ticks); + dprintf("dropping packet! cur_bytes=%u prev_ticks=%u new_ticks=%u\n", + data.cur_packet_bytes, data.cur_packet_ticks, ticks); data.cur_packet_bytes = 0; } if (data.cur_packet_bytes == 0) { @@ -1416,6 +1420,11 @@ static void int33_handler(union INTPACK r) r.w.cx = data.max.x; r.w.dx = data.max.y; break; + case INT33_GET_VERSION_STRING: + dputs("Mouse get version string"); + r.x.es = FP_SEG(&version_string); + r.x.di = FP_OFF(&version_string); + break; #if USE_WHEEL // Wheel API extensions: case INT33_GET_CAPABILITIES: |