Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Library Pengontrol Game mempertahankan basis data internal perangkat
pengontrol yang digunakan untuk mengonfigurasi tombol, tata letak sumbu gerak, pemetaan untuk
pengontrol yang dikenali, dan pemetaan default untuk pengontrol yang tidak dikenal. Database
ini mencakup banyak pengontrol yang populer, tetapi mungkin tidak mencakup semua perangkat yang
relevan dengan game tertentu. Library Pengontrol Game mendukung penyesuaian
dengan fungsi yang dapat:
Mengambil database pemetaan saat ini.
Menambahkan entri ke database yang ada.
Mengganti entri database yang ada.
Mengganti seluruh database saat ini dengan database baru.
Mengidentifikasi perangkat
Perangkat pengontrol diidentifikasi melalui nilai productId dan vendorId miliknya.
Setiap perangkat pengontrol yang dikenali memiliki setidaknya satu entri dalam database dengan
productId dan vendorId yang cocok. Struktur pemetaan pengontrol mencakup
kolom yang menentukan rentang minimum dan maksimum API Android yang memenuhi syarat
entri tersebut. Beberapa entri dengan productId dan vendorId yang sama mungkin ada dalam
database asalkan memiliki rentang API minimum dan maksimum yang unik.
Paddleboat_getControllerRemapTableData menampilkan jumlah total entri pemetaan ulang
yang ada di database internal.
Parameter
Deskripsi
destRemapTableEntryCount
Ukuran array elemen Paddleboat_Controller_Mapping_Data
yang diteruskan
di parameter mappingData.
mappingData
Pointer ke array
elemen Paddleboat_Controller_Mapping_Data.
Jika destRemapTableEntryCount lebih kecil dari jumlah total entri pemetaan ulang,
hanya jumlah entri yang ditentukan oleh destRemapTableEntryCount yang akan disalin
ke mappingData.
Menambahkan atau mengganti data pemetaan ulang
Gunakan fungsi Paddleboat_addControllerRemapData untuk menambahkan
entri pemetaan ulang, atau mengganti database pemetaan ulang saat ini.
Aturan tambahan yang digunakan untuk operasi.
Nilai yang valid adalah
PADDLEBOAT_REMAP_ADD_MODE_DEFAULT atau
PADDLEBOAT_REMAP_ADD_MODE_REPLACE_ALL
remapTableEntryCount
Ukuran array elemen Paddleboat_Controller_Mapping_Data
yang diteruskan
di parameter mappingData.
mappingData
Pointer ke array
elemen Paddleboat_Controller_Mapping_Data.
Mode tambahan
Jika PADDLEBOAT_REMAP_ADD_MODE_REPLACE_ALL ditentukan dalam addMode,
database yang ada akan dihapus dan diganti dengan konten array baru.
Jika PADDLEBOAT_REMAP_ADD_MODE_DEFAULT ditentukan dalam addMode, kriteria
berikut akan diterapkan ke setiap elemen dalam array yang diteruskan dalam mappingData:
Jika Paddleboat_getControllerRemapTableData bersifat unik (dengan kata lain,
vendorId dan productId belum ada, atau memang ada, tetapi memiliki rentang minApi atau maxApi yang
tidak tumpang-tindih), entri akan ditambahkan ke
database internal.
Jika Paddleboat_getControllerRemapTableData tidak unik (vendorId
dan productId ada dan minApi atau maxApi tumpang-tindih), entri
yang ada dalam database internal akan diganti.
Struktur Paddleboat_Controller_Mapping_Data adalah:
typedefstructPaddleboat_Controller_Mapping_Data{int16_tminimumEffectiveApiLevel;/** Min. API level for this entry */int16_tmaximumEffectiveApiLevel;/** Max. API level, 0 = no max */int32_tvendorId;/** VendorID of the controller device for this entry */int32_tproductId;/** ProductID of the controller device for this entry */int32_tflags;/** Flag bits, will be ORed with * Paddleboat_Controller_Info.controllerFlags *//** AMOTION_EVENT_AXIS value for the corresponding Paddleboat control axis, * or PADDLEBOAT_AXIS_IGNORED if unsupported. */uint16_taxisMapping[PADDLEBOAT_MAPPING_AXIS_COUNT];/** Button to set on positive or negative axis value, * PADDLEBOAT_AXIS_BUTTON_IGNORED if none. */uint8_taxisPositiveButtonMapping[PADDLEBOAT_MAPPING_AXIS_COUNT];uint8_taxisNegativeButtonMapping[PADDLEBOAT_MAPPING_AXIS_COUNT];/** AKEYCODE_ value corresponding with the corresponding Paddleboat button. * PADDLEBOAT_BUTTON_IGNORED if unsupported. */uint16_tbuttonMapping[PADDLEBOAT_BUTTON_COUNT];}Paddleboat_Controller_Mapping_Data;
Contoh pemetaan
Kode berikut mengilustrasikan Paddleboat_Controller_Mapping_Data yang diisi untuk
menjelaskan pengontrol Google Stadia:
#define PADDLEBOAT_AXIS_BUTTON_DPAD_UP 0#define PADDLEBOAT_AXIS_BUTTON_DPAD_LEFT 1#define PADDLEBOAT_AXIS_BUTTON_DPAD_DOWN 2#define PADDLEBOAT_AXIS_BUTTON_DPAD_RIGHT 3#define PADDLEBOAT_AXIS_BUTTON_L2 9#define PADDLEBOAT_AXIS_BUTTON_R2 12staticconstPaddleboat_Controller_Mapping_Datastadia_controller_map[]={16,0,0x18d1,0x9400,PADDLEBOAT_CONTROLLER_LAYOUT_STANDARD,{/* LX */AMOTION_EVENT_AXIS_X,/* LY */AMOTION_EVENT_AXIS_Y,/* RX */AMOTION_EVENT_AXIS_Z,/* RY */AMOTION_EVENT_AXIS_RZ,/* L1 */PADDLEBOAT_AXIS_IGNORED,/* L2 */AMOTION_EVENT_AXIS_BRAKE,/* R1 */PADDLEBOAT_AXIS_IGNORED,/* R2 */AMOTION_EVENT_AXIS_GAS,/* HX */AMOTION_EVENT_AXIS_HAT_X,/* HY */AMOTION_EVENT_AXIS_HAT_Y,},{/* LX */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* LY */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* RX */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* RY */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* L1 */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* L2 */PADDLEBOAT_AXIS_BUTTON_L2,/* R1 */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* R2 */PADDLEBOAT_AXIS_BUTTON_R2,/* HX */PADDLEBOAT_AXIS_BUTTON_DPAD_RIGHT,/* HY */PADDLEBOAT_AXIS_BUTTON_DPAD_DOWN,},{/* LX */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* LY */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* RX */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* RY */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* L1 */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* L2 */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* R1 */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* R2 */PADDLEBOAT_AXIS_BUTTON_IGNORED,/* HX */PADDLEBOAT_AXIS_BUTTON_DPAD_LEFT,/* HY */PADDLEBOAT_AXIS_BUTTON_DPAD_UP,},{/* UP */AKEYCODE_DPAD_UP,/* LEFT */AKEYCODE_DPAD_LEFT,/* DOWN */AKEYCODE_DPAD_DOWN,/* RIGHT */AKEYCODE_DPAD_RIGHT,/* A */AKEYCODE_BUTTON_A,/* B */AKEYCODE_BUTTON_B,/* X */AKEYCODE_BUTTON_X,/* Y */AKEYCODE_BUTTON_Y,/* L1 */AKEYCODE_BUTTON_L1,/* L2 */AKEYCODE_BUTTON_L2,/* L3 */AKEYCODE_BUTTON_THUMBL,/* R1 */AKEYCODE_BUTTON_R1,/* R2 */AKEYCODE_BUTTON_R2,/* R3 */AKEYCODE_BUTTON_THUMBR,/* SELECT */AKEYCODE_BUTTON_SELECT,/* START */AKEYCODE_BUTTON_START,/* SYSTEM */AKEYCODE_BUTTON_MODE,/* TOUCHP */PADDLEBOAT_BUTTON_IGNORED,/* AUX1 */PADDLEBOAT_BUTTON_IGNORED,/* AUX2 */PADDLEBOAT_BUTTON_IGNORED,/* AUX3 */PADDLEBOAT_BUTTON_IGNORED,/* AUX4 */PADDLEBOAT_BUTTON_IGNORED}};
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-26 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-26 UTC."],[],[],null,["The Game Controller library maintains an internal database of controller\ndevices, which is used to configure buttons, motion axis layout, mapping for\nrecognized controllers, and a default mapping for unrecognized controllers. The\ndatabase includes many popular controllers, but might not include all devices\nrelevant to a particular game. The Game Controller library supports customization\nwith functions that can:\n\n- Retrieve the current mapping database.\n- Add entries to the existing database.\n- Replace existing database entries.\n- Replace the entire current database with a new one.\n\nIdentify a device\n\nController devices are identified by their `productId` and `vendorId` values.\nEach recognized controller device has at least one entry in the database with a\nmatching `productId` and `vendorId`. The controller mapping structure includes\nfields that specify a qualifying minimum and maximum Android API range for the\nentry. Multiple entries with the same `productId` and `vendorId` may exist in\nthe database as long as they have unique minimum and maximum API ranges.\n\nRead your current remap data\n\nUse the [`Paddleboat_getControllerRemapTableData`](/reference/games/game-controller/group/paddleboat#paddleboat_getcontrollerremaptabledata) function to\nretrieve the current remap data. \n\n int32_t Paddleboat_getControllerRemapTableData(\n const int32_t destRemapTableEntryCount,\n Paddleboat_Controller_Mapping_Data* mappingData)\n\n`Paddleboat_getControllerRemapTableData` returns the total number of remap\nentries present in the internal database.\n\n| Parameter | Description |\n|----------------------------|--------------------------------------------------------------------------------------------------------|\n| `destRemapTableEntryCount` | The array size of `Paddleboat_Controller_Mapping_Data` elements passed in the `mappingData` parameter. |\n| `mappingData` | A pointer to an array of `Paddleboat_Controller_Mapping_Data` elements. |\n\nIf `destRemapTableEntryCount` is smaller than the total number of remap entries,\nonly the number of entries specified by `destRemapTableEntryCount` are copied\ninto `mappingData`.\n\nAdd or replace remap data\n\nUse the [`Paddleboat_addControllerRemapData`](/reference/games/game-controller/group/paddleboat#paddleboat_addcontrollerremapdata) function to add\nremap entries, or replace the current remap database. \n\n void Paddleboat_addControllerRemapData(\n const Paddleboat_Remap_Addition_Mode addMode,\n const int32_t remapTableEntryCount,\n const Paddleboat_Controller_Mapping_Data* mappingData)\n\n| Parameter | Description |\n|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| `addMode` | The addition rules used for the operation. Valid values are `PADDLEBOAT_REMAP_ADD_MODE_DEFAULT` or `PADDLEBOAT_REMAP_ADD_MODE_REPLACE_ALL` |\n| `remapTableEntryCount` | The array size of `Paddleboat_Controller_Mapping_Data` elements passed in the `mappingData` parameter. |\n| `mappingData` | A pointer to an array of `Paddleboat_Controller_Mapping_Data` elements. |\n\nAddition modes\n\nIf `PADDLEBOAT_REMAP_ADD_MODE_REPLACE_ALL` is specified in `addMode`, the\nexisting database is deleted and replaced by the contents of the new array.\n\nIf `PADDLEBOAT_REMAP_ADD_MODE_DEFAULT` is specified in `addMode`, the following\ncriteria are applied to each element in the array passed in `mappingData`:\n\n- If a `Paddleboat_getControllerRemapTableData` is unique (in other words, the `vendorId` and `productId` does not already exist, or does exist but has a non-overlapping `minApi` or `maxApi` range), the entry is added to the internal database.\n- If the `Paddleboat_getControllerRemapTableData` is not unique (`vendorId` and `productId` exists and there is a `minApi` or `maxApi` overlap), it *replaces* the existing entry in the internal database.\n\nThe `Paddleboat_Controller_Mapping_Data` structure is: \n\n typedef struct Paddleboat_Controller_Mapping_Data {\n int16_t minimumEffectiveApiLevel; /** Min. API level for this entry */\n int16_t maximumEffectiveApiLevel; /** Max. API level, 0 = no max */\n int32_t vendorId; /** VendorID of the controller device for this entry */\n int32_t productId; /** ProductID of the controller device for this entry */\n int32_t flags; /** Flag bits, will be ORed with\n * Paddleboat_Controller_Info.controllerFlags */\n\n /** AMOTION_EVENT_AXIS value for the corresponding Paddleboat control axis,\n * or PADDLEBOAT_AXIS_IGNORED if unsupported. */\n uint16_t axisMapping[PADDLEBOAT_MAPPING_AXIS_COUNT];\n /** Button to set on positive or negative axis value,\n * PADDLEBOAT_AXIS_BUTTON_IGNORED if none. */\n uint8_t axisPositiveButtonMapping[PADDLEBOAT_MAPPING_AXIS_COUNT];\n uint8_t axisNegativeButtonMapping[PADDLEBOAT_MAPPING_AXIS_COUNT];\n /** AKEYCODE_ value corresponding with the corresponding Paddleboat button.\n * PADDLEBOAT_BUTTON_IGNORED if unsupported. */\n uint16_t buttonMapping[PADDLEBOAT_BUTTON_COUNT];\n } Paddleboat_Controller_Mapping_Data;\n\nMapping example\n\nThe following illustrates a `Paddleboat_Controller_Mapping_Data` populated to\ndescribe a [Google Stadia controller](https://store.google.com/product/stadia_controller): \n\n #define PADDLEBOAT_AXIS_BUTTON_DPAD_UP 0\n #define PADDLEBOAT_AXIS_BUTTON_DPAD_LEFT 1\n #define PADDLEBOAT_AXIS_BUTTON_DPAD_DOWN 2\n #define PADDLEBOAT_AXIS_BUTTON_DPAD_RIGHT 3\n #define PADDLEBOAT_AXIS_BUTTON_L2 9\n #define PADDLEBOAT_AXIS_BUTTON_R2 12\n\n static const Paddleboat_Controller_Mapping_Data stadia_controller_map[] = {\n 16, 0, 0x18d1, 0x9400, PADDLEBOAT_CONTROLLER_LAYOUT_STANDARD,\n {\n /* LX */ AMOTION_EVENT_AXIS_X,\n /* LY */ AMOTION_EVENT_AXIS_Y,\n /* RX */ AMOTION_EVENT_AXIS_Z,\n /* RY */ AMOTION_EVENT_AXIS_RZ,\n /* L1 */ PADDLEBOAT_AXIS_IGNORED,\n /* L2 */ AMOTION_EVENT_AXIS_BRAKE,\n /* R1 */ PADDLEBOAT_AXIS_IGNORED,\n /* R2 */ AMOTION_EVENT_AXIS_GAS,\n /* HX */ AMOTION_EVENT_AXIS_HAT_X,\n /* HY */ AMOTION_EVENT_AXIS_HAT_Y,\n },\n {\n /* LX */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* LY */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* RX */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* RY */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* L1 */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* L2 */ PADDLEBOAT_AXIS_BUTTON_L2,\n /* R1 */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* R2 */ PADDLEBOAT_AXIS_BUTTON_R2,\n /* HX */ PADDLEBOAT_AXIS_BUTTON_DPAD_RIGHT,\n /* HY */ PADDLEBOAT_AXIS_BUTTON_DPAD_DOWN,\n },\n {\n /* LX */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* LY */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* RX */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* RY */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* L1 */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* L2 */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* R1 */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* R2 */ PADDLEBOAT_AXIS_BUTTON_IGNORED,\n /* HX */ PADDLEBOAT_AXIS_BUTTON_DPAD_LEFT,\n /* HY */ PADDLEBOAT_AXIS_BUTTON_DPAD_UP,\n },\n {\n /* UP */ AKEYCODE_DPAD_UP,\n /* LEFT */ AKEYCODE_DPAD_LEFT,\n /* DOWN */ AKEYCODE_DPAD_DOWN,\n /* RIGHT */ AKEYCODE_DPAD_RIGHT,\n /* A */ AKEYCODE_BUTTON_A,\n /* B */ AKEYCODE_BUTTON_B,\n /* X */ AKEYCODE_BUTTON_X,\n /* Y */ AKEYCODE_BUTTON_Y,\n /* L1 */ AKEYCODE_BUTTON_L1,\n /* L2 */ AKEYCODE_BUTTON_L2,\n /* L3 */ AKEYCODE_BUTTON_THUMBL,\n /* R1 */ AKEYCODE_BUTTON_R1,\n /* R2 */ AKEYCODE_BUTTON_R2,\n /* R3 */ AKEYCODE_BUTTON_THUMBR,\n /* SELECT */ AKEYCODE_BUTTON_SELECT,\n /* START */ AKEYCODE_BUTTON_START,\n /* SYSTEM */ AKEYCODE_BUTTON_MODE,\n /* TOUCHP */ PADDLEBOAT_BUTTON_IGNORED,\n /* AUX1 */ PADDLEBOAT_BUTTON_IGNORED,\n /* AUX2 */ PADDLEBOAT_BUTTON_IGNORED,\n /* AUX3 */ PADDLEBOAT_BUTTON_IGNORED,\n /* AUX4 */ PADDLEBOAT_BUTTON_IGNORED\n }\n };"]]