mouse code progress

This commit is contained in:
AJ Kelly
2011-02-15 03:38:02 -06:00
parent 186a36ddbf
commit 2d71b91c25
4 changed files with 17 additions and 41 deletions
-2
View File
@@ -132,8 +132,6 @@ static void InitNames()
g_mapNamesToString[MOUSE_MIDDLE] = "middle mouse button";
g_mapNamesToString[MOUSE_WHEELUP] = "mousewheel up";
g_mapNamesToString[MOUSE_WHEELDOWN] = "mousewheel down";
g_mapNamesToString[MOUSE_FORWARD] = "forward mouse button";
g_mapNamesToString[MOUSE_BACK] = "back mouse button";
FOREACHM( DeviceButton, RString, g_mapNamesToString, m )
g_mapStringToNames[m->second] = m->first;
+2 -4
View File
@@ -289,16 +289,14 @@ enum DeviceButton
MIDI_FIRST = 600,
MIDI_LAST = 699,
// Mouse:
// Mouse buttons
MOUSE_LEFT = 700,
MOUSE_RIGHT,
MOUSE_MIDDLE,
// for mice with forward and backwards buttons
MOUSE_FORWARD, MOUSE_BACK,
// axis
MOUSE_X_LEFT, MOUSE_X_RIGHT,
MOUSE_Y_UP, MOUSE_Y_DOWN,
// mousewheel?
// Mouse wheel (z axis)
MOUSE_WHEELUP, MOUSE_WHEELDOWN,
NUM_DeviceButton,
@@ -262,8 +262,8 @@ static HRESULT GetDeviceState( LPDIRECTINPUTDEVICE2 dev, int size, void *ptr )
return hr;
}
/* This doesn't take a timestamp; instead, we let InputHandler::ButtonPressed figure
* it out. Be sure to call InputHandler::Update() between each poll. */
/* This doesn't take a timestamp; instead, we let InputHandler::ButtonPressed
* figure it out. Be sure to call InputHandler::Update() between each poll. */
void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
{
switch( device.type )
@@ -403,17 +403,16 @@ void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
switch( in.ofs )
{
case DIMOFS_X:
LOG->Trace("mouse X axis changed (polled)");
neg = MOUSE_X_LEFT; pos = MOUSE_X_RIGHT;
val = state.lX;
LOG->Trace("mouse x: %d",val);
break;
case DIMOFS_Y:
LOG->Trace("mouse Y axis changed (polled)");
neg = MOUSE_Y_UP; pos = MOUSE_Y_DOWN;
val = state.lY;
LOG->Trace("mouse y: %d",val);
break;
case DIMOFS_Z:
LOG->Trace("mouse Z axis changed (polled)");
neg = MOUSE_WHEELUP; pos = MOUSE_WHEELDOWN;
val = state.lZ;
break;
@@ -489,7 +488,6 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
case DIMOFS_BUTTON0: mouseInput = MOUSE_LEFT; break;
case DIMOFS_BUTTON1: mouseInput = MOUSE_RIGHT; break;
case DIMOFS_BUTTON2: mouseInput = MOUSE_MIDDLE; break;
//case DIMOFS_BUTTON3: break;
default: LOG->MapLog( "unknown input",
"Mouse '%s' is returning an unknown mouse offset [button], %i",
device.m_sName.c_str(), in.ofs );
@@ -506,31 +504,31 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
DeviceButton up = DeviceButton_Invalid, down = DeviceButton_Invalid;
if(dev == DEVICE_MOUSE)
{
// xxx: mouse position doesn't work here yet -aj
float l = int(evtbuf[i].dwData);
switch(in.ofs)
{
case DIMOFS_X:
LOG->Trace("mouse X axis changed (buffered)");
// todo: update cursor position -aj
up = MOUSE_X_LEFT; down = MOUSE_X_RIGHT;
//cursorX += l;
LOG->Trace("dwData for mouse x: %f",l);
break;
case DIMOFS_Y:
LOG->Trace("mouse Y axis changed (buffered)");
// todo: update cursor position -aj
up = MOUSE_Y_UP; down = MOUSE_Y_DOWN;
//INPUTFILTER->UpdateCursorLocation(0, evtbuf[i].dwData);
//cursorY += l;
LOG->Trace("dwData for mouse y: %f",l);
break;
case DIMOFS_Z:
LOG->Trace("mouse Z axis changed (buffered)");
up = MOUSE_WHEELUP; down = MOUSE_WHEELDOWN;
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;
default: LOG->MapLog( "unknown input",
"Mouse '%s' is returning an unknown mouse offset [axis], %i",
device.m_sName.c_str(), in.ofs );
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
{
@@ -99,7 +99,7 @@ bool DIDevice::Open()
}
break;
case MOUSE:
Device->EnumObjects( DIMouse_EnumDevObjectsProc, this, DIDFT_BUTTON | DIDFT_AXIS );
Device->EnumObjects( DIMouse_EnumDevObjectsProc, this, DIDFT_BUTTON | DIDFT_AXIS | DIDFT_ANYINSTANCE );
break;
}
@@ -325,7 +325,7 @@ static BOOL CALLBACK DIMouse_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev, L
//HRESULT hr;
input_t in;
const int SupportedMask = DIDFT_BUTTON | DIDFT_AXIS;
const int SupportedMask = DIDFT_BUTTON | DIDFT_AXIS | DIDFT_ANYINSTANCE;
if(!(dev->dwType & SupportedMask))
return DIENUM_CONTINUE; // unsupported
@@ -342,27 +342,9 @@ static BOOL CALLBACK DIMouse_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev, L
{
LOG->Trace("found a mouse axis");
// todo: how to handle this correctly? -aj
//DIPROPRANGE diprg;
in.type = in.AXIS;
in.num = device->axes;
/*
diprg.diph.dwSize = sizeof(diprg);
diprg.diph.dwHeaderSize = sizeof(diprg.diph);
diprg.diph.dwObj = dev->dwOfs;
diprg.diph.dwHow = DIPH_BYOFFSET;
diprg.lMin = -100;
diprg.lMax = 100;
hr = device->Device->SetProperty( DIPROP_RANGE, &diprg.diph );
if ( hr != DI_OK )
{
LOG->Trace("error setting properties on mouse axis");
return DIENUM_CONTINUE; // don't use this axis
}
*/
device->axes++;
}