mouse code progress
This commit is contained in:
@@ -132,8 +132,6 @@ static void InitNames()
|
|||||||
g_mapNamesToString[MOUSE_MIDDLE] = "middle mouse button";
|
g_mapNamesToString[MOUSE_MIDDLE] = "middle mouse button";
|
||||||
g_mapNamesToString[MOUSE_WHEELUP] = "mousewheel up";
|
g_mapNamesToString[MOUSE_WHEELUP] = "mousewheel up";
|
||||||
g_mapNamesToString[MOUSE_WHEELDOWN] = "mousewheel down";
|
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 )
|
FOREACHM( DeviceButton, RString, g_mapNamesToString, m )
|
||||||
g_mapStringToNames[m->second] = m->first;
|
g_mapStringToNames[m->second] = m->first;
|
||||||
|
|||||||
@@ -289,16 +289,14 @@ enum DeviceButton
|
|||||||
MIDI_FIRST = 600,
|
MIDI_FIRST = 600,
|
||||||
MIDI_LAST = 699,
|
MIDI_LAST = 699,
|
||||||
|
|
||||||
// Mouse:
|
// Mouse buttons
|
||||||
MOUSE_LEFT = 700,
|
MOUSE_LEFT = 700,
|
||||||
MOUSE_RIGHT,
|
MOUSE_RIGHT,
|
||||||
MOUSE_MIDDLE,
|
MOUSE_MIDDLE,
|
||||||
// for mice with forward and backwards buttons
|
|
||||||
MOUSE_FORWARD, MOUSE_BACK,
|
|
||||||
// axis
|
// axis
|
||||||
MOUSE_X_LEFT, MOUSE_X_RIGHT,
|
MOUSE_X_LEFT, MOUSE_X_RIGHT,
|
||||||
MOUSE_Y_UP, MOUSE_Y_DOWN,
|
MOUSE_Y_UP, MOUSE_Y_DOWN,
|
||||||
// mousewheel?
|
// Mouse wheel (z axis)
|
||||||
MOUSE_WHEELUP, MOUSE_WHEELDOWN,
|
MOUSE_WHEELUP, MOUSE_WHEELDOWN,
|
||||||
|
|
||||||
NUM_DeviceButton,
|
NUM_DeviceButton,
|
||||||
|
|||||||
@@ -262,8 +262,8 @@ static HRESULT GetDeviceState( LPDIRECTINPUTDEVICE2 dev, int size, void *ptr )
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This doesn't take a timestamp; instead, we let InputHandler::ButtonPressed figure
|
/* This doesn't take a timestamp; instead, we let InputHandler::ButtonPressed
|
||||||
* it out. Be sure to call InputHandler::Update() between each poll. */
|
* figure it out. Be sure to call InputHandler::Update() between each poll. */
|
||||||
void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
|
void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
|
||||||
{
|
{
|
||||||
switch( device.type )
|
switch( device.type )
|
||||||
@@ -403,17 +403,16 @@ void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
|
|||||||
switch( in.ofs )
|
switch( in.ofs )
|
||||||
{
|
{
|
||||||
case DIMOFS_X:
|
case DIMOFS_X:
|
||||||
LOG->Trace("mouse X axis changed (polled)");
|
|
||||||
neg = MOUSE_X_LEFT; pos = MOUSE_X_RIGHT;
|
neg = MOUSE_X_LEFT; pos = MOUSE_X_RIGHT;
|
||||||
val = state.lX;
|
val = state.lX;
|
||||||
|
LOG->Trace("mouse x: %d",val);
|
||||||
break;
|
break;
|
||||||
case DIMOFS_Y:
|
case DIMOFS_Y:
|
||||||
LOG->Trace("mouse Y axis changed (polled)");
|
|
||||||
neg = MOUSE_Y_UP; pos = MOUSE_Y_DOWN;
|
neg = MOUSE_Y_UP; pos = MOUSE_Y_DOWN;
|
||||||
val = state.lY;
|
val = state.lY;
|
||||||
|
LOG->Trace("mouse y: %d",val);
|
||||||
break;
|
break;
|
||||||
case DIMOFS_Z:
|
case DIMOFS_Z:
|
||||||
LOG->Trace("mouse Z axis changed (polled)");
|
|
||||||
neg = MOUSE_WHEELUP; pos = MOUSE_WHEELDOWN;
|
neg = MOUSE_WHEELUP; pos = MOUSE_WHEELDOWN;
|
||||||
val = state.lZ;
|
val = state.lZ;
|
||||||
break;
|
break;
|
||||||
@@ -489,7 +488,6 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
|
|||||||
case DIMOFS_BUTTON0: mouseInput = MOUSE_LEFT; break;
|
case DIMOFS_BUTTON0: mouseInput = MOUSE_LEFT; break;
|
||||||
case DIMOFS_BUTTON1: mouseInput = MOUSE_RIGHT; break;
|
case DIMOFS_BUTTON1: mouseInput = MOUSE_RIGHT; break;
|
||||||
case DIMOFS_BUTTON2: mouseInput = MOUSE_MIDDLE; break;
|
case DIMOFS_BUTTON2: mouseInput = MOUSE_MIDDLE; break;
|
||||||
//case DIMOFS_BUTTON3: break;
|
|
||||||
default: LOG->MapLog( "unknown input",
|
default: LOG->MapLog( "unknown input",
|
||||||
"Mouse '%s' is returning an unknown mouse offset [button], %i",
|
"Mouse '%s' is returning an unknown mouse offset [button], %i",
|
||||||
device.m_sName.c_str(), in.ofs );
|
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;
|
DeviceButton up = DeviceButton_Invalid, down = DeviceButton_Invalid;
|
||||||
if(dev == DEVICE_MOUSE)
|
if(dev == DEVICE_MOUSE)
|
||||||
{
|
{
|
||||||
|
// xxx: mouse position doesn't work here yet -aj
|
||||||
|
float l = int(evtbuf[i].dwData);
|
||||||
switch(in.ofs)
|
switch(in.ofs)
|
||||||
{
|
{
|
||||||
case DIMOFS_X:
|
case DIMOFS_X:
|
||||||
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;
|
||||||
|
//cursorX += l;
|
||||||
|
LOG->Trace("dwData for mouse x: %f",l);
|
||||||
break;
|
break;
|
||||||
case DIMOFS_Y:
|
case DIMOFS_Y:
|
||||||
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);
|
//cursorY += l;
|
||||||
|
LOG->Trace("dwData for mouse y: %f",l);
|
||||||
break;
|
break;
|
||||||
case DIMOFS_Z:
|
case DIMOFS_Z:
|
||||||
LOG->Trace("mouse Z axis changed (buffered)");
|
|
||||||
up = MOUSE_WHEELUP; down = MOUSE_WHEELDOWN;
|
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;
|
break;
|
||||||
default: LOG->MapLog( "unknown input",
|
default: LOG->MapLog( "unknown input",
|
||||||
"Mouse '%s' is returning an unknown mouse offset [axis], %i",
|
"Mouse '%s' is returning an unknown mouse offset [axis], %i",
|
||||||
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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ bool DIDevice::Open()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MOUSE:
|
case MOUSE:
|
||||||
Device->EnumObjects( DIMouse_EnumDevObjectsProc, this, DIDFT_BUTTON | DIDFT_AXIS );
|
Device->EnumObjects( DIMouse_EnumDevObjectsProc, this, DIDFT_BUTTON | DIDFT_AXIS | DIDFT_ANYINSTANCE );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ static BOOL CALLBACK DIMouse_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev, L
|
|||||||
//HRESULT hr;
|
//HRESULT hr;
|
||||||
|
|
||||||
input_t in;
|
input_t in;
|
||||||
const int SupportedMask = DIDFT_BUTTON | DIDFT_AXIS;
|
const int SupportedMask = DIDFT_BUTTON | DIDFT_AXIS | DIDFT_ANYINSTANCE;
|
||||||
if(!(dev->dwType & SupportedMask))
|
if(!(dev->dwType & SupportedMask))
|
||||||
return DIENUM_CONTINUE; // unsupported
|
return DIENUM_CONTINUE; // unsupported
|
||||||
|
|
||||||
@@ -342,27 +342,9 @@ static BOOL CALLBACK DIMouse_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev, L
|
|||||||
{
|
{
|
||||||
LOG->Trace("found a mouse axis");
|
LOG->Trace("found a mouse axis");
|
||||||
// todo: how to handle this correctly? -aj
|
// todo: how to handle this correctly? -aj
|
||||||
//DIPROPRANGE diprg;
|
|
||||||
|
|
||||||
in.type = in.AXIS;
|
in.type = in.AXIS;
|
||||||
in.num = device->axes;
|
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++;
|
device->axes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user