Page 1 of 1

Possibility of a Python port?

PostPosted: Mon Mar 23, 2020 12:45 am
by atarumoroboshi18
Hi, I was wondering, would there ever be a possibility of converting from the current programming language into Python? Lately I've been into Python and it's been so simple and easy to code with, would this ever be in the cards in the future or is the language set in stone?

Re: Possibility of a Python port?

PostPosted: Mon Mar 23, 2020 7:21 am
by Mad
atarumoroboshi18 wrote:Hi, I was wondering, would there ever be a possibility of converting from the current programming language into Python? Lately I've been into Python and it's been so simple and easy to code with, would this ever be in the cards in the future or is the language set in stone?

The GPC2 scripting language is also quite simple and we'd be happy to help if you have any questions.

These are the two links you'll need:
https://www.consoletuner.com/wiki/index ... _scripting
https://www.consoletuner.com/wiki/index ... _reference

The latest feature CV (computer vision) scripts are done in python if this interests you: viewtopic.php?f=2&t=14717

Re: Possibility of a Python port?

PostPosted: Mon Mar 23, 2020 10:57 am
by J2Kbr
For performance reasons, it would not be viable run Python natively into the Titan Two.

However, as mentioned by Mad, you could use the Computer Vision interface to perform any process with Python, having on the Titan Two just a simple GPC script to translate the results to the desired output.

Re: Possibility of a Python port?

PostPosted: Thu Mar 26, 2020 4:18 am
by atarumoroboshi18
Alright, there are a few questions that I've had trouble finding answers to. I'm trying to be pure KB/M and I want to attempt to use my KB/M on everything from PC games to emulators and everything in between on my PC. After asking a question and getting a really quick answer(using the passthrus and a toggle_switch function) to switch my KB/M from regular mode to controller mode with a button press, here's a few questions I've got:

Since I'm using mouse_passthru and key_passthru with a toggle key, should I explicitly define the Keyboard/Mouse keys within a script or is setting up an Input Translator better?

Is there a good way of doing a double_click of a button?

When my computer goes into sleep mode, it doesn't come back online when using my KB/M, is there something I'm missing? When I have the KB/M plugged directly into my computer it wakes from sleep/hibernation, but not when connected to the Titan Two, is there a step I'm missing or is this not possible?

I'll have more questions, but these are some I've been wondering about.

Re: Possibility of a Python port?

PostPosted: Thu Mar 26, 2020 10:02 am
by J2Kbr
atarumoroboshi18 wrote:Since I'm using mouse_passthru and key_passthru with a toggle key, should I explicitly define the Keyboard/Mouse keys within a script or is setting up an Input Translator better?

The script is better as you are dynamic changing the output protocol.

atarumoroboshi18 wrote:Is there a good way of doing a double_click of a button?

If the button is mapped to an GPC designator this simple code is enough to detect double taps:
Code: Select all
main {
    if(event_active(BUTTON_16) && time_release(BUTTON_16) < 150) {
        //
        // BUTTON_16 has been double tapped
        //
    }
}
 


atarumoroboshi18 wrote:When my computer goes into sleep mode, it doesn't come back online when using my KB/M, is there something I'm missing? When I have the KB/M plugged directly into my computer it wakes from sleep/hibernation, but not when connected to the Titan Two, is there a step I'm missing or is this not possible?

Is the USB power cutoff when the computer goes to sleep?

Re: Possibility of a Python port?

PostPosted: Thu Mar 26, 2020 11:36 pm
by atarumoroboshi18
Alright, what's the best way to define a keyboard button to a GPC designation?

Re: Possibility of a Python port?

PostPosted: Thu Mar 26, 2020 11:39 pm
by Mad
atarumoroboshi18 wrote:Alright, what's the best way to define a keyboard button to a GPC designation?

keymapping() https://www.consoletuner.com/wiki/index ... keymapping

Re: Possibility of a Python port?

PostPosted: Fri Mar 27, 2020 3:23 am
by atarumoroboshi18
Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
init {
    const uint8 map[] = {
        KEY_W,            STICK_2_Y | KEYMAP_NEGATIVE,
        KEY_A,            STICK_2_X | KEYMAP_NEGATIVE,
        KEY_S,          STICK_2_Y,
        KEY_D,          STICK_2_X,
    };
    keymapping(map);
}
 
main {
  mouse_passthru();
  key_passthru();
  toggle_output(KEY_PAUSE);
}
 
void toggle_output(uint8 toggle_key){
  static bool key_down;
  if(key_status(toggle_key)){
    if(!key_down){
      bool output;
      port_status(PORT_USB_C,&output,0);
      if(output==PROTOCOL_HID) port_connect(PORT_USB_C, PROTOCOL_XB360);
      else port_connect(PORT_USB_C, PROTOCOL_HID);
      ++key_down;
    }
  } else key_down = FALSE;
}
 
//    PASTE YOUR SCRIPT BELOW.]
 


Odd, I'm just doing pure keymapping and it doesn't seem to be working. When I toggle the output to T2 mode, device monitor does not show that pressing WASD does anything.

Re: Possibility of a Python port?

PostPosted: Mon Mar 30, 2020 7:12 am
by atarumoroboshi18
Alright, nevermind. For some reason, coming back and testing the script again made the script work. Bizarre.