-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
EPICGameGuy
committed
Dec 29, 2023
1 parent
ed20898
commit edce8e8
Showing
9 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include "libpad.h" | ||
#include "tamtypes.h" | ||
|
||
namespace Input::Keyboard | ||
{ | ||
void init(); | ||
void read_inputs(); | ||
u8 get_key_status(char key); | ||
} // namespace Input::Keyboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
#include "input/input.hpp" | ||
#include "input/gamepad.hpp" | ||
#include "input/keyboard.hpp" | ||
|
||
namespace Input | ||
{ | ||
void init() | ||
{ | ||
Gamepad::init(); | ||
Keyboard::init(); | ||
} | ||
|
||
void read_inputs() | ||
{ | ||
Gamepad::read_inputs(); | ||
Keyboard::read_inputs(); | ||
} | ||
} // namespace Input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "input/keyboard.hpp" | ||
|
||
#include <loadfile.h> | ||
#include "egg/assert.hpp" | ||
#include "egg/filesystem.hpp" | ||
|
||
#include "libkbd.h" | ||
#include "ps2kbd.h" | ||
|
||
static u8 keyboard_status[256]; | ||
|
||
namespace Input | ||
{ | ||
void Keyboard::init() | ||
{ | ||
|
||
memset(keyboard_status, sizeof(keyboard_status), 0); | ||
|
||
{ | ||
int ret = SifLoadModule("PS2KBD.IRX"_p.to_full_filepath(), 0, nullptr); | ||
printf("ret: %d\n", ret); | ||
checkf(ret >= 0, "PS2KBD.IRX"_p.to_full_filepath()); | ||
} | ||
|
||
// Note: this depends on the USB modules being load (BSD.IRX) | ||
if (PS2KbdInit() == 0) | ||
{ | ||
checkf(false, "Failed to initialize"); | ||
} | ||
|
||
PS2KbdSetReadmode(PS2KBD_READMODE_RAW); | ||
} | ||
|
||
void Keyboard::read_inputs() | ||
{ | ||
PS2KbdRawKey key; | ||
while (PS2KbdReadRaw(&key) != 0) | ||
{ | ||
printf("New key: %u, %u\n", key.key, key.state); | ||
keyboard_status[key.key] = key.state & 0xF; | ||
} | ||
} | ||
|
||
u8 Keyboard::get_key_status(char key) | ||
{ | ||
return keyboard_status[(key - 'a') + 4]; | ||
} | ||
|
||
} // namespace Input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters