Skip to content

Commit

Permalink
BT Service: initial skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoquesada committed Nov 27, 2023
1 parent ca7bf98 commit 9b7e1b7
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 5 deletions.
4 changes: 4 additions & 0 deletions examples/linux/my_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ static void pc_debug_on_init_complete(void) {
logi("pc_debug: on_init_complete()\n");

// Safe to call "unsafe" functions since they are called from BT thread
if (g_delete_keys)
uni_bt_del_keys_unsafe();
else
uni_bt_list_keys_unsafe();

// Start scanning
uni_bt_enable_new_connections_unsafe(true);
Expand Down
1 change: 1 addition & 0 deletions src/components/bluepad32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(srcs
"bt/uni_bt_conn.c"
"bt/uni_bt_hci_cmd.c"
"bt/uni_bt_le.c"
"bt/uni_bt_service.c"
"bt/uni_bt_setup.c"
"controller/uni_balance_board.c"
"controller/uni_controller.c"
Expand Down
16 changes: 16 additions & 0 deletions src/components/bluepad32/bt/uni_bt_service.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Ricardo Quesada
// http://retro.moe/unijoysticle2


#include "bt/uni_bt_service.h"

static bool service_enabled;

void uni_bt_service_init(void) {

}

void uni_bt_service_set_enabled(bool enabled) {
service_enabled = enabled;
}
21 changes: 21 additions & 0 deletions src/components/bluepad32/include/bt/uni_bt_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Ricardo Quesada
// http://retro.moe/unijoysticle2

#ifndef UNI_BT_SERVICE_H
#define UNI_BT_SERVICE_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>

void uni_bt_service_init(void);
void uni_bt_service_set_enabled(bool enabled);

#ifdef __cplusplus
}
#endif

#endif // UNI_BT_SERVICE_H
4 changes: 2 additions & 2 deletions src/components/bluepad32/include/uni_mouse_quadrature.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ void uni_mouse_quadrature_setup_port(int port_idx,
void uni_mouse_quadrature_update(int port_idx, int32_t dx, int32_t dy);
void uni_mouse_quadrature_start(int port_idx);
void uni_mouse_quadrature_pause(int port_idx);
void uni_mouse_quadrature_deinit();
void uni_mouse_quadrature_deinit(void);

void uni_mouse_quadrature_set_scale_factor(float scale);
float uni_mouse_quadrature_get_scale_factor();
float uni_mouse_quadrature_get_scale_factor(void);

#endif // UNI_MOUSE_QUADRATURE_H
4 changes: 2 additions & 2 deletions src/components/bluepad32/uni_mouse_quadrature.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void uni_mouse_quadrature_setup_port(int port_idx,
s_quadratures[port_idx][UNI_MOUSE_QUADRATURE_ENCODER_V].gpios = v;
}

void uni_mouse_quadrature_deinit() {
void uni_mouse_quadrature_deinit(void) {
// Stop the timers
for (int i = 0; i < UNI_MOUSE_QUADRATURE_PORT_MAX; i++) {
for (int j = 0; j < UNI_MOUSE_QUADRATURE_ENCODER_MAX; j++) {
Expand Down Expand Up @@ -364,7 +364,7 @@ void uni_mouse_quadrature_set_scale_factor(float scale) {
uni_property_set(UNI_PROPERTY_KEY_MOUSE_SCALE, UNI_PROPERTY_TYPE_FLOAT, value);
}

float uni_mouse_quadrature_get_scale_factor() {
float uni_mouse_quadrature_get_scale_factor(void) {
uni_property_value_t value;
uni_property_value_t def;

Expand Down

0 comments on commit 9b7e1b7

Please sign in to comment.