mirror of https://github.com/stella-emu/stella.git
Disabled the analog joystick axis using actual analog values for
simulated paddles for now. I got it working, but I'm not sure how useful it will be. Maybe it's better to just add joystick emulation for paddle events, and not care whether the axis are digital or analog (it would certainly be easier code-wise), using something like JoyMouse?? git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@904 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
2d91d70189
commit
eaca8d857b
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: EventHandler.cxx,v 1.122 2005-12-08 19:01:38 stephena Exp $
|
// $Id: EventHandler.cxx,v 1.123 2005-12-08 22:30:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -101,7 +101,7 @@ EventHandler::EventHandler(OSystem* osystem)
|
||||||
for(j = 0; j < kNumJoyAxis; ++j)
|
for(j = 0; j < kNumJoyAxis; ++j)
|
||||||
{
|
{
|
||||||
myJoyAxisTable[i][j][0] = myJoyAxisTable[i][j][1] = Event::NoType;
|
myJoyAxisTable[i][j][0] = myJoyAxisTable[i][j][1] = Event::NoType;
|
||||||
myJoyAxisType[i][j] = JA_DIGITAL;
|
myJoyAxisType[i][j] = JA_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,17 +999,17 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
|
||||||
Event::Type eventAxisNeg = myJoyAxisTable[stick][axis][0];
|
Event::Type eventAxisNeg = myJoyAxisTable[stick][axis][0];
|
||||||
Event::Type eventAxisPos = myJoyAxisTable[stick][axis][1];
|
Event::Type eventAxisPos = myJoyAxisTable[stick][axis][1];
|
||||||
|
|
||||||
|
#if 0 // FIXME - This isn't ready for production use just yet ...
|
||||||
// Determine what type of axis we're dealing with
|
// Determine what type of axis we're dealing with
|
||||||
// Figure out the actual type if it's undefined
|
// Figure out the actual type if it's undefined
|
||||||
JoyAxisType type = myJoyAxisType[stick][axis];
|
JoyAxisType type = myJoyAxisType[stick][axis];
|
||||||
if(type == JA_NONE)
|
if(type == JA_NONE)
|
||||||
{
|
{
|
||||||
// TODO - will this always work??
|
// TODO - will this always work??
|
||||||
if((value > JOY_DEADZONE && value < 32667 - JOY_DEADZONE) ||
|
if(value > 32667 - JOY_DEADZONE || value < -32767 + JOY_DEADZONE)
|
||||||
(value < -JOY_DEADZONE && value > -32767 - JOY_DEADZONE))
|
|
||||||
type = myJoyAxisType[stick][axis] = JA_ANALOG;
|
|
||||||
else
|
|
||||||
type = myJoyAxisType[stick][axis] = JA_DIGITAL;
|
type = myJoyAxisType[stick][axis] = JA_DIGITAL;
|
||||||
|
else
|
||||||
|
type = myJoyAxisType[stick][axis] = JA_ANALOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make use of an analog axis/stick for those events that are analog
|
// Make use of an analog axis/stick for those events that are analog
|
||||||
|
@ -1025,10 +1025,28 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
|
||||||
case Event::PaddleOneResistance:
|
case Event::PaddleOneResistance:
|
||||||
case Event::PaddleTwoResistance:
|
case Event::PaddleTwoResistance:
|
||||||
case Event::PaddleThreeResistance:
|
case Event::PaddleThreeResistance:
|
||||||
cerr << "paddle resistance from analog axis\n";
|
{
|
||||||
|
if(value > 0) break;
|
||||||
|
int resistance = (int) (1000000.0 * -value / 32767);
|
||||||
|
myEvent->set(eventAxisNeg, resistance);
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
switch((int)eventAxisPos)
|
||||||
|
{
|
||||||
|
case Event::PaddleZeroResistance:
|
||||||
|
case Event::PaddleOneResistance:
|
||||||
|
case Event::PaddleTwoResistance:
|
||||||
|
case Event::PaddleThreeResistance:
|
||||||
|
{
|
||||||
|
if(value < 0) return;
|
||||||
|
int resistance = (int) (1000000.0 * value / 32767);
|
||||||
|
myEvent->set(eventAxisPos, resistance);
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JA_DIGITAL:
|
case JA_DIGITAL:
|
||||||
|
@ -1038,6 +1056,7 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
|
||||||
case Event::PaddleOneResistance:
|
case Event::PaddleOneResistance:
|
||||||
case Event::PaddleTwoResistance:
|
case Event::PaddleTwoResistance:
|
||||||
case Event::PaddleThreeResistance:
|
case Event::PaddleThreeResistance:
|
||||||
|
if(value > 0) break;
|
||||||
cerr << "paddle resistance - from digital axis\n";
|
cerr << "paddle resistance - from digital axis\n";
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
@ -1048,12 +1067,14 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
|
||||||
case Event::PaddleOneResistance:
|
case Event::PaddleOneResistance:
|
||||||
case Event::PaddleTwoResistance:
|
case Event::PaddleTwoResistance:
|
||||||
case Event::PaddleThreeResistance:
|
case Event::PaddleThreeResistance:
|
||||||
|
if(value < 0) return;
|
||||||
cerr << "paddle resistance + from digital axis\n";
|
cerr << "paddle resistance + from digital axis\n";
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Otherwise, treat values as digital
|
// Otherwise, treat values as digital
|
||||||
if(value == 0)
|
if(value == 0)
|
||||||
|
@ -2205,31 +2226,31 @@ ActionList EventHandler::ourActionList[kActionListSize] = {
|
||||||
{ Event::DrivingOneClockwise, "P2 Driving Controller Right", "" },
|
{ Event::DrivingOneClockwise, "P2 Driving Controller Right", "" },
|
||||||
{ Event::DrivingOneFire, "P2 Driving Controller Fire", "" },
|
{ Event::DrivingOneFire, "P2 Driving Controller Fire", "" },
|
||||||
|
|
||||||
{ Event::KeyboardZero1, "P1 GamePad 1", "" },
|
{ Event::KeyboardZero1, "P1 KeyPad 1", "" },
|
||||||
{ Event::KeyboardZero2, "P1 GamePad 2", "" },
|
{ Event::KeyboardZero2, "P1 KeyPad 2", "" },
|
||||||
{ Event::KeyboardZero3, "P1 GamePad 3", "" },
|
{ Event::KeyboardZero3, "P1 KeyPad 3", "" },
|
||||||
{ Event::KeyboardZero4, "P1 GamePad 4", "" },
|
{ Event::KeyboardZero4, "P1 KeyPad 4", "" },
|
||||||
{ Event::KeyboardZero5, "P1 GamePad 5", "" },
|
{ Event::KeyboardZero5, "P1 KeyPad 5", "" },
|
||||||
{ Event::KeyboardZero6, "P1 GamePad 6", "" },
|
{ Event::KeyboardZero6, "P1 KeyPad 6", "" },
|
||||||
{ Event::KeyboardZero7, "P1 GamePad 7", "" },
|
{ Event::KeyboardZero7, "P1 KeyPad 7", "" },
|
||||||
{ Event::KeyboardZero8, "P1 GamePad 8", "" },
|
{ Event::KeyboardZero8, "P1 KeyPad 8", "" },
|
||||||
{ Event::KeyboardZero9, "P1 GamePad 9", "" },
|
{ Event::KeyboardZero9, "P1 KeyPad 9", "" },
|
||||||
{ Event::KeyboardZeroStar, "P1 GamePad *", "" },
|
{ Event::KeyboardZeroStar, "P1 KeyPad *", "" },
|
||||||
{ Event::KeyboardZero0, "P1 GamePad 0", "" },
|
{ Event::KeyboardZero0, "P1 KeyPad 0", "" },
|
||||||
{ Event::KeyboardZeroPound, "P1 GamePad #", "" },
|
{ Event::KeyboardZeroPound, "P1 KeyPad #", "" },
|
||||||
|
|
||||||
{ Event::KeyboardOne1, "P2 GamePad 1", "" },
|
{ Event::KeyboardOne1, "P2 KeyPad 1", "" },
|
||||||
{ Event::KeyboardOne2, "P2 GamePad 2", "" },
|
{ Event::KeyboardOne2, "P2 KeyPad 2", "" },
|
||||||
{ Event::KeyboardOne3, "P2 GamePad 3", "" },
|
{ Event::KeyboardOne3, "P2 KeyPad 3", "" },
|
||||||
{ Event::KeyboardOne4, "P2 GamePad 4", "" },
|
{ Event::KeyboardOne4, "P2 KeyPad 4", "" },
|
||||||
{ Event::KeyboardOne5, "P2 GamePad 5", "" },
|
{ Event::KeyboardOne5, "P2 KeyPad 5", "" },
|
||||||
{ Event::KeyboardOne6, "P2 GamePad 6", "" },
|
{ Event::KeyboardOne6, "P2 KeyPad 6", "" },
|
||||||
{ Event::KeyboardOne7, "P2 GamePad 7", "" },
|
{ Event::KeyboardOne7, "P2 KeyPad 7", "" },
|
||||||
{ Event::KeyboardOne8, "P2 GamePad 8", "" },
|
{ Event::KeyboardOne8, "P2 KeyPad 8", "" },
|
||||||
{ Event::KeyboardOne9, "P2 GamePad 9", "" },
|
{ Event::KeyboardOne9, "P2 KeyPad 9", "" },
|
||||||
{ Event::KeyboardOneStar, "P2 GamePad *", "" },
|
{ Event::KeyboardOneStar, "P2 KeyPad *", "" },
|
||||||
{ Event::KeyboardOne0, "P2 GamePad 0", "" },
|
{ Event::KeyboardOne0, "P2 KeyPad 0", "" },
|
||||||
{ Event::KeyboardOnePound, "P2 GamePad #", "" }
|
{ Event::KeyboardOnePound, "P2 KeyPad #", "" }
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
ActionList EventHandler::ourActionList[kActionListSize];
|
ActionList EventHandler::ourActionList[kActionListSize];
|
||||||
|
|
Loading…
Reference in New Issue