DOS mouse position - how to keep "counting" position beyond screen edges
- Posted by davidj at ultrasmart.org Feb 13, 2003
- 432 views
Dear List I'm new to Euphoria, but am finding it most interesting. Question applies to DOS. QUESTION: How do I keep getting mouse position co-ordinates even beyond the edges of the screen? (I just want the co-ordinates - don't care about the cursor going off-screen.) BACKGROUND: I have the mouse working fine using Mouse.e in the standard Euph include files. And can read the x/y position using get_mouse(). However, the min (say) x position = 0 at the left edge of the screen, and the max x position = 632 at the right edge of the screen. I would like to be able to read the "virtual" mouse position on both sides of the screen if I move the mouse beyond either side. As you can see in the program copy below, I would also like to set the "ZERO" x and y position to 0 when I LEFT_DOWN - but the program does not do that yet - but it does get a constant x position readout as the mouse moves - which is the main issue for me. Hope you can help, and hope that I may be able to help in the future. For interest, copy of my DOS Euph executable follows. Pls note that some of the print to screen is just for debugging purposes. -- dj -- *********** EUPHORIA INCLUDES ************** include Mouse.e include Misc.e -- required by Mouse.e include File.e -- to allow DOS program to be terminated using CTL-C -- ************ DECLARATIONS ***************** object keybrd, mouse_event atom mouse_no_event mouse_no_event = -1 atom position_current_x position_current_x = 99 -- initialising with dummy value atom position_zero_x -- ************** PROGRAM *********************** allow_break(1) -- uses File.e Allows CTL-C to stop program (and break off infinite cycling below) -- --------- initialise mouse --------- mouse_events(LEFT_DOWN) -- only monitors mouse left button down -- needed to initialise mouse and set "0" point puts(1, "MOVE MOUSE TO ZERO POSITION \n") puts(1, "THEN PRESS LEFT MOUSE BUTTON. \n") puts(1, " \n") puts(1, " \n") -- initialise (to stop get-mouse() returning -1), check mouse position, and set zero by chcking with a button press puts(1, "******* get_mouse() - intial = \n") ? get_mouse() -- test for integer - if integer, then get_mouse() is NOT a sequence so no mouse input detected while 1 do mouse_event = get_mouse() -- need only get_mouse() once for all testing - changes too fast if use function for tests if integer(mouse_event) != 1 then -- ie is a sequence if mouse_event[1] = LEFT_DOWN then position_zero_x = mouse_event[2] puts(1, "******* position_zero, = \n") ? position_zero_x exit end if else puts(1, "Press LEFT mouse button when at ZERO position. \n") keybrd = get_key() end if end while -- need check to see if mouse events ever goes to -1 ??? ********************* puts(1, "\n") puts(1, "******** ZERO XXXXXX *********** = \n") ? position_zero_x mouse_events(MOVE) -- only monitors mouse movement - not any button movements -- ---------- continuous cycle to get "X" position ---- Break in DOS using CTL-C --------- - while 1 do mouse_event = get_mouse() -- need only get_mouse() once for all testing - changes too fast if use function for tests if integer(mouse_event) != 1 then -- ie is a sequence if mouse_event[1] = MOVE then position_current_x = mouse_event[2] puts(1, "******* position_current_x, = \n") ? position_current_x keybrd = get_key() end if else -- puts(1, "Press LEFT mouse button when at ZERO position. \n") keybrd = get_key() end if keybrd = get_key() end while