mirror of https://github.com/stella-emu/stella.git
More updates for remapping joystick axis events. It seems the
infrastructure is now ready, but I can't test that yet since I don't have a joystick at work :) git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@901 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
76a74c0577
commit
0662e27730
|
@ -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: EventHandler.cxx,v 1.119 2005-12-07 02:33:56 stephena Exp $
|
||||
// $Id: EventHandler.cxx,v 1.120 2005-12-07 20:46:49 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -116,6 +116,7 @@ EventHandler::EventHandler(OSystem* osystem)
|
|||
setSDLMappings();
|
||||
setKeymap();
|
||||
setJoymap();
|
||||
setJoyAxisMap();
|
||||
setActionMappings();
|
||||
|
||||
myGrabMouseFlag = myOSystem->settings().getBool("grabmouse");
|
||||
|
@ -771,7 +772,7 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::handleMouseButtonEvent(SDL_Event& event, uInt8 state)
|
||||
void EventHandler::handleMouseButtonEvent(SDL_Event& event, int state)
|
||||
{
|
||||
// Determine which mode we're in, then send the event to the appropriate place
|
||||
switch(myState)
|
||||
|
@ -915,7 +916,7 @@ void EventHandler::handleJoyMouse(uInt32 time)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::handleMouseWarp(uInt8 stick, uInt8 axis, Int16 value)
|
||||
void EventHandler::handleMouseWarp(int stick, int axis, int value)
|
||||
{
|
||||
if(value > JOY_DEADZONE)
|
||||
value -= JOY_DEADZONE;
|
||||
|
@ -955,7 +956,7 @@ void EventHandler::handleMouseWarp(uInt8 stick, uInt8 axis, Int16 value)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::handleJoyEvent(uInt8 stick, uInt32 code, uInt8 state)
|
||||
void EventHandler::handleJoyEvent(int stick, int code, int state)
|
||||
{
|
||||
Event::Type event = myJoyTable[stick*kNumJoyButtons + code];
|
||||
|
||||
|
@ -993,25 +994,7 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
|
|||
|
||||
// Determine if the events should be treated as discrete/digital
|
||||
// or continuous/analog values
|
||||
bool analog = false;
|
||||
switch((int)eventAxisNeg)
|
||||
{
|
||||
case Event::PaddleZeroResistance:
|
||||
case Event::PaddleOneResistance:
|
||||
case Event::PaddleTwoResistance:
|
||||
case Event::PaddleThreeResistance:
|
||||
analog = true;
|
||||
break;
|
||||
}
|
||||
switch((int)eventAxisPos)
|
||||
{
|
||||
case Event::PaddleZeroResistance:
|
||||
case Event::PaddleOneResistance:
|
||||
case Event::PaddleTwoResistance:
|
||||
case Event::PaddleThreeResistance:
|
||||
analog = true;
|
||||
break;
|
||||
}
|
||||
bool analog = eventIsAnalog(eventAxisNeg) || eventIsAnalog(eventAxisPos);
|
||||
|
||||
// Analog vs. digital events treat the input values differently
|
||||
// A value of zero might mean that an action should be turned off
|
||||
|
@ -1039,7 +1022,7 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::handleEvent(Event::Type event, Int32 state)
|
||||
void EventHandler::handleEvent(Event::Type event, int state)
|
||||
{
|
||||
// Take care of special events that aren't part of the emulation core
|
||||
// or need to be preprocessed before passing them on
|
||||
|
@ -1191,15 +1174,16 @@ bool EventHandler::eventStateChange(Event::Type type)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::setActionMappings()
|
||||
{
|
||||
// Fill the ActionList with the current key and joystick mappings
|
||||
for(Int32 i = 0; i < kActionListSize; ++i)
|
||||
{
|
||||
uInt32 j;
|
||||
int i, j, stick, axis, dir;
|
||||
ostringstream buf;
|
||||
|
||||
// Fill the ActionList with the current key and joystick mappings
|
||||
for(i = 0; i < kActionListSize; ++i)
|
||||
{
|
||||
Event::Type event = ourActionList[i].event;
|
||||
ourActionList[i].key = "None";
|
||||
string key = "";
|
||||
for(j = 0; j < SDLK_LAST; ++j) // size of myKeyTable
|
||||
for(j = 0; j < SDLK_LAST; ++j) // key mapping
|
||||
{
|
||||
if(myKeyTable[j] == event)
|
||||
{
|
||||
|
@ -1209,41 +1193,43 @@ void EventHandler::setActionMappings()
|
|||
key = key + ", " + ourSDLMapping[j];
|
||||
}
|
||||
}
|
||||
for(j = 0; j < kNumJoysticks * kNumJoyButtons; ++j)
|
||||
// Joystick button mapping/labeling
|
||||
for(stick = 0; stick < kNumJoysticks * kNumJoyButtons; ++stick)
|
||||
{
|
||||
if(myJoyTable[j] == event)
|
||||
{
|
||||
ostringstream joyevent;
|
||||
uInt32 stick = j / kNumJoyButtons;
|
||||
uInt32 button = j % kNumJoyButtons;
|
||||
|
||||
switch(button)
|
||||
{
|
||||
/*
|
||||
case kJAxisUp:
|
||||
joyevent << "J" << stick << " UP";
|
||||
break;
|
||||
|
||||
case kJAxisDown:
|
||||
joyevent << "J" << stick << " DOWN";
|
||||
break;
|
||||
|
||||
case kJAxisLeft:
|
||||
joyevent << "J" << stick << " LEFT";
|
||||
break;
|
||||
|
||||
case kJAxisRight:
|
||||
joyevent << "J" << stick << " RIGHT";
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
joyevent << "J" << stick << " B" << button;
|
||||
break;
|
||||
}
|
||||
buf.str("");
|
||||
buf << "J" << (j / kNumJoyButtons) << " B" << (j % kNumJoyButtons);
|
||||
if(key == "")
|
||||
key = key + joyevent.str();
|
||||
key = key + buf.str();
|
||||
else
|
||||
key = key + ", " + joyevent.str();
|
||||
key = key + ", " + buf.str();
|
||||
}
|
||||
}
|
||||
// Joystick axis mapping/labeling
|
||||
for(stick = 0; stick < kNumJoysticks; ++stick)
|
||||
{
|
||||
for(axis = 0; axis < kNumJoyAxis; ++axis)
|
||||
{
|
||||
for(dir = 0; dir < 2; ++dir)
|
||||
{
|
||||
if(myJoyAxisTable[stick][axis][dir] == event)
|
||||
{
|
||||
buf.str("");
|
||||
buf << "J" << stick << " axis " << axis;
|
||||
if(eventIsAnalog(event))
|
||||
buf << " abs";
|
||||
else if(dir == 0)
|
||||
buf << " neg";
|
||||
else
|
||||
buf << " pos";
|
||||
|
||||
if(key == "")
|
||||
key = key + buf.str();
|
||||
else
|
||||
key = key + ", " + buf.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1300,7 +1286,26 @@ void EventHandler::setJoymap()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::addKeyMapping(Event::Type event, uInt16 key)
|
||||
void EventHandler::setJoyAxisMap()
|
||||
{
|
||||
string list = myOSystem->settings().getString("joyaxismap");
|
||||
IntArray map;
|
||||
|
||||
if(isValidList(list, map, kNumJoysticks*kNumJoyAxis*2))
|
||||
{
|
||||
// Fill the joyaxismap table with events
|
||||
int idx = 0;
|
||||
for(int i = 0; i < kNumJoysticks; ++i)
|
||||
for(int j = 0; j < kNumJoyAxis; ++j)
|
||||
for(int k = 0; k < 2; ++k)
|
||||
myJoyAxisTable[i][j][k] = (Event::Type) map[idx++];
|
||||
}
|
||||
else
|
||||
setDefaultJoyAxisMap();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::addKeyMapping(Event::Type event, int key)
|
||||
{
|
||||
// These keys cannot be remapped.
|
||||
if(key == SDLK_TAB)
|
||||
|
@ -1313,18 +1318,27 @@ void EventHandler::addKeyMapping(Event::Type event, uInt16 key)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::addJoyMapping(Event::Type event, uInt8 stick, uInt32 code)
|
||||
void EventHandler::addJoyMapping(Event::Type event, int stick, int button)
|
||||
{
|
||||
myJoyTable[stick * kNumJoyButtons + code] = event;
|
||||
myJoyTable[stick * kNumJoyButtons + button] = event;
|
||||
saveJoyMapping();
|
||||
|
||||
setActionMappings();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::addJoyAxisMapping(Event::Type event, int stick, int axis,
|
||||
int value)
|
||||
{
|
||||
cerr << "Remap event " << (int) event
|
||||
<< " to stick " << stick << ", axis = " << axis << ", value = " << value
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::eraseMapping(Event::Type event)
|
||||
{
|
||||
uInt32 i;
|
||||
int i, j, k;
|
||||
|
||||
// Erase the KeyEvent arrays
|
||||
for(i = 0; i < SDLK_LAST; ++i)
|
||||
|
@ -1338,6 +1352,13 @@ void EventHandler::eraseMapping(Event::Type event)
|
|||
myJoyTable[i] = Event::NoType;
|
||||
saveJoyMapping();
|
||||
|
||||
// Erase the JoyAxisEvent array
|
||||
for(i = 0; i < kNumJoysticks; ++i)
|
||||
for(j = 0; j < kNumJoyAxis; ++j)
|
||||
for(k = 0; k < 2; ++k)
|
||||
myJoyAxisTable[i][j][k] = Event::NoType;
|
||||
saveJoyAxisMapping();
|
||||
|
||||
setActionMappings();
|
||||
}
|
||||
|
||||
|
@ -1346,6 +1367,7 @@ void EventHandler::setDefaultMapping()
|
|||
{
|
||||
setDefaultKeymap();
|
||||
setDefaultJoymap();
|
||||
setDefaultJoyAxisMap();
|
||||
|
||||
setActionMappings();
|
||||
}
|
||||
|
@ -1441,12 +1463,6 @@ void EventHandler::setDefaultJoymap()
|
|||
|
||||
// Left joystick
|
||||
i = 0 * kNumJoyButtons;
|
||||
/*
|
||||
myJoyTable[i + kJAxisUp] = Event::JoystickZeroUp;
|
||||
myJoyTable[i + kJAxisDown] = Event::JoystickZeroDown;
|
||||
myJoyTable[i + kJAxisLeft] = Event::JoystickZeroLeft;
|
||||
myJoyTable[i + kJAxisRight] = Event::JoystickZeroRight;
|
||||
*/
|
||||
myJoyTable[i + 0] = Event::JoystickZeroFire;
|
||||
|
||||
#ifdef PSP
|
||||
|
@ -1468,17 +1484,39 @@ void EventHandler::setDefaultJoymap()
|
|||
|
||||
// Right joystick
|
||||
i = 1 * kNumJoyButtons;
|
||||
/*
|
||||
myJoyTable[i + kJAxisUp] = Event::JoystickOneUp;
|
||||
myJoyTable[i + kJAxisDown] = Event::JoystickOneDown;
|
||||
myJoyTable[i + kJAxisLeft] = Event::JoystickOneLeft;
|
||||
myJoyTable[i + kJAxisRight] = Event::JoystickOneRight;
|
||||
*/
|
||||
myJoyTable[i + 0] = Event::JoystickOneFire;
|
||||
|
||||
saveJoyMapping();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::setDefaultJoyAxisMap()
|
||||
{
|
||||
// Erase all mappings
|
||||
for(int i = 0; i < kNumJoysticks; ++i)
|
||||
for(int j = 0; j < kNumJoyAxis; ++j)
|
||||
for(int k = 0; k < 2; ++k)
|
||||
myJoyAxisTable[i][j][k] = Event::NoType;
|
||||
|
||||
// Left joystick left/right directions (assume joystick zero)
|
||||
myJoyAxisTable[0][0][0] = Event::JoystickZeroLeft;
|
||||
myJoyAxisTable[0][0][1] = Event::JoystickZeroRight;
|
||||
|
||||
// Left joystick up/down directions (assume joystick zero)
|
||||
myJoyAxisTable[0][1][0] = Event::JoystickZeroUp;
|
||||
myJoyAxisTable[0][1][1] = Event::JoystickZeroDown;
|
||||
|
||||
// Right joystick left/right directions (assume joystick one)
|
||||
myJoyAxisTable[1][0][0] = Event::JoystickOneLeft;
|
||||
myJoyAxisTable[1][0][1] = Event::JoystickOneRight;
|
||||
|
||||
// Right joystick left/right directions (assume joystick one)
|
||||
myJoyAxisTable[1][1][0] = Event::JoystickOneUp;
|
||||
myJoyAxisTable[1][1][1] = Event::JoystickOneDown;
|
||||
|
||||
saveJoyAxisMapping();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::saveKeyMapping()
|
||||
{
|
||||
|
@ -1505,6 +1543,21 @@ void EventHandler::saveJoyMapping()
|
|||
myOSystem->settings().setString("joymap", joybuf.str());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::saveJoyAxisMapping()
|
||||
{
|
||||
// Iterate through the joyaxismap table and create a colon-separated list
|
||||
// Prepend the event count, so we can check it on next load
|
||||
ostringstream buf;
|
||||
buf << Event::LastType << ":";
|
||||
for(int i = 0; i < kNumJoysticks; ++i)
|
||||
for(int j = 0; j < kNumJoyAxis; ++j)
|
||||
for(int k = 0; k < 2; ++k)
|
||||
buf << myJoyAxisTable[i][j][k] << ":";
|
||||
|
||||
myOSystem->settings().setString("joyaxismap", buf.str());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool EventHandler::isValidList(string& list, IntArray& map, uInt32 length)
|
||||
{
|
||||
|
@ -1529,6 +1582,23 @@ bool EventHandler::isValidList(string& list, IntArray& map, uInt32 length)
|
|||
return false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
inline bool EventHandler::eventIsAnalog(Event::Type event)
|
||||
{
|
||||
bool analog = false;
|
||||
switch((int)event)
|
||||
{
|
||||
case Event::PaddleZeroResistance:
|
||||
case Event::PaddleOneResistance:
|
||||
case Event::PaddleTwoResistance:
|
||||
case Event::PaddleThreeResistance:
|
||||
analog = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return analog;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::saveState()
|
||||
{
|
||||
|
|
|
@ -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: EventHandler.hxx,v 1.59 2005-12-07 02:33:56 stephena Exp $
|
||||
// $Id: EventHandler.hxx,v 1.60 2005-12-07 20:46:49 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef EVENTHANDLER_HXX
|
||||
|
@ -84,7 +84,7 @@ struct Stella_Joystick {
|
|||
mapping can take place.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: EventHandler.hxx,v 1.59 2005-12-07 02:33:56 stephena Exp $
|
||||
@version $Id: EventHandler.hxx,v 1.60 2005-12-07 20:46:49 stephena Exp $
|
||||
*/
|
||||
class EventHandler
|
||||
{
|
||||
|
@ -138,16 +138,26 @@ class EventHandler
|
|||
@param event The event we are remapping
|
||||
@param key The key to bind to this event
|
||||
*/
|
||||
void addKeyMapping(Event::Type event, uInt16 key);
|
||||
void addKeyMapping(Event::Type event, int key);
|
||||
|
||||
/**
|
||||
Bind a joystick button/direction to an event/action
|
||||
Bind a joystick button to an event/action
|
||||
|
||||
@param event The event we are remapping
|
||||
@param stick The joystick number and button
|
||||
@param code to bind to this event
|
||||
@param stick The joystick number
|
||||
@param button The joystick button
|
||||
*/
|
||||
void addJoyMapping(Event::Type event, uInt8 stick, uInt32 code);
|
||||
void addJoyMapping(Event::Type event, int stick, int button);
|
||||
|
||||
/**
|
||||
Bind a joystick axis direction to an event/action
|
||||
|
||||
@param event The event we are remapping
|
||||
@param stick The joystick number
|
||||
@param axis The joystick axis
|
||||
@param value The value on the given axis
|
||||
*/
|
||||
void addJoyAxisMapping(Event::Type event, int stick, int axis, int value);
|
||||
|
||||
/**
|
||||
Erase the specified mapping
|
||||
|
@ -282,28 +292,34 @@ class EventHandler
|
|||
|
||||
@param event The mouse button event generated by SDL
|
||||
*/
|
||||
void handleMouseButtonEvent(SDL_Event& event, uInt8 state);
|
||||
void handleMouseButtonEvent(SDL_Event& event, int state);
|
||||
|
||||
/**
|
||||
Send a joystick event to the handler (directions are encoded as buttons)
|
||||
Send a joystick button event to the handler
|
||||
|
||||
@param stick SDL joystick
|
||||
@param code Event code
|
||||
@param state state of code (pressed/released)
|
||||
@param stick The joystick number
|
||||
@param button The joystick button
|
||||
@param state State of button (pressed/released)
|
||||
*/
|
||||
void handleJoyEvent(uInt8 stick, uInt32 code, uInt8 state);
|
||||
void handleJoyEvent(int stick, int button, int state);
|
||||
|
||||
// FIXME - comment
|
||||
/**
|
||||
Send a joystick axis event to the handler (directions are encoded as buttons)
|
||||
|
||||
@param stick The joystick number
|
||||
@param axis The joystick axis
|
||||
@param value The value on the given axis
|
||||
*/
|
||||
void handleJoyAxisEvent(int stick, int axis, int value);
|
||||
|
||||
/**
|
||||
Convert joystick motion events to simulated mouse motion events
|
||||
|
||||
@param stick SDL joystick
|
||||
@param code Event code
|
||||
@param state state of code (pressed/released)
|
||||
@param stick The joystick number
|
||||
@param axis The joystick axis
|
||||
@param value The value on the given axis
|
||||
*/
|
||||
void handleMouseWarp(uInt8 stick, uInt8 axis, Int16 value);
|
||||
void handleMouseWarp(int stick, int axis, int value);
|
||||
|
||||
/**
|
||||
Handle joystick movement emulating mouse motion
|
||||
|
@ -327,10 +343,13 @@ class EventHandler
|
|||
void setSDLMappings();
|
||||
void setKeymap();
|
||||
void setJoymap();
|
||||
void setJoyAxisMap();
|
||||
void setDefaultKeymap();
|
||||
void setDefaultJoymap();
|
||||
void setDefaultJoyAxisMap();
|
||||
void saveKeyMapping();
|
||||
void saveJoyMapping();
|
||||
void saveJoyAxisMapping();
|
||||
|
||||
/**
|
||||
Tests if a mapping list is valid, both by length and by event count.
|
||||
|
@ -343,6 +362,14 @@ class EventHandler
|
|||
*/
|
||||
bool isValidList(string& list, IntArray& map, uInt32 length);
|
||||
|
||||
/**
|
||||
Tests if a given event should use continuous/analog values.
|
||||
|
||||
@param event The event to test for analog processing
|
||||
@return True if analog, else false
|
||||
*/
|
||||
inline bool eventIsAnalog(Event::Type event);
|
||||
|
||||
void saveState();
|
||||
void changeState();
|
||||
void loadState();
|
||||
|
|
|
@ -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: Settings.cxx,v 1.66 2005-11-19 22:26:13 stephena Exp $
|
||||
// $Id: Settings.cxx,v 1.67 2005-12-07 20:46:49 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -58,6 +58,7 @@ Settings::Settings(OSystem* osystem)
|
|||
|
||||
set("keymap", "");
|
||||
set("joymap", "");
|
||||
set("joyaxismap", "");
|
||||
set("paddle", "0");
|
||||
set("joymouse", "false");
|
||||
set("sa1", "left");
|
||||
|
|
|
@ -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: Dialog.cxx,v 1.33 2005-11-13 22:25:47 stephena Exp $
|
||||
// $Id: Dialog.cxx,v 1.34 2005-12-07 20:46:49 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -382,6 +382,14 @@ void Dialog::handleJoyUp(int stick, int button)
|
|||
_focusedWidget->handleJoyUp(stick, button);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Dialog::handleJoyAxis(int stick, int axis, int value)
|
||||
{
|
||||
// Focused widget receives joystick events
|
||||
if(_focusedWidget)
|
||||
_focusedWidget->handleJoyAxis(stick, axis, value);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Dialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||
{
|
||||
|
|
|
@ -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: Dialog.hxx,v 1.20 2005-08-11 19:12:39 stephena Exp $
|
||||
// $Id: Dialog.hxx,v 1.21 2005-12-07 20:46:49 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -36,7 +36,7 @@ class TabWidget;
|
|||
This is the base class for all dialog boxes.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: Dialog.hxx,v 1.20 2005-08-11 19:12:39 stephena Exp $
|
||||
@version $Id: Dialog.hxx,v 1.21 2005-12-07 20:46:49 stephena Exp $
|
||||
*/
|
||||
class Dialog : public GuiObject
|
||||
{
|
||||
|
@ -80,6 +80,7 @@ class Dialog : public GuiObject
|
|||
virtual void handleMouseMoved(int x, int y, int button);
|
||||
virtual void handleJoyDown(int stick, int button);
|
||||
virtual void handleJoyUp(int stick, int button);
|
||||
virtual void handleJoyAxis(int stick, int axis, int value);
|
||||
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||
virtual void handleScreenChanged() {}
|
||||
|
||||
|
|
|
@ -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: DialogContainer.cxx,v 1.19 2005-12-07 02:33:56 stephena Exp $
|
||||
// $Id: DialogContainer.cxx,v 1.20 2005-12-07 20:46:49 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "OSystem.hxx"
|
||||
|
@ -257,7 +257,10 @@ void DialogContainer::handleJoyEvent(int stick, int button, uInt8 state)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DialogContainer::handleJoyAxisEvent(int stick, int axis, int value)
|
||||
{
|
||||
cerr << "DialogContainer::handleJoyAxisEvent\n"
|
||||
<< " stick = " << stick << ", axis = " << axis << ", value = " << value
|
||||
<< endl;
|
||||
if(myDialogStack.empty())
|
||||
return;
|
||||
|
||||
// Send the event to the dialog box on the top of the stack
|
||||
Dialog* activeDialog = myDialogStack.top();
|
||||
activeDialog->handleJoyAxis(stick, axis, value);
|
||||
}
|
||||
|
|
|
@ -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: EventMappingWidget.cxx,v 1.1 2005-11-13 22:25:47 stephena Exp $
|
||||
// $Id: EventMappingWidget.cxx,v 1.2 2005-12-07 20:46:49 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -197,6 +197,19 @@ void EventMappingWidget::handleJoyDown(int stick, int button)
|
|||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventMappingWidget::handleJoyAxis(int stick, int axis, int value)
|
||||
{
|
||||
// Remap joystick buttons in remap mode
|
||||
if(myRemapStatus && myActionSelected >= 0)
|
||||
{
|
||||
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
|
||||
instance()->eventHandler().addJoyAxisMapping(event, stick, axis, value);
|
||||
|
||||
stopRemapping();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventMappingWidget::handleCommand(CommandSender* sender, int cmd,
|
||||
int data, int id)
|
||||
|
|
|
@ -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: EventMappingWidget.hxx,v 1.1 2005-11-13 22:25:47 stephena Exp $
|
||||
// $Id: EventMappingWidget.hxx,v 1.2 2005-12-07 20:46:49 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -43,6 +43,7 @@ class EventMappingWidget : public Widget, public CommandSender
|
|||
|
||||
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
|
||||
virtual void handleJoyDown(int stick, int button);
|
||||
virtual void handleJoyAxis(int stick, int axis, int value);
|
||||
|
||||
bool remapMode() { return myRemapStatus; }
|
||||
|
||||
|
|
|
@ -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: InputDialog.cxx,v 1.4 2005-12-07 02:33:56 stephena Exp $
|
||||
// $Id: InputDialog.cxx,v 1.5 2005-12-07 20:46:49 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "OSystem.hxx"
|
||||
|
@ -181,7 +181,6 @@ void InputDialog::saveConfig()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||
{
|
||||
cerr << "InputDialog::handleKeyDown: " << ascii << endl;
|
||||
// Remap key events in remap mode, otherwise pass to listwidget
|
||||
if(myEventMapper->remapMode())
|
||||
myEventMapper->handleKeyDown(ascii, keycode, modifiers);
|
||||
|
@ -192,7 +191,6 @@ cerr << "InputDialog::handleKeyDown: " << ascii << endl;
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleJoyDown(int stick, int button)
|
||||
{
|
||||
cerr << "InputDialog::handleJoyDown: stick = " << stick << ", button = " << button << endl;
|
||||
// Remap joystick buttons in remap mode, otherwise pass to listwidget
|
||||
if(myEventMapper->remapMode())
|
||||
myEventMapper->handleJoyDown(stick, button);
|
||||
|
@ -200,6 +198,16 @@ cerr << "InputDialog::handleJoyDown: stick = " << stick << ", button = " << butt
|
|||
Dialog::handleJoyDown(stick, button);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleJoyAxis(int stick, int axis, int value)
|
||||
{
|
||||
// Remap joystick axis in remap mode, otherwise pass to listwidget
|
||||
if(myEventMapper->remapMode())
|
||||
myEventMapper->handleJoyAxis(stick, axis, value);
|
||||
else
|
||||
Dialog::handleJoyAxis(stick, axis, value);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleCommand(CommandSender* sender, int cmd,
|
||||
int data, int id)
|
||||
|
|
|
@ -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: InputDialog.hxx,v 1.2 2005-11-14 17:01:19 stephena Exp $
|
||||
// $Id: InputDialog.hxx,v 1.3 2005-12-07 20:46:49 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef INPUT_DIALOG_HXX
|
||||
|
@ -38,10 +38,10 @@ class InputDialog : public Dialog
|
|||
int x, int y, int w, int h);
|
||||
~InputDialog();
|
||||
|
||||
protected:
|
||||
virtual void handleKeyDown(int ascii, int keycode, int modifiers);
|
||||
virtual void handleJoyDown(int stick, int button);
|
||||
|
||||
protected:
|
||||
virtual void handleJoyAxis(int stick, int axis, int value);
|
||||
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||
|
||||
void loadConfig();
|
||||
|
|
Loading…
Reference in New Issue