Ticket #6713: joystick_volume_6713.diff

File joystick_volume_6713.diff, 4.3 KB (added by Michael Bishop <clever@…>, 15 years ago)

patch

  • libmythui/jsmenu.h

     
    2828    QString keystring;
    2929} axisMapType;
    3030
     31typedef struct
     32{
     33    int axis;
     34    int min;
     35    int max;
     36    QString control;
     37} axisBindControl_s;
     38
    3139/**
    3240 *  \class JoystickMap
    3341 *
     
    6169            m_axisMap.push_back(new_axis);
    6270        }
    6371
     72        void AddAxisBindControl(int in_axis, int min, int max, QString in_control = "volume") {
     73            axisBindControl_s new_bind = { in_axis, min, max, in_control};
     74            m_axisBindControl.push_back(new_bind);
     75        }
     76
    6477        typedef std::vector<buttonMapType> button_map_t;
    6578        typedef std::vector<axisMapType> axis_map_t;
     79        typedef std::vector<axisBindControl_s> axisBindControl_t;
    6680        const button_map_t &buttonMap() { return m_buttonMap; }
    6781        const axis_map_t &axisMap() { return m_axisMap; }
     82        const axisBindControl_t &axisBindControl() { return m_axisBindControl; }
    6883
    6984        button_map_t m_buttonMap;
    7085        axis_map_t m_axisMap;
     86        axisBindControl_t m_axisBindControl;
    7187};
    7288
    7389/**
  • libmythui/jsmenu.cpp

     
    4141
    4242// Myth headers
    4343#include "mythverbose.h"
     44#include "libmyth/volumebase.h"
    4445
    4546// Mythui headers
    4647#include "jsmenu.h"
     
    186187                          tokens[3].toInt(), tokens[4]);
    187188        else if (firstTok.startsWith("chord") && tokens.count() == 4)
    188189            m_map.AddButton(tokens[2].toInt(), tokens[3], tokens[1].toInt());
     190        else if (firstTok.startsWith("bind_axis") && tokens.count() == 5)
     191            m_map.AddAxisBindControl(tokens[1].toInt(), tokens[2].toInt(), tokens[3].toInt(), tokens[4]);
    189192        else
    190193            VERBOSE(VB_IMPORTANT, LOC_ERROR + QString("ReadConfig(%1) "
    191194                                        "unrecognized or malformed line "
     
    377380                    EmitKey(amap->keystring);
    378381        }
    379382    }
     383    JoystickMap::axisBindControl_t::const_iterator abmap;
     384    for (abmap = m_map.axisBindControl().begin(); abmap < m_map.axisBindControl().end(); ++abmap)
     385    {
     386        if (axis == abmap->axis) {
     387            if (abmap->control == "volume") {
     388                if (vbase_hack) {
     389                    float difference = abmap->max - abmap->min;
     390                    float newvol = ((float)(value - abmap->min) / difference) * 100.0;
     391                    VERBOSE(VB_IMPORTANT, QString("updating volume to %1(translated from %2)").arg(newvol).arg(value));
     392                    vbase_hack->SetCurrentVolume(newvol);
     393                }
     394            } else {
     395                VERBOSE(VB_IMPORTANT, QString("'%1' doesnt match '%2'").arg(abmap->control).arg("volume"));
     396            }
     397        }
     398    }
    380399}
  • libmythui/libmythui.pro

     
    1010INCLUDEPATH += ../libmythdb
    1111INCLUDEPATH += ../.. ../
    1212
    13 LIBS += -L../libmythdb -lmythdb-$$LIBVERSION
     13LIBS += -L../libmythdb -lmythdb-$$LIBVERSION -L../libmyth -lmyth-$$LIBVERSION
    1414
    1515QMAKE_CLEAN += $(TARGET) $(TARGETA) $(TARGETD) $(TARGET0) $(TARGET1) $(TARGET2)
    1616
  • libmyth/volumebase.cpp

     
    66using namespace std;
    77#include "volumebase.h"
    88
     9VolumeBase *vbase_hack;
     10
    911VolumeBase::VolumeBase() :
    1012    internal_vol(false), volume(80),
    1113    current_mute_state(kMuteOff)
    1214{
     15    vbase_hack = this;
    1316}
     17VolumeBase::~VolumeBase()
     18{
     19    vbase_hack = NULL;
     20}
    1421
    1522uint VolumeBase::GetCurrentVolume(void) const
    1623{
  • libmyth/volumebase.h

     
    1818{
    1919  public:
    2020    VolumeBase();   
    21     virtual ~VolumeBase() {};
     21    virtual ~VolumeBase();
    2222
    2323    virtual uint GetCurrentVolume(void) const;
    2424    virtual void SetCurrentVolume(int value);
     
    4747
    4848};
    4949
     50extern VolumeBase *vbase_hack;
     51
    5052#endif
    5153