Closed zappybiby closed 7 years ago
I apologize for making this large pull request. I do not know how to break this up.
If you want, you can fork from https://github.com/bethesirius/ChosunTruck/commit/a052ca5c8de5dbec7f7856a4861fed243558926c and make the changes noted here https://github.com/bethesirius/ChosunTruck/pull/7/commits/501083326c7ff1587f5365bc4550337735653b6d to basically come to the point I am at. This avoids the excessive formatting.
Note: I have no idea what I'm doing and have no prior coding experience. I couldn't even make a "Hello World" in C++ if you asked me right now. Merge with caution!
Main changes: Creating a framework to get input working in Windows. Formatted the solution. Fixed the freezing issue that was preventing https://github.com/bethesirius/ChosunTruck/commit/a052ca5c8de5dbec7f7856a4861fed243558926c from working.
Current Status: Pauses after the first "go straight" command, then after a couple of seconds it finds lines and adjusts accordingly. Line detection does freeze at some moments, and it seems to always want to go left when it should be going straight.
Fixed Problems: Freezing: Turns out that I had to change "unsigned char" to "uchar" (as is needed for CV_8U matrix in OpenCV 3.0). This fixed the memory leak that was causing program to freeze.
Input: KEYEVENTF_SCANCODE isn't actually defined, I'm switching to KEYEVENTF_UNICODE (Although this still doesn't work in ETS2). I originally used SCANCODE to make SendInput use hardware scan codes. Since SendInput works at a lower level than WM_KEYDOWN and keybd_event, my intention was to get input to work with programs like ETS2 that don't work with virtual key inputs. In my current build, Spy++ does not register any messages being sent to the Prism3d window. Although keybd_event was not working originally, it is possible that it may work now. Read more here
Current issues: Input: Unfortunately, input isn't working. Prism3d uses DirectInput (which is actually a wrapper for RawInput) so we will need to adapt code to this. Read more here
Debug: Also worth nothing that Debug build is failing to run with error
This error doesn't seem to affect the Release build. This error is usually caused by the Mat being of an invalid type. However since we are using hwnd2mat, it is hard to identify where we are giving the Mat it's type.