// Process USB mouse data. static void handle_mouse(struct mouseevent *data) { dprintf(9, "Got mouse b=%x x=%x y=%x\n", data->buttons, data->x, data->y); s8 x = data->x, y = -data->y; u8 flag = ((data->buttons & 0x7) | (1<<3) | (x & 0x80 ? (1<<4) : 0) | (y & 0x80 ? (1<<5) : 0)); process_mouse(flag); process_mouse(x); process_mouse(y); }
// INT74h : PS/2 mouse hardware interrupt void VISIBLE16 handle_74(void) { if (! CONFIG_PS2PORT) return; debug_isr(DEBUG_ISR_74); u8 v = inb(PORT_PS2_STATUS); if ((v & (I8042_STR_OBF|I8042_STR_AUXDATA)) != (I8042_STR_OBF|I8042_STR_AUXDATA)) { dprintf(1, "ps2 mouse irq but no mouse data.\n"); goto done; } v = inb(PORT_PS2_DATA); if (!(GET_EBDA(ps2ctr) & I8042_CTR_AUXINT)) // Interrupts not enabled. goto done; process_mouse(v); done: eoi_pic2(); }
void kos_Main() { kos_InitHeap(); load_edit_box(); init(); for (;;) { switch (kos_WaitForEvent()) { case 6: process_mouse(); break; case 1: window_drawall=true; draw_window(); break; case 2: process_key(); break; case 3: process_button(); break; } } }
static void process_ps2byte(u8 status, u8 data) { if (!MODE16) { // Don't pull in all of keyboard/mouse code into 32bit code - // just discard the data. dprintf(1, "Discarding ps2 data %x (status=%x)\n", data, status); return; } if (status & I8042_STR_AUXDATA) process_mouse(data); else process_key(data); }
int main (int argc, char **argv) { int i; double now; feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW); init_sdl_gl_flags (WIDTH, HEIGHT, 0); srandom (time (NULL)); init_gl (&argc, argv); glEnable (GL_LIGHTING); glEnable (GL_DEPTH_TEST); glEnable (GL_AUTO_NORMAL); glEnable (GL_NORMALIZE); glClearDepth (1); glViewport (0, 0, WIDTH, HEIGHT); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective (60, (GLfloat) WIDTH/(GLfloat) HEIGHT, .1, 1000); glClearColor (0, 0, 0, 0); glMatrixMode (GL_MODELVIEW); SDL_ShowCursor (1); makeImages (); glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glGenTextures (1, texName); makeTexture (texName[0], groundtexture.texturesize, (GLubyte ***) groundtexture.tex); glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glBlendFunc (GL_SRC_ALPHA, GL_ONE); gndcounter = 1; read_terrain (); player.p.x = 0; player.p.y = 0; player.p.z = ground_height (&player.p); player.loc = detect_plane (&player.p); player.movtype = GROUNDED; player.speed = 100; player.mass = 1; vset (&player.vel, 0, 0, 0); player.turnspeed = DTOR (180); player.theta = DTOR (0); player.camdist = 15; player.lasttime = get_secs (); player.moving = NO; playercamera.phi = DTOR (0); playercamera.theta_difference = 0; while (1) { process_input (); if (mousebutton[1] == 0 && mousebutton[2] == 0 && mousebutton[3] == 0) { SDL_ShowCursor (1); } else { SDL_ShowCursor (0); } movement (); if (paused == NO) { for (i = 0; i < 1; i++) { moving (); now = get_secs (); player.lasttime = now; } } process_mouse (); draw (); now = get_secs (); player.lasttime = now; SDL_Delay (10); } return (0); }