Ticket #6713: joystick_volume_6713.diff
File joystick_volume_6713.diff, 4.3 KB (added by , 15 years ago) |
---|
-
libmythui/jsmenu.h
28 28 QString keystring; 29 29 } axisMapType; 30 30 31 typedef struct 32 { 33 int axis; 34 int min; 35 int max; 36 QString control; 37 } axisBindControl_s; 38 31 39 /** 32 40 * \class JoystickMap 33 41 * … … 61 69 m_axisMap.push_back(new_axis); 62 70 } 63 71 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 64 77 typedef std::vector<buttonMapType> button_map_t; 65 78 typedef std::vector<axisMapType> axis_map_t; 79 typedef std::vector<axisBindControl_s> axisBindControl_t; 66 80 const button_map_t &buttonMap() { return m_buttonMap; } 67 81 const axis_map_t &axisMap() { return m_axisMap; } 82 const axisBindControl_t &axisBindControl() { return m_axisBindControl; } 68 83 69 84 button_map_t m_buttonMap; 70 85 axis_map_t m_axisMap; 86 axisBindControl_t m_axisBindControl; 71 87 }; 72 88 73 89 /** -
libmythui/jsmenu.cpp
41 41 42 42 // Myth headers 43 43 #include "mythverbose.h" 44 #include "libmyth/volumebase.h" 44 45 45 46 // Mythui headers 46 47 #include "jsmenu.h" … … 186 187 tokens[3].toInt(), tokens[4]); 187 188 else if (firstTok.startsWith("chord") && tokens.count() == 4) 188 189 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]); 189 192 else 190 193 VERBOSE(VB_IMPORTANT, LOC_ERROR + QString("ReadConfig(%1) " 191 194 "unrecognized or malformed line " … … 377 380 EmitKey(amap->keystring); 378 381 } 379 382 } 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 } 380 399 } -
libmythui/libmythui.pro
10 10 INCLUDEPATH += ../libmythdb 11 11 INCLUDEPATH += ../.. ../ 12 12 13 LIBS += -L../libmythdb -lmythdb-$$LIBVERSION 13 LIBS += -L../libmythdb -lmythdb-$$LIBVERSION -L../libmyth -lmyth-$$LIBVERSION 14 14 15 15 QMAKE_CLEAN += $(TARGET) $(TARGETA) $(TARGETD) $(TARGET0) $(TARGET1) $(TARGET2) 16 16 -
libmyth/volumebase.cpp
6 6 using namespace std; 7 7 #include "volumebase.h" 8 8 9 VolumeBase *vbase_hack; 10 9 11 VolumeBase::VolumeBase() : 10 12 internal_vol(false), volume(80), 11 13 current_mute_state(kMuteOff) 12 14 { 15 vbase_hack = this; 13 16 } 17 VolumeBase::~VolumeBase() 18 { 19 vbase_hack = NULL; 20 } 14 21 15 22 uint VolumeBase::GetCurrentVolume(void) const 16 23 { -
libmyth/volumebase.h
18 18 { 19 19 public: 20 20 VolumeBase(); 21 virtual ~VolumeBase() {};21 virtual ~VolumeBase(); 22 22 23 23 virtual uint GetCurrentVolume(void) const; 24 24 virtual void SetCurrentVolume(int value); … … 47 47 48 48 }; 49 49 50 extern VolumeBase *vbase_hack; 51 50 52 #endif 51 53