Mercurial > emacs
comparison src/w32inevt.c @ 29319:2069f3aa4939
(NUM_TRANSLATED_MOUSE_BUTTONS): New constant.
(emacs_button_translation): Use it.
(do_mouse_event): Allow up to 32 mouse buttons by allowing any bit
in `mask' to be set.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Tue, 30 May 2000 21:49:28 +0000 |
parents | 3e276f92852a |
children | 1743924e00dd |
comparison
equal
deleted
inserted
replaced
29318:d54d4038df20 | 29319:2069f3aa4939 |
---|---|
548 Left == 0 | 548 Left == 0 |
549 Middle == 1 | 549 Middle == 1 |
550 Right == 2 | 550 Right == 2 |
551 Others increase from there. */ | 551 Others increase from there. */ |
552 | 552 |
553 static int emacs_button_translation[NUM_MOUSE_BUTTONS] = | 553 #define NUM_TRANSLATED_MOUSE_BUTTONS 3 |
554 { | 554 static int emacs_button_translation[NUM_TRANSLATED_MOUSE_BUTTONS] = |
555 0, 2, 1, 3, 4, | 555 { |
556 0, 2, 1 | |
556 }; | 557 }; |
557 | 558 |
558 static int | 559 static int |
559 do_mouse_event (MOUSE_EVENT_RECORD *event, | 560 do_mouse_event (MOUSE_EVENT_RECORD *event, |
560 struct input_event *emacs_ev) | 561 struct input_event *emacs_ev) |
579 emacs_ev->kind = mouse_click; | 580 emacs_ev->kind = mouse_click; |
580 | 581 |
581 /* Find out what button has changed state since the last button event. */ | 582 /* Find out what button has changed state since the last button event. */ |
582 but_change = button_state ^ event->dwButtonState; | 583 but_change = button_state ^ event->dwButtonState; |
583 mask = 1; | 584 mask = 1; |
584 for (i = 0; i < NUM_MOUSE_BUTTONS; i++, mask <<= 1) | 585 for (i = 0; mask; i++, mask <<= 1) |
585 if (but_change & mask) | 586 if (but_change & mask) |
586 { | 587 { |
587 XSETINT (emacs_ev->code, emacs_button_translation[i]); | 588 if (i < NUM_TRANSLATED_MOUSE_BUTTONS) |
589 XSETINT (emacs_ev->code, emacs_button_translation[i]); | |
590 else | |
591 XSETINT (emacs_ev->code, i); | |
588 break; | 592 break; |
589 } | 593 } |
590 | 594 |
591 /* If the changed button is out of emacs' range (highly unlikely) | |
592 ignore this event. */ | |
593 if (i == NUM_MOUSE_BUTTONS) | |
594 return 0; | |
595 | |
596 button_state = event->dwButtonState; | 595 button_state = event->dwButtonState; |
597 emacs_ev->timestamp = GetTickCount (); | 596 emacs_ev->timestamp = GetTickCount (); |
598 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, 0) | | 597 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, 0) | |
599 ((event->dwButtonState & mask) ? down_modifier : up_modifier); | 598 ((event->dwButtonState & mask) ? down_modifier : up_modifier); |
600 | 599 |