{"author_link":"\/users\/dock-frankenstein","author_name":"Dock Frankenstein","author_uid":"dock-frankenstein","comments":[],"epoch":1664484114,"event":"LD51","format":"md","ldjam_node_id":301459,"likes":5,"metadata":{"p_key":"166750","p_author":"Dock Frankenstein","p_authorkey":"1121145","p_urlkey":"393307","p_title":"Fixing my Input System for Ludum Dare Day 4","p_cat":"LDJam ","p_event":"LD51","p_time":"1664484114","p_likes":"5","p_comments":"0","p_status":"WAYBACK","us_key":"1121145","us_name":"Franciszek Pyr\u0107","us_username":"franciszek-pyrc","event_start":"1664496000","event_key":"114","event_name":"Ludum Dare 51"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD51","removed_author":false},"_superparent":296586,"_trust":8,"author":121145,"body":"**Today I've managed to finally finish the Input System :)**. Of course nothing's perfect and I will have to add and rewrite a lot of things after the jam, but for now it's good enough to make a game with.\n\n# XInput\nAs I said before, **I was using Unity's legacy Input Manager (UIM) for handling gamepad input**. If you don't know: **UIM sucks**, especially if you're working with gamepads. So I've decided to ditch it and instead use xinput.\n\n![IMG_20220929_223231123.jpg](\/\/\/raw\/939\/d1\/z\/4ef1a.jpg)\n\nTurns out: **xinput is kinda cool**. It's fairly simple and easy to use. It may not have the best support for non xbox controllers out of the box, but for making simple game's it's more than plenty. ~~besides, steam input handles everything these days anyways.~~\n\n# Referencing input\nIf you want to get the state of an input, you can **call it out by its name via the Input Manager**. However, **this isn't the best**, as you have to know how something is called. That's where **input references** come in: they are just **a fancy string that stores a reference to an item** and allows you to select it in a window.\n\n![Screenshot 2022-09-29 223430.png](\/\/\/raw\/939\/d1\/z\/4ef17.png)\n\nIn the old version, **they used to store the group name and item name**, which worked, but could easily break when renaming items. And since this **new version uses guids, the references store those instead**.\n\n# Togglers\nAnother great feature of [qASIC](https:\/\/qasictools.com\/) (a collection of tools which this input system is a part of) are the **togglers**: they are just these **really simple scripts that toggle objects when you press a button**. They are great for pause menus, hiding UI and even toggling things such as a cheat console. Because they are so simple, **they required me to literally modify a single line of code to get them working again**.\n\n![Screenshot 2022-09-29 223442.png](\/\/\/raw\/939\/d1\/z\/4ef18.png)\n\n# Remapping\nThis was another interesting one. **I don't want people to remap gamepad keys in the keyboard menu**, so I had to think. In Cablebox **keys are stored as paths** (e.g. `key_keyboard\/W`, `key_gamepad\/RightStickUp`). This makes my job fairly simple as **I just need to check the root path** to identify the controller type.\n\n![Screenshot 2022-09-29 223539.png](\/\/\/raw\/939\/d1\/z\/4ef19.png)\n\nAlso, **the keyboard device was listening to my mouse**. You can imagine how fun it was to click and automatically assign my mouse on every binding. So I had to implement a small keycode exclude list and there we go.\n\n# Finished?\nAt this point **I've compleated every required feature for Cablebox to function**. Now I'm gonna do other pre-jam activities and get ready for this thing. **It's been fun, but everything has to come to an end at some point**.\n\nAlso no, **I won't release this thing**, it's probably **unstable** and I will probably have to **crack it open during the jam anyways**. For now there's **the [old version](https:\/\/assetstore.unity.com\/packages\/tools\/utilities\/qasic-198122)** that **doesn't have gamepad support**, but **it's really bad** compared to the development version.","comments":0,"created":"2022-09-29T19:01:17Z","files":[],"files-timestamp":0,"id":301459,"love":5,"love-timestamp":"2022-09-29T20:55:52Z","meta":[],"modified":"2022-09-29T20:55:52Z","name":"Fixing my Input System for Ludum Dare Day 4","node-timestamp":"2022-09-29T20:41:54Z","parent":296630,"parents":[1,5,9,296586,296630],"path":"\/events\/ludum-dare\/51\/estolec\/fixing-my-input-system-for-ludum-dare-day-4","published":"2022-09-29T20:41:54Z","scope":"public","slug":"fixing-my-input-system-for-ludum-dare-day-4","subsubtype":"","subtype":"","type":"post","version":926901},"node_metadata":{"n_key":"301459","n_urlkey":"393307","n_parent":"296630","n_path":"\/events\/ludum-dare\/51\/estolec\/fixing-my-input-system-for-ludum-dare-day-4","n_slug":"fixing-my-input-system-for-ludum","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"121145","n_created":"1664478077","n_modified":"1664484952","n_version":"926901","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/51\/estolec\/fixing-my-input-system-for-ludum-dare-day-4","text":"**Today I've managed to finally finish the Input System :)**. Of course nothing's perfect and I will have to add and rewrite a lot of things after the jam, but for now it's good enough to make a game with.\n\n# XInput\nAs I said before, **I was using Unity's legacy Input Manager (UIM) for handling gamepad input**. If you don't know: **UIM sucks**, especially if you're working with gamepads. So I've decided to ditch it and instead use xinput.\n\n![IMG_20220929_223231123.jpg](\/\/\/raw\/939\/d1\/z\/4ef1a.jpg)\n\nTurns out: **xinput is kinda cool**. It's fairly simple and easy to use. It may not have the best support for non xbox controllers out of the box, but for making simple game's it's more than plenty. ~~besides, steam input handles everything these days anyways.~~\n\n# Referencing input\nIf you want to get the state of an input, you can **call it out by its name via the Input Manager**. However, **this isn't the best**, as you have to know how something is called. That's where **input references** come in: they are just **a fancy string that stores a reference to an item** and allows you to select it in a window.\n\n![Screenshot 2022-09-29 223430.png](\/\/\/raw\/939\/d1\/z\/4ef17.png)\n\nIn the old version, **they used to store the group name and item name**, which worked, but could easily break when renaming items. And since this **new version uses guids, the references store those instead**.\n\n# Togglers\nAnother great feature of [qASIC](https:\/\/qasictools.com\/) (a collection of tools which this input system is a part of) are the **togglers**: they are just these **really simple scripts that toggle objects when you press a button**. They are great for pause menus, hiding UI and even toggling things such as a cheat console. Because they are so simple, **they required me to literally modify a single line of code to get them working again**.\n\n![Screenshot 2022-09-29 223442.png](\/\/\/raw\/939\/d1\/z\/4ef18.png)\n\n# Remapping\nThis was another interesting one. **I don't want people to remap gamepad keys in the keyboard menu**, so I had to think. In Cablebox **keys are stored as paths** (e.g. `key_keyboard\/W`, `key_gamepad\/RightStickUp`). This makes my job fairly simple as **I just need to check the root path** to identify the controller type.\n\n![Screenshot 2022-09-29 223539.png](\/\/\/raw\/939\/d1\/z\/4ef19.png)\n\nAlso, **the keyboard device was listening to my mouse**. You can imagine how fun it was to click and automatically assign my mouse on every binding. So I had to implement a small keycode exclude list and there we go.\n\n# Finished?\nAt this point **I've compleated every required feature for Cablebox to function**. Now I'm gonna do other pre-jam activities and get ready for this thing. **It's been fun, but everything has to come to an end at some point**.\n\nAlso no, **I won't release this thing**, it's probably **unstable** and I will probably have to **crack it open during the jam anyways**. For now there's **the [old version](https:\/\/assetstore.unity.com\/packages\/tools\/utilities\/qasic-198122)** that **doesn't have gamepad support**, but **it's really bad** compared to the development version.","title":"Fixing my Input System for Ludum Dare Day 4","wayback_source":[]}