Press a key to swap key setting on keyboard
5 posts
• Page 1 of 1
Press a key to swap key setting on keyboard
Hello guys,
I wonder if there is a way that I can press a key on keyboard to swap certain key mapping, or resign some keys to new bottoms, and if i release that key on keyboard, the settings will go back to normal.
I know there is a function for controller bottoms 'remapper_swap', but as far as i understand, this function only works with controller bottoms, not meant to work for keyboard keys.
I especially want to know when i already used the 'keymapping' function in the init area to remap the keyboard keys to certain controller bottoms, how can i be able to do the things i just discribed above.
Many thanks for you all. I learned so much form this great community. Specially thanks to bonefisher for your wonderful script on BF5, the player status tracking works amazing! And thank you so much for posting your source code online, I learned a lot from it.
I wonder if there is a way that I can press a key on keyboard to swap certain key mapping, or resign some keys to new bottoms, and if i release that key on keyboard, the settings will go back to normal.
I know there is a function for controller bottoms 'remapper_swap', but as far as i understand, this function only works with controller bottoms, not meant to work for keyboard keys.
I especially want to know when i already used the 'keymapping' function in the init area to remap the keyboard keys to certain controller bottoms, how can i be able to do the things i just discribed above.
Many thanks for you all. I learned so much form this great community. Specially thanks to bonefisher for your wonderful script on BF5, the player status tracking works amazing! And thank you so much for posting your source code online, I learned a lot from it.
-
DrNefario - Master Sergeant
- Posts: 35
- Joined: Sun Dec 30, 2018 12:04 pm
Re: Press a key to swap key setting on keyboard
You can use a function that reads the values of A and writes them to B and vice versa.
The code below will swap the dpad directions as long as you hold down F1 key:
The code below will swap the dpad directions as long as you hold down F1 key:
- Code: Select all
#include <keyboard.gph>
#define SWAPKEY KEY_F1 // key to hold down
main {
if (key_status(SWAPKEY)) swapper();
}
void swapper() {
// add all swappings here
swap(BUTTON_10,BUTTON_11);
swap(BUTTON_12,BUTTON_13);
}
// don't change this one
void swap(uint8 ida, uint8 idb) {
set_val(ida, get_actual(idb));
set_val(idb, get_actual(ida));
}
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: Press a key to swap key setting on keyboard
Scachi wrote:You can use a function that reads the values of A and writes them to B and vice versa.
The code below will swap the dpad directions as long as you hold down F1 key:
- Code: Select all
#include <keyboard.gph>
#define SWAPKEY KEY_F1 // key to hold down
main {
if (key_status(SWAPKEY)) swapper();
}
void swapper() {
// add all swappings here
swap(BUTTON_10,BUTTON_11);
swap(BUTTON_12,BUTTON_13);
}
// don't change this one
void swap(uint8 ida, uint8 idb) {
set_val(ida, get_actual(idb));
set_val(idb, get_actual(ida));
}
Many thanks!
Can I ask if there is a way to remap a keyboard key?
Lets just say I already map the BUTTOM_6 to KEY_C, using the following code:
- Code: Select all
#include <remapper.gph>
#include <keyboard.gph>
init {
const uint8 map[] = {
KEY_C, BUTTOM_6
};
keymapping(map);
}
and I want to switch KEY_C to BUTTOM_7 when I am pressing KEY_Q, how can I do that?
-
DrNefario - Master Sergeant
- Posts: 35
- Joined: Sun Dec 30, 2018 12:04 pm
Re: Press a key to swap key setting on keyboard
- Code: Select all
#include <keyboard.gph>
const uint8 map[] = { KEY_C, BUTTON_6, };
const uint8 map2[] = { KEY_C, BUTTON_7, };
init {
keymapping(map);
}
main {
bool key_state;
if(key_status(KEY_Q)){
if(!key_state) key_state = 1, keymapping(map2);
}else if(!key_status(KEY_Q)){
if(key_state) key_state = 0, keymapping(map);
}
}
-
Sillyasskid - Captain
- Posts: 574
- Joined: Sat May 14, 2016 3:07 am
Re: Press a key to swap key setting on keyboard
Sillyasskid wrote:
- Code: Select all
#include <keyboard.gph>
const uint8 map[] = { KEY_C, BUTTON_6, };
const uint8 map2[] = { KEY_C, BUTTON_7, };
init {
keymapping(map);
}
main {
bool key_state;
if(key_status(KEY_Q)){
if(!key_state) key_state = 1, keymapping(map2);
}else if(!key_status(KEY_Q)){
if(key_state) key_state = 0, keymapping(map);
}
}
Ah! Brillant! Thanks!
-
DrNefario - Master Sergeant
- Posts: 35
- Joined: Sun Dec 30, 2018 12:04 pm
5 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 93 guests