Permalink
Browse files

In Win32a, mouse movement reporting can now be enabled. Use mouse_set…

…( flags | REPORT_MOUSE_POSITION) to do this; any mouse movement, even without buttons pressed, will result in a KEY_MOUSE added to the queue. See 'testcurs.c' for example use. Note, not enabled yet in SDLx or X11 or Win32 console, etc.
  • Loading branch information...
Bill-Gray committed Feb 18, 2017
1 parent ef14985 commit 18404de78edbc62220899a60902d3f3b44759d86
Showing with 18 additions and 8 deletions.
  1. +10 −3 demos/testcurs.c
  2. +8 −5 win32a/pdcscrn.c
View
@@ -108,6 +108,9 @@ COMMAND command[MAX_OPTIONS] =
int width, height;
static short background_index = COLOR_BLACK;
#ifdef PDCURSES
static bool report_mouse_movement = FALSE;
#endif
int main(int argc, char *argv[])
{
@@ -152,6 +155,9 @@ int main(int argc, char *argv[])
}
}
break;
case 'z':
report_mouse_movement = TRUE;
break;
#endif
default:
break;
@@ -180,7 +186,7 @@ int main(int argc, char *argv[])
keypad(stdscr, TRUE);
raw();
#ifdef PDCURSES
mouse_set(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION);
mouse_set(ALL_MOUSE_EVENTS);
#endif
key = getch();
@@ -443,7 +449,8 @@ void inputTest(WINDOW *win)
wtimeout(win, 200);
#ifdef PDCURSES
mouse_set(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION);
mouse_set(ALL_MOUSE_EVENTS |
(report_mouse_movement ? REPORT_MOUSE_POSITION : 0));
PDC_save_key_modifiers(TRUE);
// PDC_return_key_modifiers(TRUE);
#endif
@@ -522,7 +529,7 @@ void inputTest(WINDOW *win)
waddstr(win, "double: ");
else if ((status & BUTTON_ACTION_MASK) == BUTTON_TRIPLE_CLICKED)
waddstr(win, "triple: ");
else
else if( button)
waddstr(win, "released: ");
wprintw(win, "Posn: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
View
@@ -590,7 +590,9 @@ static int set_mouse( const int button_index, const int button_state,
pt.x = LOWORD( lParam);
pt.y = HIWORD( lParam);
if( button_index != -1) /* for anything but a mouse move: */
if( button_index == -1) /* mouse moved, no button */
n_key_mouse_to_add = 1;
else
{
memset(&pdc_mouse_status, 0, sizeof(MOUSE_STATUS));
if( button_index < PDC_MAX_MOUSE_BUTTONS)
@@ -1503,9 +1505,10 @@ static void HandleMouseMove( WPARAM wParam, LPARAM lParam,
report_event |= PDC_MOUSE_MOVED | 16;
#endif
if( wParam & REPORT_MOUSE_POSITION)
report_event |= PDC_MOUSE_POSITION;
if( report_event) /* -1 signals mouse move; 0 is ignored */
if( !report_event)
if( SP->_trap_mbe & REPORT_MOUSE_POSITION)
report_event = PDC_MOUSE_POSITION;
if( report_event)
{
int i;
@@ -1517,7 +1520,7 @@ static void HandleMouseMove( WPARAM wParam, LPARAM lParam,
}
*ptr_modified_key_to_return = 0;
set_mouse( -1, 0, lParam );
}
} /* -1 to 'set_mouse' signals mouse move; 0 is ignored */
}
}

0 comments on commit 18404de

Please sign in to comment.