Skip to content

Commit

Permalink
let snake app use OnEdgeButton
Browse files Browse the repository at this point in the history
  • Loading branch information
Lance798 authored and john0312 committed Aug 17, 2024
1 parent 5d651ae commit dc1459e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fw/Core/Hitcon/App/SnakeApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ void SetMultiplayer() { snake_app.mode = MODE_MULTIPLAYER; }

void SnakeApp::OnExit() { scheduler.DisablePeriodic(&_routine_task); }

void SnakeApp::OnButton(button_t button) {
void SnakeApp::OnEdgeButton(button_t button) {
direction_t btn_direction = NONE;
if (button & BUTTON_KEYUP_BIT) return;

switch (button & BUTTON_VALUE_MASK) {
case BUTTON_RIGHT:
Expand Down Expand Up @@ -82,7 +83,6 @@ void SnakeApp::OnButton(button_t button) {
}
break;
case BUTTON_BACK:
case BUTTON_LONG_BACK:
if (mode == MODE_MULTIPLAYER) {
uint8_t code = PACKET_GAME_LEAVE;
g_xboard_logic.QueueDataForTx(&code, 1, SNAKE_RECV_ID);
Expand All @@ -96,6 +96,8 @@ void SnakeApp::OnButton(button_t button) {
_direction = btn_direction;
}

void SnakeApp::OnButton(button_t button) {}

bool SnakeApp::OnSnake(uint8_t index) {
bool on_snake = false;

Expand Down
1 change: 1 addition & 0 deletions fw/Core/Hitcon/App/SnakeApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class SnakeApp : public App {
void OnExit() override;
void OnButton(button_t button) override;
void OnXBoardRecv(void* arg);
void OnEdgeButton(button_t button) override;
};

extern SnakeApp snake_app;
Expand Down

0 comments on commit dc1459e

Please sign in to comment.