2020-08-25 19:23:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 ndeadly
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-05-11 20:30:08 +00:00
|
|
|
#include "btdrv_shim.h"
|
|
|
|
#include <stratosphere/sf/sf_mitm_dispatch.h>
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvInitializeBluetoothFwd(Service* srv, Handle *out_handle) {
|
|
|
|
return serviceMitmDispatch(srv, 1,
|
2020-05-11 20:30:08 +00:00
|
|
|
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
2020-05-22 10:29:36 +00:00
|
|
|
.out_handles = out_handle,
|
2020-05-11 20:30:08 +00:00
|
|
|
);
|
|
|
|
}
|
2020-05-22 10:29:36 +00:00
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvFinalizeBluetoothFwd(Service* srv) {
|
|
|
|
return serviceMitmDispatch(srv, 4);
|
2020-05-22 10:29:36 +00:00
|
|
|
}
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvInitializeHidFwd(Service* srv, Handle *out_handle, u16 version) {
|
|
|
|
return serviceMitmDispatchIn(srv, 16, version,
|
2020-05-22 10:29:36 +00:00
|
|
|
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
|
|
|
.out_handles = out_handle,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-11 11:43:21 +00:00
|
|
|
Result btdrvWriteHidDataFwd(Service* srv, const BluetoothAddress *address, const BluetoothHidReport *data) {
|
2020-05-22 10:29:36 +00:00
|
|
|
const struct {
|
|
|
|
BluetoothAddress address;
|
|
|
|
} in = { *address };
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
return serviceMitmDispatchIn(srv, 19, in,
|
2020-05-22 10:29:36 +00:00
|
|
|
.buffer_attrs = { SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_In },
|
2020-07-11 11:43:21 +00:00
|
|
|
.buffers = { {data, sizeof(BluetoothHidReport)} }
|
2020-05-22 10:29:36 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvGetPairedDeviceInfoFwd(Service* srv, const BluetoothAddress *address, BluetoothDevicesSettings *device) {
|
2020-06-02 21:24:40 +00:00
|
|
|
const struct {
|
|
|
|
BluetoothAddress address;
|
|
|
|
} in = { *address };
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
return serviceMitmDispatchIn(srv, 25, in,
|
2020-06-02 21:24:40 +00:00
|
|
|
.buffer_attrs = { SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_Out },
|
|
|
|
.buffers = { {device, sizeof(BluetoothDevicesSettings)} }
|
|
|
|
);
|
|
|
|
}
|
2020-06-22 21:14:54 +00:00
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvFinalizeHidFwd(Service* srv) {
|
|
|
|
return serviceMitmDispatch(srv, 26);
|
2020-05-22 10:29:36 +00:00
|
|
|
}
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvRegisterHidReportEventFwd(Service* srv, Handle *out_handle) {
|
|
|
|
return serviceMitmDispatch(srv, hosversionBefore(4, 0, 0) ? 36 : 37,
|
2020-05-22 10:29:36 +00:00
|
|
|
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
|
|
|
.out_handles = out_handle,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvGetHidReportEventInfoFwd(Service* srv, Handle *out_handle) {
|
|
|
|
return serviceMitmDispatch(srv, 38,
|
2020-05-22 10:29:36 +00:00
|
|
|
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
|
|
|
.out_handles = out_handle,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvInitializeBleFwd(Service* srv, Handle *out_handle) {
|
|
|
|
return serviceMitmDispatch(srv, 46,
|
2020-05-22 10:29:36 +00:00
|
|
|
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
|
|
|
.out_handles = out_handle,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-15 09:05:41 +00:00
|
|
|
Result btdrvFinalizeBleFwd(Service* srv) {
|
|
|
|
return serviceMitmDispatch(srv, 49);
|
2020-05-22 10:29:36 +00:00
|
|
|
}
|