Is there a way to trigger keys on Xbox or ps5 controller

For example, when I press a key on the keyboard, I want it to act as if I pressed a certain key on the controller.

Are you using those devices with the Mac? Or are you wanting to control an Xbox or PS5?

-rob.

with Mac

Did you try settling the trigger to "USB Device Key Trigger?" Do that, then click into the trigger box, and click a button on the controller…does the button click now show up as a trigger action? If so, you're done.

This thread seems to state that it should work for the Xbox controller, at least.

-rob.

What I'm trying to do is the opposite,
I want it to act like a button on the xbox controlled is pressed when I press a key on the Mac keyboard.

I connect to my xbox console with remote play and I can only control it with the controller, what I'm trying to do is play games with the keyboard.

I hope I could explain. My English is not perfect, sorry.

Ah, sorry, I misunderstood. I'm not aware of any way to send USB buttons via keyboard actions—there are MIDI devices you can control that way, but I've never seen anything that controls a USB device's buttons (other than the built-in Move or Click Mouse action, but that doesn't help here).

I think you'd need some sort of hardware device to act like a keyboard, but it'd be fully programmable to send commands to the controllers instead of typing the keys. Way beyond my skill and experience, though.

-rob.

1 Like

You could try installing the following

  • Arduino IDE
  • Teensyduino Add-on — required to program the Teensy
  • ArduinoXInput Library — enables Xbox controller emulation on Teensy
  • [Serial communication utility on Mac]
    (You can use Keyboard Maestro to send echo commands over serial)

Arduino Sketch (Teensy)

#include <XInput.h>

void setup() {
  Serial.begin(9600);  // for receiving commands from macOS
  while (!Serial);     // wait for serial to be ready
  XInput.begin();
}

void loop() {
  if (Serial.available()) {
    char cmd = Serial.read();

    switch (cmd) {
      case 'a': // Xbox A button
        pressAndRelease(BUTTON_A);
        break;
      case 'b': // Xbox B button
        pressAndRelease(BUTTON_B);
        break;
      case 'x': // Xbox X button
        pressAndRelease(BUTTON_X);
        break;
      case 'y': // Xbox Y button
        pressAndRelease(BUTTON_Y);
        break;
      case 'u': // D-Pad Up
        pressAndRelease(HAT_UP);
        break;
      case 'd': // D-Pad Down
        pressAndRelease(HAT_DOWN);
        break;
      case 'l': // D-Pad Left
        pressAndRelease(HAT_LEFT);
        break;
      case 'r': // D-Pad Right
        pressAndRelease(HAT_RIGHT);
        break;
      case 'L': // Left bumper
        pressAndRelease(BUTTON_LB);
        break;
      case 'R': // Right bumper
        pressAndRelease(BUTTON_RB);
        break;
      case 's': // Start
        pressAndRelease(BUTTON_START);
        break;
      case 'k': // Back
        pressAndRelease(BUTTON_BACK);
        break;
      case 'z': // Left stick press
        pressAndRelease(BUTTON_LS);
        break;
      default:
        // Unknown command
        break;
    }
  }
}

// Helper function to press and release a button
void pressAndRelease(uint16_t button) {
  if (button >= HAT_UP && button <= HAT_RIGHT) {
    XInput.setDpad(button);
    delay(100);
    XInput.setDpad(HAT_CENTERED);
  } else {
    XInput.press(button);
    delay(100);
    XInput.release(button);
  }
}

Hopefully that gets you pointed in the right direction at least.

1 Like

Hello, thank you very much for your interest,
I have no idea about what you wrote but I want to proceed.

*I downloaded the Arduino IDE
*Teensyduino is also OK

But I didn't understand the next step, can you please explain a little more

I've done this using the PS Remote program running on my Mac. I wouldn't consider trying to play a game with it. However, I use it for when I finish a race in GT7. I have it go to certain "pages" in the game, and take screenshots.

It's not for the faint of heart, for several reasons. You can't just issue a left arrow, for example. You have to press it for a certain period of time, then release it. Also, it's best to check portions of the screen to make sure you got to where you were supposed to be.

Anyway, if you're honestly interested in this, I can share more information. But remember that it's complicated.

I would love to learn the details,
actually my purpose is not to play the game, I use it on mac to make some tactical adjustments and player developments easier in football games.
I also use keyboard maestro macros exactly for this purpose,so I am seriously interested.

OK, it'll take me some time to gather everything together. If I don't reply in a day or two, hit me up again.

1 Like

to hear Dan say so... :flushed:

3 Likes

Haha, my thoughts too!

This is not stuff I have ventured down and just stuff I searched online that might lead you in the right direction. I wish I could help you more from experience. The most I have done is use Keyboard Maestro to try to beat my son in a racing game with some repeat triggers and other functions and to my dismay he still demolished me :man_facepalming:

You are in way better hands with Dan and he has quite the setup at his house with some racing games. I would however be a bit nervous when he says it is complicated. Dan makes complicated things much easier for the rest of mortals as you can see from his many posts on this forum.

ok, thank you for your interest. :+1: