-#define BUTTON1_RELEASED 000000000001L
-#define BUTTON1_PRESSED 000000000002L
-#define BUTTON1_CLICKED 000000000004L
-#define BUTTON1_DOUBLE_CLICKED 000000000010L
-#define BUTTON1_TRIPLE_CLICKED 000000000020L
-#define BUTTON1_RESERVED_EVENT 000000000040L
-#define BUTTON2_RELEASED 000000000100L
-#define BUTTON2_PRESSED 000000000200L
-#define BUTTON2_CLICKED 000000000400L
-#define BUTTON2_DOUBLE_CLICKED 000000001000L
-#define BUTTON2_TRIPLE_CLICKED 000000002000L
-#define BUTTON2_RESERVED_EVENT 000000004000L
-#define BUTTON3_RELEASED 000000010000L
-#define BUTTON3_PRESSED 000000020000L
-#define BUTTON3_CLICKED 000000040000L
-#define BUTTON3_DOUBLE_CLICKED 000000100000L
-#define BUTTON3_TRIPLE_CLICKED 000000200000L
-#define BUTTON3_RESERVED_EVENT 000000400000L
-#define BUTTON4_RELEASED 000001000000L
-#define BUTTON4_PRESSED 000002000000L
-#define BUTTON4_CLICKED 000004000000L
-#define BUTTON4_DOUBLE_CLICKED 000010000000L
-#define BUTTON4_TRIPLE_CLICKED 000020000000L
-#define BUTTON4_RESERVED_EVENT 000040000000L
-#define BUTTON_CTRL 000100000000L
-#define BUTTON_SHIFT 000200000000L
-#define BUTTON_ALT 000400000000L
-#define ALL_MOUSE_EVENTS 000777777777L
-#define REPORT_MOUSE_POSITION 001000000000L
+#define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
+#define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
+#define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
+#define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
+#define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
+
+#define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
+#define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
+#define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
+#define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
+#define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
+
+#define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
+#define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
+#define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
+#define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
+#define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
+
+#define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
+#define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
+#define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
+#define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
+#define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
+
+/*
+ * In 32 bits the version-1 scheme does not provide enough space for a 5th
+ * button, unless we choose to change the ABI by omitting the reserved-events.
+ */
+#if NCURSES_MOUSE_VERSION > 1
+
+#define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
+#define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
+#define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
+#define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
+#define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
+
+#define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L)
+#define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L)
+#define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L)
+#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L)