Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

win_input.c File Reference

#include "../client/client.h"
#include "win_local.h"

Include dependency graph for win_input.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  joystickInfo_t
struct  MidiInfo_t
struct  MYDATA
struct  WinMouseVars_t

Defines

#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
#define DINPUT_BUFFERSIZE   16
#define iDirectInputCreate(a, b, c, d)   pDirectInputCreate(a,b,c,d)
#define JOY_MAX_AXES   6
#define MAX_MIDIIN_DEVICES   8
#define NUM_OBJECTS   (sizeof(rgodf) / sizeof(rgodf[0]))

Typedefs

typedef MYDATA MYDATA

Functions

 DEFINE_GUID (GUID_ZAxis, 0xA36D02E2, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00)
 DEFINE_GUID (GUID_YAxis, 0xA36D02E1, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00)
 DEFINE_GUID (GUID_XAxis, 0xA36D02E0, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00)
 DEFINE_GUID (GUID_SysMouse, 0x6F1D2B60, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00)
 HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst
void IN_Activate (qboolean active)
void IN_ActivateDIMouse (void)
void IN_ActivateMouse (void)
void IN_ActivateWin32Mouse (void)
void IN_ClearStates (void)
void IN_DeactivateDIMouse (void)
void IN_DeactivateMouse (void)
void IN_DeactivateWin32Mouse (void)
void IN_DIMouse (int *mx, int *my)
void IN_Frame (void)
void IN_Init (void)
qboolean IN_InitDIMouse (void)
void IN_InitWin32Mouse (void)
void IN_JoyMove (void)
void IN_MouseEvent (int mstate)
void IN_MouseMove (void)
void IN_Shutdown (void)
void IN_ShutdownDIMouse (void)
void IN_ShutdownMIDI (void)
void IN_ShutdownWin32Mouse (void)
void IN_Startup (void)
void IN_StartupJoystick (void)
void IN_StartupMIDI (void)
void IN_StartupMouse (void)
void IN_Win32Mouse (int *mx, int *my)
float JoyToF (int value)
int JoyToI (int value)
void MIDI_NoteOff (int note)
void MIDI_NoteOn (int note, int velocity)
void MidiInfo_f (void)
void CALLBACK MidiInProc (HMIDIIN hMidiIn, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)

Variables

DIDATAFORMAT df
DWORD dwVersion
LPDIRECTINPUT g_pdi
LPDIRECTINPUTDEVICE g_pMouse
HINSTANCE hInstDI
qboolean in_appactive
cvar_tin_debugJoystick
cvar_tin_joyBallScale
cvar_tin_joystick
cvar_tin_logitechbug
cvar_tin_midi
cvar_tin_midichannel
cvar_tin_mididevice
cvar_tin_midiport
cvar_tin_mouse
joystickInfo_t joy
cvar_tjoy_threshold
int joyDirectionKeys [16]
DWORD LPDIRECTINPUT * lplpDirectInput
DWORD LPDIRECTINPUT LPUNKNOWN punkOuter
DIOBJECTDATAFORMAT rgodf []
MidiInfo_t s_midiInfo
WinMouseVars_t s_wmv
int window_center_x
int window_center_y


Define Documentation

#define DEFINE_GUID name,
l,
w1,
w2,
b1,
b2,
b3,
b4,
b5,
b6,
b7,
b8   ) 
 

Value:

EXTERN_C const GUID name \
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }

Definition at line 197 of file win_input.c.

#define DINPUT_BUFFERSIZE   16
 

Definition at line 207 of file win_input.c.

#define iDirectInputCreate a,
b,
c,
 )     pDirectInputCreate(a,b,c,d)
 

Definition at line 208 of file win_input.c.

Referenced by IN_InitDIMouse().

#define JOY_MAX_AXES   6
 

Definition at line 61 of file win_input.c.

#define MAX_MIDIIN_DEVICES   8
 

Definition at line 47 of file win_input.c.

#define NUM_OBJECTS   (sizeof(rgodf) / sizeof(rgodf[0]))
 

Definition at line 235 of file win_input.c.


Typedef Documentation

typedef struct MYDATA MYDATA
 


Function Documentation

DEFINE_GUID GUID_ZAxis  ,
0xA36D02E2  ,
0xC9F3  ,
0x11CF  ,
0xBF  ,
0xC7  ,
0x44  ,
0x45  ,
0x53  ,
0x54  ,
0x00  ,
0x00 
 

DEFINE_GUID GUID_YAxis  ,
0xA36D02E1  ,
0xC9F3  ,
0x11CF  ,
0xBF  ,
0xC7  ,
0x44  ,
0x45  ,
0x53  ,
0x54  ,
0x00  ,
0x00 
 

DEFINE_GUID GUID_XAxis  ,
0xA36D02E0  ,
0xC9F3  ,
0x11CF  ,
0xBF  ,
0xC7  ,
0x44  ,
0x45  ,
0x53  ,
0x54  ,
0x00  ,
0x00 
 

DEFINE_GUID GUID_SysMouse  ,
0x6F1D2B60  ,
0xD5A0  ,
0x11CF  ,
0xBF  ,
0xC7  ,
0x44  ,
0x45  ,
0x53  ,
0x54  ,
0x00  ,
0x00 
 

HRESULT WINAPI *  pDirectInputCreate  ) 
 

Referenced by IN_ActivateDIMouse(), IN_DIMouse(), IN_InitDIMouse(), SNDDMA_BeginPainting(), and SNDDMA_InitDS().

void IN_Activate qboolean  active  ) 
 

Definition at line 719 of file win_input.c.

References in_appactive, and IN_DeactivateMouse().

00719                                    {
00720     in_appactive = active;
00721 
00722     if ( !active )
00723     {
00724         IN_DeactivateMouse();
00725     }
00726 }

Here is the call graph for this function:

void IN_ActivateDIMouse void   ) 
 

Definition at line 365 of file win_input.c.

References Com_Printf(), Cvar_Set(), g_pMouse, HRESULT(), and IN_InitDIMouse().

Referenced by IN_ActivateMouse().

00365                                 {
00366     HRESULT     hr;
00367 
00368     if (!g_pMouse) {
00369         return;
00370     }
00371 
00372     // we may fail to reacquire if the window has been recreated
00373     hr = IDirectInputDevice_Acquire( g_pMouse );
00374     if (FAILED(hr)) {
00375         if ( !IN_InitDIMouse() ) {
00376             Com_Printf ("Falling back to Win32 mouse support...\n");
00377             Cvar_Set( "in_mouse", "-1" );
00378         }
00379     }
00380 }

Here is the call graph for this function:

void IN_ActivateMouse void   ) 
 

Definition at line 504 of file win_input.c.

References IN_ActivateDIMouse(), IN_ActivateWin32Mouse(), in_mouse, cvar_s::integer, WinMouseVars_t::mouseActive, WinMouseVars_t::mouseInitialized, and s_wmv.

00505 {
00506     if (!s_wmv.mouseInitialized ) {
00507         return;
00508     }
00509     if ( !in_mouse->integer ) 
00510     {
00511         s_wmv.mouseActive = qfalse;
00512         return;
00513     }
00514     if ( s_wmv.mouseActive ) 
00515     {
00516         return;
00517     }
00518 
00519     s_wmv.mouseActive = qtrue;
00520 
00521     if ( in_mouse->integer != -1 ) {
00522         IN_ActivateDIMouse();
00523     }
00524     IN_ActivateWin32Mouse();
00525 }

Here is the call graph for this function:

void IN_ActivateWin32Mouse void   ) 
 

Definition at line 128 of file win_input.c.

References FALSE, g_wv, height, WinVars_t::hWnd, width, window_center_x, and window_center_y.

Referenced by IN_ActivateMouse().

00128                                    {
00129     int         width, height;
00130     RECT        window_rect;
00131 
00132     width = GetSystemMetrics (SM_CXSCREEN);
00133     height = GetSystemMetrics (SM_CYSCREEN);
00134 
00135     GetWindowRect ( g_wv.hWnd, &window_rect);
00136     if (window_rect.left < 0)
00137         window_rect.left = 0;
00138     if (window_rect.top < 0)
00139         window_rect.top = 0;
00140     if (window_rect.right >= width)
00141         window_rect.right = width-1;
00142     if (window_rect.bottom >= height-1)
00143         window_rect.bottom = height-1;
00144     window_center_x = (window_rect.right + window_rect.left)/2;
00145     window_center_y = (window_rect.top + window_rect.bottom)/2;
00146 
00147     SetCursorPos (window_center_x, window_center_y);
00148 
00149     SetCapture ( g_wv.hWnd );
00150     ClipCursor (&window_rect);
00151     while (ShowCursor (FALSE) >= 0)
00152         ;
00153 }

void IN_ClearStates void   ) 
 

Definition at line 779 of file win_input.c.

References WinMouseVars_t::oldButtonState, and s_wmv.

00780 {
00781     s_wmv.oldButtonState = 0;
00782 }

void IN_DeactivateDIMouse void   ) 
 

Definition at line 387 of file win_input.c.

References g_pMouse.

Referenced by IN_DeactivateMouse().

00387                                   {
00388     if (!g_pMouse) {
00389         return;
00390     }
00391     IDirectInputDevice_Unacquire( g_pMouse );
00392 }

void IN_DeactivateMouse void   ) 
 

Definition at line 535 of file win_input.c.

References IN_DeactivateDIMouse(), IN_DeactivateWin32Mouse(), WinMouseVars_t::mouseActive, WinMouseVars_t::mouseInitialized, and s_wmv.

00535                                 {
00536     if (!s_wmv.mouseInitialized ) {
00537         return;
00538     }
00539     if (!s_wmv.mouseActive ) {
00540         return;
00541     }
00542     s_wmv.mouseActive = qfalse;
00543 
00544     IN_DeactivateDIMouse();
00545     IN_DeactivateWin32Mouse();
00546 }

Here is the call graph for this function:

void IN_DeactivateWin32Mouse void   ) 
 

Definition at line 160 of file win_input.c.

References NULL, and TRUE.

Referenced by IN_DeactivateMouse().

00161 {
00162     ClipCursor (NULL);
00163     ReleaseCapture ();
00164     while (ShowCursor (TRUE) < 0)
00165         ;
00166 }

void IN_DIMouse int *  mx,
int *  my
 

Definition at line 400 of file win_input.c.

References DWORD, g_pMouse, HRESULT(), K_MOUSE1, K_MOUSE2, K_MOUSE3, K_MOUSE4, K_MWHEELDOWN, K_MWHEELUP, NULL, qfalse, qtrue, SE_KEY, state, Sys_QueEvent(), and value.

Referenced by IN_InitDIMouse(), and IN_MouseMove().

00400                                     {
00401     DIDEVICEOBJECTDATA  od;
00402     DIMOUSESTATE        state;
00403     DWORD               dwElements;
00404     HRESULT             hr;
00405   int value;
00406     static float        oldSysTime;
00407 
00408     if ( !g_pMouse ) {
00409         return;
00410     }
00411 
00412     // fetch new events
00413     for (;;)
00414     {
00415         dwElements = 1;
00416 
00417         hr = IDirectInputDevice_GetDeviceData(g_pMouse,
00418                 sizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);
00419         if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED)) {
00420             IDirectInputDevice_Acquire(g_pMouse);
00421             return;
00422         }
00423 
00424         /* Unable to read data or no data available */
00425         if ( FAILED(hr) ) {
00426             break;
00427         }
00428 
00429         if ( dwElements == 0 ) {
00430             break;
00431         }
00432 
00433         switch (od.dwOfs) {
00434         case DIMOFS_BUTTON0:
00435             if (od.dwData & 0x80)
00436                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE1, qtrue, 0, NULL );
00437             else
00438                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE1, qfalse, 0, NULL );
00439             break;
00440 
00441         case DIMOFS_BUTTON1:
00442             if (od.dwData & 0x80)
00443                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE2, qtrue, 0, NULL );
00444             else
00445                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE2, qfalse, 0, NULL );
00446             break;
00447             
00448         case DIMOFS_BUTTON2:
00449             if (od.dwData & 0x80)
00450                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE3, qtrue, 0, NULL );
00451             else
00452                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE3, qfalse, 0, NULL );
00453             break;
00454 
00455         case DIMOFS_BUTTON3:
00456             if (od.dwData & 0x80)
00457                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE4, qtrue, 0, NULL );
00458             else
00459                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE4, qfalse, 0, NULL );
00460             break;      
00461     // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=50
00462         case DIMOFS_Z:
00463             value = od.dwData;
00464             if (value == 0) {
00465 
00466             } else if (value < 0) {
00467                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );
00468                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );
00469             } else {
00470                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );
00471                 Sys_QueEvent( od.dwTimeStamp, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );
00472             }
00473             break;
00474         }
00475     }
00476 
00477     // read the raw delta counter and ignore
00478     // the individual sample time / values
00479     hr = IDirectInputDevice_GetDeviceState(g_pMouse,
00480             sizeof(DIDEVICEOBJECTDATA), &state);
00481     if ( FAILED(hr) ) {
00482         *mx = *my = 0;
00483         return;
00484     }
00485     *mx = state.lX;
00486     *my = state.lY;
00487 }

Here is the call graph for this function:

void IN_Frame void   ) 
 

Definition at line 736 of file win_input.c.

References _3DFX_DRIVER_NAME, cls, Com_Printf(), Cvar_VariableString(), Cvar_VariableValue(), g_wv, WinVars_t::hWnd, IN_ActivateMouse(), IN_DeactivateMouse(), IN_JoyMove(), IN_MouseMove(), IN_StartupMouse(), clientStatic_t::keyCatchers, WinMouseVars_t::mouseInitialized, WinMouseVars_t::mouseStartupDelayed, s_wmv, and strcmp().

00736                      {
00737     // post joystick events
00738     IN_JoyMove();
00739 
00740     if ( !s_wmv.mouseInitialized ) {
00741     if (s_wmv.mouseStartupDelayed && g_wv.hWnd)
00742         {
00743             Com_Printf("Proceeding with delayed mouse init\n");
00744       IN_StartupMouse();
00745             s_wmv.mouseStartupDelayed = qfalse;
00746         }
00747         return;
00748     }
00749 
00750     if ( cls.keyCatchers & KEYCATCH_CONSOLE ) {
00751         // temporarily deactivate if not in the game and
00752         // running on the desktop
00753         // voodoo always counts as full screen
00754         if (Cvar_VariableValue ("r_fullscreen") == 0
00755             && strcmp( Cvar_VariableString("r_glDriver"), _3DFX_DRIVER_NAME) )  {
00756             IN_DeactivateMouse ();
00757             return;
00758         }
00759     }
00760 
00761     if ( !in_appactive ) {
00762         IN_DeactivateMouse ();
00763         return;
00764     }
00765 
00766     IN_ActivateMouse();
00767 
00768     // post events to the system que
00769     IN_MouseMove();
00770 
00771 }

Here is the call graph for this function:

void IN_Init void   ) 
 

Definition at line 686 of file win_input.c.

References Cmd_AddCommand(), CVAR_ARCHIVE, Cvar_Get(), CVAR_LATCH, CVAR_TEMP, in_debugJoystick, in_joyBallScale, in_joystick, in_logitechbug, in_midi, in_midichannel, in_mididevice, in_midiport, in_mouse, IN_Startup(), joy_threshold, and MidiInfo_f().

00686                      {
00687     // MIDI input controler variables
00688     in_midi                 = Cvar_Get ("in_midi",                  "0",        CVAR_ARCHIVE);
00689     in_midiport             = Cvar_Get ("in_midiport",              "1",        CVAR_ARCHIVE);
00690     in_midichannel          = Cvar_Get ("in_midichannel",           "1",        CVAR_ARCHIVE);
00691     in_mididevice           = Cvar_Get ("in_mididevice",            "0",        CVAR_ARCHIVE);
00692 
00693     Cmd_AddCommand( "midiinfo", MidiInfo_f );
00694 
00695     // mouse variables
00696   in_mouse              = Cvar_Get ("in_mouse",                 "1",        CVAR_ARCHIVE|CVAR_LATCH);
00697     in_logitechbug  = Cvar_Get ("in_logitechbug", "0", CVAR_ARCHIVE);
00698 
00699     // joystick variables
00700     in_joystick             = Cvar_Get ("in_joystick",              "0",        CVAR_ARCHIVE|CVAR_LATCH);
00701     in_joyBallScale         = Cvar_Get ("in_joyBallScale",          "0.02",     CVAR_ARCHIVE);
00702     in_debugJoystick        = Cvar_Get ("in_debugjoystick",         "0",        CVAR_TEMP);
00703 
00704     joy_threshold           = Cvar_Get ("joy_threshold",            "0.15",     CVAR_ARCHIVE);
00705 
00706     IN_Startup();
00707 }

Here is the call graph for this function:

qboolean IN_InitDIMouse void   ) 
 

Definition at line 257 of file win_input.c.

References Com_Printf(), df, DIRECTINPUT_VERSION, g_pdi, g_pMouse, g_wv, WinVars_t::hInstance, hInstDI, HRESULT(), WinVars_t::hWnd, iDirectInputCreate, IN_DIMouse(), NULL, qboolean, x, and y.

Referenced by IN_ActivateDIMouse(), and IN_StartupMouse().

00257                                 {
00258     HRESULT     hr;
00259     int         x, y;
00260     DIPROPDWORD dipdw = {
00261         {
00262             sizeof(DIPROPDWORD),        // diph.dwSize
00263             sizeof(DIPROPHEADER),       // diph.dwHeaderSize
00264             0,                          // diph.dwObj
00265             DIPH_DEVICE,                // diph.dwHow
00266         },
00267         DINPUT_BUFFERSIZE,              // dwData
00268     };
00269 
00270     Com_Printf( "Initializing DirectInput...\n");
00271 
00272     if (!hInstDI) {
00273         hInstDI = LoadLibrary("dinput.dll");
00274         
00275         if (hInstDI == NULL) {
00276             Com_Printf ("Couldn't load dinput.dll\n");
00277             return qfalse;
00278         }
00279     }
00280 
00281     if (!pDirectInputCreate) {
00282         pDirectInputCreate = (long (__stdcall *)(void *,unsigned long ,struct IDirectInputA ** ,struct IUnknown *))
00283             GetProcAddress(hInstDI,"DirectInputCreateA");
00284 
00285         if (!pDirectInputCreate) {
00286             Com_Printf ("Couldn't get DI proc addr\n");
00287             return qfalse;
00288         }
00289     }
00290 
00291     // register with DirectInput and get an IDirectInput to play with.
00292     hr = iDirectInputCreate( g_wv.hInstance, DIRECTINPUT_VERSION, &g_pdi, NULL);
00293 
00294     if (FAILED(hr)) {
00295         Com_Printf ("iDirectInputCreate failed\n");
00296         return qfalse;
00297     }
00298 
00299     // obtain an interface to the system mouse device.
00300     hr = IDirectInput_CreateDevice(g_pdi, &GUID_SysMouse, &g_pMouse, NULL);
00301 
00302     if (FAILED(hr)) {
00303         Com_Printf ("Couldn't open DI mouse device\n");
00304         return qfalse;
00305     }
00306 
00307     // set the data format to "mouse format".
00308     hr = IDirectInputDevice_SetDataFormat(g_pMouse, &df);
00309 
00310     if (FAILED(hr))     {
00311         Com_Printf ("Couldn't set DI mouse format\n");
00312         return qfalse;
00313     }
00314 
00315     // set the cooperativity level.
00316     hr = IDirectInputDevice_SetCooperativeLevel(g_pMouse, g_wv.hWnd,
00317             DISCL_EXCLUSIVE | DISCL_FOREGROUND);
00318 
00319     // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=50
00320     if (FAILED(hr)) {
00321         Com_Printf ("Couldn't set DI coop level\n");
00322         return qfalse;
00323     }
00324 
00325 
00326     // set the buffer size to DINPUT_BUFFERSIZE elements.
00327     // the buffer size is a DWORD property associated with the device
00328     hr = IDirectInputDevice_SetProperty(g_pMouse, DIPROP_BUFFERSIZE, &dipdw.diph);
00329 
00330     if (FAILED(hr)) {
00331         Com_Printf ("Couldn't set DI buffersize\n");
00332         return qfalse;
00333     }
00334 
00335     // clear any pending samples
00336     IN_DIMouse( &x, &y );
00337     IN_DIMouse( &x, &y );
00338 
00339     Com_Printf( "DirectInput initialized.\n");
00340     return qtrue;
00341 }

Here is the call graph for this function:

void IN_InitWin32Mouse void   ) 
 

Definition at line 111 of file win_input.c.

Referenced by IN_StartupMouse().

00112 {
00113 }

void IN_JoyMove void   ) 
 

Definition at line 133 of file linux_joystick.c.

References Com_Printf(), f, i, joy_fd, joy_keys, joy_threshold, K_JOY1, n, NULL, qfalse, qtrue, read(), SE_KEY, Sys_QueEvent(), and cvar_s::value.

Referenced by IN_Frame().

00134 {
00135   /* Store instantaneous joystick state. Hack to get around
00136    * event model used in Linux joystick driver.
00137      */
00138   static int axes_state[16];
00139   /* Old bits for Quake-style input compares. */
00140   static unsigned int old_axes = 0;
00141   /* Our current goodies. */
00142   unsigned int axes = 0;
00143   int i = 0;
00144 
00145   if( joy_fd == -1 ) {
00146     return;
00147   }
00148 
00149   /* Empty the queue, dispatching button presses immediately
00150      * and updating the instantaneous state for the axes.
00151      */
00152   do {
00153     int n = -1;
00154     struct js_event event;
00155 
00156     n = read( joy_fd, &event, sizeof( event ) );
00157 
00158     if( n == -1 ) {
00159       /* No error, we're non-blocking. */
00160       break;
00161     }
00162 
00163     if( event.type & JS_EVENT_BUTTON ) {
00164       Sys_QueEvent( 0, SE_KEY, K_JOY1 + event.number, event.value, 0, NULL );
00165     } else if( event.type & JS_EVENT_AXIS ) {
00166 
00167       if( event.number >= 16 ) {
00168     continue;
00169       }
00170 
00171       axes_state[event.number] = event.value;
00172     } else {
00173       Com_Printf( "Unknown joystick event type\n" );
00174     }
00175 
00176   } while( 1 );
00177 
00178 
00179   /* Translate our instantaneous state to bits. */
00180   for( i = 0; i < 16; i++ ) {
00181     float f = ( (float) axes_state[i] ) / 32767.0f;
00182 
00183     if( f < -joy_threshold->value ) {
00184       axes |= ( 1 << ( i * 2 ) );
00185     } else if( f > joy_threshold->value ) {
00186       axes |= ( 1 << ( ( i * 2 ) + 1 ) );
00187     }
00188 
00189   }
00190 
00191   /* Time to update axes state based on old vs. new. */
00192   for( i = 0; i < 16; i++ ) {
00193 
00194     if( ( axes & ( 1 << i ) ) && !( old_axes & ( 1 << i ) ) ) {
00195       Sys_QueEvent( 0, SE_KEY, joy_keys[i], qtrue, 0, NULL );
00196     }
00197 
00198     if( !( axes & ( 1 << i ) ) && ( old_axes & ( 1 << i ) ) ) {
00199       Sys_QueEvent( 0, SE_KEY, joy_keys[i], qfalse, 0, NULL );
00200     }
00201   }
00202 
00203   /* Save for future generations. */
00204   old_axes = axes;
00205 }

Here is the call graph for this function:

void IN_MouseEvent int  mstate  ) 
 

Definition at line 597 of file win_input.c.

References g_wv, i, K_MOUSE1, WinMouseVars_t::mouseInitialized, NULL, WinMouseVars_t::oldButtonState, qfalse, qtrue, s_wmv, SE_KEY, Sys_QueEvent(), and WinVars_t::sysMsgTime.

Referenced by MainWndProc().

00598 {
00599     int     i;
00600 
00601     if ( !s_wmv.mouseInitialized )
00602         return;
00603 
00604 // perform button actions
00605     for  (i = 0 ; i < 3 ; i++ )
00606     {
00607         if ( (mstate & (1<<i)) &&
00608             !(s_wmv.oldButtonState & (1<<i)) )
00609         {
00610             Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MOUSE1 + i, qtrue, 0, NULL );
00611         }
00612 
00613         if ( !(mstate & (1<<i)) &&
00614             (s_wmv.oldButtonState & (1<<i)) )
00615         {
00616             Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MOUSE1 + i, qfalse, 0, NULL );
00617         }
00618     }   
00619 
00620     s_wmv.oldButtonState = mstate;
00621 }

Here is the call graph for this function:

void IN_MouseMove void   ) 
 

Definition at line 629 of file win_input.c.

References IN_DIMouse(), IN_Win32Mouse(), NULL, SE_MOUSE, and Sys_QueEvent().

Referenced by IN_Frame().

00629                            {
00630     int     mx, my;
00631 
00632     if ( g_pMouse ) {
00633         IN_DIMouse( &mx, &my );
00634     } else {
00635         IN_Win32Mouse( &mx, &my );
00636     }
00637 
00638     if ( !mx && !my ) {
00639         return;
00640     }
00641 
00642     Sys_QueEvent( 0, SE_MOUSE, mx, my, 0, NULL );
00643 }

Here is the call graph for this function:

void IN_Shutdown void   ) 
 

Definition at line 673 of file win_input.c.

References Cmd_RemoveCommand(), IN_DeactivateMouse(), IN_ShutdownDIMouse(), and IN_ShutdownMIDI().

00673                          {
00674     IN_DeactivateMouse();
00675     IN_ShutdownDIMouse();
00676     IN_ShutdownMIDI();
00677     Cmd_RemoveCommand("midiinfo" );
00678 }

Here is the call graph for this function:

void IN_ShutdownDIMouse void   ) 
 

Definition at line 348 of file win_input.c.

References g_pdi, and g_pMouse.

Referenced by IN_Shutdown().

00348                                 {
00349     if (g_pMouse) {
00350         IDirectInputDevice_Release(g_pMouse);
00351         g_pMouse = NULL;
00352     }
00353 
00354     if (g_pdi) {
00355         IDirectInput_Release(g_pdi);
00356         g_pdi = NULL;
00357     }
00358 }

void IN_ShutdownMIDI void   )  [static]
 

Definition at line 1141 of file win_input.c.

References Com_Memset(), MidiInfo_t::hMidiIn, and s_midiInfo.

Referenced by IN_Shutdown().

01142 {
01143     if ( s_midiInfo.hMidiIn )
01144     {
01145         midiInClose( s_midiInfo.hMidiIn );
01146     }
01147     Com_Memset( &s_midiInfo, 0, sizeof( s_midiInfo ) );
01148 }

Here is the call graph for this function:

void IN_ShutdownWin32Mouse void   ) 
 

Definition at line 120 of file win_input.c.

00120                                    {
00121 }

void IN_Startup void   ) 
 

Definition at line 657 of file win_input.c.

References Com_Printf(), in_joystick, in_mouse, IN_StartupJoystick(), IN_StartupMIDI(), IN_StartupMouse(), and cvar_s::modified.

Referenced by IN_Init().

00657                         {
00658     Com_Printf ("\n------- Input Initialization -------\n");
00659     IN_StartupMouse ();
00660     IN_StartupJoystick ();
00661     IN_StartupMIDI();
00662     Com_Printf ("------------------------------------\n");
00663 
00664     in_mouse->modified = qfalse;
00665     in_joystick->modified = qfalse;
00666 }

Here is the call graph for this function:

void IN_StartupJoystick void   ) 
 

Definition at line 70 of file linux_joystick.c.

References Com_Printf(), i, in_joystick, cvar_s::integer, joy_fd, n, name, open(), read(), and strncpy().

Referenced by IN_Init(), and IN_Startup().

00071 {
00072   int i = 0;
00073 
00074   joy_fd = -1;
00075 
00076   if( !in_joystick->integer ) {
00077     Com_Printf( "Joystick is not active.\n" );
00078     return;
00079   }
00080 
00081   for( i = 0; i < 4; i++ ) {
00082     char filename[PATH_MAX];
00083 
00084     snprintf( filename, PATH_MAX, "/dev/js%d", i );
00085 
00086     joy_fd = open( filename, O_RDONLY | O_NONBLOCK );
00087 
00088     if( joy_fd != -1 ) {
00089       struct js_event event;
00090       char axes = 0;
00091       char buttons = 0;
00092       char name[128];
00093       int n = -1;
00094 
00095       Com_Printf( "Joystick %s found\n", filename );
00096 
00097       /* Get rid of initialization messages. */
00098       do {
00099     n = read( joy_fd, &event, sizeof( event ) );
00100 
00101     if( n == -1 ) {
00102       break;
00103     }
00104 
00105       } while( ( event.type & JS_EVENT_INIT ) );
00106 
00107       /* Get joystick statistics. */
00108       ioctl( joy_fd, JSIOCGAXES, &axes );
00109       ioctl( joy_fd, JSIOCGBUTTONS, &buttons );
00110 
00111       if( ioctl( joy_fd, JSIOCGNAME( sizeof( name ) ), name ) < 0 ) {
00112     strncpy( name, "Unknown", sizeof( name ) );
00113       }
00114 
00115       Com_Printf( "Name:    %s\n", name );
00116       Com_Printf( "Axes:    %d\n", axes );
00117       Com_Printf( "Buttons: %d\n", buttons );
00118 
00119       /* Our work here is done. */
00120       return;
00121     }
00122 
00123   }
00124 
00125   /* No soup for you. */
00126   if( joy_fd == -1 ) {
00127     Com_Printf( "No joystick found.\n" );
00128     return;
00129   }
00130 
00131 }

Here is the call graph for this function: