Possibility of a Python port?

GPC2 script programming for Titan Two. Code examples, questions, requests.

Possibility of a Python port?

Postby atarumoroboshi18 » Mon Mar 23, 2020 12:45 am

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?
User avatar
atarumoroboshi18
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Sun Aug 31, 2014 9:55 pm

Re: Possibility of a Python port?

Postby Mad » Mon Mar 23, 2020 7:21 am

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
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4532
Joined: Wed May 22, 2019 5:39 am

Re: Possibility of a Python port?

Postby J2Kbr » Mon Mar 23, 2020 10:57 am

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.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Possibility of a Python port?

Postby atarumoroboshi18 » Thu Mar 26, 2020 4:18 am

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.
User avatar
atarumoroboshi18
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Sun Aug 31, 2014 9:55 pm

Re: Possibility of a Python port?

Postby J2Kbr » Thu Mar 26, 2020 10:02 am

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?
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Possibility of a Python port?

Postby atarumoroboshi18 » Thu Mar 26, 2020 11:36 pm

Alright, what's the best way to define a keyboard button to a GPC designation?
User avatar
atarumoroboshi18
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Sun Aug 31, 2014 9:55 pm

Re: Possibility of a Python port?

Postby Mad » Thu Mar 26, 2020 11:39 pm

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
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4532
Joined: Wed May 22, 2019 5:39 am

Re: Possibility of a Python port?

Postby atarumoroboshi18 » Fri Mar 27, 2020 3:23 am

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.
User avatar
atarumoroboshi18
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Sun Aug 31, 2014 9:55 pm

Re: Possibility of a Python port?

Postby atarumoroboshi18 » Mon Mar 30, 2020 7:12 am

Alright, nevermind. For some reason, coming back and testing the script again made the script work. Bizarre.
User avatar
atarumoroboshi18
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Sun Aug 31, 2014 9:55 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 133 guests

cron