diff --git a/pc_software/ds3_preprocessor.py b/pc_software/ds3_preprocessor.py index a20363ac..3f45046c 100644 --- a/pc_software/ds3_preprocessor.py +++ b/pc_software/ds3_preprocessor.py @@ -782,6 +782,27 @@ def split_str_cmd(cmd_type, this_line): return cmd_list def run_all(program_listing): + + # a bit preprocessing + new_program_listing = [] + for index, this_line in enumerate(program_listing): + + # remove leading space and tabs + this_line = this_line.lstrip(" ").lstrip("\t") + first_word = this_line.split(" ")[0] + + # remove single-line comments + if first_word == cmd_REM or first_word.startswith(cmd_C_COMMENT): + continue + + # remove cmd_INJECT_MOD + if first_word == cmd_INJECT_MOD: + this_line = this_line.replace(cmd_INJECT_MOD, "", 1) + + this_line = this_line.lstrip(" ").lstrip("\t") + new_program_listing.append(this_line) + program_listing = new_program_listing + # ----------- expand MOUSE_MOVE ---------- new_program_listing = [] for index, this_line in enumerate(program_listing): @@ -801,12 +822,9 @@ def run_all(program_listing): program_listing = new_program_listing - # ----------- remove cmd_INJECT_MOD ---------- - - for index, this_line in enumerate(program_listing): - first_word = this_line.split(" ")[0] - if first_word == cmd_INJECT_MOD: - program_listing[index] = this_line.replace(cmd_INJECT_MOD, "", 1) + print("preprocessed lines:") + for item in program_listing: + print(item) # ----------- Do a pass --------------- diff --git a/pc_software/duckypad_config_latest_source.zip b/pc_software/duckypad_config_latest_source.zip index 287bcae3..a91922d3 100644 Binary files a/pc_software/duckypad_config_latest_source.zip and b/pc_software/duckypad_config_latest_source.zip differ diff --git a/pc_software/sample_script.txt b/pc_software/sample_script.txt index 34bc2d9f..2ffc1b39 100644 --- a/pc_software/sample_script.txt +++ b/pc_software/sample_script.txt @@ -1,14 +1,28 @@ -DEFINE TEN 10 -VAR $spam = TEN*7+3 +FUNCTION wait_keypress() + VAR $k = 0 + WHILE $k == 0 + $k = $_READKEY + DELAY 50 + END_WHILE +END_FUNCTION -DEFAULTDELAY 30 +OLED_CLEAR +OLED_CURSOR 0 0 +OLED_PRINT READY +OLED_UPDATE -STRINGLN_BLOCK +VAR $row = 1 +VAR $col = 1 +INJECT_MOD ALT +WHILE $row <= 5 + WHILE $col <= 4 + // wait_keypress() + STRINGLN WTFSW_R$rowC$col + $col = $col + 1 + END_WHILE + $row = $row + 1 +END_WHILE -I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux! +OLED_RESTORE -hello world! -END_STRINGLN - -DELAY $spam \ No newline at end of file