Afficher l'axis x
This commit is contained in:
parent
6656022edc
commit
7246c3b853
|
@ -33,6 +33,9 @@ enum Parameters {
|
|||
kParameterTimeBeatType,
|
||||
kParameterTimeTicksPerBeat,
|
||||
kParameterTimeBeatsPerMinute,
|
||||
kParameterTabletX,
|
||||
kParameterTabletY,
|
||||
kParameterTabletPressure,
|
||||
kParameterCount
|
||||
};
|
||||
|
||||
|
|
|
@ -153,6 +153,24 @@ protected:
|
|||
parameter.name = "TimeBeatsPerMinute";
|
||||
parameter.symbol = "time_beatsperminute";
|
||||
break;
|
||||
case kParameterTabletX:
|
||||
parameter.name = "TabletX";
|
||||
parameter.symbol = "tablet_x";
|
||||
parameter.ranges.min = 0;
|
||||
parameter.ranges.max = 1024;
|
||||
break;
|
||||
case kParameterTabletY:
|
||||
parameter.name = "TabletY";
|
||||
parameter.symbol = "tablet_y";
|
||||
parameter.ranges.min = 0;
|
||||
parameter.ranges.max = 1024;
|
||||
break;
|
||||
case kParameterTabletPressure:
|
||||
parameter.name = "TabletPressure";
|
||||
parameter.symbol = "tablet_p";
|
||||
parameter.ranges.min = 0;
|
||||
parameter.ranges.max = 1024;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,6 +249,9 @@ protected:
|
|||
fParameters[kParameterTimeTicksPerBeat] = 0.0f;
|
||||
fParameters[kParameterTimeBeatsPerMinute] = 0.0f;
|
||||
}
|
||||
|
||||
//il faut seulment changer un des parametres pour mettre à jour les donnés de la tablet
|
||||
fParameters[kParameterTabletPressure] = 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -14,40 +14,60 @@ public:
|
|||
Tablet(HWND hwnd) {
|
||||
if (!hwnd) { return; }
|
||||
|
||||
if (!LoadWintab() || !gpWTInfoA(0, 0, nullptr)) {
|
||||
if (!LoadWintab() || !gpWTInfoA(0, 0, NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wintabAvailable = true;
|
||||
NewContext(hwnd);
|
||||
}
|
||||
|
||||
~Tablet() {
|
||||
gpWTClose(hctx); //Chui pas certain s'il faut fermer le context.
|
||||
UnloadWintab();
|
||||
}
|
||||
|
||||
void NewPacket() {
|
||||
//Serial number of newest packet.
|
||||
UINT oldest, newest;
|
||||
gpWTQueuePacketsEx(hctx, &oldest, &newest);
|
||||
|
||||
//Store newest packet in pkt, flush older packets.
|
||||
gpWTPacket(hctx, newest, &pkt);
|
||||
}
|
||||
|
||||
bool wintabAvailable = false;
|
||||
PACKET pkt = { 0 };
|
||||
UINT maxPressure = 1;
|
||||
|
||||
private:
|
||||
|
||||
HCTX hctx = nullptr;
|
||||
HCTX hctx = NULL;
|
||||
UINT wDevice = 0;
|
||||
AXIS TabletX = { 0 };
|
||||
AXIS TabletY = { 0 };
|
||||
AXIS TabletPressure = { 0 };
|
||||
LOGCONTEXT ctx = {};
|
||||
|
||||
void NewContext(HWND hwnd) {
|
||||
if (hctx) { gpWTClose(hctx); }
|
||||
|
||||
ctx.lcOptions |= CXO_SYSTEM;
|
||||
gpWTInfoA(WTI_DEFSYSCTX, 0, &ctx);
|
||||
ctx.lcOptions |= CXO_MESSAGES; //TODO: checker çela
|
||||
ctx.lcPktData = PACKETDATA;
|
||||
ctx.lcPktMode = PACKETMODE;
|
||||
|
||||
|
||||
//Tablet extents.
|
||||
gpWTInfoA(WTI_DEVICES, DVC_X, &TabletX);
|
||||
gpWTInfoA(WTI_DEVICES, DVC_Y, &TabletY);
|
||||
gpWTInfoA(WTI_DEVICES, DVC_NPRESSURE, &TabletPressure);
|
||||
|
||||
ctx.lcInOrgX = 0;
|
||||
ctx.lcInOrgY = 0;
|
||||
ctx.lcInExtX = TabletX.axMax;
|
||||
ctx.lcInExtY = TabletY.axMax;
|
||||
maxPressure = TabletPressure.axMax;
|
||||
|
||||
ctx.lcOutOrgX = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||
ctx.lcOutOrgY = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||
|
@ -55,6 +75,9 @@ private:
|
|||
ctx.lcOutExtY = -GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
|
||||
hctx = gpWTOpenA(hwnd, &ctx, FALSE);
|
||||
|
||||
gpWTEnable(hctx, TRUE);
|
||||
}
|
||||
|
||||
|
||||
};
|
|
@ -15,7 +15,7 @@ public:
|
|||
fResizable(isResizable()),
|
||||
fScale(1.0f),
|
||||
fScaleFactor(getScaleFactor()),
|
||||
tab(getWindow().getNativeWindowHandle())
|
||||
tab(reinterpret_cast<HWND>(getWindow().getNativeWindowHandle()))
|
||||
{
|
||||
std::memset(fParameters, 0, sizeof(float) * kParameterCount);
|
||||
std::memset(fStrBuf, 0, sizeof(char) * (0xff + 1));
|
||||
|
@ -45,6 +45,14 @@ protected:
|
|||
return;
|
||||
|
||||
fParameters[index] = value;
|
||||
|
||||
//Lire donnés de la tablet
|
||||
tab.NewPacket();
|
||||
fParameters[kParameterTabletX] = tab.pkt.pkX;
|
||||
fParameters[kParameterTabletY] = tab.pkt.pkY;
|
||||
fParameters[kParameterTabletPressure] = tab.pkt.pkNormalPressure;
|
||||
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
@ -163,6 +171,10 @@ protected:
|
|||
drawLeft(x, y, "BPM:");
|
||||
drawRight(x, y, getTextBufFloat(fParameters[kParameterTimeBeatsPerMinute]));
|
||||
y += lineHeight;
|
||||
|
||||
drawLeft(x, y, "x:");
|
||||
drawRight(x, y, getTextBufFloat(fParameters[kParameterTabletX]));
|
||||
y += lineHeight;
|
||||
}
|
||||
|
||||
void onResize(const ResizeEvent& ev) override
|
||||
|
|
|
@ -47,6 +47,7 @@ using WTMGRDEFCONTEXT = HCTX (API*)(HMGR, BOOL);
|
|||
using WTMGRDEFCONTEXTEX = HCTX (API*)(HMGR, UINT, BOOL);
|
||||
|
||||
// TODO - add more wintab32 function defs as needed
|
||||
using WTQPACKETSEX = BOOL(API*)(HCTX, UINT FAR*, UINT FAR*);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -75,6 +76,7 @@ extern WTMGRDEFCONTEXT gpWTMgrDefContext;
|
|||
extern WTMGRDEFCONTEXTEX gpWTMgrDefContextEx;
|
||||
|
||||
// TODO - add more wintab32 function pointers as needed
|
||||
extern WTQPACKETSEX gpWTQueuePacketsEx;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
Loading…
Reference in New Issue