vike256 / Unibot

All in one video game assistant tool that works with and without hardware. Has aim assist, autoshoot, rapid-fire, and recoil mitigation.
GNU General Public License v3.0
156 stars 34 forks source link

Pi pico #60

Closed maropboia closed 4 months ago

maropboia commented 4 months ago

include <hardware/gpio.h>

include <hardware/uart.h>

include <lwip/opt.h>

include <lwip/arch.h>

include <lwip/api.h>

include <lwip/sys.h>

include <lwip/stats.h>

include <lwip/netif.h>

include <lwip/ip_addr.h>

include <lwip/tcp.h>

include <lwip/priv/tcp_priv.h>

define UART_ID uart0

define BAUD_RATE 115200

const int led_pin = 25; const int mouse_x_pin = 16; const int mouse_y_pin = 17; const int mouse_btn_pin = 18;

int x = 0; int y = 0; String cmd = ""; char symbols[] = "-,0123456789"; char code[] = "UNIBOTCYPHER"; bool encrypt = false;

void decryptCommand(String &command) { if (encrypt) { for (int i = 0; i < command.length(); i++) { for (int j = 0; j < sizeof(code) - 1; j++) { if (command[i] == code[j]) { command[i] = symbols[j]; break; } } } } }

void move_mouse(int x, int y) { gpio_put(mouse_x_pin, x > 0); gpio_put(mouse_y_pin, y > 0); gpio_put(MOUSE_BTN_PIN, 1); sleep_ms(1); gpio_put(MOUSE_BTN_PIN, 0); }

void setup() { gpio_init(led_pin); gpio_set_dir(led_pin, GPIO_OUT); gpio_put(led_pin, 1);

gpio_init(mouse_x_pin); gpio_set_dir(mouse_x_pin, GPIO_OUT);

gpio_init(mouse_y_pin); gpio_set_dir(mouse_y_pin, GPIO_OUT);

gpio_init(mouse_btn_pin); gpio_set_dir(mouse_btn_pin, GPIO_OUT);

uart_init(UART_ID, BAUD_RATE); uart_set_hw_flow(UART_ID, false, false); uart_set_format(UART_ID, UART_BAUD_9600, UART_WORD_8N1, 1); }

void loop() { cmd = uart_getc_raw(UART_ID);

if (cmd.length() > 0) { if (cmd[0] == 'M') { decryptCommand(cmd); int commaIndex = cmd.indexOf(','); if (commaIndex != -1) { x = cmd.substring(1, commaIndex).toInt(); y = cmd.substring(commaIndex + 1).toInt();

    while (x != 0 || y != 0) {
      int moveX = constrain(x, -128, 127);
      int moveY = constrain(y, -128, 127);

      move_mouse(moveX, moveY);

      x -= moveX;
      y -= moveY;
    }
  }
} else if (cmd[0] == 'C') {
  intrandomDelay = random(40, 80);
  gpio_put(mouse_btn_pin, 1);
  sleep_ms(randomDelay);
  gpio_put(mouse_btn_pin, 0);
} else if (cmd[0] == 'B') {
  if (cmd[1] == '1') {
    gpio_put(mouse_btn_pin, 1);
  } else if (cmd[1] == '0') {
    gpio_put(mouse_btn_pin, 0);
  }
}
uart_puts(UART_ID, "a\r\n");

} }