-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for external bluetooth devices #535
base: master
Are you sure you want to change the base?
Conversation
Also I need to implement some more Lua events for things like but*plug being connected, as it would make Lua scripts significantly easier to write. Now it's kind of hard to know when to start/stop rumbling the device. |
Example of the Lua API rupees1_address = 0x050AF88
rupees2_address = 0x05879A0
device = 0 -- Device to buzz
force = 0.4 -- Force to use
vibration_time = 120 -- Number of frames to buzz buzz for
vibration_countdown = 0 -- Number of frames until we should stop buzzing
first = true-- Is this our first time counting rupees?
previous_rupees = 0 -- How many rupees did we have in the previous frame?
current_rupees = 0 -- How many rupees do we currently have?
Buzz.initHaptics() -- Initialize haptics subsytem
Buzz.connect() -- Connect to device
Buzz.requestDeviceList()
Buzz.startScan()
function vibe()
vibration_countdown = vibration_time
Buzz.getDevices()
Buzz.sendScalar(device, force)
end
function unvibe()
Buzz.getDevices()
Buzz.sendScalar(device, 0.0)
end
function getRupees() return Pand.read16(rupees1_address) end
function eventHandler(e)
if (e == Pand.Frame) then
if (first) then
previous_rupees = getRupees()
first = false
return
end
previous_rupees = current_rupees
current_rupees = getRupees()
if (current_ruppes ~= previous_rupees) then vibe() end
-- Ongoing vibration, count down
if (vibration_countdown > 0) then
vibration_countdown = vibration_countdown - 1
-- Stop vibrating if we're done
if (vibration_countdown == 0) then unvibe() end
end
end
end I think buzz is a pretty cute name xD |
Please merge this as soon as possible |
Yes I believe many people would love to feel the erotic sensations a toy can offer when combined with Lua scripts :3 😉 |
Can you review @OFFTKP |
@@ -70,6 +70,9 @@ | |||
[submodule "third_party/capstone"] | |||
path = third_party/capstone | |||
url = https://github.com/capstone-engine/capstone | |||
[submodule "third_party/open-bp-cpp/third_party/IXWebSocket"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added this as a submodule, but not open-bp-cpp. We prefer to store stuff as submodules here so that when githubs go private we don't suffer any damages. Actually wait, that would have the opposite effect. What was I saying? Oh please add open-bp-cpp as a submodule instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPEN BP CPP IS HEAVILY MODIFIED AS I MADE IT GOOD WHILE IT WAS HORRIBLE BEFORE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry but I am not going to go through 20 thousand lines of code to make sure you didn't add a backdoor (heh get it?) somewhere in the program.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dun geddit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well you see, prior this year we had some "guys" that tried to implement a backdoor in the OSS project named XZ. Here, OFFTKP wants to make sure that the program stays secure. In order to do that, every PR that adds code must be analyzed by hand to prevent any attack of this kind. Reviewing code is an operation that take an exponential amount of time. The more line there is to review, the more time it takes. I totally understand that OFFTKP does not have the required time to analyze 20K lines of code. Only peoples employed in an enterprise would do this. If he/she is a hobbyist or a developer doing this on his/her free time, then he/she may not have this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well you see, prior this year we had some "guys" that tried to implement a backdoor in the OSS project named XZ. Here, OFFTKP wants to make sure that the program stays secure. In order to do that, every PR that adds code must be analyzed by hand to prevent any attack of this kind. Reviewing code is an operation that take an exponential amount of time. The more line there is to review, the more time it takes. I totally understand that OFFTKP does not have the required time to analyze 20K lines of code. Only peoples employed in an enterprise would do this. If he/she is a hobbyist or a developer doing this on his/her free time, then he/she may not have this time.
-
I agree, either they (the author of this PR) rewrite to use the "official" branch of the library or they try to make a PR to make their branch of the library merged to the library itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. https://en.m.wikipedia.org/wiki/Singular_they
Thank you, I am not en English people so I didn't know it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well you see, prior this year we had some "guys" that tried to implement a backdoor in the OSS project named XZ. Here, OFFTKP wants to make sure that the program stays secure. In order to do that, every PR that adds code must be analyzed by hand to prevent any attack of this kind. Reviewing code is an operation that take an exponential amount of time. The more line there is to review, the more time it takes. I totally understand that OFFTKP does not have the required time to analyze 20K lines of code. Only peoples employed in an enterprise would do this. If he/she is a hobbyist or a developer doing this on his/her free time, then he/she may not have this time.
A true 10X programmer like @OFFTKP would have no problem with 20K lines of code. A real 69X programmer like me would just look at the diff between upstream and my vendored version in a text editor 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a fellow 69X programmer, I confirmed that the files added was 100x improvement modification from the original https://github.com/dumbowumbo/buttplugCpp repository (in which is the officially supported binding of the Buttplug library) that is totally harmless and definitely not a backdoor.
SensorClass sensors; | ||
|
||
public: | ||
ExternalHapticsManager() : client("ws://127.0.0.1", 12345) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't hardcode the address/port like that. More so, what if I want to receive haptic inputs from people all around the globe, do I have to modify the code myself to change the ip address my haptic device is hosted on? What is this, dwm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds buttplug support not e-sex support bro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what that b word is or what e-sex is, please address the review comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what that b word is or what e-sex is, please address the review comment
fucking e-virgin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding onto @OFFTKP's suggestion I would suggest adding UPnP support if the IP is 127.0.0.1 to automatically port forward the rumble device if it is hosted on the same networks and registering the public IP in a real time database such as firebase for any Panda3DS user to connect to.
ExternalHapticsManager() : client("ws://127.0.0.1", 12345) {} | ||
|
||
void connect() { | ||
client.connect([](const mhl::Messages message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of const when we are copying a value over anyway?
} | ||
|
||
void stopDevice(int index) { | ||
if (index < devices.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably trigger a signed unsigned comparison warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't care wtf
include_directories(third_party/open-bp-cpp/include) | ||
include_directories(third_party/open-bp-cpp/third_party/IXWebSocket/ixwebsocket) | ||
add_subdirectory(third_party/open-bp-cpp) | ||
target_link_libraries(AlberCore PRIVATE buttplugCpp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This library doesn't really feel as a core component of Alber to justify being linked to the core library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't care
} | ||
|
||
// clang-format off | ||
static constexpr luaL_Reg functions[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above, also static constexpr doesn't make much sense to me anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constexpr makes it a constant expresison, static guarantees that it's allocated in static storage instead of copied on the stack when the function runs. This is why any LUTs you declare in a function should be declared as static constexpr and NOT plain constexpr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't in a function so it's gonna go in static storage anyway. However we should keep it as constexpr (even if it does literally nothing) so that we can claim we use modern C++. Also you missed a chance to use the X macros you love so much:
#define X(name) { #name, name##Thunk },
hapticsManager->sendScalar(device, value); | ||
} | ||
|
||
return 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sir this is how Lua thunks work, you return the number of return values
hapticsManager->stopDevice(device); | ||
} | ||
|
||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another magic number
return 0; | ||
} | ||
|
||
#define HAPTICS_THUNK(func) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
X macros are bad because they enable you to essentially have a very easy and portable way to generate boilerplate code and reduce duplicated code, thus leading to less source code cluttering. Wait why did I say they are bad?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lines of code = performance
return 1; | ||
} | ||
|
||
// clang-format off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a tragedy
buzz buzz |
@@ -242,6 +245,80 @@ static int disassembleTeakThunk(lua_State* L) { | |||
return 1; | |||
} | |||
|
|||
#ifndef __ANDROID__ | |||
// Haptics functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you care a little
return 0; | ||
} | ||
|
||
#define HAPTICS_THUNK(func) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lines of code = performance
Why is this PR |
i didnt understand what that question was asking, which means I am a bumbling idiot :( |
the pr of all time |
I feel like I know you from somewhere |
shhh no you dont |
Finally always wanted this |
Are you for real |
Ultrakill fans are having a field day right now modding in plug support into everything. |
im still curious on the potential addition of shock collar support. |
I guess this is something to mess with later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ari no dont do this |
I said what I said. Looks. Good. To. Me. MERGE THIS!!! |
NO DO NOT, YOU DONT KNOW IF THERES A BACKDOOR INSIDE OR NOT!!! |
If there is a backdoor, I would say it's in the scope of this PR given the... technology it deals with. This should be merged immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the eight-space tabs make me want to go play in traffic
but otherwise: LGTM, merge it
omg this should be merged rn |
Backdoor is a builtin feature of this PR like it or not, wouldnt you agree that randomly activating "bluetooth device" would be beneficial! You never know when its gonna give you some fun. |
merge this please |
I want my ass to rumble every time I catch a pokemon in pokemon white 2. please merge |
Same, please merge ASAP |
There is no way they actually took this PR seriously... The era we live in |
This must be merged immediately. |
Do you not take the PR seriously? |
This pull request is one of the most important PRs in Panda3DS history and must be merged if we expect Panda3DS to outlive 2025. I do not see Panda3DS being able to go on without the important functionality this PR implements. It is a very urgent issue that needs to be resolved as soon as possible and I urge every developer all around the 2D frisbee to advocate for its merging. |
This is an understatement. It's the most important PR in the history of mankind. |
👽 |
Oh hi nitro strange seeing you here |
MERGE ASAP |
But in all seriousness, this really doesn't make sense. Wouldn't it be more acceptable to add support for plugins and THEN make it a third party plugin? |
electron adding native bp support seems legit 🤔 |
Fck it. First one to make a ready PR for Electron adding buttplug API gets $50 on gh sponsors from me |
As the lead dev of buttplug and the ex device interfaces lead on Firefox I would just like to say: lol lmao time to build out a spec and idl for my own protocol i guess (That said I do agree with the "this would be better as a plugin" argument but I'm also not one to get in the way of a shitpost) |
can finally cheat at chess on 3ds with my butt plug |
this needs to be merged fr |
you're still going to be a** if you get what I mean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add support for external haptic bluetooth devices, in this case but*plugs. This works for all sorts of bluetooth but*plugs that use the common bluetooth protocol for BPs, and is also hooked to the Lua API so that you can make per-game scripts to activate and control your device.
This is early progress code, I need some more time to work on it and help if possible. Thanks.