| 385 | } |
| 386 | |
| 387 | bool Push2Control::Initialize() |
| 388 | { |
| 389 | if (!ThePushBridge.IsInitialized()) |
| 390 | { |
| 391 | if (auto result = ThePushBridge.Init(); result.Failed()) |
| 392 | { |
| 393 | mPushBridgeInitErrMsg = result.GetDescription(); |
| 394 | ofLog() << mPushBridgeInitErrMsg; |
| 395 | return false; |
| 396 | } |
| 397 | ofLog() << "push 2 connected"; |
| 398 | } |
| 399 | |
| 400 | mPixels = new unsigned char[GetNumDisplayPixels()]; |
| 401 | |
| 402 | mFontHandle = nvgCreateFont(sVG, ofToResourcePath("frabk.ttf").c_str(), ofToResourcePath("frabk.ttf").c_str()); |
| 403 | mFontHandleBold = nvgCreateFont(sVG, ofToResourcePath("frabk_m.ttf").c_str(), ofToResourcePath("frabk_m.ttf").c_str()); |
| 404 | |
| 405 | const std::vector<std::string>& devices = mDevice.GetPortList(false); |
| 406 | for (int i = 0; i < devices.size(); ++i) |
| 407 | { |
| 408 | #if JUCE_WINDOWS |
| 409 | if (strcmp(devices[i].c_str(), "Ableton Push 2") == 0) |
| 410 | #else |
| 411 | if (strcmp(devices[i].c_str(), "Ableton Push 2 Live Port") == 0) |
| 412 | #endif |
| 413 | { |
| 414 | mDevice.ConnectOutput(i); |
| 415 | mDevice.ConnectInput(devices[i].c_str()); |
| 416 | |
| 417 | std::string touchStripConfig = { 0x00, 0x21, 0x1D, 0x01, 0x01, 0x17, 0x03 }; |
| 418 | mDevice.SendSysEx(touchStripConfig); |
| 419 | break; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | return true; |
| 424 | } |
| 425 | |
| 426 | int Push2Control::GetNumDisplayPixels() const |
| 427 | { |
no test coverage detected