Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




next up previous contents
Next: 9.2 Modem Programming Up: 9 Programming I/O ports Previous: 9 Programming I/O ports

9.1 Mouse Programming

A mouse is either connected to a serial port or directly to the AT bus and different types of mouse send distinct kinds of data, which makes mouse programming a bit harder. But, Andrew Haylett was so kind as to put a generous copyright on his selection program which means you can use his mouse routines for your own programs. Included in this guide you can find the pre-release of selection-1.8 with the COPYRIGHT notice. X11 already offers a comfortable mouse API, so Andrew's routines should be used for non-X11 applications only.
You only need the modules mouse.c and mouse.h from the selection package. To get mouse events you basically have to call ms_init() and get_ms_event(). ms_init needs the following 10 arguments:

  1. int acceleration
    is the acceleration factor. If you move the mouse more than delta pixels, motion becomes faster depending on this value.
  2. int baud
    is the bps rate your mouse uses (normally 1200).
  3. int delta
    this is the number of pixels that you have to move the mouse before the acceleration starts.
  4. char *device
    is the name of your mouse device (e.g. /dev/mouse).
  5. int toggle
    toggle the DTR, RTS or both DTR and RTS mouse modem lines on initialization (normally 0).
  6. int sample
    the resolution (dpi) of your mouse (normally 100).
  7. mouse_type mouse
    the identifier of the connected mouse like P_MSC (Mouse Systems Corp.) for my mouse ;).
  8. int slack
    amount of slack for wraparound which means if slack is -1 a try to move the mouse over the screen border will leave the mouse at the border. Values >= 0 mean that the mouse cursor will wrap to the other end after moving the mouse slack pixels against the border.
  9. int maxx
    the resolution of your current terminal in x direction. With the default font, a char is 10 pixels wide, and therefore the overall x screen resolution is 10*80-1.
  10. int maxy
    the resolution of your current terminal in y direction. With the default font, a char is 12 pixels high and therefore the overall y screen resolution is 12*25-1.
get_ms_event() just needs a pointer to a struct ms_event. If get_ms_event() returns -1, an error occured. On success, it returns 0, and the struct ms_event will contain the actual mouse state.


next up previous contents
Next: 9.2 Modem Programming Up: 9 Programming I/O ports Previous: 9 Programming I/O ports

Converted on:
Fri Mar 29 14:43:04 EST 1996


With any suggestions or questions please feel free to contact us