Titan Two on PC (not emulating a controller)- beginner help!

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

Titan Two on PC (not emulating a controller)- beginner help!

Postby pablosscripts » Sun Apr 14, 2019 2:36 am

What is the code pattern for taking a basic input, manipulating it, then outputting?

This is my starting point:

Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
init {
    keymapping();
    mousemapping();
}
 
main {
    key_passthru();
    mouse_passthru();
 
    // Code here
}


What I then need is the equivalent of a:

Code: Select all
if(get_val(xxxx)) {
    // some logic
    set_val(xxxx, 100);
}


What is the equivalent when using a Multi Interface HID output? I have the code for "get_val" but I have no idea how to set keyboard outputs, this is uncharted territory for me!
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am


Re: Titan Two on PC (not emulating a controller)- beginner h

Postby antithesis » Sun Apr 14, 2019 5:17 am

Also, search for xkeys.gph. That adds a few more kb functions.
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: Titan Two on PC (not emulating a controller)- beginner h

Postby Scachi » Sun Apr 14, 2019 9:42 am

xkeys.gph won't work in multi interface HID mode I think.
It uses key_status to monitor the keys, I think that isn't working for that mode.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Titan Two on PC (not emulating a controller)- beginner h

Postby pablosscripts » Sun Apr 14, 2019 10:12 am

Woo hoo I got it! I didn't get how to use key_set but it makes sense now. Here's the code pattern I got working, now time to get to work on my new script! :)

Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
bool    key_is_ready;
 
init {
    keymapping();
    mousemapping();
}
 
main {
    key_passthru();
    mouse_passthru();
 
    if(key_status(KEY_PADASTERISK)) {
        key_set(KEY_PADASTERISK, FALSE);
        if(key_is_ready) {
            key_set(KEY_T, TRUE);
            key_is_ready = 0;
        }
    } else {
        key_is_ready = 1;
    }
}
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: Titan Two on PC (not emulating a controller)- beginner h

Postby antithesis » Sun Apr 14, 2019 10:55 am

Scachi wrote:xkeys.gph won't work in multi interface HID mode I think.
It uses key_status to monitor the keys, I think that isn't working for that mode.

Good to know, thanks Scachi!

Glad you've got it working piiwii.
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: Titan Two on PC (not emulating a controller)- beginner h

Postby Scachi » Sun Apr 14, 2019 2:45 pm

antithesis wrote:
Scachi wrote:xkeys.gph won't work in multi interface HID mode I think.
It uses key_status to monitor the keys, I think that isn't working for that mode.

Good to know, thanks Scachi!

Glad you've got it working piiwii.

Looks like I was wrong and key_status works in HID mode too as his code uses it. :innocent_smile_1:
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Titan Two on PC (not emulating a controller)- beginner h

Postby pablosscripts » Mon Apr 15, 2019 12:37 am

Sweet! I'm so excited to be coding for PC now:)
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: Titan Two on PC (not emulating a controller)- beginner h

Postby Brunissimus » Wed Oct 16, 2019 5:57 pm

pablosscripts wrote:What is the code pattern for taking a basic input, manipulating it, then outputting?

This is my starting point:

Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
init {
    keymapping();
    mousemapping();
}
 
main {
    key_passthru();
    mouse_passthru();
 
    // Code here
}


What I then need is the equivalent of a:

Code: Select all
if(get_val(xxxx)) {
    // some logic
    set_val(xxxx, 100);
}


What is the equivalent when using a Multi Interface HID output? I have the code for "get_val" but I have no idea how to set keyboard outputs, this is uncharted territory for me!


Trick question: is it possible to passthru only the "movement" of the mouse? Because my goal is to remap and script the mouse buttons...
User avatar
Brunissimus
Staff Sergeant
Staff Sergeant
 
Posts: 10
Joined: Tue Apr 11, 2017 11:34 am

Re: Titan Two on PC (not emulating a controller)- beginner h

Postby J2Kbr » Thu Oct 17, 2019 2:09 pm

Brunissimus wrote:Trick question: is it possible to passthru only the "movement" of the mouse? Because my goal is to remap and script the mouse buttons...


Code: Select all
#include <mouse.gph>
 
init {
    mousemapping();
}
 
main {
    if(mouse_status(MREPORT_UPDATED)) {
        mouse_set(MOUSE_X, mouse_status(MOUSE_X));
        mouse_set(MOUSE_Y, mouse_status(MOUSE_Y));
    }
}
 
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Next

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 172 guests