Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Jan 21, 2025
1 parent f927820 commit 75f81aa
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 223 deletions.
5 changes: 0 additions & 5 deletions src/ChaiLove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ void ChaiLove::update() {
// Update and poll all the events.
event.update();

// Update the input systems.
mouse.update();
joystick.update();
keyboard.update();

// Step forward the timer, and update the game.
if (script != NULL) {
script->update(pntr_app_delta_time(app));
Expand Down
1 change: 1 addition & 0 deletions src/love/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SoundData* audio::newSource(const std::string& filename) {
ChaiLove::getInstance()->sound.sounds.push_back(newSound);
return newSound;
}
delete newSound;
return NULL;
}

Expand Down
1 change: 1 addition & 0 deletions src/love/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ config::config() {
options["alphablending"] = true;
options["highquality"] = true;
version = CHAILOVE_VERSION_STRING;
console = false;
}

} // namespace love
2 changes: 2 additions & 0 deletions src/love/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class config {
* @endcode
*/
std::map<std::string, bool> options;

bool console = false;
};

} // namespace love
Expand Down
15 changes: 0 additions & 15 deletions src/love/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ void event::quit() {
}

void event::update() {
//if (ChaiLove::hasInstance()) {
// Poll all the inputs.
//ChaiLove::input_poll_cb();

// TODO(RobLoach): Is polling the SDL events required?
/*
while (SDL_PollEvent(&sdlEvent)) {
switch (sdlEvent.type) {
case SDL_QUIT:
quit();
break;
}
}
*/
//}
}

} // namespace love
7 changes: 0 additions & 7 deletions src/love/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ pntr_image* graphics::getScreen() {
}

bool graphics::load() {
// Enable alpha blending.
// if (ChaiLove::getInstance()->config.options["alphablending"]) {
// if (SDL_SetAlpha(getScreen(), SDL_SRCALPHA, 0) == -1) {
// LibretroLog::log(RETRO_LOG_ERROR) << "[ChaiLove] Enabling alpha blending failed" << std::endl;
// }
// }

// Set the default font.
graphics::setFont();

Expand Down
6 changes: 0 additions & 6 deletions src/love/joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ bool joystick::isDown(int joystick, const std::string& button) {
return m_joysticks[joystick]->isDown(button);
}

void joystick::update() {
// for (std::vector<Joystick*>::iterator it = m_joysticks.begin(); it != m_joysticks.end(); ++it) {
// (*it)->update();
// }
}

Joystick* joystick::operator[](int joystick) {
if (joystick < 0) {
joystick = 0;
Expand Down
1 change: 0 additions & 1 deletion src/love/joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class joystick {
public:
~joystick();
void load(pntr_app* app);
void update();

/**
* Gets a list of connected Joysticks.
Expand Down
22 changes: 0 additions & 22 deletions src/love/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,28 +171,6 @@ std::string keyboard::getKeyFromScancode(int scancode) {
return scancodeToKey[scancode];
}

bool keyboard::update() {
// // Go through all keys.
// int16_t state;
// for (int i = 0; i < RETROK_LAST; i++) {
// // Get updated state for each key.
// state = ChaiLove::input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0, i);

// // If the state is different, then issue a keyPressed, or keyReleased.
// if (keys[i] != state) {
// keys[i] = state;

// if (state == 1) {
// eventKeyPressed(i);
// } else {
// eventKeyReleased(i);
// }
// }
// }
// return true;
return true;
}

void keyboard::eventKeyPressed(int scancode) {
std::string key = getKeyFromScancode(scancode);
ChaiLove* app = ChaiLove::getInstance();
Expand Down
2 changes: 0 additions & 2 deletions src/love/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class keyboard {
*/
bool isScancodeDown(int scancode);

bool update();

/**
* Retrieve a scancode from the given key.
*
Expand Down
31 changes: 4 additions & 27 deletions src/love/mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,6 @@ std::string mouse::getButtonName(int button) {
return "unknown";
}

void mouse::update() {
// int16_t state, dx, dy;

// // Update the x/y coordinates.
// dx = ChaiLove::input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
// dy = ChaiLove::input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
// if (dx != 0 || dy != 0) {
// m_x = m_x + dx;
// m_y = m_y + dy;
// mousemoved(m_x, m_y, dx, dy);
// }

// // Update all buttons.
// for (int i = RETRO_DEVICE_ID_MOUSE_LEFT; i <= RETRO_DEVICE_ID_MOUSE_BUTTON_5; i++) {
// state = ChaiLove::input_state_cb(0, RETRO_DEVICE_MOUSE, 0, i);

// if (state != m_buttonState[i]) {
// m_buttonState[i] = state;
// if (m_buttonState[i] == 0) {
// mousereleased(m_x, m_y, getButtonName(i));
// } else {
// mousepressed(m_x, m_y, getButtonName(i));
// }
// }
// }
}

void mouse::mousemoved(int x, int y, int dx, int dy) {
ChaiLove::getInstance()->script->mousemoved(x, y, dx, dy);
}
Expand All @@ -117,6 +90,10 @@ void mouse::mousereleased(int x, int y, const std::string& button) {
ChaiLove::getInstance()->script->mousereleased(x, y, button);
}

void mouse::wheelmoved(int x, int y) {
ChaiLove::getInstance()->script->wheelmoved(x, y);
}

Point mouse::getPosition() {
return Point(pntr_app_mouse_x(m_app), pntr_app_mouse_y(m_app));
}
Expand Down
3 changes: 1 addition & 2 deletions src/love/mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ class mouse {
*/
bool isDown(const std::string& button);

void update();

int getButtonKey(const std::string& button);
std::string getButtonName(int button);

void mousemoved(int x, int y, int dx, int dy);
void mousepressed(int x, int y, const std::string& button);
void mousereleased(int x, int y, const std::string& button);
void wheelmoved(int x, int y);

pntr_app* m_app;
};
Expand Down
Loading

0 comments on commit 75f81aa

Please sign in to comment.