diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 58a108b..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "configurations": [ - { - "name": "(Windows) Launch", - "type": "cppvsdbg", - "request": "launch", - "program": "${config:ps4emu.exe}", - "args": ["-f", "${workspaceRoot}\\..\\", "-e", "${workspaceRoot}\\..\\eboot.bin", "-pad", "sdl2"], - "stopAtEntry": false, - "cwd": "${config:ps4emu.path}", - "environment": [], - "console": "integratedTerminal", - "preLaunchTask": "Build" - } - - ] -} diff --git a/input/controller.cpp b/input/controller.cpp index be36595..9b661d2 100644 --- a/input/controller.cpp +++ b/input/controller.cpp @@ -3,13 +3,14 @@ Controller::Controller() { this->currPadColor = 0; - this->padColors[0] = {0x00, 0xff, 0x00}; - this->padColors[1] = {0xff, 0x00, 0x00}; - this->padColors[2] = {0x00, 0x00, 0xff}; - this->padColors[3] = {0xff, 0xff, 0x00}; - this->padColors[4] = {0xff, 0x00, 0xff}; - this->padColors[5] = {0x00, 0xff, 0xff}; - this->padColors[6] = {0xff, 0xff, 0xff}; + this->padColors[0] = {0xff, 0xff, 0xff}; + this->padColors[1] = {0x00, 0xff, 0x00}; + this->padColors[2] = {0xff, 0x00, 0x00}; + this->padColors[3] = {0x00, 0x00, 0xff}; + this->padColors[4] = {0xff, 0xff, 0x00}; + this->padColors[5] = {0xff, 0x00, 0xff}; + this->padColors[6] = {0x00, 0xff, 0xff}; + this->padColors[7] = {0xff, 0xff, 0xff}; } Controller::~Controller() {} @@ -160,8 +161,9 @@ bool Controller::TouchpadPressed() { return CheckButtonsPressed(ORBIS_PAD_BUTTON_TOUCH_PAD); } -void Controller::NextColor() { +OrbisPadColor Controller::NextColor() { scePadSetLightBar(this->pad, &this->padColors[this->currPadColor = (this->currPadColor + 1) % 7]); + return this->padColors[this->currPadColor]; } void Controller::ReadSticks(float *leftx, float *lefty, float *rightx, float *righty) { diff --git a/input/controller.h b/input/controller.h index f02621e..832ff31 100644 --- a/input/controller.h +++ b/input/controller.h @@ -12,7 +12,7 @@ class Controller int buttonState; int currPadColor; OrbisPadData padData; - OrbisPadColor padColors[7]; + OrbisPadColor padColors[8]; void setButtonState(int state); public: @@ -41,7 +41,7 @@ class Controller bool TouchpadPressed(); int ReadFingers(OrbisPadTouch **fingers); void ReadSticks(float *leftx, float *lefty, float *rightx, float *righty); - void NextColor(); + OrbisPadColor NextColor(); }; #endif diff --git a/input/main.cpp b/input/main.cpp index 3f87f92..49da550 100644 --- a/input/main.cpp +++ b/input/main.cpp @@ -14,13 +14,27 @@ std::stringstream debugLogStream; int frameID = 0; -Color bgColor; -int main(void) { - int rc; - int video; - int curFrame = 0; +static void repaintBar(PNG *png, OrbisPadColor newColor) { + static uint32_t prevColor = 0xFFFFFFFF; + uint32_t newColorU32 = + ((uint32_t)newColor.r << 00) | + ((uint32_t)newColor.g << 8) | + ((uint32_t)newColor.b << 16); + if (prevColor == newColorU32) return; + static int32_t iWidth = 0, iHeight = 0; + auto idata = png->GetImgData(&iWidth, &iHeight); + for (int x = 840; x < 1079; x++) { + for (int y = 323; y < 474; y++) { + ptrdiff_t off = (y * iWidth) + x; + if (prevColor == idata[off]) + idata[off] = newColorU32; + } + } + prevColor = newColorU32; +} +int main(void) { // No buffering setvbuf(stdout, NULL, _IONBF, 0); // Create a 2D scene @@ -66,7 +80,7 @@ int main(void) { triangleBtn->Draw(scene, 1187, 359); released = false; } else if (released == false) { - controller->NextColor(); + repaintBar(controllerBackground, controller->NextColor()); released = true; } diff --git a/input/png.cpp b/input/png.cpp index 48c89c6..2712051 100644 --- a/input/png.cpp +++ b/input/png.cpp @@ -23,6 +23,12 @@ PNG::~PNG() stbi_image_free(this->img); } +uint32_t *PNG::GetImgData(int *width, int *height) { + if (width != NULL) *width = this->width; + if (height != NULL) *height = this->height; + return this->img; +} + void PNG::Draw(Scene2D *scene, int startX, int startY) { // Don't draw non-existant images diff --git a/input/png.h b/input/png.h index 3f08c8e..096bafd 100644 --- a/input/png.h +++ b/input/png.h @@ -13,6 +13,7 @@ class PNG { PNG(const char *imagePath); ~PNG(); + uint32_t *GetImgData(int *width = NULL, int *height = NULL); void Draw(Scene2D *scene, int startX, int startY); };