latest work on mice stuff, still not too far. also slight cleanup

This commit is contained in:
AJ Kelly
2011-02-15 01:54:43 -06:00
parent a2af7dc1a9
commit bf9609ca5c
7 changed files with 46 additions and 41 deletions
+5
View File
@@ -397,6 +397,11 @@ void InputFilter::GetPressedButtons( vector<DeviceInput> &array ) const
array = g_CurrentState; array = g_CurrentState;
} }
void InputFilter::UpdateCursorLocation()
{
// todo
}
/* /*
* (c) 2001-2004 Chris Danford * (c) 2001-2004 Chris Danford
* All rights reserved. * All rights reserved.
+9 -8
View File
@@ -7,15 +7,15 @@
enum InputEventType enum InputEventType
{ {
/* The device was just pressed. */ // The device was just pressed.
IET_FIRST_PRESS, IET_FIRST_PRESS,
/* The device is auto-repeating. This event is guaranteed to be sent only between /* The device is auto-repeating. This event is guaranteed to be sent only
* IET_FIRST_PRESS and IET_RELEASE pairs. */ * between IET_FIRST_PRESS and IET_RELEASE pairs. */
IET_REPEAT, IET_REPEAT,
/* The device is no longer pressed. Exactly one IET_RELEASE event will be sent /* The device is no longer pressed. Exactly one IET_RELEASE event will be
* for each IET_FIRST_PRESS. */ * sent for each IET_FIRST_PRESS. */
IET_RELEASE, IET_RELEASE,
NUM_InputEventType, NUM_InputEventType,
@@ -29,7 +29,7 @@ struct InputEvent
DeviceInput di; DeviceInput di;
InputEventType type; InputEventType type;
/* A list of all buttons that were pressed at the time of this event: */ // A list of all buttons that were pressed at the time of this event:
DeviceInputList m_ButtonState; DeviceInputList m_ButtonState;
}; };
@@ -62,6 +62,9 @@ public:
void GetInputEvents( vector<InputEvent> &aEventOut ); void GetInputEvents( vector<InputEvent> &aEventOut );
void GetPressedButtons( vector<DeviceInput> &array ) const; void GetPressedButtons( vector<DeviceInput> &array ) const;
// cursor
void UpdateCursorLocation();
private: private:
void CheckButtonChange( ButtonState &bs, DeviceInput di, const RageTimer &now ); void CheckButtonChange( ButtonState &bs, DeviceInput di, const RageTimer &now );
void ReportButtonChange( const DeviceInput &di, InputEventType t ); void ReportButtonChange( const DeviceInput &di, InputEventType t );
@@ -71,10 +74,8 @@ private:
RageMutex *queuemutex; RageMutex *queuemutex;
}; };
extern InputFilter* INPUTFILTER; // global and accessable from anywhere in our program extern InputFilter* INPUTFILTER; // global and accessable from anywhere in our program
#endif #endif
/* /*
-1
View File
@@ -34,7 +34,6 @@ InputMapper::InputMapper()
m_pInputScheme = NULL; m_pInputScheme = NULL;
} }
InputMapper::~InputMapper() InputMapper::~InputMapper()
{ {
SaveMappingsToDisk(); SaveMappingsToDisk();
+4 -6
View File
@@ -100,9 +100,9 @@ struct AutoMappings
#undef PUSH #undef PUSH
} }
/* Strings used by automatic joystick mappings. */ // Strings used by automatic joystick mappings.
RString m_sGame; // only used RString m_sGame; // only used
RString m_sDriverRegex; // reported by InputHandler RString m_sDriverRegex; // reported by InputHandler
RString m_sControllerName; // the product name of the controller RString m_sControllerName; // the product name of the controller
vector<AutoMappingEntry> m_vMaps; vector<AutoMappingEntry> m_vMaps;
@@ -118,7 +118,7 @@ public:
const char *m_szName; // The name used by the button graphics system. e.g. "left", "right", "middle C", "snare" const char *m_szName; // The name used by the button graphics system. e.g. "left", "right", "middle C", "snare"
GameButton m_SecondaryMenuButton; GameButton m_SecondaryMenuButton;
}; };
/* Data for each Game-specific GameButton. This starts at GAME_BUTTON_NEXT. */ // Data for each Game-specific GameButton. This starts at GAME_BUTTON_NEXT.
GameButtonInfo m_GameButtonInfo[NUM_GameButton]; GameButtonInfo m_GameButtonInfo[NUM_GameButton];
const AutoMappings *m_pAutoMappings; const AutoMappings *m_pAutoMappings;
@@ -211,10 +211,8 @@ protected:
const InputScheme *m_pInputScheme; const InputScheme *m_pInputScheme;
}; };
extern InputMapper* INPUTMAPPER; // global and accessable from anywhere in our program extern InputMapper* INPUTMAPPER; // global and accessable from anywhere in our program
#endif #endif
/* /*
+15 -19
View File
@@ -1,25 +1,21 @@
#ifndef INPUT_HANDLER_H #ifndef INPUT_HANDLER_H
#define INPUT_HANDLER_H #define INPUT_HANDLER_H
/* /* This is a simple class to handle special input devices. Update() will be
* This is a simple class to handle special input devices. Update() * called during the input update; the derived class should send appropriate
* will be called during the input update; the derived class should * events to InputHandler.
* send appropriate events to InputHandler. * Note that, if the underlying device is capable of it, you're free to start
* * a blocking thread; just store inputs in your class and send them off in a
* Note that, if the underlying device is capable of it, you're free to * batch on the next Update. This gets much more accurate timestamps; we get
* start a blocking thread; just store inputs in your class and send them * events more quickly and timestamp them, instead of having a rough timing
* off in a batch on the next Update. This gets much more accurate timestamps; * granularity due to the framerate.
* we get events more quickly and timestamp them, instead of having a rough * Send input events for a specific type of device. Only one driver for a given
* timing granularity due to the framerate. * set of InputDevice types should be loaded for a given arch. For example,
* * any number of drivers may produce DEVICE_PUMPn events, but only one may be
* Send input events for a specific type of device. Only one driver * loaded at a time. (This will be inconvenient if, for example, we have two
* for a given set of InputDevice types should be loaded for a given * completely distinct methods of getting input for the same device; we have no
* arch. For example, any number of drivers may produce DEVICE_PUMPn * method to allocate device numbers. We don't need this now; I'll write it
* events, but only one may be loaded at a time. (This will be inconvenient * if it becomes needed.) */
* if, for example, we have two completely distinct methods of getting
* input for the same device; we have no method to allocate device numbers.
* We don't need this now; I'll write it if it becomes needed.)
*/
#include "RageInputDevice.h" // for InputDevice #include "RageInputDevice.h" // for InputDevice
#include "arch/RageDriver.h" #include "arch/RageDriver.h"
@@ -425,7 +425,8 @@ void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
if( neg != DeviceButton_Invalid ) if( neg != DeviceButton_Invalid )
{ {
float l = SCALE( int(val), 0.0f, 100.0f, 0.0f, 1.0f ); //float l = SCALE( int(val), 0.0f, 100.0f, 0.0f, 1.0f );
float l = val;
ButtonPressed( DeviceInput(dev, neg, max(-l,0), tm) ); ButtonPressed( DeviceInput(dev, neg, max(-l,0), tm) );
ButtonPressed( DeviceInput(dev, pos, max(+l,0), tm) ); ButtonPressed( DeviceInput(dev, pos, max(+l,0), tm) );
} }
@@ -509,11 +510,14 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
{ {
case DIMOFS_X: case DIMOFS_X:
LOG->Trace("mouse X axis changed (buffered)"); LOG->Trace("mouse X axis changed (buffered)");
// todo: update cursor position -aj
up = MOUSE_X_LEFT; down = MOUSE_X_RIGHT; up = MOUSE_X_LEFT; down = MOUSE_X_RIGHT;
break; break;
case DIMOFS_Y: case DIMOFS_Y:
LOG->Trace("mouse Y axis changed (buffered)"); LOG->Trace("mouse Y axis changed (buffered)");
// todo: update cursor position -aj
up = MOUSE_Y_UP; down = MOUSE_Y_DOWN; up = MOUSE_Y_UP; down = MOUSE_Y_DOWN;
//INPUTFILTER->UpdateCursorLocation(0, evtbuf[i].dwData);
break; break;
case DIMOFS_Z: case DIMOFS_Z:
LOG->Trace("mouse Z axis changed (buffered)"); LOG->Trace("mouse Z axis changed (buffered)");
@@ -524,6 +528,9 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
device.m_sName.c_str(), in.ofs ); device.m_sName.c_str(), in.ofs );
continue; continue;
} }
float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f );
ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) );
ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) );
} }
else else
{ {
@@ -532,7 +539,7 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
// joystick // joystick
case DIJOFS_X: up = JOY_LEFT; down = JOY_RIGHT; break; case DIJOFS_X: up = JOY_LEFT; down = JOY_RIGHT; break;
case DIJOFS_Y: up = JOY_UP; down = JOY_DOWN; break; case DIJOFS_Y: up = JOY_UP; down = JOY_DOWN; break;
case DIJOFS_Z: up = JOY_Z_UP; down = JOY_Z_DOWN; break; case DIJOFS_Z: up = JOY_Z_UP; down = JOY_Z_DOWN; break;
case DIJOFS_RX: up = JOY_ROT_UP; down = JOY_ROT_DOWN; break; case DIJOFS_RX: up = JOY_ROT_UP; down = JOY_ROT_DOWN; break;
case DIJOFS_RY: up = JOY_ROT_LEFT; down = JOY_ROT_RIGHT; break; case DIJOFS_RY: up = JOY_ROT_LEFT; down = JOY_ROT_RIGHT; break;
case DIJOFS_RZ: up = JOY_ROT_Z_UP; down = JOY_ROT_Z_DOWN; break; case DIJOFS_RZ: up = JOY_ROT_Z_UP; down = JOY_ROT_Z_DOWN; break;
@@ -543,11 +550,10 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
device.m_sName.c_str(), in.ofs ); device.m_sName.c_str(), in.ofs );
continue; continue;
} }
float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f );
ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) );
ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) );
} }
float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f );
ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) );
ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) );
break; break;
} }
case in.HAT: case in.HAT: