Skip to content

Commit

Permalink
feat: Renew codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeLayer committed Oct 19, 2024
1 parent aa59759 commit 979ae93
Show file tree
Hide file tree
Showing 101 changed files with 5,011 additions and 254 deletions.
3 changes: 3 additions & 0 deletions configurator/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cmake.sourceDirectory": "/Users/shapelayer/Desktop/Code/configurator/linux"
}
19 changes: 15 additions & 4 deletions configurator/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
macOS Requirements:
# configurator

```
brew install libserialport
```
A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
40 changes: 40 additions & 0 deletions configurator/lib/build_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:configurator/models/keycode.dart';
import 'package:configurator/models/key_config.dart';

class BuildConfig {
static const serialBaudRate = 9600;
static const serialBits = 8;
static const serialStopBits = 1;
static const serialParity = null;

static KeyConfig defaultKeyConfig = KeyConfig(
Keycode.esc,
Keycode.enter,
Keycode.tab,
Keycode.undefined, // Keycode.space,
Keycode.undefined, // Keycode.speedUp,
Keycode.undefined, // Keycode.speedDown,
Keycode.backspace,
Keycode.leftShift,
Keycode.rightShift,
Keycode.upArrow,
Keycode.downArrow,
Keycode.leftArrow,
Keycode.rightArrow,
Keycode.leftShift,
Keycode.undefined, // Keycode.tuneS,
Keycode.undefined, // Keycode.tuneD,
Keycode.undefined, // Keycode.tuneF,
Keycode.undefined, // Keycode.tuneC,
Keycode.undefined, // Keycode.tuneM,
Keycode.undefined, // Keycode.tuneJ,
Keycode.undefined, // Keycode.tuneK,
Keycode.undefined, // Keycode.tuneL,
Keycode.rightShift,
Keycode.undefined, // Keycode.emoticon1,
Keycode.undefined, // Keycode.emoticon2,
Keycode.undefined, // Keycode.emoticon3,
Keycode.undefined, // Keycode.emoticon4,
Keycode.undefined, // Keycode.emoticon5,
);
}
174 changes: 89 additions & 85 deletions configurator/lib/globals.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:configurator/const/config.dart';
import 'package:configurator/const/keycode.dart';
import 'package:configurator/classes/key_config.dart';
import 'package:configurator/build_config.dart';
import 'package:configurator/models/keycode.dart';
import 'package:configurator/models/key_config.dart';

class Globals {
late KeyConfig keyConfig;
Expand All @@ -13,115 +13,119 @@ class Globals {

Globals._privateConstructor() {
KeyConfig loaded = KeyConfig(
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined,
Key.undefined);
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined,
Keycode.undefined);
// Load from Arduino
keyConfig = KeyConfig(
loaded.esc != Key.undefined ? loaded.esc : Config.defaultKeyConfig.esc,
loaded.enter != Key.undefined
loaded.esc != Keycode.undefined
? loaded.esc
: BuildConfig.defaultKeyConfig.esc,
loaded.enter != Keycode.undefined
? loaded.enter
: Config.defaultKeyConfig.enter,
loaded.tab != Key.undefined ? loaded.tab : Config.defaultKeyConfig.tab,
loaded.space != Key.undefined
: BuildConfig.defaultKeyConfig.enter,
loaded.tab != Keycode.undefined
? loaded.tab
: BuildConfig.defaultKeyConfig.tab,
loaded.space != Keycode.undefined
? loaded.space
: Config.defaultKeyConfig.space,
loaded.speedUp != Key.undefined
: BuildConfig.defaultKeyConfig.space,
loaded.speedUp != Keycode.undefined
? loaded.speedUp
: Config.defaultKeyConfig.speedUp,
loaded.speedDown != Key.undefined
: BuildConfig.defaultKeyConfig.speedUp,
loaded.speedDown != Keycode.undefined
? loaded.speedDown
: Config.defaultKeyConfig.speedDown,
loaded.rewind != Key.undefined
: BuildConfig.defaultKeyConfig.speedDown,
loaded.rewind != Keycode.undefined
? loaded.rewind
: Config.defaultKeyConfig.rewind,
loaded.leftShift != Key.undefined
: BuildConfig.defaultKeyConfig.rewind,
loaded.leftShift != Keycode.undefined
? loaded.leftShift
: Config.defaultKeyConfig.leftShift,
loaded.rightShift != Key.undefined
: BuildConfig.defaultKeyConfig.leftShift,
loaded.rightShift != Keycode.undefined
? loaded.rightShift
: Config.defaultKeyConfig.rightShift,
loaded.arrowUp != Key.undefined
: BuildConfig.defaultKeyConfig.rightShift,
loaded.arrowUp != Keycode.undefined
? loaded.arrowUp
: Config.defaultKeyConfig.arrowUp,
loaded.arrowDown != Key.undefined
: BuildConfig.defaultKeyConfig.arrowUp,
loaded.arrowDown != Keycode.undefined
? loaded.arrowDown
: Config.defaultKeyConfig.arrowDown,
loaded.arrowLeft != Key.undefined
: BuildConfig.defaultKeyConfig.arrowDown,
loaded.arrowLeft != Keycode.undefined
? loaded.arrowLeft
: Config.defaultKeyConfig.arrowLeft,
loaded.arrowRight != Key.undefined
: BuildConfig.defaultKeyConfig.arrowLeft,
loaded.arrowRight != Keycode.undefined
? loaded.arrowRight
: Config.defaultKeyConfig.arrowRight,
loaded.tuneLeftSide != Key.undefined
: BuildConfig.defaultKeyConfig.arrowRight,
loaded.tuneLeftSide != Keycode.undefined
? loaded.tuneLeftSide
: Config.defaultKeyConfig.tuneLeftSide,
loaded.tuneS != Key.undefined
: BuildConfig.defaultKeyConfig.tuneLeftSide,
loaded.tuneS != Keycode.undefined
? loaded.tuneS
: Config.defaultKeyConfig.tuneS,
loaded.tuneD != Key.undefined
: BuildConfig.defaultKeyConfig.tuneS,
loaded.tuneD != Keycode.undefined
? loaded.tuneD
: Config.defaultKeyConfig.tuneD,
loaded.tuneF != Key.undefined
: BuildConfig.defaultKeyConfig.tuneD,
loaded.tuneF != Keycode.undefined
? loaded.tuneF
: Config.defaultKeyConfig.tuneF,
loaded.tuneC != Key.undefined
: BuildConfig.defaultKeyConfig.tuneF,
loaded.tuneC != Keycode.undefined
? loaded.tuneC
: Config.defaultKeyConfig.tuneC,
loaded.tuneM != Key.undefined
: BuildConfig.defaultKeyConfig.tuneC,
loaded.tuneM != Keycode.undefined
? loaded.tuneM
: Config.defaultKeyConfig.tuneM,
loaded.tuneJ != Key.undefined
: BuildConfig.defaultKeyConfig.tuneM,
loaded.tuneJ != Keycode.undefined
? loaded.tuneJ
: Config.defaultKeyConfig.tuneJ,
loaded.tuneK != Key.undefined
: BuildConfig.defaultKeyConfig.tuneJ,
loaded.tuneK != Keycode.undefined
? loaded.tuneK
: Config.defaultKeyConfig.tuneK,
loaded.tuneL != Key.undefined
: BuildConfig.defaultKeyConfig.tuneK,
loaded.tuneL != Keycode.undefined
? loaded.tuneL
: Config.defaultKeyConfig.tuneL,
loaded.tuneRightSide != Key.undefined
: BuildConfig.defaultKeyConfig.tuneL,
loaded.tuneRightSide != Keycode.undefined
? loaded.tuneRightSide
: Config.defaultKeyConfig.tuneRightSide,
loaded.emoticon1 != Key.undefined
: BuildConfig.defaultKeyConfig.tuneRightSide,
loaded.emoticon1 != Keycode.undefined
? loaded.emoticon1
: Config.defaultKeyConfig.emoticon1,
loaded.emoticon2 != Key.undefined
: BuildConfig.defaultKeyConfig.emoticon1,
loaded.emoticon2 != Keycode.undefined
? loaded.emoticon2
: Config.defaultKeyConfig.emoticon2,
loaded.emoticon3 != Key.undefined
: BuildConfig.defaultKeyConfig.emoticon2,
loaded.emoticon3 != Keycode.undefined
? loaded.emoticon3
: Config.defaultKeyConfig.emoticon3,
loaded.emoticon4 != Key.undefined
: BuildConfig.defaultKeyConfig.emoticon3,
loaded.emoticon4 != Keycode.undefined
? loaded.emoticon4
: Config.defaultKeyConfig.emoticon4,
loaded.emoticon5 != Key.undefined
: BuildConfig.defaultKeyConfig.emoticon4,
loaded.emoticon5 != Keycode.undefined
? loaded.emoticon5
: Config.defaultKeyConfig.emoticon5);
: BuildConfig.defaultKeyConfig.emoticon5);
}
}
7 changes: 2 additions & 5 deletions configurator/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:configurator/widgets/pages/main_config_page.dart';
import 'package:configurator/widgets/pages/_debug_serial_comm.dart';
import 'package:configurator/screens/main_config_page.dart';

void main() {
runApp(const MyApp());
Expand All @@ -9,13 +8,11 @@ void main() {
class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'Configurator',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MainConfigPage(),
Expand Down
70 changes: 70 additions & 0 deletions configurator/lib/models/key_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:configurator/models/keycode.dart';

class KeyConfig {
Keycode esc;
Keycode enter;
Keycode tab; // for Difficulty(Lobby)
Keycode space; // for Option(Lobby), Manual Fever(Ingame)

Keycode speedUp; // digit1
Keycode speedDown; // digit2
Keycode rewind; // Backspace

Keycode
leftShift; // It may be useless (duplicated with tuneLeftSide in default)
Keycode
rightShift; // It may be useless (duplicated with tuneRightSide in default)

Keycode arrowUp;
Keycode arrowDown;
Keycode arrowLeft;
Keycode arrowRight;

Keycode tuneLeftSide;
Keycode tuneS;
Keycode tuneD;
Keycode tuneF;
Keycode tuneC;
Keycode tuneM;
Keycode tuneJ;
Keycode tuneK;
Keycode tuneL;
Keycode tuneRightSide;

Keycode emoticon1; // digit3
Keycode emoticon2; // digit4
Keycode emoticon3; // digit5
Keycode emoticon4; // digit6
Keycode emoticon5; // digit7

KeyConfig(
this.esc,
this.enter,
this.tab,
this.space,
this.speedUp,
this.speedDown,
this.rewind,
this.leftShift,
this.rightShift,
this.arrowUp,
this.arrowDown,
this.arrowLeft,
this.arrowRight,
this.tuneLeftSide,
this.tuneS,
this.tuneD,
this.tuneF,
this.tuneC,
this.tuneM,
this.tuneJ,
this.tuneK,
this.tuneL,
this.tuneRightSide,
this.emoticon1,
this.emoticon2,
this.emoticon3,
this.emoticon4,
this.emoticon5,
);
}
Loading

0 comments on commit 979ae93

Please sign in to comment.