On Wednesday 19 December 2007 02:05:59 Robin Sheat wrote: > Some more patchy-goodness. This is against head, again. And this one is just the same, but as an added bonus, it lets you compile with djconsole_legacy off as well.
-- Robin <[EMAIL PROTECTED]> JabberID: <[EMAIL PROTECTED]> Hostes alienigeni me abduxerunt. Qui annus est? PGP Key 0xA99CEB6D = 5957 6D23 8B16 EFAB FEF8 7175 14D3 6485 A99C EB6D
Index: herculeslinux.h
===================================================================
--- herculeslinux.h (revision 1696)
+++ herculeslinux.h (working copy)
@@ -98,22 +98,22 @@
const int kiHerculesCrossfade = 0x28;
// TODO: 1.5.0+ investigate and revise led codes
-const int kiHerculesLedRightSync = 0;
-const int kiHerculesLedLeftLoop = 1;
-const int kiHerculesLedRightLoop = 2;
-const int kiHerculesLedLeftMasterTempo = 3;
-const int kiHerculesLedRightMasterTempo = 4;
-const int kiHerculesLedLeftFx = 5;
-const int kiHerculesLedRightFx = 6;
-const int kiHerculesLedRightCueLamp = 7;
-const int kiHerculesLedRightCueBtn = 8;
-const int kiHerculesLedRightPlay = 9;
-const int kiHerculesLedLeftCueLamp = 10;
-const int kiHerculesLedLeftPlay = 11;
-const int kiHerculesLedLeftHeadphone = 12;
-const int kiHerculesLedRightHeadphone = 13;
-const int kiHerculesLedLeftCueBtn = 14;
-const int kiHerculesLedLeftSync = 15;
+const int kiHerculesLedRightSync = 0x0D;
+const int kiHerculesLedLeftLoop = 0x0E;
+const int kiHerculesLedRightLoop = 0x0F;
+const int kiHerculesLedLeftMasterTempo = 0x00;
+const int kiHerculesLedRightMasterTempo = 0x01;
+const int kiHerculesLedLeftFx = 0x02;
+const int kiHerculesLedRightFx = 0x03;
+const int kiHerculesLedRightCueLamp = 0x04;
+const int kiHerculesLedRightCueBtn = 0x05;
+//const int kiHerculesLedRightPlay = 9; // doesn't exist
+const int kiHerculesLedLeftCueLamp = 0x07;
+//const int kiHerculesLedLeftPlay = 11; // doesn't exist
+const int kiHerculesLedLeftHeadphone = 0x09;
+const int kiHerculesLedRightHeadphone = 0x0A;
+const int kiHerculesLedLeftCueBtn = 0x0B;
+const int kiHerculesLedLeftSync = 0x0C;
#define __THOMAS_HERC__
#ifdef __THOMAS_HERC__
@@ -164,7 +164,10 @@
double m_dJogLeftOld, m_dJogRightOld;
+ //double PitchChange(const QString ControlSide, const int ev_value, int &m_iPitchPrevious, int &m_iPitchOffset);
+ int PitchChangeOrdinal(const QString ControlSide, const int ev_value, int &m_iPitchPrevious, int &m_iPitchOffset);
double PitchChange(const QString ControlSide, const int ev_value, int &m_iPitchPrevious, int &m_iPitchOffset);
+ bool m_bClearLeftPitchPlus, m_bClearLeftPitchMinus, m_bClearRightPitchPlus, m_bClearRightPitchMinus;
};
#endif
Index: herculeslinuxlegacy.cpp
===================================================================
--- herculeslinuxlegacy.cpp (revision 1696)
+++ herculeslinuxlegacy.cpp (working copy)
@@ -18,8 +18,12 @@
m_dJogRightOld = 0.;
m_iPitchOffsetLeft=-9999;
m_iPitchOffsetRight=-9999;
- m_iPitchLeft = 127;
- m_iPitchRight = 127;
+ m_iPitchLeft = -1;
+ m_iPitchRight = -1;
+ m_bClearLeftPitchPlus=false;
+ m_bClearLeftPitchMinus=false;
+ m_bClearRightPitchPlus=false;
+ m_bClearRightPitchMinus=false;
}
HerculesLinux::~HerculesLinux()
@@ -30,30 +34,73 @@
{
while (1)
{
+
getNextEvent();
if (m_pControlObjectLeftBtnPlayProxy->get()!=m_bPlayLeft)
{
m_bPlayLeft=!m_bPlayLeft;
- led_write(kiHerculesLedLeftPlay, m_bPlayLeft);
+ led_write(kiHerculesLedLeftCueBtn, m_bPlayLeft);
}
if (m_pControlObjectRightBtnPlayProxy->get()!=m_bPlayRight)
{
m_bPlayRight=!m_bPlayRight;
- led_write(kiHerculesLedRightPlay, m_bPlayRight);
+ led_write(kiHerculesLedRightCueBtn, m_bPlayRight);
}
if (m_pControlObjectLeftBtnLoopProxy->get()!=m_bLoopLeft)
{
m_bLoopLeft=!m_bLoopLeft;
- led_write(kiHerculesLedLeftCueBtn, m_bLoopLeft);
+ //led_write(kiHerculesLedLeftCueBtn, m_bLoopLeft);
}
if (m_pControlObjectRightBtnLoopProxy->get()!=m_bLoopRight)
{
m_bLoopRight=!m_bLoopRight;
- led_write(kiHerculesLedRightCueBtn, m_bLoopRight);
+ //led_write(kiHerculesLedRightCueBtn, m_bLoopRight);
}
- m_bHeadphoneLeft=m_pControlObjectLeftBtnHeadphoneProxy->get();
- m_bHeadphoneRight=m_pControlObjectRightBtnHeadphoneProxy->get();
+ if (m_pControlObjectLeftBtnHeadphoneProxy->get() != m_bHeadphoneLeft) {
+ m_bHeadphoneLeft=!m_bHeadphoneLeft;
+ led_write(kiHerculesLedLeftHeadphone, m_bHeadphoneLeft);
+ }
+ if (m_pControlObjectRightBtnHeadphoneProxy->get() != m_bHeadphoneRight) {
+ m_bHeadphoneRight=!m_bHeadphoneRight;
+ led_write(kiHerculesLedRightHeadphone, m_bHeadphoneRight);
+ }
+ int leftVU = (int)(m_pControlObjectLeftVuMeter->get()*4.0);
+ if (leftVU != m_iLeftVU) {
+ m_iLeftVU = leftVU;
+ led_write(kiHerculesLedLeftFx, leftVU == 3);
+ led_write(kiHerculesLedLeftCueLamp, leftVU > 1);
+ led_write(kiHerculesLedLeftLoop, leftVU > 0);
+ }
+ int rightVU = (int)(m_pControlObjectRightVuMeter->get()*4.0);
+ if (rightVU != m_iRightVU) {
+ m_iRightVU = rightVU;
+ led_write(kiHerculesLedRightFx, rightVU == 3);
+ led_write(kiHerculesLedRightCueLamp, rightVU > 1);
+ led_write(kiHerculesLedRightLoop, rightVU > 0);
+ }
+ // We wait as long as possible to do this, otherwise we reset too
+ // quick, and the faked press is never picked up.
+ // (note: this currently isn't used, as no matter where I put it
+ // it's too fast. A better solution would be to find/make a relative
+ // shifter interface)
+ if (m_bClearLeftPitchPlus) {
+ m_bClearLeftPitchPlus = false;
+ sendButtonEvent(0,m_pControlObjectLeftBtnPitchBendPlus);
+ }
+ if (m_bClearLeftPitchMinus) {
+ m_bClearLeftPitchMinus = false;
+ sendButtonEvent(0,m_pControlObjectLeftBtnPitchBendMinus);
+ }
+ if (m_bClearRightPitchPlus) {
+ m_bClearRightPitchPlus = false;
+ sendButtonEvent(0,m_pControlObjectRightBtnPitchBendPlus);
+ }
+ if (m_bClearRightPitchMinus) {
+ m_bClearRightPitchMinus = false;
+ sendButtonEvent(0,m_pControlObjectRightBtnPitchBendMinus);
+ }
+
}
}
@@ -78,8 +125,8 @@
// Turn off led
led_write(kiHerculesLedLeftCueBtn, false);
led_write(kiHerculesLedRightCueBtn, false);
- led_write(kiHerculesLedLeftPlay, false);
- led_write(kiHerculesLedRightPlay, false);
+// led_write(kiHerculesLedLeftPlay, false);
+// led_write(kiHerculesLedRightPlay, false);
led_write(kiHerculesLedLeftSync, false);
led_write(kiHerculesLedRightSync, false);
led_write(kiHerculesLedLeftHeadphone, false);
@@ -204,7 +251,8 @@
//qDebug("code %i",ev.code);
int iDiff;
double dDiff;
-
+ int pitchValue;
+
switch (ev.code)
{
case kiHerculesLeftTreble:
@@ -221,8 +269,15 @@
sendEvent(ev.value/d1, m_pControlObjectLeftVolume);
break;
case kiHerculesLeftPitch:
- //qDebug("");
- sendEvent(PitchChange("Left", ev.value, m_iPitchLeft, m_iPitchOffsetLeft), m_pControlObjectLeftPitch);
+ pitchValue = PitchChangeOrdinal("Left", ev.value, m_iPitchLeft, m_iPitchOffsetLeft);
+ if (pitchValue > 0) {
+ for (int i=0; i<pitchValue; i++)
+ sendButtonEvent(1, m_pControlObjectLeftBtnPitchBendPlus);
+ } else {
+ for (int i=0; i>pitchValue; i--)
+ sendButtonEvent(1, m_pControlObjectLeftBtnPitchBendMinus);
+ }
+// sendEvent(PitchChange("Left", ev.value, m_iPitchLeft, m_iPitchOffsetLeft), m_pControlObjectLeftPitch);
break;
case kiHerculesLeftJog:
iDiff = 0;
@@ -253,7 +308,17 @@
break;
case kiHerculesRightPitch:
//qDebug("");
- sendEvent(PitchChange("Right", ev.value, m_iPitchRight, m_iPitchOffsetRight), m_pControlObjectRightPitch);
+ pitchValue = PitchChangeOrdinal("Right", ev.value, m_iPitchRight, m_iPitchOffsetRight);
+ if (pitchValue > 0) {
+ for (int i=0; i<pitchValue; i++) {
+ sendButtonEvent(1, m_pControlObjectRightBtnPitchBendPlus);
+ }
+ } else {
+ for (int i=0; i>pitchValue; i--) {
+ sendButtonEvent(1, m_pControlObjectRightBtnPitchBendMinus);
+ }
+ }
+// sendEvent(PitchChange("Right", ev.value, m_iPitchRight, m_iPitchOffsetRight), m_pControlObjectRightPitch);
break;
case kiHerculesRightJog:
iDiff = 0;
@@ -336,13 +401,13 @@
case kiHerculesLeftBtnHeadphone:
if (ev.value) {
- led_write(kiHerculesLedLeftHeadphone, !m_pControlObjectLeftBtnHeadphone->get());
+ //led_write(kiHerculesLedLeftHeadphone, !m_pControlObjectLeftBtnHeadphone->get());
sendButtonEvent(!m_bHeadphoneLeft, m_pControlObjectLeftBtnHeadphone);
}
break;
case kiHerculesRightBtnHeadphone:
if (ev.value) {
- led_write(kiHerculesLedRightHeadphone, !m_pControlObjectRightBtnHeadphone->get());
+ //led_write(kiHerculesLedRightHeadphone, !m_pControlObjectRightBtnHeadphone->get());
sendButtonEvent(!m_bHeadphoneRight, m_pControlObjectRightBtnHeadphone);
}
break;
@@ -454,15 +519,15 @@
struct input_event ev;
memset(&ev, 0, sizeof(struct input_event));
- //ev.type = EV_LED;
- ev.type = 0x0000;
+ ev.type = EV_LED;
+ //ev.type = 0x0000;
ev.code = iLed;
if (bOn)
- ev.value = 3;
+ ev.value = 1;
else
ev.value = 0;
- //qDebug("Hercules: led_write(iLed=%d, bOn=%d)", iLed, bOn);
+ //qDebug("Hercules: led_write(iLed=%d, value=%d)", iLed, ev.value);
if (write(m_iFd, &ev, sizeof(struct input_event)) != sizeof(struct input_event))
qDebug("Hercules: write(): %s", strerror(errno));
@@ -484,12 +549,12 @@
}
}
-double HerculesLinux::PitchChange(const QString ControlSide, const int ev_value, int &m_iPitchPrevious, int &m_iPitchOffset) {
+/*double HerculesLinux::PitchChange(const QString ControlSide, const int ev_value, int &m_iPitchPrevious, int &m_iPitchOffset) {
// Handle the initial event from the Hercules and set pitch to default of 0% change
if (m_iPitchPrevious < 0) {
m_iPitchOffset = ev_value;
m_iPitchPrevious = 64;
- return m_iPitchPrevious;
+ return ((m_iPitchPrevious+1)-64)/64.;
}
int delta = ev_value - m_iPitchOffset;
@@ -520,5 +585,28 @@
// old range was 0..127
// new range is -1.0 to 1.0
return ((m_iPitchPrevious+1) - 64)/64.;
+}*/
+
+/*
+ The old version of this sets the absolute pitch, but the herc doesn't have
+ an absolute pitch slider, so this treats it like a pitch bend. This function
+ returns the number of fake button presses that should be performed.
+*/
+int HerculesLinux::PitchChangeOrdinal(const QString ControlSide, const int ev_value, int &m_iPitchPrevious, int &m_iPitchOffset) {
+ // We have to ignore the first value we get here, as that lets us calibrate.
+ // We don't know which way they've turned it. A better option would be
+ // either to query it on start, or reset the device. I don't know how to
+ // do either through the event interface.
+ if (m_iPitchPrevious < 0)
+ m_iPitchPrevious = ev_value;
+ int delta = ev_value - m_iPitchPrevious;
+ if (delta >= 240) {
+ delta = (255 - delta) * -1;
+ } else if (delta <= -240) {
+ delta = 255 + delta;
+ }
+ m_iPitchPrevious = ev_value;
+ return delta;
}
+
Index: hercules.cpp
===================================================================
--- hercules.cpp (revision 1696)
+++ hercules.cpp (working copy)
@@ -61,6 +61,11 @@
m_pControlObjectLeftBtnHeadphoneProxy = new ControlObjectThread(ControlObject::getControl(ConfigKey("[Channel1]","pfl")));
m_pControlObjectRightBtnHeadphoneProxy = new ControlObjectThread(ControlObject::getControl(ConfigKey("[Channel2]","pfl")));
+ m_pControlObjectLeftVuMeter = new ControlObjectThread(ControlObject::getControl(ConfigKey("[Channel1]","VuMeter")));
+ Q_ASSERT(m_pControlObjectLeftVuMeter != 0);
+ m_pControlObjectRightVuMeter = new ControlObjectThread(ControlObject::getControl(ConfigKey("[Channel2]","VuMeter")));
+ Q_ASSERT(m_pControlObjectRightVuMeter != 0);
+
selectMapping(kqInputMappingHerculesStandard);
m_pRotaryLeft = new Rotary();
@@ -165,6 +170,7 @@
m_pControlObjectRightBtn123[1] = m_pControlObjectRightBtn2;
m_pControlObjectRightBtn123[2] = m_pControlObjectRightBtn3;
m_pControlObjectRightBtnFx = new ControlObjectThread(new ControlObject(ConfigKey("[Channel2]","Hercules4")));
+
}
void Hercules::changeJogMode(int iLeftFxMode, int iRightFxMode)
Index: hercules.h
===================================================================
--- hercules.h (revision 1696)
+++ hercules.h (working copy)
@@ -103,7 +103,7 @@
Rotary *m_pRotaryLeft, *m_pRotaryRight;
ControlObjectThread *m_pControlObjectLeftBeatLoop, *m_pControlObjectRightBeatLoop;
-
+ ControlObjectThread *m_pControlObjectLeftVuMeter, *m_pControlObjectRightVuMeter;
QString m_qMapping;
@@ -114,6 +114,7 @@
m_bSyncLeft, m_bSyncRight;
double m_dLeftVolumeOld, m_dRightVolumeOld;
+ int m_iLeftVU, m_iRightVU;
};
#endif
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ Mixxx-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mixxx-devel
