Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mythologyli committed Apr 17, 2021
1 parent 7eafae7 commit e34d696
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 22 deletions.
Binary file modified KeyboardAddin/MainIcon.bmp
Binary file not shown.
Binary file modified KeyboardAddin/eActivityIcon.bmp
Binary file not shown.
6 changes: 5 additions & 1 deletion KeyboardAddin/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ extern "C"
#include "log.h"


Log::Log() : cursor_x(1), cursor_y(1)
int Log::cursor_x = 1;
int Log::cursor_y = 1;


Log::Log()
{

}
Expand Down
24 changes: 12 additions & 12 deletions KeyboardAddin/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ class Log
public:
Log();

void Init(void); // Must call this function in main function once!
static void Init(void); // Must call this function in main function once!

void Print(void); // Print space.
void Print(unsigned char uch); // Print uch.
void Print(const unsigned char* ustr); // Print ustr.
void Print(int num); // Print int.
static void Print(void); // Print space.
static void Print(unsigned char uch); // Print uch.
static void Print(const unsigned char* ustr); // Print ustr.
static void Print(int num); // Print int.

void PrintLn(void); // Print a blank line.
void PrintLn(unsigned char uch); // Print uch with a new line.
void PrintLn(const unsigned char* ustr); // Print ustr with a new line.
void PrintLn(int num); // Print int with a new line.
static void PrintLn(void); // Print a blank line.
static void PrintLn(unsigned char uch); // Print uch with a new line.
static void PrintLn(const unsigned char* ustr); // Print ustr with a new line.
static void PrintLn(int num); // Print int with a new line.

void Clear(void); // Clear the screen and reset line position.
static void Clear(void); // Clear the screen and reset line position.

private:
int cursor_x;
int cursor_y;
static int cursor_x;
static int cursor_y;
};


Expand Down
5 changes: 1 addition & 4 deletions KeyboardAddin/sendkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ class SendKey
public:
SendKey();

void Send(void); // Send pressed key by usb port.

private:

static void Send(void); // Send pressed key by usb port.
};


Expand Down
29 changes: 29 additions & 0 deletions KeyboardAddin/usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ extern "C"
#endif


#include <fxlib.h>
#include <timer.h>

#include "tool.h"
#include "syscall.h"
#include "usb.h"
Expand All @@ -32,8 +35,18 @@ USB::USB()
// -1 : port already open
int USB::Init(void)
{
// If the cable not connected, the program would stuck in Comm_Open.
// This timer is used to force exit.
SetTimer(ID_USER_TIMER1, 2000, ForceExit);

#ifdef DEBUG_USB
log.PrintLn((const unsigned char*)"#Linking...");
#endif

if (Comm_Open(0x20) == 0)
{
KillTimer(ID_USER_TIMER1);

#ifdef DEBUG_USB
log.PrintLn((const unsigned char*)"#Port open!");
#endif
Expand All @@ -44,6 +57,8 @@ int USB::Init(void)
}
else
{
KillTimer(ID_USER_TIMER1);

#ifdef DEBUG_USB
log.PrintLn((const unsigned char*)"#Port already open!");
#endif
Expand Down Expand Up @@ -115,6 +130,20 @@ void USB::Close(void)
}


// Force exit.
// Called by timer.
void USB::ForceExit(void)
{
log.PrintLn((const unsigned char*)"#Link error!");
log.PrintLn((const unsigned char*)"#Use [MENU] to exit.");

unsigned int key;

while (1)
GetKey(&key);
}


#ifdef __cplusplus
}
#endif
10 changes: 5 additions & 5 deletions KeyboardAddin/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class USB
public:
USB();

int Init(void); // Try to open the usb port.
static int Init(void); // Try to open the usb port.

int Send(unsigned char* ustr); // Send ustr to usb port.
static int Send(unsigned char* ustr); // Send ustr to usb port.

void ClearSendBuffer(void); // Clear send buffer.
static void ClearSendBuffer(void); // Clear send buffer.

void Close(void); // Close the usb port.
static void Close(void); // Close the usb port.

private:

static void ForceExit(void); // Force exit.
};


Expand Down

0 comments on commit e34d696

Please sign in to comment.