26 #define Z_SENSITIVITY 100
28 static struct mouseinfo {
29 int delta_x, delta_y, delta_z;
33 void d_mouse_init(void)
35 memset(&Mouse,0,sizeof(Mouse));
38 void mouse_button_handler(SDL_MouseButtonEvent *mbe)
40 // to bad, SDL buttons use a different mapping as descent expects,
41 // this is at least true and tested for the first three buttons
42 int button_remap[11] = {
56 int button = button_remap[mbe->button - 1]; // -1 since SDL seems to start counting at 1
58 vkey_handler(KEY_MB1 + button, mbe->state == SDL_PRESSED);
60 if (mbe->state == SDL_PRESSED) {
61 if (button == MB_Z_UP) {
62 Mouse.delta_z += Z_SENSITIVITY;
63 Mouse.z += Z_SENSITIVITY;
64 } else if (button == MB_Z_DOWN) {
65 Mouse.delta_z -= Z_SENSITIVITY;
66 Mouse.z -= Z_SENSITIVITY;
71 void mouse_motion_handler(SDL_MouseMotionEvent *mme)
74 Mouse.delta_y += mme->xrel;
75 Mouse.delta_x += mme->yrel;
79 Mouse.delta_x += mme->xrel;
80 Mouse.delta_y += mme->yrel;
86 void mouse_flush() // clears all mice events...
98 SDL_GetMouseState(&Mouse.x, &Mouse.y); // necessary because polling only gives us the delta.
101 //========================================================================
102 void mouse_get_pos( int *x, int *y )
105 #ifdef _WIN32_WCE // needed here only for touchpens?
107 SDL_GetMouseState(&Mouse.y, &Mouse.x);
109 SDL_GetMouseState(&Mouse.x, &Mouse.y);
116 void mouse_get_delta( int *dx, int *dy )
125 void mouse_get_pos_z( int *x, int *y, int *z )
133 void mouse_get_delta_z( int *dx, int *dy, int *dz )
152 for (i=0; i<MOUSE_MAX_BUTTONS; i++ ) {
153 if (keyd_pressed[KEY_MB1 + i])
161 void mouse_get_cyberman_pos( int *x, int *y )
166 // Returns 1 if this button is currently down
167 int mouse_button_state(int button)
170 return keyd_pressed[KEY_MB1 + button];