Afficher l'axis x

This commit is contained in:
yaw-man 2022-08-09 12:54:02 -03:00
parent 6656022edc
commit 7246c3b853
5 changed files with 65 additions and 4 deletions

View File

@ -33,6 +33,9 @@ enum Parameters {
kParameterTimeBeatType, kParameterTimeBeatType,
kParameterTimeTicksPerBeat, kParameterTimeTicksPerBeat,
kParameterTimeBeatsPerMinute, kParameterTimeBeatsPerMinute,
kParameterTabletX,
kParameterTabletY,
kParameterTabletPressure,
kParameterCount kParameterCount
}; };

View File

@ -153,6 +153,24 @@ protected:
parameter.name = "TimeBeatsPerMinute"; parameter.name = "TimeBeatsPerMinute";
parameter.symbol = "time_beatsperminute"; parameter.symbol = "time_beatsperminute";
break; 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[kParameterTimeTicksPerBeat] = 0.0f;
fParameters[kParameterTimeBeatsPerMinute] = 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;
} }
/* -------------------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------------------

View File

@ -14,40 +14,60 @@ public:
Tablet(HWND hwnd) { Tablet(HWND hwnd) {
if (!hwnd) { return; } if (!hwnd) { return; }
if (!LoadWintab() || !gpWTInfoA(0, 0, nullptr)) { if (!LoadWintab() || !gpWTInfoA(0, 0, NULL)) {
return; return;
} }
wintabAvailable = true;
NewContext(hwnd); NewContext(hwnd);
} }
~Tablet() { ~Tablet() {
gpWTClose(hctx); //Chui pas certain s'il faut fermer le context.
UnloadWintab(); 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: private:
HCTX hctx = nullptr; HCTX hctx = NULL;
UINT wDevice = 0; UINT wDevice = 0;
AXIS TabletX = { 0 }; AXIS TabletX = { 0 };
AXIS TabletY = { 0 }; AXIS TabletY = { 0 };
AXIS TabletPressure = { 0 };
LOGCONTEXT ctx = {}; LOGCONTEXT ctx = {};
void NewContext(HWND hwnd) { void NewContext(HWND hwnd) {
if (hctx) { gpWTClose(hctx); }
ctx.lcOptions |= CXO_SYSTEM; ctx.lcOptions |= CXO_SYSTEM;
gpWTInfoA(WTI_DEFSYSCTX, 0, &ctx); gpWTInfoA(WTI_DEFSYSCTX, 0, &ctx);
ctx.lcOptions |= CXO_MESSAGES; //TODO: checker çela ctx.lcOptions |= CXO_MESSAGES; //TODO: checker çela
ctx.lcPktData = PACKETDATA; ctx.lcPktData = PACKETDATA;
ctx.lcPktMode = PACKETMODE; ctx.lcPktMode = PACKETMODE;
//Tablet extents.
gpWTInfoA(WTI_DEVICES, DVC_X, &TabletX); gpWTInfoA(WTI_DEVICES, DVC_X, &TabletX);
gpWTInfoA(WTI_DEVICES, DVC_Y, &TabletY); gpWTInfoA(WTI_DEVICES, DVC_Y, &TabletY);
gpWTInfoA(WTI_DEVICES, DVC_NPRESSURE, &TabletPressure);
ctx.lcInOrgX = 0; ctx.lcInOrgX = 0;
ctx.lcInOrgY = 0; ctx.lcInOrgY = 0;
ctx.lcInExtX = TabletX.axMax; ctx.lcInExtX = TabletX.axMax;
ctx.lcInExtY = TabletY.axMax; ctx.lcInExtY = TabletY.axMax;
maxPressure = TabletPressure.axMax;
ctx.lcOutOrgX = GetSystemMetrics(SM_XVIRTUALSCREEN); ctx.lcOutOrgX = GetSystemMetrics(SM_XVIRTUALSCREEN);
ctx.lcOutOrgY = GetSystemMetrics(SM_YVIRTUALSCREEN); ctx.lcOutOrgY = GetSystemMetrics(SM_YVIRTUALSCREEN);
@ -55,6 +75,9 @@ private:
ctx.lcOutExtY = -GetSystemMetrics(SM_CYVIRTUALSCREEN); ctx.lcOutExtY = -GetSystemMetrics(SM_CYVIRTUALSCREEN);
hctx = gpWTOpenA(hwnd, &ctx, FALSE); hctx = gpWTOpenA(hwnd, &ctx, FALSE);
gpWTEnable(hctx, TRUE);
} }
}; };

View File

@ -15,7 +15,7 @@ public:
fResizable(isResizable()), fResizable(isResizable()),
fScale(1.0f), fScale(1.0f),
fScaleFactor(getScaleFactor()), fScaleFactor(getScaleFactor()),
tab(getWindow().getNativeWindowHandle()) tab(reinterpret_cast<HWND>(getWindow().getNativeWindowHandle()))
{ {
std::memset(fParameters, 0, sizeof(float) * kParameterCount); std::memset(fParameters, 0, sizeof(float) * kParameterCount);
std::memset(fStrBuf, 0, sizeof(char) * (0xff + 1)); std::memset(fStrBuf, 0, sizeof(char) * (0xff + 1));
@ -45,6 +45,14 @@ protected:
return; return;
fParameters[index] = value; 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(); repaint();
} }
@ -163,6 +171,10 @@ protected:
drawLeft(x, y, "BPM:"); drawLeft(x, y, "BPM:");
drawRight(x, y, getTextBufFloat(fParameters[kParameterTimeBeatsPerMinute])); drawRight(x, y, getTextBufFloat(fParameters[kParameterTimeBeatsPerMinute]));
y += lineHeight; y += lineHeight;
drawLeft(x, y, "x:");
drawRight(x, y, getTextBufFloat(fParameters[kParameterTabletX]));
y += lineHeight;
} }
void onResize(const ResizeEvent& ev) override void onResize(const ResizeEvent& ev) override

View File

@ -47,6 +47,7 @@ using WTMGRDEFCONTEXT = HCTX (API*)(HMGR, BOOL);
using WTMGRDEFCONTEXTEX = HCTX (API*)(HMGR, UINT, BOOL); using WTMGRDEFCONTEXTEX = HCTX (API*)(HMGR, UINT, BOOL);
// TODO - add more wintab32 function defs as needed // 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; extern WTMGRDEFCONTEXTEX gpWTMgrDefContextEx;
// TODO - add more wintab32 function pointers as needed // TODO - add more wintab32 function pointers as needed
extern WTQPACKETSEX gpWTQueuePacketsEx;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////