Fixed mouse input

This commit is contained in:
eukos 2015-09-18 08:50:09 +02:00
parent 4cd6eca4ed
commit b805bb77ad

View file

@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "globaldef.h"
#include "d_local.h"
#include "../splash.xpm"
#include "../icon.xpm"
viddef_t vid; // global video state
unsigned short d_8to16table[256];
@ -174,7 +175,7 @@ void VID_Init(unsigned char *palette)
/* initialize GDK */
gtk_init(NULL, NULL);
gdk_rgb_init();
gdk_initialized = 1;
gdk_initialized = 1;;
sigaction(SIGINT, 0, &sa);
sa.sa_handler = TragicDeath;
@ -193,6 +194,7 @@ void VID_Init(unsigned char *palette)
g_signal_connect (x_win, "destroy", G_CALLBACK (exit), NULL);
gtk_widget_set_events(x_win, GDK_BUTTON_PRESS_MASK);
// FOR LATER!
/*
GtkWidget *menubar;
@ -435,13 +437,16 @@ void GetEvent(void)
config_notify = 1;
}
}
static int vid_center_x, vid_center_y;
// flushes the given rectangles from the view buffer to the screen
void VID_Update(vrect_t * rects)
{
gtk_window_get_position(x_win, &vid_frame[0], &vid_frame[1]);
vid_frame[2] = vid_frame[0] + vid.width;
vid_frame[3] = vid_frame[1] + vid.height;
gdk_window_get_geometry (gtk_widget_get_window(x_win), &vid_frame[0], &vid_frame[1], &vid_frame[2], &vid_frame[3], NULL);
gdk_window_get_position(gtk_widget_get_window(x_win), &vid_frame[0], &vid_frame[1]);
vid_center_x = (int)(((float)vid_frame[2] / 2) + vid_frame[0]);
vid_center_y = (int)(((float)vid_frame[2] / 2) + vid_frame[1]);
vid_frame[2] += vid_frame[0];
vid_frame[3] += vid_frame[1];
if (config_notify)
{
@ -565,11 +570,10 @@ void IN_Move (usercmd_t *cmd)
if (mouse_enabled == true)
{
gdk_window_get_pointer (gtk_widget_get_window(x_win), &vid_mouseposx, &vid_mouseposy, NULL);
mouse_x = (float)(vid_mouseposx - ((float)vid.width / 2)) +1;
mouse_y = (float)(vid_mouseposy - ((float)vid.height / 2)) +18;
gdk_display_get_pointer (display, NULL, &vid_mouseposx, &vid_mouseposy, NULL);
mouse_x = (float)vid_mouseposx - vid_center_x;
mouse_y = (float)vid_mouseposy - vid_center_y;
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
@ -577,28 +581,40 @@ void IN_Move (usercmd_t *cmd)
mouse_y *= sensitivity->value;
}
if (deathcam_yesiamdead){
tangles[0] = deathcam_angles[0]; tangles[1] = deathcam_angles[1]; tangles[2] = deathcam_angles[2];
if (deathcam_yesiamdead)
{
tangles[0] = deathcam_angles[0];
tangles[1] = deathcam_angles[1];
tangles[2] = deathcam_angles[2];
}
else
{
tangles[0] = cl.viewangles[0];
tangles[1] = cl.viewangles[1];
tangles[2] = cl.viewangles[2];
}
else{
tangles[0] = cl.viewangles[0]; tangles[1] = cl.viewangles[1]; tangles[2] = cl.viewangles[2];
}
if ( (in_strafe.state & 1) || (lookstrafe->value && ((in_mlook.state & 1) ^ ((int)m_look->value & 1)) ))
cmd->sidemove += m_side->value * mouse_x;
else
tangles[YAW] -= m_yaw->value * mouse_x; // eukara - was cl.viewangles, not tangles
tangles[YAW] -= m_yaw->value * mouse_x;
if ((in_mlook.state & 1) ^ ((int)m_look->value & 1))
V_StopPitchDrift ();
if ( ((in_mlook.state & 1) ^ ((int)m_look->value & 1)) && !(in_strafe.state & 1)) {
if ( ((in_mlook.state & 1) ^ ((int)m_look->value & 1)) && !(in_strafe.state & 1))
{
tangles[PITCH] += m_pitch->value * mouse_y;
if (!deathcam_yesiamdead){
if (tangles[PITCH] > m_lockdown->value) // eukara - was cl.viewangles, not tangles
tangles[PITCH] = m_lockdown->value; // ditto for the next few lines
if (tangles[PITCH] < m_lockup->value)
tangles[PITCH] = m_lockup->value;}
} else {
if (!deathcam_yesiamdead)
{
if (tangles[PITCH] > m_lockdown->value)
tangles[PITCH] = m_lockdown->value;
if (tangles[PITCH] < m_lockup->value)
tangles[PITCH] = m_lockup->value;
}
}
else
{
if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward->value * mouse_y;
else
@ -606,15 +622,21 @@ void IN_Move (usercmd_t *cmd)
}
if (deathcam_yesiamdead){
deathcam_angles[0] = tangles[0]; deathcam_angles[1] = tangles[1]; deathcam_angles[2] = tangles[2];
if (deathcam_yesiamdead)
{
deathcam_angles[0] = tangles[0];
deathcam_angles[1] = tangles[1];
deathcam_angles[2] = tangles[2];
}
else{
cl.viewangles[0] = tangles[0]; cl.viewangles[1] = tangles[1]; cl.viewangles[2] = tangles[2];
else
{
cl.viewangles[0] = tangles[0];
cl.viewangles[1] = tangles[1];
cl.viewangles[2] = tangles[2];
}
if(mouse_x || mouse_y)
gdk_display_warp_pointer (display, screen, (int)(vid_frame[0] + (float)(vid.width / 2)), (int)(vid_frame[1] + (float)(vid.height / 2)));
if((mouse_x || mouse_y) && mouse_enabled)
gdk_display_warp_pointer (display, screen, vid_center_x, vid_center_y);
}
void IN_Commands(){}
void IN_Init(){}
@ -630,8 +652,14 @@ void VID_CreateSplash()
GdkBitmap *splash_mask;
GdkPixmap *splash_image;
GtkWidget *x_splash, *x_splash_image;
GdkPixbuf *icon_image;
GtkWidget *x_icon;
gtk_init(NULL, NULL);
icon_image = gdk_pixbuf_new_from_xpm_data(icon_xpm);
gtk_window_set_default_icon (icon_image);
x_splash = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request (x_splash, 440, 116);
gtk_window_set_decorated(x_splash, FALSE);