mirror of https://github.com/stella-emu/stella.git
- Added Driving Controllers to the list of devices supported by the
Stelladaptor. - Thanks for Mark Grebe for this code. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@255 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
c9f9448e77
commit
4c15baa3b1
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: mainSDL.cxx,v 1.1 2004-05-24 17:18:22 stephena Exp $
|
||||
// $Id: mainSDL.cxx,v 1.2 2004-06-04 12:22:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <fstream>
|
||||
|
@ -98,6 +98,9 @@ static bool setupProperties(PropertiesSet& set);
|
|||
Event::JoystickOneLeft, Event::JoystickOneRight, Event::PaddleTwoResistance,
|
||||
Event::JoystickOneUp, Event::JoystickOneDown, Event::PaddleThreeResistance
|
||||
};
|
||||
static Event::Type SA_DrivingValue[2] = {
|
||||
Event::DrivingZeroValue, Event::DrivingOneValue
|
||||
};
|
||||
#endif
|
||||
|
||||
// Pointer to the console object or the null pointer
|
||||
|
@ -647,11 +650,13 @@ void handleEvents()
|
|||
if(type == JT_STELLADAPTOR_1)
|
||||
{
|
||||
theConsole->eventHandler().sendEvent(Event::JoystickZeroFire, state);
|
||||
theConsole->eventHandler().sendEvent(Event::DrivingZeroFire, state);
|
||||
theConsole->eventHandler().sendEvent(Event::PaddleZeroFire, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
theConsole->eventHandler().sendEvent(Event::JoystickOneFire, state);
|
||||
theConsole->eventHandler().sendEvent(Event::DrivingOneFire, state);
|
||||
theConsole->eventHandler().sendEvent(Event::PaddleTwoFire, state);
|
||||
}
|
||||
}
|
||||
|
@ -677,6 +682,19 @@ void handleEvents()
|
|||
// Send axis events for the paddles
|
||||
resistance = (Int32) (1000000.0 * (32767 - value) / 65534);
|
||||
theConsole->eventHandler().sendEvent(SA_Axis[type-2][axis][2], resistance);
|
||||
|
||||
// Send events for the driving controllers
|
||||
if(axis == 1)
|
||||
{
|
||||
if(value <= -16384-4096)
|
||||
theConsole->eventHandler().sendEvent(SA_DrivingValue[type-2],2);
|
||||
else if(value > 16384+4096)
|
||||
theConsole->eventHandler().sendEvent(SA_DrivingValue[type-2],1);
|
||||
else if(value >= 16384-4096)
|
||||
theConsole->eventHandler().sendEvent(SA_DrivingValue[type-2],0);
|
||||
else
|
||||
theConsole->eventHandler().sendEvent(SA_DrivingValue[type-2],3);
|
||||
}
|
||||
}
|
||||
break; // Stelladaptor joystick
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Driving.cxx,v 1.2 2004-05-28 19:08:12 stephena Exp $
|
||||
// $Id: Driving.cxx,v 1.3 2004-06-04 12:22:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -60,6 +60,8 @@ bool Driving::read(DigitalPin pin)
|
|||
{
|
||||
return (clockwise[(myCounter / delay) & 0x03] & 0x01) != 0;
|
||||
}
|
||||
else
|
||||
return(myEvent.get(Event::DrivingZeroValue) & 0x01);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -71,6 +73,8 @@ bool Driving::read(DigitalPin pin)
|
|||
{
|
||||
return (clockwise[(myCounter / delay) & 0x03] & 0x01) != 0;
|
||||
}
|
||||
else
|
||||
return(myEvent.get(Event::DrivingOneValue) & 0x01);
|
||||
}
|
||||
|
||||
case Two:
|
||||
|
@ -84,6 +88,8 @@ bool Driving::read(DigitalPin pin)
|
|||
{
|
||||
return (clockwise[(myCounter / delay) & 0x03] & 0x02) != 0;
|
||||
}
|
||||
else
|
||||
return(myEvent.get(Event::DrivingZeroValue) & 0x02);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -95,6 +101,8 @@ bool Driving::read(DigitalPin pin)
|
|||
{
|
||||
return (clockwise[(myCounter / delay) & 0x03] & 0x02) != 0;
|
||||
}
|
||||
else
|
||||
return(myEvent.get(Event::DrivingOneValue) & 0x02);
|
||||
}
|
||||
|
||||
case Three:
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Event.hxx,v 1.4 2003-09-25 16:20:34 stephena Exp $
|
||||
// $Id: Event.hxx,v 1.5 2004-06-04 12:22:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef EVENT_HXX
|
||||
|
@ -25,7 +25,7 @@ class Event;
|
|||
|
||||
/**
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Event.hxx,v 1.4 2003-09-25 16:20:34 stephena Exp $
|
||||
@version $Id: Event.hxx,v 1.5 2004-06-04 12:22:12 stephena Exp $
|
||||
*/
|
||||
class Event
|
||||
{
|
||||
|
@ -64,8 +64,10 @@ class Event
|
|||
KeyboardOne7, KeyboardOne8, KeyboardOne9,
|
||||
KeyboardOneStar, KeyboardOne0, KeyboardOnePound,
|
||||
|
||||
DrivingZeroClockwise, DrivingZeroCounterClockwise, DrivingZeroFire,
|
||||
DrivingOneClockwise, DrivingOneCounterClockwise, DrivingOneFire,
|
||||
DrivingZeroClockwise, DrivingZeroCounterClockwise, DrivingZeroValue,
|
||||
DrivingZeroFire,
|
||||
DrivingOneClockwise, DrivingOneCounterClockwise, DrivingOneValue,
|
||||
DrivingOneFire,
|
||||
|
||||
ChangeState, LoadState, SaveState, TakeSnapshot, Pause, Quit,
|
||||
|
||||
|
|
Loading…
Reference in New Issue