}
}
+static keynum_t buttonremap[18] =
+{
+ K_MOUSE1,
+ K_MOUSE3,
+ K_MOUSE2,
+ K_MWHEELUP,
+ K_MWHEELDOWN,
+ K_MOUSE4,
+ K_MOUSE5,
+ K_MOUSE6,
+ K_MOUSE7,
+ K_MOUSE8,
+ K_MOUSE9,
+ K_MOUSE10,
+ K_MOUSE11,
+ K_MOUSE12,
+ K_MOUSE13,
+ K_MOUSE14,
+ K_MOUSE15,
+ K_MOUSE16,
+};
+
static void HandleEvents(void)
{
XEvent event;
case ButtonPress:
// mouse button pressed
- switch(event.xbutton.button)
- {
- case 1:
- Key_Event(K_MOUSE1, 0, true);
- break;
- case 2:
- Key_Event(K_MOUSE3, 0, true);
- break;
- case 3:
- Key_Event(K_MOUSE2, 0, true);
- break;
- case 4:
- Key_Event(K_MWHEELUP, 0, true);
- break;
- case 5:
- Key_Event(K_MWHEELDOWN, 0, true);
- break;
- case 6:
- Key_Event(K_MOUSE4, 0, true);
- break;
- case 7:
- Key_Event(K_MOUSE5, 0, true);
- break;
- case 8:
- Key_Event(K_MOUSE6, 0, true);
- break;
- case 9:
- Key_Event(K_MOUSE7, 0, true);
- break;
- case 10:
- Key_Event(K_MOUSE8, 0, true);
- break;
- case 11:
- Key_Event(K_MOUSE9, 0, true);
- break;
- case 12:
- Key_Event(K_MOUSE10, 0, true);
- break;
- default:
- Con_Printf("HandleEvents: ButtonPress gave value %d, 1-12 expected\n", event.xbutton.button);
- break;
- }
+ if (event.xbutton.button <= 18)
+ Key_Event(buttonremap[event.xbutton.button - 1], 0, true);
+ else
+ Con_Printf("HandleEvents: ButtonPress gave value %d, 1-18 expected\n", event.xbutton.button);
break;
case ButtonRelease:
// mouse button released
- switch(event.xbutton.button)
- {
- case 1:
- Key_Event(K_MOUSE1, 0, false);
- break;
- case 2:
- Key_Event(K_MOUSE3, 0, false);
- break;
- case 3:
- Key_Event(K_MOUSE2, 0, false);
- break;
- case 4:
- Key_Event(K_MWHEELUP, 0, false);
- break;
- case 5:
- Key_Event(K_MWHEELDOWN, 0, false);
- break;
- case 6:
- Key_Event(K_MOUSE4, 0, false);
- break;
- case 7:
- Key_Event(K_MOUSE5, 0, false);
- break;
- case 8:
- Key_Event(K_MOUSE6, 0, false);
- break;
- case 9:
- Key_Event(K_MOUSE7, 0, false);
- break;
- case 10:
- Key_Event(K_MOUSE8, 0, false);
- break;
- case 11:
- Key_Event(K_MOUSE9, 0, false);
- break;
- case 12:
- Key_Event(K_MOUSE10, 0, false);
- break;
- default:
- Con_Printf("HandleEvents: ButtonRelease gave value %d, 1-12 expected\n", event.xbutton.button);
- break;
- }
+ if (event.xbutton.button <= 18)
+ Key_Event(buttonremap[event.xbutton.button - 1], 0, false);
+ else
+ Con_Printf("HandleEvents: ButtonRelease gave value %d, 1-18 expected\n", event.xbutton.button);
break;
case CreateNotify:
#endif
}
+static keynum_t buttonremap[16] =
+{
+ K_MOUSE1,
+ K_MOUSE3,
+ K_MOUSE2,
+ K_MOUSE4,
+ K_MOUSE5,
+ K_MOUSE6,
+ K_MOUSE7,
+ K_MOUSE8,
+ K_MOUSE9,
+ K_MOUSE10,
+ K_MOUSE11,
+ K_MOUSE12,
+ K_MOUSE13,
+ K_MOUSE14,
+ K_MOUSE15,
+ K_MOUSE16,
+};
+
void Sys_SendKeyEvents( void )
{
SDL_Event event;
}
break;
case SDL_MOUSEBUTTONDOWN:
- if( event.button.button == SDL_BUTTON_MIDDLE )
- event.button.button = SDL_BUTTON_RIGHT;
- else if( event.button.button == SDL_BUTTON_RIGHT )
- event.button.button = SDL_BUTTON_MIDDLE;
- Key_Event( K_MOUSE1 + event.button.button - 1, 0, true );
+ if (event.button.button <= 16)
+ Key_Event( buttonremap[event.button.button - 1], 0, true );
break;
case SDL_MOUSEBUTTONUP:
- if( event.button.button == SDL_BUTTON_MIDDLE )
- event.button.button = SDL_BUTTON_RIGHT;
- else if( event.button.button == SDL_BUTTON_RIGHT )
- event.button.button = SDL_BUTTON_MIDDLE;
- Key_Event( K_MOUSE1 + event.button.button - 1, 0, false );
+ if (event.button.button <= 16)
+ Key_Event( buttonremap[event.button.button - 1], 0, false );
break;
}
}
LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+static keynum_t buttonremap[16] =
+{
+ K_MOUSE1,
+ K_MOUSE2,
+ K_MOUSE3,
+ K_MOUSE4,
+ K_MOUSE5,
+ K_MOUSE6,
+ K_MOUSE7,
+ K_MOUSE8,
+ K_MOUSE9,
+ K_MOUSE10,
+ K_MOUSE11,
+ K_MOUSE12,
+ K_MOUSE13,
+ K_MOUSE14,
+ K_MOUSE15,
+ K_MOUSE16,
+};
+
/* main window procedure */
LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
{
// perform button actions
int i;
- for (i=0 ; i<mouse_buttons ; i++)
+ for (i=0 ; i<mouse_buttons && i < 16 ; i++)
if ((temp ^ mouse_oldbuttonstate) & (1<<i))
- Key_Event (K_MOUSE1 + i, 0, (temp & (1<<i)) != 0);
+ Key_Event (buttonremap[i], 0, (temp & (1<<i)) != 0);
mouse_oldbuttonstate = temp;
}
}
// perform button actions
- for (i=0 ; i<mouse_buttons ; i++)
+ for (i=0 ; i<mouse_buttons && i < 16 ; i++)
if ((mstate_di ^ mouse_oldbuttonstate) & (1<<i))
- Key_Event (K_MOUSE1 + i, 0, (mstate_di & (1<<i)) != 0);
+ Key_Event (buttonremap[i], 0, (mstate_di & (1<<i)) != 0);
mouse_oldbuttonstate = mstate_di;
in_mouse_x = mx;