-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwildcatuserdriver.cpp
44 lines (29 loc) · 985 Bytes
/
wildcatuserdriver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "wildcatuserdriver.h"
#include "helpers.h"
#include <SDL.h>
#include <filesystem>
#include <fstream>
WildcatUserDriver::WildcatUserDriver(bool run) {
SDL_Log("Starting user driver...");
if (!run) {
SDL_Log("Not running inital driver setup!");
return;
}
std::filesystem::path driverPath = "/sys/bus/usb/drivers/cdc_acm/new_id";
try {
std::filesystem::create_directories(driverPath.parent_path());
SDL_Log("DriverPath = %s", driverPath.c_str());
SDL_Log("Writing to driver path...");
std::ofstream ofs(driverPath);
ofs.exceptions(std::ifstream::failbit);
const std::string driverString = "1965 0017 2 076d 0006\n";
ofs << driverString;
ofs.close();
std::ofstream cookieFile("/tmp/.wildcat_cookie");
cookieFile << "WCAT_COOKIE";
cookieFile.close();
SDL_Log("Created device files!");
} catch (std::exception &e) {
Helper_ErrorMsg("Driver failed to initalize! " + std::string(e.what()));
}
}