mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-05 06:42:57 +12:00
Implement support to sensors (#618)
* Implement sensors * Fix memory leak in accel
This commit is contained in:
parent
cdc61ea95a
commit
8cf0fbef1b
7 changed files with 169 additions and 23 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "renderer_gl/renderer_gl.hpp"
|
||||
#include "services/hid.hpp"
|
||||
#include "android_utils.hpp"
|
||||
#include "sdl_sensors.hpp"
|
||||
|
||||
std::unique_ptr<Emulator> emulator = nullptr;
|
||||
HIDService* hidService = nullptr;
|
||||
|
@ -110,6 +111,19 @@ AlberFunction(void, TouchScreenUp)(JNIEnv* env, jobject obj) { hidService->relea
|
|||
AlberFunction(void, KeyUp)(JNIEnv* env, jobject obj, jint keyCode) { hidService->releaseKey((u32)keyCode); }
|
||||
AlberFunction(void, KeyDown)(JNIEnv* env, jobject obj, jint keyCode) { hidService->pressKey((u32)keyCode); }
|
||||
|
||||
AlberFunction(void, SetGyro)(JNIEnv* env, jobject obj, jfloat roll, jfloat pitch, jfloat yaw) {
|
||||
auto rotation = Sensors::SDL::convertRotation({ float(roll), float(pitch), float(yaw) });
|
||||
hidService->setPitch(s16(rotation.x));
|
||||
hidService->setRoll(s16(rotation.y));
|
||||
hidService->setYaw(s16(rotation.z));
|
||||
}
|
||||
|
||||
AlberFunction(void, SetAccel)(JNIEnv* env, jobject obj, jfloat rawX, jfloat rawY, jfloat rawZ) {
|
||||
float data[3] = { float(rawX), float(rawY), float(rawZ) };
|
||||
auto accel = Sensors::SDL::convertAcceleration(data);
|
||||
hidService->setAccel(accel.x, accel.y, accel.z);
|
||||
}
|
||||
|
||||
AlberFunction(void, SetCirclepadAxis)(JNIEnv* env, jobject obj, jint x, jint y) {
|
||||
hidService->setCirclepadX((s16)x);
|
||||
hidService->setCirclepadY((s16)y);
|
||||
|
@ -139,4 +153,4 @@ int AndroidUtils::openDocument(const char* path, const char* perms) {
|
|||
env->DeleteLocalRef(jmode);
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue